2012-04-09 14 views
13

मेरे पास MKStoreKit का उपयोग कर एक प्रोजेक्ट के साथ एक कार्यान्वयन समस्या है। मैं विभिन्न खरीद विकल्पों के साथ UIAlertView को लागू करने की कोशिश कर रहा हूं।आईओएस असंगत ब्लॉक सूचक प्रकार

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex]; 

    if([title isEqualToString:@"Cancel"]) 
    { 
     NSLog(@"Cancel Button was selected."); 
    } 
    else if([title isEqualToString:@"7 Day Subscription $0.99"]) 
    { 
     NSLog(@"7 Day Subscription button pressed."); 
     //Buy a 7 day subscription 
     if([SKPaymentQueue canMakePayments]) { 
      [[MKStoreManager sharedManager] buyFeature:kFeatureAId onComplete:^(NSString* purchasedFeature) 
      { 
       NSLog(@"Purchased: %@", purchasedFeature); 
       // Send an alert to the user 
       UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Purchase Successful" 
                   message:@"Thank you. You have successfully purchased a 7 Day Subscription." 
                   delegate:nil 
                 cancelButtonTitle:@"OK" 
                 otherButtonTitles:nil]; 
       [alert autorelease]; 
       [alert show]; 

       // Show the user the content now 
       payWallFlag = TRUE; 
       return TRUE; 
      } 
              onCancelled:^ 
      { 
       // Send an alert to the user 
       UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Purchase Failed" 
                   message:@"Unfortunately you have cancelled your purchase of a 7 Day Subscription. Please try again." 
                   delegate:nil 
                 cancelButtonTitle:@"OK" 
                 otherButtonTitles:nil]; 
       [alert autorelease]; 
       [alert show]; 

       // Block the content again 
       payWallFlag = FALSE; 
      }]; 
     } 
     else 
     { 
      NSLog(@"Parental control enabled"); 
      // Send an alert to the user 
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Purchase Failed" 
                  message:@"Unfortunately Parental Controls are preventing you from purchasing a subscription. Please try again." 
                  delegate:nil 
                cancelButtonTitle:@"OK" 
                otherButtonTitles:nil]; 
      [alert autorelease]; 
      [alert show]; 

      // Block the content again 
      payWallFlag = FALSE; 
     } 
    } 
} 

मुद्दा है:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch 
{  
    if(FALSE == payWallFlag) 
    {   
     // Display Alert Dialog 
     UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Subscription Options" 
                  message:@"You do not have an active subscription. Please purchase one of the options below." 
                 delegate:self 
               cancelButtonTitle:@"Cancel" 
               otherButtonTitles:nil]; 

     [message addButtonWithTitle:@"7 Day Subscription $0.99"]; 

     [message show]; 

     return FALSE; 
    } else if(TRUE == payWallFlag) 
    { 
     // Load content 
    } 
} 

इस कोड को जो मैं फोन करने के लिए कोशिश कर रहा हूँ के साथ शारीरिक alertView है:

यहाँ कोड है जहाँ मैं विभिन्न बातें करते हैं और UIAlertView फोन है मुझे UIAlertView में निम्नलिखित एक्सकोड त्रुटि संदेश मिलता है:

असंगत ब्लॉक सूचक प्रकार प्रकार के पैरामीटर के लिए 'पूर्णांक (^) (NSString *)' भेजने के 'शून्य (^) (NSString *)'

ऐसा प्रतीत होता है समस्याएं हैं: onComplete:^(NSString* purchasedFeature) और onCancelled:^ लेकिन मैं पता नहीं है इसे कैसे ठीक करें।

उत्तर

20

आप return TRUE; कि ब्लॉक से क्योंकि तब संकलक मानता है कि ब्लॉक रिटर्न एक int, जबकि यह void (इसलिए असंगत ब्लॉक प्रकार) लौटना चाहिए नहीं करना चाहिए,।

...onComplete:^(NSString* purchasedFeature) { 
    NSLog(@"Purchased: %@", purchasedFeature); 
    // Send an alert to the user 
    UIAlertView *alert = [[UIAlertView alloc] ...]; 
    [alert autorelease]; 
    [alert show]; 

    // Show the user the content now 
    payWallFlag = TRUE; 
    return TRUE; // <--- Remove this line. 
}... 

दूसरे खंड (onCancelled एक) के लिए, आप शायद NSString* पैरामीटर, या जो कुछ भी यह उम्मीद याद किया।

संबंधित मुद्दे