Questions tagged [nsinteger]

An NSInteger is a data type in Objective-C. It is used to describe an integer.

An NSInteger is data type in Objective-C used to describe an integer. When building 32-bit applications, NSInteger is a 32-bit integer. A 64-bit application treats NSInteger as a 64-bit integer.

258 questions
1
vote
1 answer

Implicit conversion loses integer precision: warning, code for 64-bit platform

after getting a lot of warnings when changing (by accident) the simulator (from 32 to 64 bit platforms), I'm getting rid of all the int declaration and changing those for NSintegers. But I have another warning in this piece of code: -…
Marcal
  • 1,371
  • 5
  • 19
  • 37
1
vote
2 answers

Handle NSNumber and NSInteger

Following is a code snippet i am using to add data to nsmutable array, now I am not sure on what to type cast it on while extracting, i need integer value. Problem is that I am getting warnings of 'id' and 'NSInteger' conversion. What could be…
Firdous
  • 4,624
  • 13
  • 41
  • 80
1
vote
0 answers

Storing a short value in a long memory space: efficient or memory hog?

This question is sparked by a response to: Should NSInteger really be used everywhere? I'm still trying to wrap my head around the implications of using NSInteger for small values, especially now that NSInteger converts to long in a 64-bit…
Justin Whitney
  • 1,242
  • 11
  • 17
1
vote
1 answer

Converting NSInteger and NSString into array of bytes

I need to represent a NSInteger and NSString into array of bytes. below are the sample of what I am looking for. For how, this harcodings are working fine. I want to do this through code. Any clue. First, NSInteger into bytes of Hex: NSInteger test…
Abhinav
  • 37,684
  • 43
  • 191
  • 309
1
vote
1 answer

OSAtmonicCompareAndSwap32 is giving me a warning that I can't figure out

- (void)decrementActivityCount { [self willChangeValueForKey:@"activityCount"]; bool success; do { int32_t currentCount = (int32_t)_activityCount; success = OSAtomicCompareAndSwap32(currentCount, MIN(currentCount - 1,…
software is fun
  • 7,286
  • 18
  • 71
  • 129
1
vote
2 answers

get integer value from NSInteger

This in the function which i am implementing -(NSString *)DeleteFolder:(NSInteger)FolderId; In my implementation, I am creating string using FolderId NSString *dbScript = [NSString stringWithFormat:@"Delete from Folders Where FolderId =…
user1970081
  • 11
  • 1
  • 2
1
vote
3 answers

Float to integer conversion

I want to take the value from my slider and without rounding up, crop the decimals. So if I have a float value of 10.973. I want it in an integer as 10. I dont use negative values but if the slider value is between 0 and 1 id rather it round up.…
4GetFullOf
  • 1,738
  • 4
  • 22
  • 47
1
vote
1 answer

Set maximum value of NSInteger

*Sorry if this has been posted before but I have been looking for 30 mins now and cant find anything* Hi, I have an NSInteger called currentcoins and I want the coins maximum value to be 999. I have tried everything including #undef…
OnkaPlonka
  • 1,232
  • 10
  • 19
1
vote
2 answers

Adding +1 to a variable on click of a button adding the wrong number

I am very new to Objective-c and probably really easy to solve but couldnt find an answer anywhere.... I am trying to add +1 to a variable every time the user clicks on the button but instead of adding +1 it adds +4 - (IBAction)addNewSet:(UIButton…
Jonathan Thurft
  • 4,087
  • 7
  • 47
  • 78
1
vote
1 answer

Convert a CFNumberRef to NSInteger

#import "someClass.h" @implementation someClass - (NSInteger *)checkWakeOnLan { SCDynamicStoreRef ds = SCDynamicStoreCreate(kCFAllocatorDefault, CFSTR("myapp"), NULL, NULL); CFDictionaryRef dr = SCDynamicStoreCopyValue(ds,…
Ol Sen
  • 3,163
  • 2
  • 21
  • 30
1
vote
1 answer

Does NSInteger allow for decimal places?

I need to have someone type in a value say "40" and then the app converts this to anther value by dividing by 7.5. at the moment i've done: NSString *pCO2 = _pCO2.text; float thepCO2 = [pCO2 floatValue]; NSInteger newpCO2 =…
LaythT
  • 23
  • 4
1
vote
1 answer

Transform NSInteger to NSString as a 5-digit number

I have an int and I transform it to a NSString like this: NSString *myStr = [NSString stringWithFormat:@"%d",myInt]; myInt is ranged from 0 to 99999. What I want is to get myStr as a 5-digit number. for example : 00072 or 09856 or 00002 Thank you.
tchike
  • 154
  • 4
  • 21
1
vote
3 answers

'setInt' on another VC not working

I'm trying to set an Integer on another VC using prepareForSeguemethod. I've got four buttons and each button has its own boolean value changed when pressed - (IBAction)answerChoiceFourPressed:(id)sender { self.ButtonFourPressed = YES; } I have…
Sergey Grischyov
  • 11,995
  • 20
  • 81
  • 120
1
vote
2 answers

sqlite sum() into nsinteger

I want to build a function which takes the sum of all rows in a column called hours. it should then return an integer value, which i am going to use to multiply with another number. -(NSInteger)calculateTotal{ FMDatabase *dbHandler = [FMDatabase…
uba2012
  • 373
  • 1
  • 3
  • 14
1
vote
1 answer

FMDB database and xcode inserting into database

I am trying to insert data into a database but I have it seems like it won't insert integer values, it is inputing strings. the app just crashes. if I push the button that saves it into the database, with the textfields empty, the methods does…
uba2012
  • 373
  • 1
  • 3
  • 14