0

Dont why this is happening I have a method getOutage which returns an array of managed objects

NSArray *fetchedOutages = [context executeFetchRequest:fetchRequest error:&error];
if (error) {
    NSLog(@"Error in Core Data: %@", [error description]);
}
return fetchedOutages;

when I try to copy this array to listOutage (this is a property)

@property (nonatomic, retain) NSArray *listOutage

I tried to copy this array like this in didRowSelectMethod like this

if (listOutage) {
        NSLog(@"Its there");
        [listOutage release];
    }

    listOutage=[[NSArray alloc] initWithArray:[self getOutage]];

I tried various other methods but all of then are failing.

This getoutage method returns 5 objects five objects got copied in listOutage but when I try to access the listOutage elements they are displayed as 'out of scope' Please help me to overcome this I have to pass this to next ViewController.

Thanks in advance

1 Answer 1

1

when there is a property, use 'self.property' instead of 'property' that way, when somebody else reads your code it is more obvious if you mean an ivar or a property.

if you use self.property, you do not need to write

if (listOutage) {
        NSLog(@"Its there");
        [listOutage release];
    }

    listOutage=[[NSArray alloc] initWithArray:[self getOutage]];

instead, just write

NSArray newListOutage=[[NSArray alloc]  initWithArray:[self getOutage]];
self.listOutage = newListOutage;
[newListOutage release];

the release and retain will be handled by the get/set method generated by the @synthesize property.

Sign up to request clarification or add additional context in comments.

Comments

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.