我在服务器上有一些记录,当前台应用服务器的背景将发送所有记录,而从客户端我将所有数据保存到coredata。但我的应用程序被冻结了,只有在完成所有更新和节省后才能正常工作。我发现了一些代码,它们需要花费太多时间来解决死锁问题
SRWebSocket handleMessage: _block_invoke
我不知道如何处理这个问题,请指导我 探查者:https://www.dropbox.com/s/snjmob5akhcq865/Instruments6.trace.zip?dl=0
websocket.h
#import <Foundation/Foundation.h>
#import "SRWebSocket.h"
#import <CoreFoundation/CoreFoundation.h>
typedef enum _IXResponseTypes
{
eIXConnectToWebSocket=1,
eIXBindWithWebSocket
}
IXResponseType;
@protocol IXWebSocketDataManagerDelegate;
@interface IXWebSocketDataManager : NSObject<SRWebSocketDelegate>
+ (IXWebSocketDataManager*)sharedNetworkDataManager;
//@property (weak, nonatomic, assign) id<IXWebSocketDataManagerDelegate> delegate;
@property (nonatomic, weak) id<IXWebSocketDataManagerDelegate> delegate;
@property (strong, nonatomic)SRWebSocket *webSocket;
@property (assign, nonatomic)CFMutableBitVectorRef bitvec;
@property(nonatomic,retain)NSMutableArray *selectedMessageArray;
@property BOOL feedbackSaveIndicator;
//@property (nonatomic, weak) id <SRWebSocketDelegate> delegate;
- (void)connectWebSocket;
-(void)closeWebSocket;
websocket.m
- (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message
{
AppDelegate *sharedAppdelegate=(AppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"MESSAGE FROM WEBSOCKET==%@",message);
NSDictionary *responseDict = [message JSONValue];
if ([[responseDict allKeys] containsObject:@"body"])
{
//adding activity id
NSString *strings = [NSString stringWithFormat:@"%@", [responseDict objectForKey:@"body"]];
NSString *firstLetter = [strings substringToIndex:1];
if ([firstLetter isEqualToString:@"{"]) {
int responseCode=[[[responseDict objectForKey:@"body"] objectForKey:@"code"] intValue];
[self checkResponseCode:responseDict indexvalue:responseCode isArray:0];
} else {
NSArray *bodyDicta=[responseDict objectForKey:@"body"];
// if (!sharedAppdelegate.flag) {
for (int i=0; i<bodyDicta.count; i++) {
int responseCode=[[[[responseDict objectForKey:@"body"] objectAtIndex:i ] objectForKey:@"code"] intValue];
//Call your function or whatever work that needs to be done
//Code in this part is run on a background thread
//Stop your activity indicator or anything else with the GUI
//Code here is run on the main thread
NSLog(@"Delaying");
[self checkResponseCode:[bodyDicta objectAtIndex: i] indexvalue:responseCode isArray:1];
}
}
// sharedAppdelegate.flag = YES;
}
}