當我的NSLog affecteddate值它顯示正確的,但是當我將它存儲在VAR它給出錯誤的值JSON解析數據顯示,iPhone爲同一對象的不同值
SBJsonParser *parser= [[SBJsonParser alloc] init];
NSString *url = [NSString stringWithFormat:@"http://www.krsconnect.no/community/api.html?method=bareListEventsByCategory&appid=620&category-selected=%@&counties-selected=Vest-Agder,Aust-Agder&range=0-10", test];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
NSDictionary *object = [parser objectWithString:json_string error:nil];
NSArray *results = [parser objectWithString:json_string error:nil];
appDelegate.books1 = [[NSMutableArray alloc] init];
appDelegate.dates =[[NSMutableArray alloc]init];
appDelegate.books2=[[NSMutableArray alloc]init];
appDelegate.books3=[[NSMutableArray alloc]init];
appDelegate.books4=[[NSMutableArray alloc]init];
appDelegate.books5=[[NSMutableArray alloc]init];
appDelegate.books6=[[NSMutableArray alloc]init];
appDelegate.books7=[[NSMutableArray alloc]init];
appDelegate.books8=[[NSMutableArray alloc]init];
appDelegate.books9=[[NSMutableArray alloc]init];
appDelegate.books10=[[NSMutableArray alloc]init];
NSArray *activitiesArray;
mycount=[results count];
for (int j=0;j<[results count]; j++) {
NSDictionary *dictOne = [results objectAtIndex:j];
NSLog(@"%@ - %@", [dictOne objectForKey:@"date"]);
Date *aDate = [[Date alloc] initWithDictionary:[results objectAtIndex:j]];
[appDelegate.dates addObject:aDate];
[aDate release];
activitiesArray = [dictOne objectForKey:@"events"];
for (int i=0; i<[activitiesArray count]; i++) {
int testcount =[activitiesArray count];
NSDictionary *dictTwo = [activitiesArray objectAtIndex:i];
NSDictionary *eventDict=[dictTwo objectForKey:@"event"];
// NSLog(@"%@ - %@", [dictOne objectForKey:@"date"]);
// NSLog(@"%@ - %@", [dictTwo objectForKey:@"affectedDate"]);
// NSLog(@"%@ - %@", [eventDict objectForKey:@"location"]);
NSInteger*date=[dictTwo objectForKey:@"affectedDate"];
NSInteger*affecteddate=[dictTwo objectForKey:@"affectedDate"];
NSLog(@"%@ - %@", [dictTwo objectForKey:@"affectedDate"]);
NSString*appId =[eventDict objectForKey:@"appId"];
NSLog(@"%@ - %@", [eventDict objectForKey:@"eventId"]);
NSInteger*eventId=[eventDict objectForKey:@"eventId"];
int next=[affecteddate intValue];
int next_int = [eventId intValue];
NSString*location=[eventDict objectForKey:@"location"];
NSString*municipality=[eventDict objectForKey:@"municipality"];
NSString*title=[eventDict objectForKey:@"title"];
Book1 *aBook=[[Book1 alloc] initWithDate:date affecteddate:affecteddate eventId:eventId location:location municipality:municipality title:title];
第一冊類 @interface第一冊:NSObject的{ NSInteger的*日期; NSInteger * affecteddate;
NSString *title;
NSString *location;
NSString *municipality;
NSInteger eventId;
NSString* event;
}
@property(nonatomic,readwrite) NSInteger eventId;
@property(nonatomic,retain) NSString* event;
@property(nonatomic) NSInteger *date;
@property(nonatomic,readwrite)NSInteger* affecteddate;
@property(nonatomic,retain)NSString *title;
@property(nonatomic,retain) NSString *location;
@property(nonatomic,retain) NSString *municipality;
-(id)initWithDate:(NSInteger *)d affecteddate:(NSInteger *)ad eventId:(NSInteger*)eId location:(NSString *)l municipality:(NSString *)m title:(NSString *)t ;
@end
什麼是「正確的」這裏什麼是「錯了嗎?」 –
nslog值是正確的 – ali
你認爲NSLog輸出是「正確的」,並且你認爲「錯誤的」是什麼?你不應該需要一頁代碼來證明這一點。 –