In my application I don't use the upper bar that displays Wi-Fi/Date/Time because it's a game. However I need to be able to let my user to pick his music, so I'm using a MPMediaPickerController. The problem is, that when I present my controller, the controller ends up leaving a 10 pixels ( aprox ) bar at the top of the screen, just in th...
I want to do some fairly complex arithmetics that require very high precision, i.e. calculating
10000000000 + 0.00000000001 = 10000000000.00000000001
10000000000.00000000001 * 3 = 30000000000.00000000003
I want to use NSDecimalNumber for this kind of math, but the problem is: How to feed it with these values?
The documentation says:
...
Currently, I am doing it like this:
NSDecimalNumber *myDecimalNumber = // ... assume it's there
NSNumber *number = [NSNumber numberWithDouble:[myDecimalNumber doubleValue]];
[myLabel setText:[myNSNumberFormatter stringFromNumber:number]];
First, I have an NSDecimalNumber object. Then I throw that out to double, which I feel is very ve...
My question is about how to access the TabBarController from within one of its viewControllers.
Imagine a mainClass.m that adds tabBarController which has two viewControllers - viewController1 and viewController2.
In viewController1.m there is a game. When the game is over, viewController1.m wants to tell tabBarController to displ...
I have a tight loop that iterates about 500 times. In every iteration, it will create a few NSDecimalNumber objects to do some arithmetics.
Example - this code snippet is in the for loop. the -decimalNumberByAdding: method creates a new NSDecimalNumber instance and autoreleases it.
resultDecimalNumber = [resultDecimalNumber decimalNumb...
I've got several annotations I want to add to my MKMapView (it could 0-n items, where n is generally around 5). I can add the annotations fine, but I want to resize the map to fit all annotations onscreen at once, and I'm not sure how to do this.
I've been looking at -regionThatFits: but I'm not quite sure what to do with it. I'll post ...
Hi Everyone:
I am wondering how I would go about animating a UIView's to a specific CGPoint. The following is what I have so far (which doesn't work in it's current state):
#define MOVE_ANIMATION_DURATION_SECONDS 2
NSValue *pointValue = [[NSValue valueWithCGPoint:point] retain];
[UIView beginAnimations:nil context:pointValue];
[UIVie...
I am not sure if that would make any trouble. Normally, lets say, I sum up a few values. I would do it like this:
val1 = val1 + val2;
val1 = val1 + val3;
val1 = val1 + val4;
and so on...
Could I do something similar with NSDecimal, or should I not provide the same NSDecimal "object" twice in the parameters? (btw, how's that called? no...
Two things are strange with NSDecimalAdd(). First, when I search for examples, people seem to provide parameters by reference like NSDecimalAdd(&foobar, &foo, &bar, ....) and so on. The second strange thing is this const. Why's the parameter saying it wants a constant there? And why does this not apply for result?
NSCalculationError NSD...
I was wondering how animations work in Cocoa Touch. For example:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
view1.alpha = 1.0;
view2.frame.origin.x += 100;
[UIView commitAnimations];
How does UIView tracks the changes to the properties of the two views?
I suspect that KVO is used, but does it real...
I can only guess, but please correct me if I am wrong:
[encoder encodeValueOfObjCType:@encode(NSDecimal) at:&theDecimal];
where encoder is an instance of NSCoder.
But one thing is strange: Why is there no key to provide? How would I get that back then, without a key?
...
I am not sure about this:
// assume value is a NSDecimal type and exists
NSDecimalNumber *decNum = [[NSDecimalNumber alloc] initWithDecimal:value];
[encoder encodeObject:decNum forKey:@"someKey"];
[decNum release];
I'm wrapping the NSDecimal into an NSDecimalNumber object. I have to release it somewhere. But I am not sure... does the ...
I have an NSDecimal in a tight calculations loop, where I need to floor the value. I want to prevent creating fat NSDecimalNumber objects just for that. Is there a cost-efficient way to get a floor? That floor is just needed to calculate how many times another value might fit in there, with no rest. The NSDecimal API doesn't provide some...
Hi Everyone:
I am looking for a way to store references to variables inside a NSMutableArray. As variables are going to be created dynamically based upon what the user has chosen, I want to be able to simply sort through this array and get references to these created variables. In case it matters, I am creating a iPhone project. Howe...
I have an iPhone app with a tableviewcontroller. When you click a certain cell it opens a new uiviewcontroller with this code:
nextViewController = [[avTouchViewController alloc] initWithNibName:@"avTouchViewController" bundle:nil];
The uiviewcontroller above called avTouchViewController has a property that looks like:
IBOutlet Som...
It's been a while since I messed with my TableViewController so I'm a bit rusty...but now I'd like to set it up so that when a section has zero rows to display (array is empty) then it will "lie" to the controller and return 1 for numberOfRowsInSection. Then in the cellForRowAtIndexPath it will place a UILabel over the one row's cell tha...
The documentation confuses me about this. They say:
void NSDecimalCompact (
NSDecimal *number
);
Discussion Formats number so that
calculations using it will take up as
little memory as possible. All the
NSDecimal... arithmetic functions
expect compact NSDecimal arguments.
The last part is important:
All the
NSD...
For example, I try to do something like this:
- (BOOL)compare:(NSDecimal)leftOperand greaterThan:(NSDecimal)rightOperand {
BOOL returnValue = NO;
NSComparisonResult result = NSDecimalCompare(&leftOperand, &rightOperand);
if (result == NSOrderedDescending) { // if the left operand is greater than the right operand
return...
For example:
- (BOOL)compare:(NSDecimal)leftOperand greaterThan:(NSDecimal)rightOperand {
NSComparisonResult result = NSDecimalCompare(&leftOperand, &rightOperand);
// rest not important
}
like you can see, the method just receives these two types of NSDecimal, leftOperand and rightOperand. Then it passes them on to a C API fu...
In the iPhone docset for NSDate, in the discussion area they discuss -dateWithNaturalLanguageString:locale:, however they don't document the method elsewhere on the page.
I've used the method before for iPhone and it worked just fine, although I got warnings. Now that I'm building with -Werror (which I should have been doing all along ^...