我是iOS開發的新手,我目前正在使用ARC測試RestCit 0.9.3 for iOS和xCode 4.2,我遇到了一些簡單的獲取請求的問題。RestKit iOS:簡單的請求錯誤
我下面這個教程:https://github.com/RestKit/RestKit/wiki/Tutorial-%3A-Introduction-to-RestKit
我嘗試發送一個簡單的GET請求,我的web服務上TouchUpInside
一個UIButton
。
但是我收到一個 「EXC_BAD_ACCESS」:[6373:fb03] *** -[DataAccess respondsToSelector:]: message sent to deallocated instance 0x8275160
在此行中的應用程序停機,對RKRequest.m
文件:
if ([self.delegate respondsToSelector:@selector(requestDidStartLoad:)]) {
[self.delegate requestDidStartLoad:self];
}
我的代碼:
MyViewController.m:
- (IBAction)myAction:(id)sender {
DataAccess *data = [DataAccess alloc];
[data sendRequests];
}
數據訪問:
@implementation DataAccess
-(void)sendRequests {
[RKClient clientWithBaseURL:SERVER_URL username:SERVER_USERNAME password:SERVER_PASSWORD];
[[RKClient sharedClient] get:@"/myDistantAction" delegate:self];
}
#pragma mark - Delegate
-(void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response {
if ([response isOK]) {
NSLog(@"Retrieved : %@", [response bodyAsString]);
}
}
@end
我在互聯網上搜索,但我沒有找到解決辦法
有人能幫助我嗎?
謝謝,
你可以嘗試讓數據訪問爲單身? 我認爲這是你的問題 – Beber 2012-02-13 01:11:32