cgfloat

Using iPhone/Objective C CGFloats: Is 0.1 okay, or should it be 0.1f?

Hi there, When using an iPhone Objective C method that accepts CGFloats, e.g. [UIColor colorWithRed:green:blue:], is it important to append a f to constant arguments to specifiy them explicitly as floats, e.g. should I always type 0.1f rather than 0.1 in such cases? Or does the compiler automatically cast 0.1 (which is a double in gener...

How to set a CGFloat to a UILabel's text property

I have a UILabel called optionsDisplayerBrushSizeLabel who's text property I want to set to a CGFloat: brushSizeVal. I understand that the text property needs to be a string but I don't know how to convert a CGFloat to an NSString. ...

How to round CGFloat

I made this method + (CGFloat) round: (CGFloat)f { int a = f; CGFloat b = a; return b; } It works as expected but it only rounds down. And if it's a negative number it still rounds down. This was just a quick method I made, it isn't very important that it rounds correctly, I just made it to round the camera's x and y valu...

NSNumber floatValue not equal to NSNumber value

Hi Everyone, First post here. Having a problem with NSNumber's floatValue method -- somehow, it returns an imprecise number. Here's the problem: I store a bunch of NSNumbers in an array, like this: NSArray *a = [NSArray arrayWithObjects: [NSNumber numberWithFloat:0.04f], [NSNumber numberWithFloat:0.028f], [NSNumber numbe...

How do I make an array of CGFloats in objective c?

So I'm working on a simple iPhone game and am trying to make a local high score table. I want to make an array and push the highest scores into it. Below is the code I have so far: CGFloat score; score=delegate.score; NSInteger currentindex=0; for (CGFloat *oldscore in highscores) { if (score>oldscore) ...

Use CGFloat instead of float? They don't do it

[I might be misunderstanding this entire topic, as I've grown up with languages that allow the dev to almost entirely ignore processor architecture, like Java, except in some particular cases. Please correct me if I have some of the concepts wrong.] Reading here it seems that the advice is to use CGFloat instead of, say, float, because ...

Integer to CGFloat help needed.

In my iPhone app, I have a appSettings.plist. This allows me, but also others to simply change some parameters. One of the parameters is the predominant color of the app. The .plist looks like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd...

Iphone development: UIColor / CGColor components comparison

Hello, I've got some internal codes for colors in my application, so I created a function that, given a color, returns the code. I'm having problems as it just doesn't work and return always "01" for every color else than the red, which returns the proper code. Has someone a clue about it? (NSString *)internalColorCode:(UIColor *)color ...