线程 1:信号 SIGABRT Xcode 5.1

Posted

技术标签:

【中文标题】线程 1:信号 SIGABRT Xcode 5.1【英文标题】:Thread 1: signal SIGABRT Xcode 5.1 【发布时间】:2014-09-23 16:08:05 【问题描述】:

但是,我正在尝试运行我的应用程序,但每次单击配置文件链接时,我的应用程序都会崩溃,并且在调试输出中会收到以下消息。请参阅下面的屏幕截图。我正在运行 Xcode 5.1。

[UIImageView setFile:]: unrecognized selector sent to instance 0x10b2ebe00
2014-09-23 11:54:33.498 [1295:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView setFile:]: unrecognized selector sent to instance 0x10b2ebe00'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000102a97495 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x00000001027f699e objc_exception_throw + 43
    2   CoreFoundation                      0x0000000102b2865d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x0000000102a88d8d ___forwarding___ + 973
    4   CoreFoundation                      0x0000000102a88938 _CF_forwarding_prep_0 + 120
    5   Uscout                              0x00000001000084c9 -[ProfileViewController updateUserStatus] + 185
    6   Uscout                              0x0000000100008408 -[ProfileViewController viewWillAppear:] + 88
    7   UIKit                               0x000000010149cdb5 -[UIViewController _setViewAppearState:isAnimating:] + 422
    8   UIKit                               0x00000001014bac4d -[UINavigationController _startTransition:fromViewController:toViewController:] + 707
    9   UIKit                               0x00000001014bb787 -[UINavigationController _startDeferredTransitionIfNeeded:] + 547
    10  UIKit                               0x00000001014bc238 -[UINavigationController __viewWillLayoutSubviews] + 43
    11  UIKit                               0x00000001015d6895 -[UILayoutContainerView layoutSubviews] + 202
    12  UIKit                               0x0000000101403993 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 354
    13  QuartzCore                          0x0000000100e9a802 -[CALayer layoutSublayers] + 151
    14  QuartzCore                          0x0000000100e8f369 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 363
    15  QuartzCore                          0x0000000100e8f1ea _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    16  QuartzCore                          0x0000000100e02fb8 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 252
    17  QuartzCore                          0x0000000100e04030 _ZN2CA11Transaction6commitEv + 394
    18  UIKit                               0x00000001013a2024 _UIApplicationHandleEventQueue + 10914
    19  CoreFoundation                      0x0000000102a26d21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    20  CoreFoundation                      0x0000000102a265f2 __CFRunLoopDoSources0 + 242
    21  CoreFoundation                      0x0000000102a4246f __CFRunLoopRun + 767
    22  CoreFoundation                      0x0000000102a41d83 CFRunLoopRunSpecific + 467
    23  GraphicsServices                    0x0000000102d5bf04 GSEventRunModal + 161
    24  UIKit                               0x00000001013a3e33 UIApplicationMain + 1010
    25  Uscout                              0x0000000100007073 main + 115
    26  libdyld.dylib                       0x0000000105c505fd start + 1
    27  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

ProfileViewController.m

#import "ProfileViewController.h"

@interface ProfileViewController ()
@property (weak, nonatomic) IBOutlet PFImageView *profileImageView;
@property (weak, nonatomic) IBOutlet UILabel *userNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *followersNumberLabel;
@property (weak, nonatomic) IBOutlet UILabel *followingNumberLabel;


@end


@implementation ProfileViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) 
        // Custom initialization
    
    return self;


- (void)viewDidLoad

    [super viewDidLoad];
    // Do any additional setup after loading the view.


- (void)didReceiveMemoryWarning

    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.


- (void)viewWillAppear:(BOOL)animated 
    [super viewWillAppear:animated];
    [self updateUserStatus];


- (void)updateUserStatus 
    PFUser *user = [PFUser currentUser];
    self.profileImageView.file = user[@"profilePicture"];
    [self.profileImageView loadInBackground];
    self.userNameLabel.text = user.username;

    PFQuery *followingQuery = [PFQuery queryWithClassName:@"Activity"];
    [followingQuery whereKey:@"fromUser" equalTo:user];
    [followingQuery whereKey:@"type" equalTo:@"follow"];
    [followingQuery findObjectsInBackgroundWithBlock:^(NSArray *followingActivities, NSError *error) 
        if (!error) 
            self.followingNumberLabel.text = [[NSNumber numberWithInteger:followingActivities.count] stringValue];
        
    ];

    PFQuery *followerQuery = [PFQuery queryWithClassName:@"Activity"];
    [followerQuery whereKey:@"toUser" equalTo:user];
    [followerQuery whereKey:@"type" equalTo:@"follow"];
    [followerQuery findObjectsInBackgroundWithBlock:^(NSArray *followerActivities, NSError *error) 
        if (!error) 
            self.followersNumberLabel.text = [[NSNumber numberWithInteger:followerActivities.count] stringValue];
        
    ];


- (IBAction)logout:(id)sender 





@end

【问题讨论】:

你在哪里打电话setFile?可以发一些代码吗? updateUserStatus 方法中的某处,您在错误类型的对象 (UIImageView) 上调用 setFile:,或者使用指向已释放对象的指针并替换为UIImageView. 另外,在 Objective-C 异常的断点导航器中设置断点。它将导致应用程序停止在比 main() 例程更有趣的地方。 @NicolaMiotto 我为我的 ProfileViewController 添加了代码。感谢您的回复。 @Annette:我不知道教程,但是你在某个地方将一个对象放在user 字典中,键为profilePicture。什么对象要进入字典?如果是UIImage,那么我的代码是正确的。如果不是UIImage,那么您需要找出字典中的内容并将其转换为UIImageView 可以显示的内容。 【参考方案1】:

在您的ProfileViewController 中,在updateUserStatus 方法中,您正在对一个不知道它的对象调用setFile 方法。即:一个UIImageView。确保您正在使用您打算调用该方法的对象。

更新

我们去:

self.profileImageView.file = user[@"profilePicture"];

一个 UIImageView,比如 profileImageView,没有file 属性,所以你不能设置它。仔细检查设置文件的预期类。

【讨论】:

谢谢。课程不正确。我需要将其更改为 PFImageView。投票

以上是关于线程 1:信号 SIGABRT Xcode 5.1的主要内容,如果未能解决你的问题,请参考以下文章

XCode 错误线程 1:信号 SIGABRT

线程 1:信号 SIGABRT IOS Xcode 5

XCode 线程 1:信号 SIGABRT 错误以 NSException (lldb) 类型的未捕获异常终止

Xcode 线程 1 SIGABRT 上的 Firebase 通知错误

线程1:信号SIGABRT不断弹出

线程 1:信号 SIGABRT