在我的应用程序中使用块仅在iOS4.3上导致EXC_BAD_ACCESS

时间:2011-04-19 12:46:02

标签: iphone ios4 objective-c-blocks

我已将LambdaAlert中的示例代码粘贴到我的应用中,当我在iOS4.3上运行时,它会生成EXC_BAD_ACCESS错误。相同的代码在较旧版本的操作系统中运行良好。

  LambdaAlert *alert = [[LambdaAlert alloc]
                          initWithTitle:@"Test Alert"
                          message:@"See if the thing works."];
    [alert addButtonWithTitle:@"Foo" block:^{ NSLog(@"Foo"); }]; // <-- Crashes here with EXC_BAD_ACCESS no matter what code is in the block (even an empty block!)
    [alert addButtonWithTitle:@"Bar" block:^{ NSLog(@"Bar"); }];
    [alert addButtonWithTitle:@"Cancel" block:NULL];
    [alert show];
    [alert release];

对于iOS4.3,我需要做些什么?

1 个答案:

答案 0 :(得分:1)

-weak_library /usr/lib/libSystem.B.dylib打破了iOS模拟器。请改用-weak-lSystem