尽管我对此很陌生,但让我与您分享我在做什么。
首先,我创建引擎(我调用的服务位于何处)。
在我的界面中:
@interface INGMainViewController (){
MKNetworkEngine *engine_;
}
在我的初始化中:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
engine_= [[MKNetworkEngine alloc] initWithHostName:@"www.xxx.gr"];
// Custom initialization
}
return self;
}
然后在我将调用服务的函数中:
NSDictionary *formParams = [NSDictionary dictionaryWithObjectsAndKeys:
theClientCode, @"ClientCode",
theContractNumber, @"ContractCode",
theAppleID, @"AppleID",
@" ", @"AndroidID",
@" ", @"WindowsID",
uid, @"AppleDeviceID",
@" ", @"AndroidDeviceID",
@" ", @"WindowsDeviceID",
theCellPhone, @"TelephoneNumber"
, nil];
MKNetworkOperation *operation = [self.engine operationWithPath:@"/services/Authentication.ashx"
params: formParams
httpMethod:@"POST"];
[operation addCompletionHandler:
^(MKNetworkOperation *operation)
{
NSLog(@" Operation succeds: %@", [operation responseString]);
}
errorHandler:^(MKNetworkOperation *errorOperation, NSError *error)
{
NSLog(@" Errors occured: %@", error);
}];
[self.engine enqueueOperation:operation];
}
……仅此而已。
当然我仍然面临一些问题,但我认为没有来自套件。
我希望我对你有所帮助。