Blocks and Methods...
Blocks and Methods...
- Subject: Blocks and Methods...
- From: R <email@hidden>
- Date: Fri, 27 Jan 2012 21:32:08 -0800 (PST)
I'm writing code in for iOS 5....
Ok, in my async com class, I'm receiving a block in one method and
want to execute it in the another method. I've concluded that I need
to place the block in a property. The only way that has worked is via
copy.
Is this the conventional way to save a block?
Thanks in advance -- Ron
in *.h file:
typedef void(^opBlockCom_t)(NSData *opData,NSError *opError,int
opResultResponse);
@property (copy,nonatomic)opBlockCom_t comBlock;
_______________________________
in *m file:
@synthesize comBlock=_comBlock;
-(void)asyncWebConnect:(NSURLRequest *)request
withBlock:(void(^)(NSData *resultData,NSError *resultError,int
resultResponse))opBlock
{
[self setComBlock:opBlock];
...
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
...
[self comBlock]([self resultData],[self resultError],[self
resultResponse]);
[self setComBlock:nil];
}
_______________________________________________
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