Это мой код:
- (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]; }
все мои данные печатаются нормально, но в этой строке
[eventPHP addObject:[Events eventsNamed:[tempdict objectForKey:@"title"] description:[tempdict objectForKey:@"description"] date:t]];
есть исключение:
** Завершение работы приложения из-за необработанного исключения «NSInvalidArgumentException», причина: '- [__ NSDate length]: нераспознанный селектор отправлен в экземпляр 0x6149cb0'