nsnumber

What is the class NSCFNumber in iOS 4.1?

纵然是瞬间 提交于 2019-11-29 05:30:25
After successfully acquiring a picture from the iPhone camera on iOS 4.1, you can use the key @"UIImagePickerControllerMediaMetadata" to return information about the picture. One of the keys in that dictionary is @"Orientation" From my experimentation, Portrait and Upside down are 6 and 8 respectively, and the landscapes are 1 and 3. Look at this code: - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSDictionary *metaData = [info objectForKey:@"UIImagePickerControllerMediaMetadata"]; id orientation = [metaData objectForKey:@

Generating permutations of NSArray elements

杀马特。学长 韩版系。学妹 提交于 2019-11-28 23:55:53
Let's say I have an NSArray of NSNumbers like this: 1, 2, 3 Then the set of all possible permutations would look something like this: 1, 2, 3 1, 3, 2 2, 1, 3 2, 3, 1 3, 1, 2 3, 2, 1 What's a good way to do this in objective-c? I have used the code from Wevah's answer above and discovered some problems with it so here my changes to get it to work properly: NSArray+Permutation.h @interface NSArray(Permutation) - (NSArray *)allPermutations; @end NSArray+Permutation.m #import "NSArray+Permutation.h" #define MAX_PERMUTATION_COUNT 20000 NSInteger *pc_next_permutation(NSInteger *perm, const NSInteger

Convert NSNumber (double) value into time

守給你的承諾、 提交于 2019-11-28 20:32:33
问题 i try to convert a value like "898.171813964844" into 00:17:02 (hh:mm:ss). How can this be done in objective c? Thanks for help! 回答1: Final solution: NSNumber *time = [NSNumber numberWithDouble:([online_time doubleValue] - 3600)]; NSTimeInterval interval = [time doubleValue]; NSDate *online = [NSDate date]; online = [NSDate dateWithTimeIntervalSince1970:interval]; NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateFormat:@"HH:mm:ss"]; NSLog(@

Why NSNumber points to the same address when value are equals?

一个人想着一个人 提交于 2019-11-28 10:14:42
Given the following code: int firstInt, secondInt; firstInt = 5; secondInt = 5; NSNumber *firstNumber = [NSNumber numberWithInt:firstInt]; NSNumber *secondNumber = [NSNumber numberWithInt:secondInt]; Why on Earth do those two NSNumber instances are pointing to the same address? This drives me crazy! Of course, if you change secondInt to, say '4', all works as expected. Thanks, Jérémy This is likely either a compiler optimisation or an implementation detail: as NSNumber is immutable there's no need for them be separate instances. EDIT: probably an implementation optimisation thinking about it.

NSNumber Literals

岁酱吖の 提交于 2019-11-28 01:25:29
问题 I am very new to Objective-C. I know C and C++ but Objective-C has quite the learning curve. Anyway, is there a shorter way (possibly by some kind of NSNumber literal if such exists) to write the following: [Tyler setArms:[[[NSNumber alloc] autorelease] initWithInt:1]]; 回答1: Yes, just use one of the many helper functions such as numberWithInt:: [Tyler setArms:[NSNumber numberWithInt:1]]; The expression [NSNumber numberWithInt:1] is equivalent to [[[NSNumber alloc] initWithInt:1] autorelease]

How to read crash log? How to find why the app crashes in system library? What means EXC_CRASH (SIGABRT)?

老子叫甜甜 提交于 2019-11-28 00:50:37
问题 I got an crash logs from a customer to figure why my app crash on her iPhone. Here some info from crash log: Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x00000000, 0x00000000 Crashed Thread: 0 Stack trace for Thread 0 Thread 0 Crashed: 0 libSystem.B.dylib 0x3293f98c 0x328c1000 + 518540 1 libSystem.B.dylib 0x3293f97c 0x328c1000 + 518524 2 libSystem.B.dylib 0x3293f96e 0x328c1000 + 518510 3 libSystem.B.dylib 0x3295461a 0x328c1000 + 603674 4 libstdc++.6.dylib 0x30a143b0 0x309cf000 +

What is the class NSCFNumber in iOS 4.1?

a 夏天 提交于 2019-11-27 23:23:04
问题 After successfully acquiring a picture from the iPhone camera on iOS 4.1, you can use the key @"UIImagePickerControllerMediaMetadata" to return information about the picture. One of the keys in that dictionary is @"Orientation" From my experimentation, Portrait and Upside down are 6 and 8 respectively, and the landscapes are 1 and 3. Look at this code: - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSDictionary *metaData =

How do you store “int” values in an NSMutableArray* or NSMutableDictionary*? Chronic problems with JSON data that come in as integers.

纵饮孤独 提交于 2019-11-27 21:50:49
问题 How do you store "int" values in an NSMutableArray or NSMutableDictionary ? Chronic problems with JSON data that come in as integers. Should I try to store these integers as NSNumber objects or just as strings that contain the integer? How dangerous is it to do a "raw" (int) conversion on the pointers if I know the values will always be Natural Numbers (numbers>=0 including zero for null.) The integers I'm always working with are Foreign Key Id's from a database. 回答1: Use NSNumber like this:

What's the difference between NSNumber and NSInteger?

Deadly 提交于 2019-11-27 16:59:35
What's the difference between NSNumber and NSInteger? Are there more primitives like these that I should know about? Is there one for floats? Tyler The existing answers are useful; adding to them: Yes, NSUInteger gives twice the range among positive integers as NSInteger , but I think another critical reason to choose between the two is simply to distinguish among cases where negative values simply do not make sense . Example: the return value of NSArray 's count method is an NSUInteger , which makes sense since we cannot have an array with a negative number of elements. When the coder knows

Generating permutations of NSArray elements

三世轮回 提交于 2019-11-27 15:07:32
问题 Let's say I have an NSArray of NSNumbers like this: 1, 2, 3 Then the set of all possible permutations would look something like this: 1, 2, 3 1, 3, 2 2, 1, 3 2, 3, 1 3, 1, 2 3, 2, 1 What's a good way to do this in objective-c? 回答1: I have used the code from Wevah's answer above and discovered some problems with it so here my changes to get it to work properly: NSArray+Permutation.h @interface NSArray(Permutation) - (NSArray *)allPermutations; @end NSArray+Permutation.m #import "NSArray