很简单...
这里有几个链接可以帮助您入门
http://mobiledevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
本教程将告诉您如何在您的 plist 文件中进行必要的更改,以及如何告诉您的应用程序从 URL 启动。其次,代码需要在你的应用委托类的方法中完成,命名为:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
从 url...获取您需要的所有信息并从中调用 JSON Web 服务。调用 JSON 的示例如下:
[[AFCoVuAPIClient sharedClient] getPath:@"whatever.json"
parameters:[NSDictionary dictionaryWithObject:loginSessionKey forKey:@"login_session_key"]
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Did logout successfully on app termination");
[application endBackgroundTask: background_task]; //End the task so the system knows that you are done with what you need to perform
background_task = UIBackgroundTaskInvalid; //Invalidate the background_task
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Did NOT logout successfully on app termination");
}];
你可以将数据保存在你的单例类中
你的 AFCovuAPIClient 类 .h 文件的样子
#import "AFHTTPClient.h"
@interface AFCoVuAPIClient : AFHTTPClient
+(AFCoVuAPIClient *)sharedClient;
@end
和 AFCOvuAPIClient.m 文件看起来像这样
#import "AFCoVuAPIClient.h"
#import "AFJSONRequestOperation.h"
@implementation AFCoVuAPIClient
+(AFCoVuAPIClient *)sharedClient {
static AFCoVuAPIClient *_sharedClient = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedClient = [[AFCoVuAPIClient alloc] initWithBaseURL:[NSURL URLWithString:@"url goes here"]];
});
return _sharedClient;
}
-(id)initWithBaseURL:(NSURL *)url {
self = [super initWithBaseURL:url];
if (!self) {
return nil;
}
[self registerHTTPOperationClass:[AFJSONRequestOperation class]];
[self setDefaultHeader:@"Accept" value:@"application/json"];
return self;
}
@end
希望对你有帮助