My code follows as:
NSArray *vis = [tableView1 visibleCells];
NSLog (@"vis %@", vis);
And I get:
2012-07-04 21:16:44.564 xxx[1933:12e03] vis (
"<UITableViewCell: 0xb2dcc80; frame = (0 0; 320 80); text = 'xxx1'; autoresize = W; layer = <CALayer: 0xb2dcd60>>",
"<UITableViewCell: 0x635ea10; frame = (0 80; 320 80); text = 'xxx2'; autoresize = W; layer = <CALayer: 0x6353620>>",
"<UITableViewCell: 0xb2ddca0; frame = (0 160; 320 80); text = 'xxx3'; autoresize = W; layer = <CALayer: 0xb2ddc70>>",
"<UITableViewCell: 0x635f7d0; frame = (0 240; 320 80); text = 'xxx4'; autoresize = W; layer = <CALayer: 0x635f650>>"
When I write:
NSString *aText = [vis objectAtIndex:0];
NSLog (@"aText %@", aText);
I get invariably a warning:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array'
Is this a kind of multidimensional array? If yes, how can I extract only text?
The array returned by
visibleCellscontainsUITableViewCellobjects, and notNSStringobjects. You can see that in the output of yourNSLog(@"vis %@", vis);.To get the strings, you’d need to ask the
UITableViewCells for them.In other words: