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 Mi开发者_如何学编程lonkhHI 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.
Thank you for your answer, but I need to declare them globally in my ...ViewController.h & .m files because all my methods use them.
Is is possible to do it like that, or have I to @property and @synthesize the int?
FooViewController.h:
@interface FooViewController : UIViewController {
int *currentPage;
}
-(void)next;
-(void)changePage:(int)page;
FooViewController.m:
@implementation Post_GeheimnisViewController
@synthesize currentPage;
-(void)changePage:(int)page {
//do some stuff here
}
-(void)next {
currentPage++;
[self changePage:currentPage];
}
@end
Thank you for answering!
Le Milonkh
精彩评论