From d2a0a06db28dcd00f619f1d136e6149387834055 Mon Sep 17 00:00:00 2001 From: Bruno Farache Date: Thu, 31 Jul 2014 09:51:12 -0300 Subject: [PATCH] Add documentation about Objective-C blocks support --- android/README.md | 2 +- ios/README.md | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/android/README.md b/android/README.md index 196f72cc..058fb819 100644 --- a/android/README.md +++ b/android/README.md @@ -192,7 +192,7 @@ Session session = new SessionImpl("http://10.0.2.2:8080"); However, most portal remote methods don't accept unauthenticated remote calls, you will get a `Authentication required` exception message in most cases. -This will work only if the remote method on the portal or your plugin has the +This will only work if the remote method on the portal or your plugin has the `@AccessControlled` annotation just before the method: ```java diff --git a/ios/README.md b/ios/README.md index fef51eb5..f05a9a97 100644 --- a/ios/README.md +++ b/ios/README.md @@ -12,6 +12,7 @@ * [Use](#use) * [Unauthenticated session](#unauthenticated-session) * [Asynchronous](#asynchronous) + * [Blocks](#blocks) * [Batch](#batch) * [Non-primitive arguments](#non-primitive-arguments) * [OrderByComparator](#orderbycomparator) @@ -242,6 +243,32 @@ safely. In this example, the `getGroupEntriesWithGroupId` method returns a `onSuccess` is called on the main UI thread after the request has finished. +##### Blocks + +It is also possible to use Objective-C blocks as callbacks: + +```objective-c +LRSession *session = [[LRSession alloc] initWithServer:@"http://localhost:8080" username:@"test@liferay.com" password:@"test"]; + +[session + onSuccess:^(id result) { + // Called after request has finished successfully + } + onFailure:^(NSError *e) { + // Implement error handling code + } +]; + +LRGroupService_v62 *service = [[LRGroupService_v62 alloc] initWithSession:session]; + +NSError *error; +[service getUserSites:&error]; +``` + +Do not set a `LRCallback` to the session in this case, otherwise it will get +overriden. Blocks support works the same way as described in the previous +section. + #### Batch The SDK allows sending requests using batch processing, which can be much more