私は ASIFormDataRequest を使用しており、次のコードでどこかに EXC_BAD_ACCESS を与えています。NSZombie を有効にしましたが、これは ASIFormDataRequest と関係があり、責任のあるライブラリは GraphicsServices であることがわかります。
データを取得するためのさまざまなメソッドを保持する別のクラスがあり、UIViewControllers からこれらのメソッドを呼び出すことができます...
- (Account *) signInAccount:(NSString *)duid user:(NSString *)userName password: (NSString *)passWord
{
Account *myAccount = [[[Account alloc] init] autorelease];
NSURL *apiURL = [NSURL URLWithString:@"http://xxxxxxxxxxxxxxx.com/api.json"];
ASIFormDataRequest *request = [[ASIFormDataRequest requestWithURL:apiURL] autorelease];
[request addPostValue:@"duid025" forKey:@"duid"]; //todo - add the actual passed in value
[request addPostValue:userName forKey:@"user[email]"];
[request addPostValue:passWord forKey:@"user[password]"];
[request setUsername:@"xxxxxxxx"];
[request setPassword:@"yyyyyyyy"];
[request startSynchronous];
int statusCode = request.responseStatusCode;
NSDictionary *json = [request.responseString JSONValue];
NSString *status = [json valueForKeyPath:@"status"];
NSLog(@"API JSON %@", request.responseString);
myAccount.statusCode = statusCode;
if(statusCode == 200)
{
myAccount.status = status;
myAccount.error = @"";
Credentials *myCredentials = [[Credentials alloc] init];
myCredentials.emailAddress = userName;
myCredentials.passWord = passWord;
myAccount.credentials = myCredentials;
//assign division to default division
}
else if(statusCode==403)
{
NSString *error = [json valueForKeyPath:@"error"];
myAccount.status = status;
myAccount.error = error;
}
else
{
// major issue, probably connection
}
return myAccount;
}