这是我的标题部分:
@interface RootViewController : UIViewController
{
NSString *status_id;
}
在控制器文件中,我正在分配变量:
- (void)updateStatus
{
NSURL *url = [NSURL URLWithString:@"http://localhost/RightNow/API/status.json"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request startSynchronous];
NSError *error = [request error];
NSString *response = [NSString alloc];
NSError *error2;
NSData* data = [response dataUsingEncoding:NSUTF8StringEncoding];
NSMutableDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error2];
status_id = [json objectForKey:@"id"];
}
现在,当我再次尝试使用 status_id 时,我得到了错误
- (IBAction)likeClick:(id)sender
{
NSURL *url = [NSURL URLWithString:@"http://localhost/RightNow/API/vote"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setRequestMethod:@"POST"];
[request setPostValue:status_id forKey:@"id"]; //The error comes here
[request setPostValue:@"like" forKey:@"vote"];
[request startSynchronous];
}
对不起我的英语不好。请帮助我,谢谢!