Fattaneh Talebi
Fattaneh Talebi

Reputation: 767

How to store long values in nsmutablearray in objective-c

I want to have a array which contains long value. this one contains int.

@property (nonatomic,retain) NSMutableArray *selectedMessages;

adding element to it:

[selectedMessages addObject:[NSNumber numberWithInteger:id]]

retrieving each element:

for (id selectedMessageId in self.selectedMessages) {
    // selectedMessageId is int
}

How should I change this to store long values?

Upvotes: 0

Views: 236

Answers (1)

Andrey Chernukha
Andrey Chernukha

Reputation: 21808

NSNumber class has numberWithLong and longValue methods.

In your example selectedMessageId is not int. It is NSNumber. You can retrieve its int value by using intValue method. Therefore as you need long use methods that I've provided above

Upvotes: 1

Related Questions