代码在iPhone 5s +上运行良好,而不是之前的版本?

时间:2015-08-26 22:44:28

标签: ios objective-c iphone

当我在iPhone 5s或更高版本上运行这段代码时,它会按预期执行。但是当我在低于5s(5,4s,4)的任何版本上运行它时,它不会。

应该进入第一个if语句,忽略第二个if语句并执行else。这在模拟器中超过5s的任何版本都可以正常工作,但是当我在5或4上运行它时会进入第二个if语句...而不是忽略它并执行else。

currentProduct.productID是一个NSNumber

任何可以帮助我的事情都会非常感激!

    NSNumber *currentProductID = [[NSNumber alloc] initWithInt:4121];

if (productPurchased != YES) {
    if (currentProduct.productID != currentProductID) {
        [self performSegueWithIdentifier:@"InAppPurchaseViewController" sender:nil];
    } else {
        [self showActivityView];
        [self performSelector:@selector(configureExam) withObject:nil afterDelay:0.1];
    }

1 个答案:

答案 0 :(得分:0)

我有同样的问题并通过从if ([currentProduct.productID integerValue] != [currentProductID integerValu]) { 提取整数值来修复它,然后比较它们。如下所示

#include <stdio.h>
#include <math.h>
#include <conio.h>
#define PI 3.142

float surface(int x);
float volume(int y);
int radius();
int main()
{
    int r;
    float a, b;
    clrscr();
    printf("Enter the radius :");
    scanf("%d", &r);
    a=surface(r);
    b=volume(r);
    printf("Surface Area =%f", a);
    printf("\n");
    printf("Volume =%f", b);
    getch();
    return 0;
 }
int radius(int z)
{
    int f;
    f=z*z;
    return (f);
}
float surface(int x)
{
    float s;
    s = 4*PI*radius(x);
    return (s);
}
float volume(int y)
{
    float v;
    v = (4*PI*radius(y)/3);
    return (v);
}