Search code examples
uiimageviewtransparentincrementnsnumberdecrement

iPhone: Problem with incrementing NSNumber & displaying transparent images (UIImageView)


I have a problem with NSNumber: I don't understand how to increment and decrement it! I've tried int with [NSNumber intValue] and so on, but it didn't work!!!! I just want a page counter which can be converted to an NSNumber at the end.

My second problem is displaying a (partially) transparent image in an UIImageView. It has ever a (white) background.

Thanks for answering,
Le Milonkh


Solution

  • HI there

    don't use nsnumbers, use ints. Much easier... (NSNumber is merely a wrapper for storing numbers, whereas int provides the default set of C based mathematical interfaces you are looking for, with relative ease - I'm sure you can do math with NSNumber -> although many people say NSDecimal is better. I say use floats, ints and doubles).

    int pagenumber;
    for(pagenumber = 0; pagenumber < 5; pagenumber++){
        NSLog(@"%i", pagenumber);
    }
    

    then if you really need it in an NSNumber then do:

    NSNumber *pagenumberns = [NSNumber numberWithInt:pagenumber];

    In answer to your second question I have never had that problem, but try doing: [ImageView setOpaque:no] and [ImageView setBackgroundColor:[UIColor clearColor]];

    Hope some of that helps.