首先,您需要阅读一些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