我的代码中出现以下错误,并且很难找出原因。
-[NSRecursiveLock dealloc]: lock (<NSRecursiveLock: 0x1e559730> '(null)') deallocated while still in use
Break on _NSLockError() to debug.
因此,我在NSLock Error上设置了一个断点。这是堆栈跟踪。
frame #0: 0x327e5288 Foundation`_NSLockError
frame #1: 0x327e6258 Foundation`-[NSRecursiveLock dealloc] + 108
frame #2: 0x327478ba ExternalAccessory`-[EAInputStream dealloc] + 122
frame #3: 0x32748420 ExternalAccessory`-[EAInputStream _streamEventTrigger] + 448
frame #4: 0x31ebf682 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
frame #5: 0x31ebeee8 CoreFoundation`__CFRunLoopDoSources0 + 212
frame #6: 0x31ebdcb6 CoreFoundation`__CFRunLoopRun + 646
frame #7: 0x31e30ebc CoreFoundation`CFRunLoopRunSpecific + 356
frame #8: 0x31e30d48 CoreFoundation`CFRunLoopRunInMode + 104
frame #9: 0x359e32ea GraphicsServices`GSEventRunModal + 74
frame #10: 0x33d46300 UIKit`UIApplicationMain + 1120
frame #11: 0x0009e93e Checkout`main(argc=1, argv=0x2fd6ad20) + 174 at main.mm:15
frame #12: 0x39fa1b20 libdyld.dylib`start + 4
NSRecursiveLock Deallocated是类似的帖子,他解决了更新Xcode的问题,但这对我不起作用=(。90%的时间我都收到此错误,而10%的错误我正常
我在有问题的VC中的.h文件...
#import <UIKit/UIKit.h>
#import "SignalR.h"
#import "ClientInterface.h"
@class POS;
@interface SignalRVC : UIViewController <UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate>
@property (nonatomic, strong) NSString *stringFromScan;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic) NSMutableArray *data;
@property (weak, nonatomic) IBOutlet UILabel *errorLabel;
@property (strong, nonatomic, readwrite) SRHubConnection *connection;
@property (strong, nonatomic, readwrite) SRHubProxy *hub;
@property (strong, nonatomic) UIBarButtonItem *backBarButton;
@property (nonatomic, strong) NSMutableArray *registeredUpcs;
-(void)initConnection;
@end
我的.m文件在崩溃前通过viewDidLoad ...
@interface SignalRVC ()
@property (strong,nonatomic) POS *myPOS;
@property (nonatomic, strong) NSString *qrLocation;
@property (nonatomic, strong) NSString *qrStation;
@property (nonatomic, strong) NSString *RPHost;
@property (nonatomic, strong) NSString *RPPort;
@property (nonatomic, strong) NSString *registeredUpc;
@property (nonatomic, strong) NSString *thumbnail;
@property (nonatomic, strong) NSString *productName;
@property (nonatomic, strong) NSString *color;
@property (nonatomic, strong) NSString *alu;
@property (nonatomic, strong) NSString *size;
@property (nonatomic, strong) NSString *upc;
@property (nonatomic, strong) NSDictionary *itemSpecs;
@property (weak, nonatomic) IBOutlet UIButton *checkoutButton;
@property (weak, nonatomic) IBOutlet UILabel *employeeLabel;
@end
@implementation SignalRVC
-(void)viewWillDisappear:(BOOL)animated{
[_myPOS closeConnection];
self.navigationController.toolbarHidden = YES;
}
-(void)viewWillAppear:(BOOL)animated{
self.navigationController.navigationBar.hidden = NO;
NSData *dataFromQR = [self.stringFromScan dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *jsonQR = [NSJSONSerialization JSONObjectWithData:dataFromQR options:NSJSONReadingMutableContainers error:nil];
self.qrLocation = [jsonQR valueForKey:@"loc"];
self.qrStation = [jsonQR valueForKey:@"id"];
self.host = [jsonQR valueForKey:@"host"];
self.port = [jsonQR valueForKey:@"port"];
}
- (void)viewDidLoad{
[super viewDidLoad];
//self.tableView.layer.cornerRadius = 10;
if(!_myPOS){
_myPOS = [[POS alloc] init];
}
_myPOS.mySignalRVC = self;
}
堆栈跟踪告诉我什么?如何做才能更好地理解问题?
带有NSRecursiveLock类的唯一位置是在SignalR中包含的AFJSONRequestOperation.m和AFURLConnectionOperation.m文件中,但是这些类永远不会触发断点...
谢谢你的帮助。
最佳答案
从堆栈跟踪中,它看起来像是EAInputStream类型的对象拥有该锁对象,并且在该锁仍然有效时将对其进行释放。谷歌快速搜索显示EAInputStream是github框架。您添加了它,还是它与您正在使用的另一个框架一起提供?
关于ios - -[NSRecursiveLock dealloc]:锁定了解堆栈跟踪和ios调试,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21148914/