Reputation: 115
I need to set a string from my NSOperation, but how can I know if the operation is finished? Cause it is not hitting the breakpoint that I've set, or I am not calling my NSOperation properly? If yes, how should I call my operation?
Here's my code
- (void)operationDidFinish:(MJOperation *)operation
{
NSString *strng = [MJUtilities decodedStringFromXMLData:operation.receivedData];
mainString = [NSString stringWithFormat:mainString, strng];
}
Now I need to get the value of mainString
Upvotes: 1
Views: 344
Reputation: 2255
Set the completionBlock
property on your NSOperation
. When the operation finishes, the completionBlock
is called.
See the NSOperation
documentation for more info: https://developer.apple.com/library/mac/documentation/Cocoa/Reference/NSOperation_class/#//apple_ref/occ/instp/NSOperation/completionBlock
Try something like this:
__block NSString *mainString;
...
myOperation.completionBlock = ^{
NSString *strng = [MJUtilities decodedStringFromXMLData:myOperation.receivedData];
mainString = [NSString stringWithFormat:mainString, strng];
// here you should do something with mainString
};
Upvotes: 3