开发者

iOS Beginners Question

I have updated this one question removing the HUD items. I am looking to split this one line of code into two.

I have this call:

[service2 PerformInsert:self action:@selector(PerformInsertHandler:) ApplicationID: applicationID ImageData: UIImageJPEGRepresentation([self.capturedImage objectAtIndex:0], 0.5) ImageDataType: @".jpg"];

I would like to split it similar to this but I am pretty new to Objective-C.

[service2 PerformInsert:self action:????? ApplicationID: applicationID ImageData: UIImageJPEGRepresentation([self.capturedImage objectAtIndex:0], 0.5) ImageDataType: @".jpg"];  
[self PerformInsertHandler:????];

Here is the service2 method:

- (SoapRequest*) PerformInsert: (id <SoapDelegate>) handler ApplicationID: (int) ApplicationID ImageData: (NSData*) ImageData ImageDataType: (NSString*) ImageDataType
        {
            return [self PerformInsert: handler action: nil ApplicationID: ApplicationID ImageData: ImageData ImageDataType: ImageDataType];
        }

 - (SoapRequest*) PerformInsert: (id) _target action: (SEL) _action ApplicationID: (int) ApplicationID ImageData: (NSData*) ImageData ImageDataType: (NSString*) ImageDataType
        {
            NSMutableArray* _params = [NSMutableArray array];

            [_params addObject: [[[SoapParameter alloc] initWithValue: [NSNumber numberWithInt: ApplicationID] forName: @"ApplicationID"] autorelease]];
            [_params addObject: [[[SoapParameter alloc] initWithValue: ImageData forName: @"ImageData"] autorelease]];
            [_params addObject: [[[SoapParameter alloc] initWithValue: ImageDataType forName: @"ImageDataType"] autorelease]];
            NSString* _envelope = [Soap createEnvelope: @"Perform开发者_运维技巧Insert" forNamespace: self.namespace withParameters: _params withHeaders: self.headers];
            SoapRequest* _request = [SoapRequest create: _target action: _action service: self soapAction: @"http://tempuri.org/XXXXService/PerformInsert" postData: _envelope deserializeTo: [[XXXInsert alloc] autorelease]];
            [_request send];
            return _request;
        }

Is there any way to do what I am asking? Thank you for any help you can provide.


Consider using something like this:

SEL selector = [service2 performInsert:self 
                                action:@selector(performInsertHandler:) 
                         applicationID:applicationID 
                             imageData:storedImage 
                         imageDataType:@".jpg"]
// show hud
[hud setCaption:@"Working..."];
[hud setActivity:YES];
[hud show];

NSObject result = [self performSelector:selector withObject:nil];

// update hud
[hud setCaption:[NSString stringWithFormat:@"done with %@",result]];
[hud setActivity:NO];
[hud setImage:[UIImage imageNamed:@"19-check"]];
[hud update];
[hud hideAfter:2.0];

This example uses ATMHud. You should name your methods in lowercase, blah:blah: instead Blah:Blah. And avoid writing nested sentences 225 characters long.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜