我試圖訪問函數外的nsstring數據以及類之外的數據。如何訪問函數外的字符串數據和類
如何在函數和類之外訪問useridStr
?這是我的代碼:
-(id)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *loginStatus = [[NSString alloc] initWithBytes:[webData mutableBytes]
length:[webData length] encoding:NSUTF8StringEncoding];
NSDictionary *loginDict = [[loginStatus JSONValue] objectForKey:@"UserDetails"];
NSArray *userId = [loginDict valueForKey: @"userid"];
NSString *useridStr = [userId lastObject];
NSLog(@"--------------....%@", useridStr);
}
你不使用Appdelegate類來存儲全局值嗎? – 2012-04-07 04:49:45