2012-03-07 18 views
2

我在从我的plist抓住App Store的ID,并使用它与Appirater的问题。 I NSLog ged当用户按下“Rate Now”时正在使用的URL,并且App Store ID与我在Info.plist中设置的App Store ID有所不同。不知道它从哪里得到这些数字 - 每次都是9个不同的数字。这真的很奇怪。App Store的ID通过Appirater比plist中ID不同,明显的随机

与抓在App Store ID和链接使用它涉及在Appirater.m的代码看起来是这样的:NSString *const kAppiraterAppIdBundleKey = @"AppStoreId";

NSString *templateReviewURL = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=APP_ID"; 

.... 

+ (NSString*)appStoreAppID { 

    NSString* value = [[[NSBundle mainBundle] infoDictionary] objectForKey:kAppiraterAppIdBundleKey]; 

    NSAssert1(value, @"Error - you have not specified %@ property in your info.plist", kAppiraterAppIdBundleKey); 

    return value; 

} 
//... 

+ (void)rateApp { 
    //... 
    NSString *reviewURL = [templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%d", [self appStoreAppID]]]; 
    //... 
} 

我添加了名为“AppStoreId” plist中的字段,并进入9位数字代码。我做了一个字符串类型。现在,代码完美运行时,我将“APP_ID”在上面的iTunes链接实际的9位数代码,但是当我把它作为APP_ID,我得到错误“无法连接到iTunes Store”,并且NSLog输出在链接中有9个随机数,并且每次都是不同的。

这可能是一个简单的办法,但我似乎无法弄清楚。

+1

好的老应用Pirater。每次看到这个名字我都会笑。 – 2012-03-07 19:29:19

回答

6

随机数?您正在使用:

[NSString stringWithFormat:@"%d", [self appStoreAppID]] 

其中appStoreAppIDNSString

因此,您将指向NSString的指针替换为“APP_ID”,而不是NSString的内容。

只需使用%@而不是%d

+0

非常感谢,这工作! – John 2012-03-07 19:37:07