2011-04-29 26 views
0

我已經更新了這個刪除HUD項目的問題。我期待將這一行代碼分成兩部分。iOS初學者問題

我有這樣的電話:

[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:????]; 

這裏是客服2方法:

- (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

你可以顯示你的'HUD'和'service2'對象的文檔嗎?看看你的代碼很明顯,它不能工作,但不知道事情應該如何看,我不能提供任何建議。 – kubi 2011-04-29 15:15:15

+0

我添加了server2代碼,並完全刪除HUD部分。感謝您的幫助。 – Phil 2011-04-29 15:59:34

回答

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個字符長的嵌套句子。

+0

感謝您的幫助,但我刪除了HUD項目,我真的需要上面更新項目的幫助。謝謝 – Phil 2011-04-30 04:09:33