This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation about Objective-C blocks support
- Loading branch information
Bruno Farache
committed
Jul 31, 2014
1 parent
d5b2da6
commit d2a0a06
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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:@"[email protected]" 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 | ||
|