13.07.2015 Views

Beginning Objective-C pdf - EBook Free Download

Beginning Objective-C pdf - EBook Free Download

Beginning Objective-C pdf - EBook Free Download

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 9: Writing an Application 347dispatch_async(dispatch_get_main_queue(), ^{[person setValue: result forKey: @"phoneNumbers"];[person setValue: @NO forKey: @"loadingPhones"];});}];}];// the completion block runs when the operation is complete or canceled__weak NSOperation * weakOp = op;[op setCompletionBlock: ^{// if cancelled, we're no longer loadingif ( [weakOp isCancelled] )[person setValue: @NO forKey: @"loadingPhones"];}];[_loaderQ addOperation: op];}if ( [[person valueForKey: @"loadingEmails"] isEqual: @NO] && [[person valueForKey: @"emails"]count] == 0 ){[person setValue: @YES forKey: @"loadingEmails"];NSOperation * op = [NSBlockOperation blockOperationWithBlock: ^{[_remoteAddressBook emailAddressesForPersonWithIdentifier: personID reply: ^(id result,NSError *error) {// again, update the controller's content on the main queue, since it// will update the UI in response.dispatch_async(dispatch_get_main_queue(), ^{[person setValue: result forKey: @"emails"];[person setValue: @NO forKey: @"loadingEmails"];});}];}];// the completion block runs when the operation is complete or canceled__weak NSOperation * weakOp = op;[op setCompletionBlock: ^{if ( [weakOp isCancelled] )[person setValue: @NO forKey: @"loadingEmails"];}];[_loaderQ addOperation: op];}if ( [[person valueForKey: @"loadingAddresses"] isEqual: @NO] && [[person valueForKey:@"addresses"] count] == 0 ){[person setValue: @YES forKey: @"loadingAddresses"];NSOperation * op = [NSBlockOperation blockOperationWithBlock: ^{[_remoteAddressBook mailingAddressesForPersonWithIdentifier: personID reply: ^(idresult, NSError *error) {// again, update the controller's content on the main queue, since it// will update the UI in response.dispatch_async(dispatch_get_main_queue(), ^{www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!