这是我的代码
TWRequest *twRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@", kTwitterURLBase, kTwitterMethodHelpConfiguration]]
parameters:nil
requestMethod:TWRequestMethodGET];
[twRequest setAccount:[self twitterAccount]];
[twRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
// Handling
}];twitterAccount方法
- (ACAccount *)twitterAccount {
NSString *identifier = [[Session getInstance] selectedAccountIdentifier];
ACAccount *account = nil;
if ([identifier length] > 0) {
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
account = [accountStore accountWithIdentifier:identifier];
}
return account;
}正如调试器所说,帐户被正确返回,但是当我在控制台中打印它时,我什么也得不到,一个空格;但是account对象有一个引用。
就在开始执行请求之后,我得到了一个EXC_BAD_ACCESS错误。堆栈说明错误发生在发送错误的消息[ACAccount accountType]时。
很明显,这是一个内存问题,我刚接触ARC,所以我猜问题应该在那里。
有什么帮助吗?
发布于 2012-09-12 22:07:27
我不知道为什么我一定要这样做,但是如果我声明一个实例变量来保留ACAccountStore,并以这种方式更改方法
- (ACAccount *)twitterAccount {
NSString *identifier = [[Session getInstance] selectedAccountIdentifier];
ACAccount *account = nil;
if ([identifier length] > 0) {
if (accountStore_ == nil) {
accountStore_ = [[ACAccountStore alloc] init];
}
account = [accountStore_ accountWithIdentifier:identifier];
}
return account;
}一切都很完美。为什么?:\
https://stackoverflow.com/questions/12389372
复制相似问题