I am attempting to display an array which I receive from a JSON Dictionary onto a UITableView but I keep getting an error. I am trying to display all the comments for a given Instagram Picture onto a Table. Here is how I am attempting to display the cells:
MessageTableViewCell *cell = (MessageTableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:MessengerCellIdentifier];
NSDictionary *instaPics = self.instagramData;
NSArray *commentArray = instaPics[#"comments"][#"data"];
NSString *commentText = [commentArray valueForKey:#"text"]; // Error occurs here
Message *message = self.messages[indexPath.row];
cell.titleLabel.text = message.username;
cell.bodyLabel.text = commentText;
Here is the error I receive:
-[__NSArrayI length]: unrecognized selector sent to instance 0x7f913052db10
2015-05-05 22:16:08.848 Floadt[6061:514032] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI length]: unrecognized selector sent to instance 0x7f913052db10'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107d60c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010763cbb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000107d680ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000107cbe13c ___forwarding___ + 988
4 CoreFoundation 0x0000000107cbdcd8 _CF_forwarding_prep_0 + 120
5 UIKit 0x0000000106543ab4 -[UILabel _textRectForBounds:limitedToNumberOfLines:includingShadow:] + 65
6 UIKit 0x000000010654390f -[UILabel textRectForBounds:limitedToNumberOfLines:] + 76
7 UIKit 0x00000001065473b9 -[UILabel _intrinsicSizeWithinSize:] + 170
8 UIKit 0x0000000106547499 -[UILabel intrinsicContentSize] + 76
9 UIKit 0x00000001069e5b6c -[UIView(UIConstraintBasedLayout) _generateContentSizeConstraints] + 33
10 UIKit 0x00000001069e5930 -[UIView(UIConstraintBasedLayout) _updateContentSizeConstraints] + 422
11 UIKit 0x00000001069ecd25 -[UIView(AdditionalLayoutSupport) updateConstraints] + 162
12 UIKit 0x0000000106547304 -[UILabel updateConstraints] + 274
13 UIKit 0x00000001069ec346 -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 242
14 UIKit 0x00000001069ec53e -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
15 CoreFoundation 0x0000000107c67354 CFArrayApplyFunction + 68
16 UIKit 0x00000001069ec2ed -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
17 Foundation 0x0000000105b021be -[NSISEngine withBehaviors:performModifications:] + 155
18 UIKit 0x00000001069ec53e -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
19 CoreFoundation 0x0000000107c67354 CFArrayApplyFunction + 68
20 UIKit 0x00000001069ec2ed -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
21 UIKit 0x00000001069ec53e -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
22 UIKit 0x00000001069eca0e __60-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded]_block_invoke + 96
23 UIKit 0x00000001069ec6d6 -[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded] + 231
24 UIKit 0x00000001067d7531 -[UITableViewCellContentView updateConstraintsIfNeeded] + 94
25 UIKit 0x00000001069ecdde -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeeded] + 146
26 UIKit 0x00000001063e4a3d -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 114
27 UIKit 0x00000001063f0a2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
28 QuartzCore 0x00000001061b4ec2 -[CALayer layoutSublayers] + 146
29 QuartzCore 0x00000001061a96d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
30 UIKit 0x00000001063e4675 -[UIView(Hierarchy) layoutBelowIfNeeded] + 607
31 Floadt 0x0000000104195848 -[SLKTextViewController viewWillAppear:] + 296
32 UIKit 0x00000001064a4fa1 -[UIViewController _setViewAppearState:isAnimating:] + 487
33 UIKit 0x00000001064c6395 -[UINavigationController _startCustomTransition:] + 887
34 UIKit 0x00000001064d23bf -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
35 UIKit 0x00000001064d2f0e -[UINavigationController __viewWillLayoutSubviews] + 43
36 UIKit 0x000000010661d715 -[UILayoutContainerView layoutSubviews] + 202
37 UIKit 0x00000001063f0a2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
38 QuartzCore 0x00000001061b4ec2 -[CALayer layoutSublayers] + 146
39 QuartzCore 0x00000001061a96d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
40 QuartzCore 0x00000001061a9546 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
41 QuartzCore 0x0000000106115886 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
42 QuartzCore 0x0000000106116a3a _ZN2CA11Transaction6commitEv + 462
43 UIKit 0x000000010636d626 _UIApplicationHandleEventQueue + 2140
44 CoreFoundation 0x0000000107c94431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
45 CoreFoundation 0x0000000107c8a2fd __CFRunLoopDoSources0 + 269
46 CoreFoundation 0x0000000107c89934 __CFRunLoopRun + 868
47 CoreFoundation 0x0000000107c89366 CFRunLoopRunSpecific + 470
48 GraphicsServices 0x0000000109716a3e GSEventRunModal + 161
49 UIKit 0x0000000106370900 UIApplicationMain + 1282
50 Floadt 0x0000000104218c5f main + 111
51 libdyld.dylib 0x0000000109f2b145 start + 1
52 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Here is an example copy of the JSON:
{
attribution = "<null>";
caption = {
"created_time" = 1430877943;
from = {
"full_name" = "Shreya M.";
id = 25085898;
"profile_picture" = "https://igcdn-photos-h-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/10890672_320752588135679_1815913692_a.jpg";
username = "shreya_mandava";
};
id = 978597576956579585;
text = "9+10????";
};
comments = {
count = 2;
data = (
{
"created_time" = 1430878007;
from = {
"full_name" = "Aleesha Toteja";
id = 17117902;
"profile_picture" = "https://instagramimages-a.akamaihd.net/profiles/profile_17117902_75sq_1373927314.jpg";
username = leeshtotes;
};
id = 978598112887967529;
text = "DIRT \Ud83d\Ude3b";
},
{
"created_time" = 1430878307;
from = {
"full_name" = "Shritha M.";
id = 375799796;
"profile_picture" = "https://igcdn-photos-f-a.akamaihd.net/hphotos-ak-xpf1/t51.2885-19/10454159_1056687271012469_2048676049_a.jpg";
username = "shritha_m";
};
id = 978600630846098439;
text = sigh;
}
);
};
"created_time" = 1430877943;
filter = Normal;
id = "978597574314167442_25085898";
images = {
"low_resolution" = {
height = 306;
url = "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s306x306/e15/11241842_1401517966839213_670743424_n.jpg";
width = 306;
};
"standard_resolution" = {
height = 640;
url = "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/e15/11241842_1401517966839213_670743424_n.jpg";
width = 640;
};
thumbnail = {
height = 150;
url = "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s150x150/e15/11241842_1401517966839213_670743424_n.jpg";
width = 150;
};
};
likes = {
count = 22;
data = (
{
"full_name" = "Ronak Chopra";
id = 347652824;
"profile_picture" = "https://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-19/11142328_1644920965736964_1040275960_a.jpg";
username = "conak_rhopra";
},
{
"full_name" = "emily bach";
id = 292615252;
"profile_picture" = "https://igcdn-photos-a-a.akamaihd.net/hphotos-ak-xap1/t51.2885-19/10454121_1558984144374824_122699173_a.jpg";
username = "emily_bach_";
},
{
"full_name" = "\Ud83c\Udf38Trisha\Ud83c\Udf38";
id = 303629882;
"profile_picture" = "https://igcdn-photos-g-a.akamaihd.net/hphotos-ak-xfp1/t51.2885-19/10955125_708435799269374_749376734_a.jpg";
username = trishddishh;
},
{
"full_name" = "Shritha M.";
id = 375799796;
"profile_picture" = "https://igcdn-photos-f-a.akamaihd.net/hphotos-ak-xpf1/t51.2885-19/10454159_1056687271012469_2048676049_a.jpg";
username = "shritha_m";
}
);
};
link = "https://instagram.com/p/2UrU8bDgyS/";
location = {
id = 772010926;
latitude = "38.913782928";
longitude = "-77.383238738";
name = "ft. dirt";
};
tags = (
);
type = image;
user = {
"full_name" = "Shreya M.";
id = 25085898;
"profile_picture" = "https://igcdn-photos-h-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/10890672_320752588135679_1815913692_a.jpg";
username = "shreya_mandava";
};
"user_has_liked" = 0;
"users_in_photo" = (
{
position = {
x = "0.6703125";
y = "0.246875";
};
user = {
"full_name" = "John Nguyen";
id = 1477626916;
"profile_picture" = "https://igcdn-photos-d-a.akamaihd.net/hphotos-ak-xfp1/t51.2885-19/11018467_1431648953794187_659343544_a.jpg";
username = bumbonguyen;
};
}
);
}
You are trying to get a value from key in a NSArray on:
[commentArray valueForKey:#"text"];
NSArray is not a dictionary has not keys (has multiple comments), should be accessed by his index.
[[commentArray objectAtIndex:0] valueForKey:#"text"];
Probably you will want, iterate over the comments and on each comment get his "text"
You can replace this line :
NSString *commentText = [commentArray valueForKey:#"text"];
with
for (NSDictionary *comment in commentArray ) {
NSString *commentText = [comment valueForKey:#"text"];
cell.bodyLabel.text = commentText;
}
Gonzalo is right. Your accessing commentArray like a NSDictionary but it is actually a NSArray. That causes the crash.
NSArray *commentArray = instaPics[#"comments"][#"data"];
It looks like a wrong access of key value..
As per my understanding you are trying to get value of comments.
your Json data contains root & child key value like,
comments
count
Data
caption
images
likes
...
Here your Comments having child value like count,data.
So can write the code to fetch value of comment > data>text
--------1--------
NSMutableDictionary *response = [[[json valueForKey:#"comments"] objectAtIndex:0]mutableCopy];
NSMutableDictionary *data = [[[response valueForKey:#"data"] objectAtIndex:0]mutableCopy];
NSString *text = [data valueForKey:#"text"];
----OR----2--------
NSMutableDictionary *response = [[[json valueForKey:#"comments"] objectAtIndex:0]mutableCopy];
NSArray *textarr=[response valueForKey:#"text"];
Related
I am getting an exception when I filter and try to delete records from Realm DB. It appears that the records are being deleted. The do / catch however is not responding as I expected. What am I doing wrong?
func deleteRecords (module: String, version:String, workorder: String) {
let realm = try! Realm()
let predicate = NSPredicate(format: "module = %# && version = %# && workorder = %#" , module, version, workorder)
let results = realm.objects(NewRecord.self).filter(predicate)
print("FILTERED: \(results.count) \(results)")
do {
try? realm.write {
for result in results {
print("DELETING: \(result)")
realm.delete(result)
}
}
} catch {
// Catch anything that the above catches didn't catch
print("ERROR THROWN DELETONG")
}
}
The output looks like so:
FILTERED: 2 Results<NewRecord> <0x7f9cb1d27950> (
[0] NewRecord {
id = eaAerator008quantityWRK-000001;
module = eaAerator;
workorder = WRK-000001;
version = 008;
field = quantity;
measure = None;
valueString = 200;
valueData = < — 0 total bytes>;
diStatus = INSTALLED;
},
[1] NewRecord {
id = eaAerator008installedQuantityWRK-000001;
module = eaAerator;
workorder = WRK-000001;
version = 008;
field = installedQuantity;
measure = None;
valueString = 150;
valueData = < — 0 total bytes>;
diStatus = INSTALLED;
}
)
DELETING: NewRecord {
id = eaAerator008quantityWRK-000001;
module = eaAerator;
workorder = WRK-000001;
version = 008;
field = quantity;
measure = None;
valueString = 200;
valueData = < — 0 total bytes>;
diStatus = INSTALLED;
}
DELETING: NewRecord {
id = eaAerator008installedQuantityWRK-000001;
module = eaAerator;
workorder = WRK-000001;
version = 008;
field = installedQuantity;
measure = None;
valueString = 150;
valueData = < — 0 total bytes>;
diStatus = INSTALLED;
}
2017-08-13 23:05:07.982 DSMTracker[925:147376108] *** Terminating app due to uncaught exception 'RLMException', reason: 'Object has been deleted or invalidated.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107bbab0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000106d03141 objc_exception_throw + 48
2 Realm 0x00000001055eccf3 _ZL17RLMVerifyAttachedP13RLMObjectBase + 83
3 Realm 0x00000001055ee94c _ZN12_GLOBAL__N_18getBoxedIN5realm10StringDataEEEP11objc_objectP13RLMObjectBasem + 28
4 Realm 0x00000001055ee927 ___ZN12_GLOBAL__N_115makeBoxedGetterIN5realm10StringDataEEEP11objc_objectm_block_invoke + 39
5 DSMTracker 0x00000001044bdfb9 _TFC10DSMTracker23DirectInstallController9tableViewfTCSo11UITableView6commitOSC27UITableViewCellEditingStyle8forRowAtV10Foundation9IndexPath_T_ + 841
6 DSMTracker 0x00000001044be0af _TToFC10DSMTracker23DirectInstallController9tableViewfTCSo11UITableView6commitOSC27UITableViewCellEditingStyle8forRowAtV10Foundation9IndexPath_T_ + 95
7 UIKit 0x000000010942ec8c -[UITableView _animateDeletionOfRowWithCell:] + 172
8 UIKit 0x0000000109404289 __52-[UITableView _swipeActionButtonsForRowAtIndexPath:]_block_invoke + 84
9 UIKit 0x0000000109430334 -[UITableView _actionButton:pushedInCell:] + 212
10 UIKit 0x0000000109690d75 -[UITableViewCell _actionButtonPushed:] + 82
11 UIKit 0x00000001092c1d22 -[UIApplication sendAction:to:from:forEvent:] + 83
12 UIKit 0x000000010944625c -[UIControl sendAction:to:forEvent:] + 67
13 UIKit 0x0000000109446577 -[UIControl _sendActionsForEvents:withEvent:] + 450
14 UIKit 0x00000001094454b2 -[UIControl touchesEnded:withEvent:] + 618
15 UIKit 0x00000001097eaea9 _UIGestureEnvironmentSortAndSendDelayedTouches + 5553
16 UIKit 0x00000001097e5ec0 _UIGestureEnvironmentUpdate + 1409
17 UIKit 0x00000001097e58f3 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 484
18 UIKit 0x00000001097e4aba -[UIGestureEnvironment _updateGesturesForEvent:window:] + 274
19 UIKit 0x0000000109330b9a -[UIWindow sendEvent:] + 4092
20 UIKit 0x00000001092dd7b0 -[UIApplication sendEvent:] + 352
21 UIKit 0x0000000109ac0adc __dispatchPreprocessedEventFromEventQueue + 2926
22 UIKit 0x0000000109ab8a3a __handleEventQueue + 1122
23 CoreFoundation 0x0000000107b60c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
24 CoreFoundation 0x0000000107b460cf __CFRunLoopDoSources0 + 527
25 CoreFoundation 0x0000000107b455ff __CFRunLoopRun + 911
26 CoreFoundation 0x0000000107b45016 CFRunLoopRunSpecific + 406
27 GraphicsServices 0x0000000110337a24 GSEventRunModal + 62
28 UIKit 0x00000001092c00d4 UIApplicationMain + 159
29 DSMTracker 0x00000001048cad27 main + 55
30 libdyld.dylib 0x000000010ca6d65d start + 1
31 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I have a tableView which should load its cells with data from server.
When my data is loaded from server I call [self.tableView reloadData] inside completionhandler block.
So the method cellForRowAtIndexPath gets called again.
My implementation for cellForRowAtIndexPath is this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Configure the cell...
NewsCell* cell = [self.tableView dequeueReusableCellWithIdentifier:#"NewsCell" forIndexPath:indexPath];
if(!cell){
cell = [[NewsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"NewsCell"];
}
News* currentNews = (News*)[self.newsList objectAtIndex:indexPath.row];
cell.newsTitle.text = currentNews.title;
// cell.newsTitle.text = #"salam";
return cell;
}
Note: self.newsList is an array that is populated with data from server
The code that parses response json from server is this:
[GNetworkHelper getJsonDataFromURL:urlString
withCompletionHandler:^(NSDictionary * jsonResponse) {
// Parse retrieved json and pass it to completion handler;;
NSMutableArray* news = [[NSMutableArray alloc] init];
if (jsonResponse) {
for (NSDictionary* new in jsonResponse) {
News *currentNew = [[News alloc] initWithDictionary:new];
[news addObject:currentNew];
}
}else{
News* testNew = [[News alloc] init];
[testNew setTitle:#"salam"];
[news addObject:testNew];
}
completionHandler(news);
}];
My problem: When I debug this code the cell variable I create using dequeueReusableCellWithIdentifier:forIndexPath function is null in the debugger's variables section, but when I use lldb command po to print it out I get this
(lldb) po cell
<NewsCell: 0x7fc5fadb2ee0; baseClass = UITableViewCell; frame = (0 0; 375 143); autoresize = W; layer = <CALayer: 0x7fc5fad9fcd0>>
The same happens for currentNews variable. For it I get this from po command
(lldb) po currentNews
<News: 0x7fc5fd0480d0>
I even can get properties on it like this:
(lldb) po currentNews.title
<__NSCFArray 0x7fc5fd047300>(
"some title"
)
There is no exception when stepping through this method's statements. But when the method returns the Unrecognized Selector exception is thrown
Why this happens??
The Strange thing is that if I change this line:
cell.newsTitle.text = currentNews.title;
to this:
cell.newsTitle.text = #"Some test text";
everything goes well, specifically the cell and currentNews variables are not null anymore and tableView renders the cells without any problem
The full stack trace is :
[__NSCFArray length]: unrecognized selector sent to instance 0x7fc5fd047300
2015-09-16 11:30:40.630 Gallery[12013:952548] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray length]: unrecognized selector sent to instance 0x7fc5fd047300'
--- First throw call stack:
(
0 CoreFoundation 0x0000000105af3f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010578cbb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000105afb04d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000105a5327c ___forwarding___ + 988
4 CoreFoundation 0x0000000105a52e18 _CF_forwarding_prep_0 + 120
5 UIKit 0x00000001060a5f45 -[UILabel _textRectForBounds:limitedToNumberOfLines:includingShadow:] + 65
6 UIKit 0x00000001060a5da0 -[UILabel textRectForBounds:limitedToNumberOfLines:] + 76
7 UIKit 0x00000001060a9852 -[UILabel _intrinsicSizeWithinSize:] + 170
8 UIKit 0x00000001060a9932 -[UILabel intrinsicContentSize] + 76
9 UIKit 0x000000010655fea4 -[UIView(UIConstraintBasedLayout) _generateContentSizeConstraints] + 33
10 UIKit 0x000000010655fc64 -[UIView(UIConstraintBasedLayout) _updateContentSizeConstraints] + 422
11 UIKit 0x00000001065670d6 -[UIView(AdditionalLayoutSupport) updateConstraints] + 163
12 UIKit 0x00000001060a979d -[UILabel updateConstraints] + 272
13 UIKit 0x00000001065666fa -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 248
14 UIKit 0x00000001065668f2 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
15 CoreFoundation 0x00000001059fc194 CFArrayApplyFunction + 68
16 UIKit 0x000000010656669b -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
17 Foundation 0x0000000105332d6e -[NSISEngine withBehaviors:performModifications:] + 155
18 UIKit 0x00000001065668f2 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
19 CoreFoundation 0x00000001059fc194 CFArrayApplyFunction + 68
20 UIKit 0x000000010656669b -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
21 UIKit 0x00000001065668f2 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
22 UIKit 0x0000000106566dbe __60-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded]_block_invoke + 96
23 UIKit 0x0000000106566a86 -[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded] + 231
24 UIKit 0x000000010635c8b8 -[UITableViewCellContentView updateConstraintsIfNeeded] + 95
25 UIKit 0x000000010656719e -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeeded] + 159
26 UIKit 0x0000000105f4db2d -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 114
27 UIKit 0x0000000105f59973 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
28 QuartzCore 0x000000010504ade8 -[CALayer layoutSublayers] + 150
29 QuartzCore 0x000000010503fa0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
30 QuartzCore 0x000000010503f87e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
31 QuartzCore 0x0000000104fad63e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
32 QuartzCore 0x0000000104fae74a _ZN2CA11Transaction6commitEv + 390
33 QuartzCore 0x0000000104faedb5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
34 CoreFoundation 0x0000000105a28dc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
35 CoreFoundation 0x0000000105a28d20 __CFRunLoopDoObservers + 368
36 CoreFoundation 0x0000000105a1eb53 __CFRunLoopRun + 1123
37 CoreFoundation 0x0000000105a1e486 CFRunLoopRunSpecific + 470
38 GraphicsServices 0x00000001085d29f0 GSEventRunModal + 161
39 UIKit 0x0000000105ee0420 UIApplicationMain + 1282
40 Gallery 0x000000010346ded3 main + 115
41 libdyld.dylib 0x0000000107325145 start + 1
42 ??? 0x0000000000000001 0x0 + 1
)
Can anybody tell me the reason for this?
The server JSON is an array of a string, ["some title"], and you expect it to be just a string "some title".
Try adding an assertion so that your parsing of the server data is correct.
News* currentNews = (News*)[self.newsList objectAtIndex:indexPath.row];
NSAssert([currentNews.title isKindOfClass:[NSString class]],
#"Title is not a string but a %#.",
NSStringFromClass([currentNews.title class]));
cell.newsTitle.text = currentNews.title;
It simply indicates at some point when you try to access title value in currentNews object, it would be null. thats why your app throws exception. put a condition to check null value.
Use following method to check any value/object exist or not.
Usage
write following code in your cellForRowAtIndexPath method.
if([self isEmpty:currentNews.title])
{
cell.newsTitle.text = #"default value";
}
else
{
cell.newsTitle.text = currentNews.title[0];
}
// Method to check empty value/object
- (BOOL)isEmpty:(id)object
{
return object == nil
|| [object isKindOfClass:[NSNull class]]
|| ([object respondsToSelector:#selector(length)]
&& [(NSData *)object length] == 0)
|| ([object respondsToSelector:#selector(count)]
&& [(NSArray *)object count] == 0);
}
I am attempting to display Instagram Comments in a Detail View Controller. I am pushing the data from a Master View Controller shown below:
MessageViewController *message = [[MessageViewController alloc] init];
NSInteger row = [[self tableView].indexPathForSelectedRow row];
NSDictionary *pic = [instaPics objectAtIndex:row];
message.instagramData = pic;
[self.navigationController pushViewController:message animated:YES];
However when I tap the button to go to the Detail View Controller I get this error:
2015-05-02 01:29:56.464 Floadt[40646:4284271] Successfully commented Picture
2015-05-02 01:29:56.516 Floadt[40646:4284271] -[__NSCFArray objectForKeyedSubscript:]: unrecognized selector sent to instance 0x7fd06be6cc40
2015-05-02 01:29:56.529 Floadt[40646:4284271] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray objectForKeyedSubscript:]: unrecognized selector sent to instance 0x7fd06be6cc40'
*** First throw call stack:
(
0 CoreFoundation 0x000000010dc5bc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010d537bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010dc630ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010dbb913c ___forwarding___ + 988
4 CoreFoundation 0x000000010dbb8cd8 _CF_forwarding_prep_0 + 120
5 Floadt 0x000000010a1104d0 -[MessageViewController messageCellForRowAtIndexPath:] + 256
6 Floadt 0x000000010a11035c -[MessageViewController tableView:cellForRowAtIndexPath:] + 188
7 UIKit 0x000000010c36ca28 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 508
8 UIKit 0x000000010c34b248 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2853
9 UIKit 0x000000010c3618a9 -[UITableView layoutSubviews] + 210
10 UIKit 0x000000010c2eba2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
11 QuartzCore 0x000000010c0afec2 -[CALayer layoutSublayers] + 146
12 QuartzCore 0x000000010c0a46d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
13 UIKit 0x000000010c2df675 -[UIView(Hierarchy) layoutBelowIfNeeded] + 607
14 Floadt 0x000000010a0908a8 -[SLKTextViewController viewWillAppear:] + 296
15 UIKit 0x000000010c39ffa1 -[UIViewController _setViewAppearState:isAnimating:] + 487
16 UIKit 0x000000010c3c1395 -[UINavigationController _startCustomTransition:] + 887
17 UIKit 0x000000010c3cd3bf -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
18 UIKit 0x000000010c3cdf0e -[UINavigationController __viewWillLayoutSubviews] + 43
19 UIKit 0x000000010c518715 -[UILayoutContainerView layoutSubviews] + 202
20 UIKit 0x000000010c2eba2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
21 QuartzCore 0x000000010c0afec2 -[CALayer layoutSublayers] + 146
22 QuartzCore 0x000000010c0a46d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
23 QuartzCore 0x000000010c0a4546 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
24 QuartzCore 0x000000010c010886 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
25 QuartzCore 0x000000010c011a3a _ZN2CA11Transaction6commitEv + 462
26 QuartzCore 0x000000010c0120eb _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
27 CoreFoundation 0x000000010db8eca7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
28 CoreFoundation 0x000000010db8ec00 __CFRunLoopDoObservers + 368
29 CoreFoundation 0x000000010db84a33 __CFRunLoopRun + 1123
30 CoreFoundation 0x000000010db84366 CFRunLoopRunSpecific + 470
31 GraphicsServices 0x000000010f611a3e GSEventRunModal + 161
32 UIKit 0x000000010c26b900 UIApplicationMain + 1282
33 Floadt 0x000000010a113c5f main + 111
34 libdyld.dylib 0x000000010fe26145 start + 1
35 ??? 0x0000000000000001 0x0 + 1
)
Here is my setup code for adding a UITableViewCell to the Table View Controller:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [self messageCellForRowAtIndexPath:indexPath];
}
- (MessageTableViewCell *)messageCellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MessageTableViewCell *cell = (MessageTableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:MessengerCellIdentifier];
NSDictionary *instaPics = self.instagramData;
NSString *commentText = instaPics[#"comments"][#"data"][#"text"];
Message *message = self.messages[indexPath.row];
cell.titleLabel.text = message.username;
cell.bodyLabel.text = commentText;
if (message.attachment) {
cell.attachmentView.image = message.attachment;
cell.attachmentView.layer.shouldRasterize = YES;
cell.attachmentView.layer.rasterizationScale = [UIScreen mainScreen].scale;
}
cell.indexPath = indexPath;
cell.usedForMessage = YES;
if (cell.needsPlaceholder)
{
CGFloat scale = [UIScreen mainScreen].scale;
if ([[UIScreen mainScreen] respondsToSelector:#selector(nativeScale)]) {
scale = [UIScreen mainScreen].nativeScale;
}
CGSize imgSize = CGSizeMake(kAvatarSize*scale, kAvatarSize*scale);
[LoremIpsum asyncPlaceholderImageWithSize:imgSize
completion:^(UIImage *image) {
UIImage *thumbnail = [UIImage imageWithCGImage:image.CGImage scale:scale orientation:UIImageOrientationUp];
cell.thumbnailView.image = thumbnail;
cell.thumbnailView.layer.shouldRasterize = YES;
cell.thumbnailView.layer.rasterizationScale = [UIScreen mainScreen].scale;
}];
}
// Cells must inherit the table view's transform
// This is very important, since the main table view may be inverted
cell.transform = self.tableView.transform;
return cell;
}
Instagram JSON Data:
{
attribution = "<null>";
caption = {
"created_time" = 1430594453;
from = {
"full_name" = "Siwani Regmi";
id = 247899182;
"profile_picture" = "https://igcdn-photos-g-a.akamaihd.net/hphotos-ak-xpa1/t51.2885-19/10948979_810376228999798_661235337_a.jpg";
username = "siwani_32";
};
id = 976219494210952254;
text = "perfect night with the most perfect man\Ud83d\Ude1b\Ud83c\Udf89\U2728 #seniorprom";
};
comments = {
count = 0;
data = (
);
};
"created_time" = 1430594453;
filter = Normal;
id = "976219491862142549_247899182";
images = {
"low_resolution" = {
height = 306;
url = "https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-15/s306x306/e15/11191276_1060001617348197_1550964556_n.jpg";
width = 306;
};
"standard_resolution" = {
height = 640;
url = "https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-15/e15/11191276_1060001617348197_1550964556_n.jpg";
width = 640;
};
thumbnail = {
height = 150;
url = "https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-15/s150x150/e15/11191276_1060001617348197_1550964556_n.jpg";
width = 150;
};
};
likes = {
count = 17;
data = (
{
"full_name" = "Bridget Carroll";
id = 223765496;
"profile_picture" = "https://igcdn-photos-e-a.akamaihd.net/hphotos-ak-xpa1/t51.2885-19/11208422_409436919229236_670022667_a.jpg";
username = "bridget_carroll33";
},
{
"full_name" = "";
id = 190249955;
"profile_picture" = "https://igcdn-photos-g-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/10747956_726218724133062_1939114518_a.jpg";
username = hayleymarierussell;
},
{
"full_name" = "Jill Bracaglia";
id = 205453413;
"profile_picture" = "https://instagramimages-a.akamaihd.net/profiles/profile_205453413_75sq_1373835555.jpg";
username = "jilli_beanz";
},
{
"full_name" = "Priya Nakhre";
id = 177807366;
"profile_picture" = "https://igcdn-photos-c-a.akamaihd.net/hphotos-ak-xtp1/t51.2885-19/11098479_870674976323434_1264837026_a.jpg";
username = priyanakhre;
}
);
};
link = "https://instagram.com/p/2MOnSjQV5V/";
location = {
id = 764529229;
};
tags = (
seniorprom
);
type = image;
user = {
"full_name" = "Siwani Regmi";
id = 247899182;
"profile_picture" = "https://igcdn-photos-g-a.akamaihd.net/hphotos-ak-xpa1/t51.2885-19/10948979_810376228999798_661235337_a.jpg";
username = "siwani_32";
};
"user_has_liked" = 0;
"users_in_photo" = (
{
position = {
x = "0.358666667";
y = "0.32";
};
user = {
"full_name" = "Sahan Pandey \U26bd";
id = 435571613;
"profile_picture" = "https://igcdn-photos-a-a.akamaihd.net/hphotos-ak-xpa1/t51.2885-19/10727510_301263856731264_1868575282_a.jpg";
username = pandeyexpress;
};
}
);
}
I have the following code and receive the error code indicated in title:
This is the only messages i send to User object (other than initialising it by using "new")
When I out comment addObject: it doesn't complain.
Can anybody help? Thanks!
self.freshUser.name = self.name.text;
self.freshUser.age = (int)self.age.text;
self.freshUser.gender = self.gender.text;
//NSLog(#"%#",[NSThread callStackSymbols]);
[appDelegate.users addObject:self.freshUser];
(My user object subclasses NSObject. it has more property that I don't use. just a little extra info)
-(UITableViewCell *)tableView:(UITableView *)tableViewPara cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UserCell *cell = [tableViewPara dequeueReusableCellWithIdentifier:usersTableIdentifier forIndexPath:indexPath];
if(indexPath.row == [appDelegate.users count]){
cell.nameLabel.text = #"+";
cell.nameLabel.font = [UIFont systemFontOfSize:36];
cell.bgImg.image = [UIImage imageNamed:#"background_gray"];
cell.statusImg.image = nil;
}else{
cell.nameLabel.text = appDelegate.users[indexPath.row];
cell.nameLabel.font = [UIFont systemFontOfSize:17];
cell.bgImg.image = [UIImage imageNamed:#"background_dark_red"];
cell.statusImg.image = [UIImage imageNamed:#"icon_cloud"];
}
cell.nameLabel.textAlignment = NSTextAlignmentCenter;
cell.nameLabel.textColor = [UIColor whiteColor];
cell.nameLabel.backgroundColor = [UIColor clearColor];
return cell;
}
space
0 CoreFoundation 0x000000010ff1bf35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010fbb4bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010ff2304d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010fe7b27c ___forwarding___ + 988
4 CoreFoundation 0x000000010fe7ae18 _CF_forwarding_prep_0 + 120
5 UIKit 0x00000001104d034b -[UILabel _setFont:] + 101
6 Raymio 0x000000010f67857f -[StartViewController tableView:cellForRowAtIndexPath:] + 991
7 UIKit 0x00000001103ff4b3 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 508
8 UIKit 0x00000001103defb1 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2846
9 UIKit 0x00000001103f4e3c -[UITableView layoutSubviews] + 213
10 UIKit 0x0000000110381973 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
11 QuartzCore 0x0000000113c09de8 -[CALayer layoutSublayers] + 150
12 QuartzCore 0x0000000113bfea0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
13 QuartzCore 0x0000000113bfe87e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
14 QuartzCore 0x0000000113b6c63e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
15 QuartzCore 0x0000000113b6d74a _ZN2CA11Transaction6commitEv + 390
16 QuartzCore 0x0000000113b6ddb5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
17 CoreFoundation 0x000000010fe50dc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
18 CoreFoundation 0x000000010fe50d20 __CFRunLoopDoObservers + 368
19 CoreFoundation 0x000000010fe46b53 __CFRunLoopRun + 1123
20 CoreFoundation 0x000000010fe46486 CFRunLoopRunSpecific + 470
21 GraphicsServices 0x00000001134fd9f0 GSEventRunModal + 161
22 UIKit 0x0000000110308420 UIApplicationMain + 1282
23 Raymio 0x000000010f678a83 main + 115
24 libdyld.dylib 0x00000001124ab145 start + 1
This line:
cell.nameLabel.text = appDelegate.users[indexPath.row];
You're trying to set a User object to the text of a label field. That's not going to work. You'll want this or something close:
cell.nameLabel.text = ((User *)appDelegate.users[indexPath.row]).name;
You shared your stack trace with us. A useful technique is to look in it for anything that references code you wrote. You may notice that line 6 references your StartViewController:
6 Raymio 0x000000010f67857f -[StartViewController tableView:cellForRowAtIndexPath:] + 991
You can show the relevant line of code by typing source list command using that address in the third column:
(lldb) source list -a 0x000000010f67857f
43 cell.nameLabel.text = #"+";
44 cell.nameLabel.font = [UIFont systemFontOfSize:36];
45 cell.bgImg.image = [UIImage imageNamed:#"background_gray"];
46 cell.statusImg.image = nil;
47 }else{
-> 48 cell.nameLabel.text = appDelegate.users[indexPath.row];
49 cell.nameLabel.font = [UIFont systemFontOfSize:17];
50 cell.bgImg.image = [UIImage imageNamed:#"background_dark_red"];
51 cell.statusImg.image = [UIImage imageNamed:#"icon_cloud"];
52 }
Clearly your line numbers and memory addresses will vary, but hopefully this will illustrate the idea. Scan the stack trace for anything that references your code, and examine that line of code for any potential issues.
By the way, this discussion. also shows you how to use the -[StartViewController tableView:cellForRowAtIndexPath:] + 991 of the stack trace to show the relevant line of code.
I have a NSDictionary that I add to a mutable array but when I try add the array to populate a uitableview I get an error.
NSMutableArray *array = [[NSMutableArray alloc] init];
for (id element in self.categoriesMutableNameArray) {
[array addObject:#"No"];
}
self.categoryDict = #{ #"title" : self.categoriesMutableNameArray, #"selected" : array};
self.categoryArr = [[NSMutableArray alloc] init];
self.categoryMutableDict = [NSMutableDictionary dictionaryWithDictionary:self.categoryDict];
[self.categoryArr addObject:self.categoryDict];
and the following categoryArr is printed like this:
2014-02-27 15:09:07.397 App[7982:70b] (
{
selected = (
No,
No,
No,
No,
No,
No,
No,
No,
No,
No,
No,
No,
No,
No
);
title = (
"Fashion - Women",
"Fashion - Men",
Kids,
"Accessories - Women",
"Accessories - Men",
"Styling / Hair",
Inspiration,
"Decoration / Architecture",
"Great Places",
"Art / Design",
"Music / Movie / Books",
"Food / Drink",
"Gadgets / Tech",
Rides
);
}
)
The trouble I am having is in the uitableview cellforrowatindexpath method I try and add the title key for the categoryArr to populate the uitableview and I get the following error on this line:
UILabel *categoryLabel = (UILabel *)[cell viewWithTag:111];
categoryLabel.text = [NSString stringWithFormat:#"%#",[[self.categoryArr objectAtIndex:indexPath.row] objectForKey:#"title"];
And the error log:
2014-02-27 15:24:33.804 App[8153:70b] -[__NSArrayM length]: unrecognized selector sent to instance 0xa9bc3a0
2014-02-27 15:24:33.807 App[8153:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM length]: unrecognized selector sent to instance 0xa9bc3a0'
*** First throw call stack:
(
0 CoreFoundation 0x020c75e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01e4a8b6 objc_exception_throw + 44
2 CoreFoundation 0x02164903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x020b790b ___forwarding___ + 1019
4 CoreFoundation 0x020b74ee _CF_forwarding_prep_0 + 14
5 Foundation 0x006e18ed -[NSConcreteMutableAttributedString replaceCharactersInRange:withString:] + 39
6 Foundation 0x006e255a -[NSConcreteMutableAttributedString initWithString:attributes:] + 293
7 UIKit 0x01172bc6 -[UILabel _setText:] + 97
8 UIKit 0x01172d84 -[UILabel setText:] + 40
9 App 0x00047ebd -[PiccImageCategoriesViewController tableView:cellForRowAtIndexPath:] + 1533
10 UIKit 0x010b461f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412
11 UIKit 0x010b46f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
12 UIKit 0x01098774 -[UITableView _updateVisibleCellsNow:] + 2378
13 UIKit 0x010abe95 -[UITableView layoutSubviews] + 213
14 UIKit 0x01030267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
15 libobjc.A.dylib 0x01e5c81f -[NSObject performSelector:withObject:] + 70
16 QuartzCore 0x00c8e2ea -[CALayer layoutSublayers] + 148
17 QuartzCore 0x00c820d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
18 QuartzCore 0x00c81f40 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
19 QuartzCore 0x00be9ae6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
20 QuartzCore 0x00beae71 _ZN2CA11Transaction6commitEv + 393
21 QuartzCore 0x00beb544 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
22 CoreFoundation 0x0208f4ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
23 CoreFoundation 0x0208f41f __CFRunLoopDoObservers + 399
24 CoreFoundation 0x0206d344 __CFRunLoopRun + 1076
25 CoreFoundation 0x0206cac3 CFRunLoopRunSpecific + 467
26 CoreFoundation 0x0206c8db CFRunLoopRunInMode + 123
27 GraphicsServices 0x027779e2 GSEventRunModal + 192
28 GraphicsServices 0x02777809 GSEventRun + 104
29 UIKit 0x00fc5d3b UIApplicationMain + 1225
30 App 0x0001406d main + 141
31 libdyld.dylib 0x02f4d70d start + 1
32 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Thanks
The return of [[self.categoryArr objectAtIndex:indexPath.row] objectForKey:#"title"]; is a array of NSString, categoryLabel.text = [NSString stringWithFormat:#"%#", /*the return array*/]; this is the problem.
Maybe what you want is:
NSArray *categoryDetailArr = [[self.categoryArr objectAtIndex:indexPath.section] objectForKey:#"title"];
categoryLabel.text = [[categoryDetailArr objectAtIndex:indexPath.row];
Write this code
categoryLabel.text = [[[self.categoryArr objectAtIndex:0] objectForKey:#"title"]objectAtIndex:indexPath.row];
instead OF
categoryLabel.text = [NSString stringWithFormat:#"%#",[[self.categoryArr objectAtIndex:indexPath.row] objectForKey:#"title"];
And plz check that in UITableView dataSource methods i.e
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [categoryLabel objectAtIndex:0]valueForKey:#"selected"].count;
}
OR
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [categoryLabel objectAtIndex:0]valueForKey:#"title"].count;
}