Reputation: 13
This is my code :
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *str = [[[NSString alloc] initWithData:buffer encoding:NSUTF8StringEncoding] autorelease];
NSLog(@"str: %@",str);
NSDictionary *dict = [str JSONValue];
NSDateFormatter *fmt = [[[NSDateFormatter alloc] init] autorelease];
[fmt setDateFormat:@"yyyy-MM-dd"];
NSArray *array = [[dict objectForKey:@"event"] retain];
NSLog(@"Array: %@",array);
for (NSDictionary *tempdict in array)
{
NSDate *d = [fmt dateFromString:[tempdict objectForKey:@"eve_date"]];
NSLog(@"Date %@",d);
NSLog(@"Date of event %@",[tempdict objectForKey:@"eve_date"]);
NSDate *t =[tempdict objectForKey:@"eve_date"];
NSLog(@"Date of t %@",t);
NSLog(@"This is title_event %@",[tempdict objectForKey:@"title"]);
NSLog (@"Time of event %@", [tempdict objectForKey:@"eve_time"]);
NSLog(@"This is description %@",[tempdict objectForKey:@"description"]);
[eventPHP addObject:[Events eventsNamed:[tempdict objectForKey:@"title"] description:[tempdict objectForKey:@"description"] date:t]];}
dataReady = YES;
[callback loadedDataSource:self];}
+ (Events*)eventsNamed:(NSString *)atitle description:(NSString *)adescription date:(NSDate *)aDate {
return [[[Events alloc] initWithName:atitle description:adescription date:aDate] autorelease]; }
it is print all my data fine but in this line
[eventPHP addObject:[Events eventsNamed:[tempdict objectForKey:@"title"] description:[tempdict objectForKey:@"description"] date:t]];
there is exception :
** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDate length]: unrecognized selector sent to instance 0x6149cb0'
Upvotes: 0
Views: 2361
Reputation: 385540
You're sending the length
message to an NSDate
object, but NSDate
objects do not understand the length
message. You did not show us the code that sends that message.
If you set a breakpoint on objc_exception_throw
, Xcode will stop your app in the debugger when the exception occurs, so you can see exactly where the length
message is sent.
Upvotes: 1