0

I have an NSMutableArray (called postArray) of Objects Post.

The object Post is:

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>

@interface PostAnnotation : NSObject <MKAnnotation>

@property NSInteger annotationID;
@property NSInteger postID;
@property (nonatomic, copy) NSString* profile;
@end

How I am going to change the value of the postArray.postID at object i? Thanks in advance!

1
  • You just change it. If you don't have a pointer to it stashed, access the array with objectAtIndex to fetch the pointer. Keep in mind that NS(Mutable)Array does not contain copies of the objects, but rather pointers to the original objects you inserted. Commented Jul 20, 2013 at 17:28

1 Answer 1

1

One alternative is to cast the object from the array:

((PostAnnotation*)[postArray objectAtIndex:index]).postId = 1234; 

Otherwise, you can use this method:

PostAnnotation *postAnnotation = postArray[index]
postAnnotation.postId = 1234;
Sign up to request clarification or add additional context in comments.

1 Comment

I was trying [postArray objectAtIndex:index]).postId = 1234;. Thank you very much!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.