Здравствуйте, у меня есть этот NS-объект:
@interface Checkin : NSObject {
NSString *name;
NSString *profID;
NSString *time;
NSString *lon;
NSString *lat;
NSString *country;
NSString *city;
NSString *place;
NSString *photoURL;
NSMutableArray *taggedID;
NSMutableArray *taggedName;
}
@property(nonatomic, retain)NSString *name;
@property(nonatomic, retain)NSString *profID;
@property(nonatomic, retain)NSString *time;
@property(nonatomic, retain)NSString *lon;
@property(nonatomic, retain)NSString *lat;
@property(nonatomic, retain)NSString *country;
@property(nonatomic, retain)NSString *city;
@property(nonatomic, retain)NSString *place;
@property(nonatomic, retain)NSString *photoURL;
@property(nonatomic, retain)NSMutableArray *taggedID;
@property(nonatomic, retain)NSMutableArray *taggedName;
@end
Теперь я хочу создать NSMutable Array и добавить в него несколько «Checkins».
Когда я делаю это:
Checkin *checkinsA = [[NSObject alloc] init];
NSDictionary *decodedJson = result;
NSArray *users = [decodedJson objectForKey:@"data"];
for(NSDictionary *user in users) {
NSLog(@"Created item: %@ \n", [user objectForKey:@"created_time"]);
checkinsA.time = [NSString stringWithFormat:@"%@",[user objectForKey:@"created_time"]];
NSDictionary *fromData = [user objectForKey:@"from"];
NSLog(@"user id is: %@ \n", [fromData objectForKey:@"id"]);
checkinsA.profID = [fromData objectForKey:@"id"];
NSLog(@"user name is: %@\n ", [fromData objectForKey:@"name"]);
checkinsA.name =[fromData objectForKey:@"name"];
NSDictionary *placeData = [user objectForKey:@"place"];
NSDictionary *locationData = [placeData objectForKey:@"location"];
NSLog(@"City: %@ \n", [locationData objectForKey:@"city"]);
checkinsA.city = [locationData objectForKey:@"city"];
NSLog(@"Country: %@ \n", [locationData objectForKey:@"country"]);
checkinsA.country = [locationData objectForKey:@"country"];
NSLog(@"Latitude: %@ \n", [locationData objectForKey:@"latitude"]);
checkinsA.lat = [locationData objectForKey:@"latitude"];
NSLog(@"Longitude: %@ \n", [locationData objectForKey:@"longitude"]);
checkinsA.lon = [locationData objectForKey:@"longitude"];
NSLog(@"Place name: %@ \n", [placeData objectForKey:@"name"]);
checkinsA.place = [placeData objectForKey:@"name"];
NSDictionary *tagData = [user objectForKey:@"tags"];
NSArray *tagDataArray = [tagData objectForKey:@"data"];
for(NSDictionary *tagData2 in tagDataArray){
NSLog(@"tagged user id is: %@ \n", [tagData2 objectForKey:@"id"]);
[checkinsA.taggedID addObject:[tagData2 objectForKey:@"id"]];
NSLog(@"tagged user name is: %@\n ", [tagData2 objectForKey:@"name"]);
[checkinsA.taggedName addObject:[tagData2 objectForKey:@"name"]];
}
[checkinArray addObject:checkinsA];
}
Я получаю ошибку:
- [NSObject setTime:]: нераспознанный селектор, отправленный экземпляру для checkinsA.time = [NSString stringWithFormat: @ "% @", [user objectForKey: @ "create_time"]];
Как правильно изменить значение checkinsA.time checkins.id и т. д.?