Reputation: 755
I want to be able to load the data i have in Core Data.
I figured out how to save it, but to load it it throws a __NSarray length error, how ever NSLog can read the data just fine??!?
I'm trying to have my UITextView
populated with data from core data
I'm using MagicalRecord to manage my Core Data
NSArray *people = [TextView MR_findByAttribute:@"belongsTo" withValue:@"barneDaabStartSide" andOrderBy:nil ascending:NO];
textView1.text = [people valueForKey:@"textDataView"];
I also tried this :
NSMutableString *textViewText = [NSMutableString string];
for (NSString *str in people) {
[textViewText appendFormat:@"%@\n", str];
self.textView1.text = textViewText;
}
But then it just writes all sort of code and then my string "data" so this isn't working properly
Upvotes: 1
Views: 506
Reputation: 4001
The following line would be returning an array of TextView instances - or nil.
NSArray *people = [TextView MR_findByAttribute:@"belongsTo" withValue:@"barneDaabStartSide" andOrderBy:nil ascending:NO];
This should get you started.
NSArray *people = [TextView MR_findByAttribute:@"belongsTo" withValue:@"barneDaabStartSide" andOrderBy:nil ascending:NO];
if(people)
for(TextView *textView in people) {
textView1.text = textView.textDataView;
}
}
Are you only trying to get one single TextView
instance? Then you may consider using this instead (or a similar method, check out MagicalRecord's documentation):
TextView *textView = [TextView MR_findFirstByAttribute:@"belongsTo" withValue:@"barneDaabStartSide"];
if(textView) {
textView1.text = textView.textDataView;
}
Upvotes: 3