You cannot cast it because
NSInteger is not an object, just an alias for a built-in type. You can always create a new
NSNumber object from
NSInteger, like this:
NSNumber *myNum = @(myNsIntValue);
or in the prior version of the compiler, use
NSNumber *myNum = [NSNumber numberWithInteger:myNsIntValue];
- Why does an NSInteger variable have to be cast to long when used as a format argument?
- How to convert an NSString into an NSNumber
- In Objective-C, what is the equivalent of Java’s “instanceof” keyword?
- NSLog/printf specifier for NSInteger?
- How to convert NSNumber to NSString
- Convert NSNumber to int in Objective-C
- How to convert An NSInteger to an int?
- How to add two NSNumber objects?
- Comparing NSNumbers in Objective C
- What’s the difference between NSNumber and NSInteger?
- How do I convert a float to an int in Objective C?
- Determine if NSNumber is NaN
- How to check if an NSDictionary or NSMutableDictionary contains a key?
- Assign a variable inside a Block to a variable outside a Block
- What is the significance of #pragma marks? Why do we need #pragma marks?
- How to stop unwanted UIButton animation on title change?
- iOS – Build fails with CocoaPods cannot find header files
- What are the details of “Objective-C Literals” mentioned in the Xcode 4.4 release notes?
- Method Syntax in Objective-C
- What is the best way to create constants in Objective-C
- Generate a random alphanumeric string in Cocoa
- Objective-C formatting string for boolean?
- “Auto Layout still required after executing -layoutSubviews” with UITableViewCell subclass
- Get parts of a NSURL in objective-c
- libxml/tree.h no such file or directory
- Converting UIColor to CGColor in swift
- Remove characters from NSString?
- Create objective-c class instance by name?
- Format string, integer with leading zeros
- Class extension vs class category
- How to use Objective-C CocoaPods in a Swift Project
- Objective-C – float checking for nan
- What’s the difference between a method and a selector?
- How to identify previous view controller in navigation stack
- Getting the visible rect of an UIScrollView’s content
- Command-line tool for converting PLIST to JSON?
- ‘+entityForName: nil is not a legal NSManagedObjectContext parameter – Core Data
- C Language: what does the .mm extension stand for?
- Xcode 6 and Embedded Frameworks only supported in iOS8
- BOOL to NSString
- Number of occurrences of a substring in an NSString?
- How can I call a method in Objective-C?
- Can I overload an operator in Objective-C?
- UITabBar not showing selected item images in ios 7
- In Cocoa do you prefer NSInteger or int, and why?
- What’s the difference between XCTAssert and XCTAssertTrue?
- Implementing -hash / -isEqual: / -isEqualTo…: for Objective-C collections
- Checking if one NSDate is greater than another
- What are the default attributes for Objective-C properties?
- setStatusBarHidden is deprecated in iOS 9.0