I have an object Foo that has an NSNumber property which is declared like this:
@property (retain) NSNumber *siteID;
and @synthesized.
When I I do something like this:
Foo *myFoo = [[Foo alloc] init];
NSNumber *newNumber = [[NSNumber alloc] initWithInt:42];
myFoo.siteID = newNumber;
[newNumber release];
The assignment on line 3 th...
I accept NSString as
NSString *value = [valuelist objectAtIndex:valuerow];
NSString *value2 = [valuelist2 objectAtIndex:valuerow2];
from UIPickerView.
I want to
double *cal = value + (value2 * 8) + 3;
NSString *message =[[NSString alloc] initWithFormat:@"%@",cal];
I should be able to get the string in message after I do the calc...
I have an NSNumber being passed to be via a 3rd party API, and when I call intValue on the index I get a EXC_BAD_ACCESS error:
-(CPFill *) barFillForBarPlot:(CPBarPlot *)barPlot recordIndex:(NSNumber *)index;
{
NSLog(@"bar index %i", index);
int value = [index intValue];
}
The output I get in the debugger is:
bar index 0
ba...
Hi all,
I have an Cocoa Core-Date Application. I added a search field and bound it. Now, I have tried to add some predicates but failed! Here are my two questions:
First, the predicate should filter NSNumbers but I cannot build a working predicate. My try:
keyPath == [NSNumber numberWithInteger:[$value integerValue]]
(keyPath repre...
I'm creating an object that will have two integers (or NSNumbers) and an NSDate as ivars. This object will be in an NSMutableArray. To my knowledge, we cannot put primative integers in an NSMutableArray, but will my object work with ints? The reason I don't want to use NSNumbers is because these will have to be mutable, and I don't reall...
Hi guys,
I can't figure out why it's not working, I have a NSString which I need to convert to NSNumber (to save it to Core Data)
e.g
NSLog(stringNum);
returns 1
NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
[f setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber *myNumber = [f numberFromString:stringNum];
[f releas...
Hi everyone,
how can I get timestamp as NSNumber? I only need something like this: 1232885280
Thanks
...
I don't understand how NSNumberFormatterPercentStyle works!
Example:
NSNumber *number = [NSNumber numberWithFloat:90.5];
NSNumberFormatter *percentageFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[percentageFormatter setNumberStyle:NSNumberFormatterPercentStyle];
NSString *strNumber = [percentageFormatter stringFromNumbe...
I'm from a Flash ActionScript background. Where I'm from, I can set a dictionary-like object like this:
var data:Object = {startPoint:5, endPoint:12};
So coming to Objective-C, I was surprised to discover that the equivalent to this appears to be:
NSMutableDictionary *data = [NSMutableDictionary dictionary];
[data setObject:[NSNumber...
Before putting int value into dictionary i have set the int value as [NSNumber numberWithInt:2], now when i try to retrieve back the dictionary content , i want it back in int format.. hw to do this??
here's my code;
NSMutabelDictionary *dict = [[NSMutableDictionary alloc]init];
int intValue = 300;
[dict setObject:[NSNumber numberWith...
Hello. I'm trying to convert an NSString object to an NSNumber with the same numerical value. When I create the NSString object using this statement...
NSString *songID = [localNotif.userInfo objectForKey:@"SongID"];
the var songID contains the string value @"10359537395704663785". and when I attempt to convert it to an NSNumber ob...
My understanding is that a 'convenience' method such as [nsnumber initWithInt] should create a copy of the indicated class, initialized to the desired value.
minutesLeft=[NSNumber initWithInt:((timeLeft)%60)];
Timeleft is an integer, so initWithInt should be working, and the result should be that minutesLeft (a property set to retain)...
Hi Guys!
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 e...
Hi,
i get a nsstring from a nsdictionary via:
inputString = [dataUsage valueForKey:@"amount"];
after that the string looks like: 23,56
how can i convert this string into a nsnumber?
i have tried the following:
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];...
I'm converting a string date/time to a numerical time value. In my case I'm only using it to determine if something is newer/older than something else, so this little decimal problem is not a real problem. It doesn't need to be seconds precise. But still it has me scratching my head and I'd like to know why..
My date comes in a strin...
How do I check if a NSNumber object is nil or empty?
OK nil is easy:
NSNumber *myNumber;
if (myNumber == nil)
doSomething
But if the object has been created, but there is no value in it because an assignment failed, how can I check this? Use something like this?
if ([myNumber intValue]==0)
doSomething
Is there a general met...
Hi all,
I'm using NSNumber to store various values, but sometimes run into issues when doing calculations with the values and initializing new NSNumber objects for the results. I've figured out how to overcome it, but I couldn't for the life of me explain why it works and since my grasp on numerical values in computer environments (doub...
So essentially my question is this, I am creating an NSMutableDictionary using uint64_t objects as the key.
Is there any better way to create them than doing this?
uint64_t bob=7;
NSNumber *bobsNumber;
#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
bobsNumber=[NSNumber numberWithUnsig...
I love the shorthand handling of string literals in Objective C with the @"string" notation. Is there any way to get similar behavior with NSNumbers? I deal with numbers more and it's so tedious having [NSNumber numberWithWhatever:] calls everywhere. Even creating a macro would work, but my knowledge of how best to do that is limited.
...
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 XCode?
...