0

I use swift and obj-c classes together in my project.

And I declare this in obj-c header file.

@property (nonatomic, copy) NSString *AppStoreId;

I want to use this obj-c code in my swift class:

NSDictionary *productParameters = @{ SKStoreProductParameterITunesItemIdentifier : [NSNumber numberWithInt:[appItem.AppStoreId intValue]]};

I convert it to swift like this:

var productParameters : NSDictionary = SKStoreProductParameterITunesItemIdentifier(NSNumber.numberWithInt(appItem.AppStoreId))

However, it gives me an error which says "UnsafeMutablePointer < Int32>" is not convertible to "Int32"

I also tried this:

var productParameters : NSDictionary = SKStoreProductParameterITunesItemIdentifier(NSNumber.numberWithInt(appItem.AppStoreId(IntegerType)).intValue)

But this time it gives me an error about using of IntegerType. I don't know what should I do. I am a beginner in swift and objective c. Thank you for any help.

simge
  • 259
  • 2
  • 5
  • 10

1 Answers1

0

SKStoreProductParameterITunesItemIdentifier is just a key for the dictionary, not a function to create one. You should use:

var productParameters : NSDictionary = NSDictionary(object: NSNumber.numberWithInt(appItem.AppStoreId.intValue), forKey: SKStoreProductParameterITunesItemIdentifier)
Louis Zhu
  • 792
  • 5
  • 12