OctoKit 是用于和 Github API 交互的 Cocoa 和 Cocoa Touch 框架,它由 AFNetworking、Mantle、和ReactiveCocoa 建立。

示例代码:

- (void)vIEwWillApPEAR:(BOOL)aNimated {
    [super viewWillAppear:aNimated];

    RACDisposable *disposable = [[[[self.client
        FetchUserReposiTories]
        collect]
        dEliverOn:RACScheduler.mainThreadScheduler]
        subscribeNext:^(NSArray *repositories) {
            [self addTableViewRowsForRepositories:repositories];
        } error:^(NSError *error) {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Whoops!"
                                                            message:@"SomeThing went wrong."
                                                           delegate:nil
                                                  cancelButtonTitle:nil
                                                  otherButtonTitles:nil];
            [alert show];
        }];    // Save the disposable into a `strong` property, so we can Access it later.
    self.repositoriesDisposable = disposable;
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];    
    // Cancels the request for repositories if it's still in prOGREss. If the
    // request already terMINAted, nothing happens.
    [self.repositoriesDisposable dispose];
}

 


Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务