gpt4 book ai didi

iphone - 请求发送获取错误 : [CFString release]: message sent to deallocated instance 0x6a83e00

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:55:11 25 4
gpt4 key购买 nike

我想检查苹果的应用程序版本,所以我发送如下请求

- (void)connectToCheckVersion{
NSString *url = @"http://itunes.apple.com/lookup?id=466424846";
TTURLRequest *_request = [TTURLRequest requestWithURL:url delegate:self];
_request.httpMethod = @"GET";
_request.cachePolicy = TTURLRequestCachePolicyNone;
_request.shouldHandleCookies = NO;
TTURLJSONResponse* response = [[TTURLJSONResponse alloc] init];
_request.response = response;
TT_RELEASE_SAFELY(response);
[_request send];
}


- (void)requestDidFinishLoad:(TTURLRequest*)request {
TTURLJSONResponse* response = request.response;
NSDictionary* json = response.rootObject;

NSArray *results = [json objectForKey:@"results"];
NSString *version;
for (NSDictionary *rawResult in results) {

version = [rawResult objectForKey:@"version"];
}
NSString *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
if (version != nil && currentVersion != nil && ![version isEqualToString:currentVersion]) {

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"info"
message:@"newer version"
delegate:self
cancelButtonTitle:@"ok"
otherButtonTitles:nil, nil];
[alert show];
[alert release];

}

}

在[_request send]之后;将获得 [CFString release]: message sent to deallocated instance 0x6a83e00。我检查了这个方法中的所有字符串,似乎它们没问题,我仍然可以从远程获得正确的响应。

如果我注释掉此 connectToCheckVersion 方法,则没有任何问题。有什么办法吗?

最佳答案

我认为您应该保留_request 变量并将其保存为成员。因为它会在函数返回后自动释放

请求成功或失败后都需要释放。

谢谢。

关于iphone - 请求发送获取错误 : [CFString release]: message sent to deallocated instance 0x6a83e00,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7834259/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com