iOS初学者问题

时间:2011-04-29 15:07:31

标签: iphone ios

我已经更新了这个删除HUD项目的问题。我希望将这一行代码分成两行。

我有这个电话:

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

我想将它拆分为类似于此但我对Objective-C很新。

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

这是service2方法:

- (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: @"PerformInsert" 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;
        }

有什么方法可以做我要问的事吗?感谢您提供的任何帮助。

1 个答案:

答案 0 :(得分:0)

考虑使用这样的东西:

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];

此示例使用ATMHud。您应该使用小写命名方法,blah:blah:而不是Blah:Blah。并避免编写长度为225个字符的嵌套句子。