相关疑难解决方法(0)

为什么我不能再释放一个物体了?

在我更新到Xcode 4.2后,我无法再发布任何内容.当我开始键入"release"时,它会建议"释放",但是会有一条红线.

如果我写它仍然显示错误并显示以下两条消息:

'release'不可用:在自动引用计数模式下不可用自动引用计数禁止显式消息发送'release'

有谁知道我能做什么?

objective-c automatic-ref-counting

26
推荐指数
1
解决办法
4万
查看次数

错误'autorelease'不可用:在自动参考计数模式下不可用

我尝试使用Stig的JSON库发出HTTP请求并解析JSON.我收到此错误'autorelease'不可用:当我使用此代码时,在自动引用计数模式下不可用

NSURLRequest *request2;
request2 = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://sandbox.CompanyName.com/api/%@/users/%@/user_badges?url=CompanyName.map2.com&amount=999999999999",[information stringForKey:@"apiKey"] , [information stringForKey:@"userID"]]]];

NSURLConnection *connection2;
connection2 = [[NSURLConnection alloc] initWithRequest:request2 delegate:self startImmediately:YES];
NSURLResponse *resp2;
NSData *cData2 = [NSURLConnection sendSynchronousRequest:request2 returningResponse:&resp2 error:nil];
NSString *cDataString2 = [[NSString alloc] initWithData:cData2 encoding:NSUTF8StringEncoding];
NSLog(@"getUsersBadges called");
NSError *error4;
SBJSON *json4 = [[SBJSON new] autorelease];
// NSArray *luckyNumbers = [json objectWithString:responseString error:&error];
NSDictionary *luckyNumbers4 = [json4 objectWithString:cDataString2 error:&error4];

[cDataString2 release]; 
Run Code Online (Sandbox Code Playgroud)

UPDATE

对于任何感兴趣的人,这是正确的代码:NSURLRequest*request2; request2 = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@" http://sandbox.CompanyName.com/api/%@/users/%@/user_badges?url=CompanyName.map2.com&ount =999999999999 ",[ information stringForKey:@"apiKey"],[information stringForKey:@"userID"]]]];

NSURLConnection *connection2;
connection2 …
Run Code Online (Sandbox Code Playgroud)

iphone ios automatic-ref-counting

15
推荐指数
2
解决办法
3万
查看次数

Xcode ARC(自动引用计数),"发布不可用"

我第一次使用Xcode时,我在线学习了一个教程.我按照教程向我展示了所有内容,但我担心它已经过时了.

我遇到的错误是:

[font_attributes release]; 
Run Code Online (Sandbox Code Playgroud)

'release'不可用:在自动参考计数模式下不可用

ARC禁止"发布"的显式消息发送

我对Cocoa和Xcode的了解有限,但我仍然希望扩展我的学习.

我该如何解决这个ARC问题?

xcode cocoa automatic-ref-counting

8
推荐指数
2
解决办法
3万
查看次数

标签 统计

automatic-ref-counting ×3

cocoa ×1

ios ×1

iphone ×1

objective-c ×1

xcode ×1