1

我正在尝试使用 RackSpace API 进行身份验证以使用 ASIHttp 库获取 Auth-Token 但我的问题是有时它可以正常工作但大多数时候我都遇到了这个崩溃

libobjc.A.dylib`objc_release:
0x16cd090:  pushl  %ebp
0x16cd091:  movl   %esp, %ebp
0x16cd093:  subl   $8, %esp
0x16cd096:  calll  0x16cd09b                 ; objc_release + 11
0x16cd09b:  popl   %ecx
0x16cd09c:  movl   8(%ebp), %eax
0x16cd09f:  testl  %eax, %eax
0x16cd0a1:  je     0x16cd0d5                 ; objc_release + 69
0x16cd0a3:  movl   (%eax), %edx
0x16cd0a5:  movl   16(%edx), %edx
0x16cd0a8:  andl   $-4, %edx
0x16cd0ab:  testb  $2, 2(%edx)
0x16cd0af:  je     0x16cd0c5                 ; objc_release + 53
0x16cd0b1:  movl   1002149(%ecx), %ecx
0x16cd0b7:  movl   %ecx, 4(%esp)
0x16cd0bb:  movl   %eax, (%esp)
0x16cd0be:  calll  0x16cc08c                 ; objc_msgSend
0x16cd0c3:  jmp    0x16cd0d5                 ; objc_release + 69
0x16cd0c5:  movl   %eax, (%esp)
0x16cd0c8:  movl   $0, 4(%esp)
0x16cd0d0:  calll  0x16ce9d0                 ; -[NSObject release]
0x16cd0d5:  addl   $8, %esp
0x16cd0d8:  popl   %ebp
0x16cd0d9:  ret

我无法理解到底出了什么问题。请帮我解决这个问题。

编辑 :

这是我正在使用的代码

+ (void)authenticate
{
    [accessDetailsLock lock];
    ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:RACSPACE_AUTHENTICATE_API]];
    [request addRequestHeader:@"Content-type" value:@"application/json"];

    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:RACSPACE_USER_NAME forKey:@"username"];
    [dic setObject:RACSPACE_PASSWORD forKey:@"apiKey"];

    NSMutableDictionary *dic1 = [[NSMutableDictionary alloc] init];
    [dic1 setObject:dic forKey:@"RAX-KSKEY:apiKeyCredentials"];

    NSMutableDictionary *finalDic = [[NSMutableDictionary alloc] init];
    [finalDic setObject:dic1 forKey:@"auth"];

    SBJSON *sbJson= [[SBJSON alloc] init];
    NSString *strJson =[sbJson stringWithObject:finalDic];
    NSLog(@"%@",strJson);
    [request setPostBody:(NSMutableData*)[strJson dataUsingEncoding:NSUTF8StringEncoding]];

    [strJson release];
    [dic release];
    [dic1 release];
    [finalDic release];
    [request startSynchronous];

    if (![request error])
    {
        NSDictionary *responseHeaders = [request responseHeaders];
        NSLog(@"Response%@",[responseHeaders description]);
        NSLog(@"Response 2=%@",[request responseString]);
        SBJSON *parser = [[SBJSON alloc] init];
        NSDictionary *jsonObject = [[parser objectWithString:[request responseString]] objectForKey:@"access"];
        [parser release];

        authToken = [[jsonObject objectForKey:@"token"] objectForKey:@"id"];

        NSArray *services = [jsonObject objectForKey:@"serviceCatalog"];

        for (NSDictionary *service in services)
        {
            if ([[service valueForKey:@"type"] isEqualToString:@"object-store"])
            {
                if ([[service valueForKey:@"name"] isEqualToString:@"cloudFiles"])
                {

                    NSDictionary *endpoint = [[service valueForKey:@"endpoints"] objectAtIndex:0];
                    storageURL = [NSURL URLWithString:[endpoint valueForKey:@"publicURL"]];

                }
            }
            else if([[service valueForKey:@"type"] isEqualToString:@"rax:object-cdn"])
            {
                if ([[service valueForKey:@"name"] isEqualToString:@"cloudFilesCDN"])
                {
                    NSDictionary *endpoint = [[service valueForKey:@"endpoints"] objectAtIndex:0];
                    cdnManagementURL = [NSURL URLWithString:[endpoint valueForKey:@"publicURL"]];

                }
            }
        }
        [request release];
        [accessDetailsLock unlock];
    }

}
4

1 回答 1

3

从我所见,您似乎正在释放一个已经在自动释放池中的对象。

看看这一行:

NSString *strJson = [sbJson stringWithObject:finalDic];

SBJson 源我可以看到这返回了一个自动释放的 NSString。然后,您将在此行下面发布:

[strJson release];

这导致 EXC_BAD_ACCESS。

我在 Rackspace 的移动团队工作,所以让我知道这是否适合您,或者我是否可以以任何其他方式提供帮助。

于 2012-12-04T21:55:22.433 回答