我在我的应用程序中集成了facebook api,运行正常。现在我正在努力获得新的更新。我在每1分钟的时间间隔内打电话给NStimer。它第一次调用很好但是第二次或第三次调用函数我得到一个EXC_BAD_ACCESS异常。这是我的代码详细信息。
@interface {
NSMutableArray* prevFacebookMessageList;
}
//从UIPickerView中选择时间
- (void)pickerView:(UIPickerView *)pickerView didSelectRow: (NSInteger)row inComponent:(NSInteger)component {
[NSTimer scheduledTimerWithTimeInterval:updateTime target:self selector:@selector(updateMethod) userInfo:nil repeats:YES];
}
// Facebook功能
- (void)request:(FBRequest*)request didLoad:(id)result {
int preFacebookCount=0;
if([prevFacebookMessageList count]>0) {
preFacebookCount=[prevFacebookMessageList count];
prevFacebookMessageList=nil;
}
prevFacebookMessageList=[[result objectAtIndex:5]objectForKey:@"fql_result_set" ] ;
// Showing a image icon if update occured on interface
if([prevFacebookMessageList count] > preFacebookCount && updateImage.hidden) {
updateImage.hidden=NO;
}
}
//这个facebook api函数抛出异常
- (id)parseXMLResponse:(NSData*)data error:(NSError**)error {
FBXMLHandler* handler = [[[FBXMLHandler alloc] init] autorelease];
NSXMLParser* parser = [[[NSXMLParser alloc] initWithData:data] autorelease];
parser.delegate = handler ; **// EXCEPTION IS OCCURING TO THIS POINT "EXC_BAD_ACCESS EXCEPTION"**
[parser parse];
if (handler.parseError) {
if (error) {
*error = [[handler.parseError retain] autorelease];
}
return nil;
} else if ([handler.rootName isEqualToString:@"error_response"]) {
NSDictionary* errorDict = handler.rootObject;
NSInteger code = [[errorDict objectForKey:@"error_code"] intValue];
NSDictionary* info = [NSDictionary dictionaryWithObjectsAndKeys:
[errorDict objectForKey:@"error_msg"], NSLocalizedDescriptionKey,
[errorDict objectForKey:@"request_args"], @"request_args",
nil];
if (error) {
*error = [NSError errorWithDomain:FBAPI_ERROR_DOMAIN code:code userInfo:info];
}
return nil;
} else {
return [[handler.rootObject retain] autorelease];
}
}
提前致谢。