Block Confusion...
Block Confusion...
- Subject: Block Confusion...
- From: R <email@hidden>
- Date: Mon, 30 Jan 2012 18:56:52 -0800 (PST)
I thought I understood block until today.... Here is my situation:
One class creates a STRONG pointer to a NSMutableArray. It then
passes that pointer to another class, which has a WEAK reference.
that class is listed below. When I fork a new thread for the
simpleBlock, I lose the pointer. I tried this on a fresh, very simple
test and I did not have this behavior. It behaved as expected with
the same memory address for all three logs.
You can see that the first log is just calling on the array. The
second log is called within the block. The third (NULL) log is called
within same block on another thread.
HELP!
@property (weak,nonatomic)NSMutableArray *checkMutableArray; //this is
set from a strong pointer in another class
@synthesize checkMutableArray=_checkMutableArray;
- (void)parseIt{
NSLog(@"checkMutableArray to start=%p",[self checkMutableArray]);
void(^simpleBlock)(void)=^{
NSLog(@"checkMutableArray in block %p",[self checkMutableArray]);
};
simpleBlock();
dispatch_queue_t aSimpleQueue=dispatch_queue_create("Easy", NULL);
dispatch_async(aSimpleQueue, simpleBlock);
dispatch_release(aSimpleQueue);
}
checkMutableArray to start=0x6a3a3d0
checkMutableArray in block 0x6a3a3d0
checkMutableArray in block 0x0
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden