mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-29 13:15:34 +08:00
Add new RKReachabilityState, RKReachabilityIndeterminate.
Make RKRequestQueue smart, don't start dequeuing requests until reachability state has been determined. Simplify examples.
This commit is contained in:
@@ -37,26 +37,7 @@
|
||||
_tableView.backgroundColor = [UIColor clearColor];
|
||||
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
|
||||
// Load the object model via RestKit
|
||||
|
||||
if ([[RKClient sharedClient] isNetworkAvailable]) {
|
||||
[self loadData];
|
||||
} else {
|
||||
NSLog(@"Network is not available");
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:RKReachabilityStateChangedNotification object:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reachabilityChanged:(NSNotification*)note {
|
||||
if ([[RKClient sharedClient] isNetworkAvailable]) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:RKReachabilityStateChangedNotification object:nil];
|
||||
[self loadData];
|
||||
} else {
|
||||
NSLog(@"Network is not available");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)loadData {
|
||||
// Load the object model via RestKit
|
||||
RKObjectManager* objectManager = [RKObjectManager sharedManager];
|
||||
[objectManager loadObjectsAtResourcePath:@"/status/user_timeline/twotoasters.json" objectClass:[RKTStatus class] delegate:self];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user