uikit

Does UIImage's -imageNamed: method work for image files stored in 'Documents'?

My app downloads a small image file from a remote server and I am trying to display it along with some other small image files that are pre-installed in the app. I am using [UIImage imageNamed:@"TheImageName.png"] to get the images (see below for more detail). The pre-installed images display as expected but the image in my apps 'Documen...

How to save a UIImage to the application's Bundle?

I am currently getting images from the 'Documents' directory (using -imageWithContentsOfFile:) with no problems except that I cannot get the images to display immediately (for example as soon as touchesEnded was called). I am assuming that this has to do with image caching and that image objects created in the above way are not cached? S...

Problem with very small numbers?

I tried to assign a very small number to a double value, like so: double verySmall = 0.000000001; 9 fractional digits. For some reason, when I multiplicate this value by 10, I get something like 0.000000007. I slighly remember there were problems writing big numbers like this in plain text into source code. Do I have to wrap it in som...

How to port this doubles into an NSDecimalNumber?

I have a some doubles that I want to port into NSDecimalNumber, because I'm getting too bad floating-point arithmetic errors with them. They are: double one = 0.0000001; double two = 1000000000.0000001; They are very problematic, but I hope that NSDecimalNumber can help out to get calculations right. I'm not that big math genius, so ...

Secure and valid way for converting a "float integer" into a natural integer?

I have a CGFloat that contains only "integers", in the meaning that it actually wants to represent integers only but due to float inprecision it may happen that it internally has a 23.00000000000000000000000142 or something like that. I try to feed an NSDecimalNumber with clean input, so I need to make sure this is truly a naked integer ...

what's the biggest integer data type in cocoa-touch and how big can the number be?

I think NSInteger, but maybe there's something that can hold larger values? How big can the number be? ...

How to make sure an NSDecimalNumber represents no fractional digits?

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: ...

Is there a better way of formatting the output of an NSDecimalNumber?

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...

Easy way to feed in a decimal number as string into an NSDecimalNumber?

Reading the documentation, I would have to do something ugly like this: NSLocale *usLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]; NSDecimalNumber *number = [NSDecimalNumber decimalNumberWithString:@"0.00001" locale:usLocale]; But: Isn't there a nicer way of telling that NSDecimalNumber class to look out ...

Memory Management with NSDecimalNumber: How to avoid memory problems in tight loops?

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...

Can I provide to NSDecimalAdd() the same NSDecimal used as leftOperand also as result?

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...

NSDecimalAdd() - what does that const thing mean for the parameter?

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...

How to encode an NSDecimal?

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? ...

Memory issue when encoding an NSDecimalNumber like this?

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 ...

Lightweight way of flooring an NSDecimal?

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...

Do I have to execute the NSDecimalCompact() function on every NSDecimal I create?

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...

How big is the memory cost when passing an type as parameter to an method?

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...

Any way to get a Cached UIImage from my 'Documents' directory?

I know that the -imageNamed: method returns a Cached UIImage, but the problem is that my image file is stored in 'Documents', and the -imageNamed: method seems to only search the Bundle... I am currently (reluctantly) using -imageWithContentsOfFile: to get my image from 'Documents' but it is not the same...Scaling up/down a UIImageView c...

How to know when a UITableView animation is completed?

I want to do a series of things in reaction to the end of certain UITableView animations. For example, I want the table view cell to highlight (via selectRowAtIndexPath) after it has been scrolled to via scrollToRowAtIndexPath. How can this be done? ...

How to provide something like nil to this parameter?

I have a parameter like this: rightOperand:(const NSDecimal*)rightOperand how could I provide a value that represents "nothing" or "empty"? would that be void? i.e. [myObj rightOperand:void]; or something different? Or is that impossible for structs? ...