1

I have a core data database and I would like to show the data into a tableview. I have been searching on the web how to do that but I never can find it.

NSEntityDescription *entitydesc = [NSEntityDescription entityForName:@"Host" inManagedObjectContext;context];
NSFetchRequest *request = [[NSFetchRequest alloc]init];
[request setEntity:entitydesc];

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"I DON'T KNOW WHAT TO PUT HERE"];
[request setPredicate:predicate];

But I have no idea what I have to write in the predicateWithFormat so I can select all the data of my database table.

And when I have all the data of my database table how can I put them in an array so i can add the array to a tableview?

Thanks :)

1 Answer 1

1

from the NSFetchRequest docs:

If you don’t specify a predicate, then all instances of the specified entity are selected

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

4 Comments

Ok thanks :) that works :) but It will only add the last data so in my table view I have just 1 row and in my database are 3 rows
that will fetch all objects of that entity type, so if it only returns 1 item, you only have 1 item of that entity in core data
but i want the data in my entity
I have it :) I used an NSArray but I had to use an NSMutableArray :) Thanks for your help

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.