[NSCFString VIEWWILLISPEND::]:在iPhone 3G上发送到实例的选择器无法识别,但在模拟器或iPhone 4上则无法识别

[NSCFString VIEWWILLISPEND::]:在iPhone 3G上发送到实例的选择器无法识别,但在模拟器或iPhone 4上则无法识别,iphone,ios,Iphone,Ios,我一直在寻找一个解决方案将近4个小时,但我一直找不到任何东西 我有一个有两个标签的应用程序。第一个包含导航控制器,第二个包含MKMapView。所有东西都正确地链接到IB上。这在模拟器和iPhone4上都可以正常工作,但如果我在iPhone3G上尝试(实际上我在两个不同的手机上尝试过),就会出现内存错误 以下是堆栈跟踪: 2011-05-04 11:38:44.652 GeoSocial[8191:307] -[NSCFString viewWillAppear:]: unrecognized

我一直在寻找一个解决方案将近4个小时,但我一直找不到任何东西

我有一个有两个标签的应用程序。第一个包含导航控制器,第二个包含
MKMapView
。所有东西都正确地链接到IB上。这在模拟器和iPhone4上都可以正常工作,但如果我在iPhone3G上尝试(实际上我在两个不同的手机上尝试过),就会出现内存错误

以下是堆栈跟踪:

2011-05-04 11:38:44.652 GeoSocial[8191:307] -[NSCFString viewWillAppear:]: unrecognized selector sent to instance 0x3e7b7040
2011-05-04 11:38:44.901 GeoSocial[8191:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString viewWillAppear:]: unrecognized selector sent to instance 0x3e7b7040'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x3759dc7b __exceptionPreprocess + 114
    1   libobjc.A.dylib                     0x32d9bee8 objc_exception_throw + 40
    2   CoreFoundation                      0x3759f3e3 -[NSObject(NSObject) doesNotRecognizeSelector:] + 98
    3   CoreFoundation                      0x37544467 ___forwarding___ + 506
    4   CoreFoundation                      0x37544220 _CF_forwarding_prep_0 + 48
    5   UIKit                               0x3597b7bc -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 220
    6   UIKit                               0x3597b6d4 -[UITabBarController transitionFromViewController:toViewController:] + 40
    7   UIKit                               0x3597ad40 -[UITabBarController _setSelectedViewController:] + 256
    8   UIKit                               0x35a83c4c -[UITabBarController setSelectedViewController:] + 20
    9   UIKit                               0x35a84890 -[UITabBarController _tabBarItemClicked:] + 316
    10  CoreFoundation                      0x37542a43 -[NSObject(NSObject) performSelector:withObject:withObject:] + 26
    11  UIKit                               0x35902f20 -[UIApplication sendAction:to:from:forEvent:] + 136
    12  UIKit                               0x35902e88 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 40
    13  UIKit                               0x35b69ee0 -[UITabBar _sendAction:withEvent:] + 424
    14  CoreFoundation                      0x37542a43 -[NSObject(NSObject) performSelector:withObject:withObject:] + 26
    15  UIKit                               0x35902f20 -[UIApplication sendAction:to:from:forEvent:] + 136
    16  UIKit                               0x35902e88 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 40
    17  UIKit                               0x35902e50 -[UIControl sendAction:to:forEvent:] + 52
    18  UIKit                               0x35902aa0 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 536
    19  UIKit                               0x35947340 -[UIControl sendActionsForControlEvents:] + 24
    20  UIKit                               0x35b66568 -[UITabBar(Static) _buttonUp:] + 116
    21  CoreFoundation                      0x37542a43 -[NSObject(NSObject) performSelector:withObject:withObject:] + 26
    22  UIKit                               0x35902f20 -[UIApplication sendAction:to:from:forEvent:] + 136
    23  UIKit                               0x35902e88 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 40
    24  UIKit                               0x35902e50 -[UIControl sendAction:to:forEvent:] + 52
    25  UIKit                               0x35902aa0 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 536
    26  UIKit                               0x359035cc -[UIControl touchesEnded:withEvent:] + 460
    27  UIKit                               0x358f4eb0 -[UIWindow _sendTouchesForEvent:] + 588
    28  UIKit                               0x358f44e4 -[UIWindow sendEvent:] + 396
    29  UIKit                               0x358d7c9c -[UIApplication sendEvent:] + 452
    30  UIKit                               0x358d73b4 _UIApplicationHandleEvent + 6824
    31  GraphicsServices                    0x33e77c88 PurpleEventCallback + 1048
    32  CoreFoundation                      0x3752f5cb __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 28
    33  CoreFoundation                      0x3752f589 __CFRunLoopDoSource1 + 164
    34  CoreFoundation                      0x37521835 __CFRunLoopRun + 580
    35  CoreFoundation                      0x3752150b CFRunLoopRunSpecific + 226
    36  CoreFoundation                      0x37521419 CFRunLoopRunInMode + 60
    37  GraphicsServices                    0x33e76d24 GSEventRunModal + 196
    38  UIKit                               0x3591d57c -[UIApplication _run] + 588
    39  UIKit                               0x3591a558 UIApplicationMain + 972
    40  GeoSocial                           0x00002ec1 main + 72
    41  GeoSocial                           0x00002e74 start + 40
)
terminate called after throwing an instance of 'NSException'
还有一件事有点奇怪:每次我启动应用程序,不管是什么设备,我的实例地址都是相同的(0x3e7b7040)。 我试着一步一步地调试。
viewDidLoad
方法运行良好,但是在它之后(进入xCode的汇编模式几步之后)就会抛出异常

有人有想法或线索来调试它吗

以下是相关的视图控制器代码:

LastLocViewController.h

//
//  SecondViewController.h
//  LocateMe
//
//  Created by Hugo Briand on 07/04/11.
//  Copyright 2011 Neotiq. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

#import "LocateMeAppDelegate.h"

@interface LastLocViewController : UIViewController <CLLocationManagerDelegate, AdBannerDelegate> {
    IBOutlet MKMapView *mapView;
    IBOutlet ADBannerView *adBanView;
}

@property (nonatomic, retain) IBOutlet MKMapView *mapView;
@property (nonatomic, retain) IBOutlet UIView *contentView;
@end
提前谢谢

编辑

听了安德鲁的第二个建议后,我终于明白了。问题出在
viewDidLoad
方法中。该区块:

NSMutableArray *locations = [[NSMutableArray alloc] init];
    LocateMeAppDelegate *del = (LocateMeAppDelegate *) [[UIApplication sharedApplication] delegate];
    for (NSArray *ac in [[del.contactManager clContacts] allValues]) {
        for (CLContact *c in ac) {
            if (c.coordinate.latitude !=0 || c.coordinate.longitude != 0) {
                [locations addObject:c];
            }
        }
    }
    [mapView addAnnotations:[NSArray arrayWithArray:locations]];
    [locations release];
如果我在位置数组中没有位置,则不正确。不知怎的,它导致了一场车祸。我添加了一个对数组大小的检查,这就成功了


谢谢你的回复,安德鲁

我建议您使用NSZombie目标在仪器中运行代码。或者,您可以尝试使用应用程序可执行选项中设置的NSZombieEnabled环境变量运行

这样做可以帮助您找到问题的根源


除此之外,试着离开几小时,重新思考,重新审视你现有的假设。

谢谢你的提醒。但是,我已经尝试了NSZombie Enabled(显然无法在设备上运行带有nszombies的仪器,并且由于该错误没有出现在模拟器上,因此没有帮助),这是我给出的堆栈跟踪。可能值得在带有nszombies的模拟器中尝试,即使崩溃本身可能无法重现,您仍可能发现潜在的问题。
NSMutableArray *locations = [[NSMutableArray alloc] init];
    LocateMeAppDelegate *del = (LocateMeAppDelegate *) [[UIApplication sharedApplication] delegate];
    for (NSArray *ac in [[del.contactManager clContacts] allValues]) {
        for (CLContact *c in ac) {
            if (c.coordinate.latitude !=0 || c.coordinate.longitude != 0) {
                [locations addObject:c];
            }
        }
    }
    [mapView addAnnotations:[NSArray arrayWithArray:locations]];
    [locations release];