首先,您需要閱讀一些iOS編程基礎知識。而且,
NSMutableDictionary *temp = [[NSMutableDictionary alloc]init];
NSString *responseString = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding];
temp = [responseString JSONValue]; //----> this line is wrong
因爲,temp
指針指向新創建NSMutableDictionary
對象時,你重新分配給由JSONValue
方法,這是autorelease
對象返回另一個對象,你並不擁有它,從而可以」 t release
它。一些更好的方法來達到想要你想會是:
NSString *responseString = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding];
NSMutableDictionary *temp = [responseString JSONValue];
NSLog(@"webdata is %@",temp);
NSLog(@"inside usersignup success");
[[NSNotificationCenter defaultCenter] postNotificationName:CNotifySignupSucess object:temp];
//NO RELEASING the AUTORELEASE OBJECT!!!!
OR:
NSString *responseString = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding];
NSMutableDictionary *temp = [[NSMutableDictionary alloc]initWithDictionary:[responseString JSONValue]];
NSLog(@"webdata is %@",temp);
NSLog(@"inside usersignup success");
[[NSNotificationCenter defaultCenter] postNotificationName:CNotifySignupSucess object:temp];
[temp release];
OR:
NSMutableDictionary *temp = [[NSMutableDictionary alloc]init];
NSString *responseString = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding];
[temp addEntriesFromDictionary:[responseString JSONValue]];
NSLog(@"webdata is %@",temp);
NSLog(@"inside usersignup success");
[[NSNotificationCenter defaultCenter] postNotificationName:CNotifySignupSucess object:temp];
[temp release];
在過去的2情況下,我正在考慮是JSONValue
方法返回NSDictionary
。祝你好運!
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(signupsucessreceived :) name:CNotifySignupSucess object:nil]; – jpd 2013-03-06 05:20:52
NSMutableDictionary * dict = notification.object;如果([[dict objectForKey:@「Success」] isEqualToString:@「1」]) { appDelegate.islogin = TRUE; self.title = nil; [appDelegate.userinfo setObject:[dict objectForKey:@「user_id」] forKey:@「userid」]; NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; NSString * strtemp = [NSString stringWithFormat:@「%@」,[dict objectForKey:@「user_id」]]; [默認setObject:strtemp forKey:@「userid」]; – jpd 2013-03-06 05:21:38
羅布我試圖這 – jpd 2013-03-06 05:22:49