2

Problem: I have a list of 4 different cells in my UITableView. Each cell has its own unique ip address. When it's initialize, my app will check (using reachability) to see if each cell's ip address is connected to the internet or wifi. If any of the cells is connected, the cell will be enabled and user can click it. If the cell is not connected, it will remain disabled.

*Do take note that I have a devicelist.plist which stores all list of devices. Hence, how do I approach this problem?

Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
  • Check this - http://stackoverflow.com/questions/5195012/how-to-use-reachability-class-to-detect-valid-internet-connection – rishi Jan 04 '13 at 07:28
  • Also this - http://stackoverflow.com/questions/3790957/reachability-guide-for-ios-4 – rishi Jan 04 '13 at 07:29
  • Thanks for the comment. but I still not sure how to disable my cells when it's not connected to the wifi/internet. Plz help me. I'm a newbie in objective c. Thank you. – MrExperimental Jan 05 '13 at 15:09
  • Out of curiosity, is your UITableView only those 4 cells? If so, you can just use the [NameOfYourUITableView setHidden:YES]; method if your reachability code shows that the device isn't connected. Alternatively, if not, you could always use reachability code in your tableview cellForRowAtIndexPath to check if the indexPath is one of your 4 IP cells, and if it isn't reachable you could return a blank UITableViewCell instead of a populated one. I guess it really depends on how you want to implement it. Hopefully that is helpful. – dmason82 Jan 12 '13 at 15:58

1 Answers1

1

You can try this approach.

First of all check reach ability that your IP is connected or not through This reach ability code.

and you can also put this thing in separate thread (like lazy loading in UITableview)

note that :- Lazy loading is just for example through that you can check reach ability in separate thread.

Now store the status of of your IP in some Array or Dictionary and then reload the Tableview.

And in your CellForRowAtIndexpath check if IP is connected then keep as it is like

userInteractionEnabled = YES;

if the IP is not connected then

cell.userInteractionEnabled = NO;
cell.selectionStyle = UITableViewCellSelectionStyleNone;

This is my approach hope this will help you.

Community
  • 1
  • 1
Muhammad Rizwan
  • 3,470
  • 1
  • 27
  • 35