String truncated in Core-Data on iPhone

I have Entity (Article) with a class defined in xcdatamodel. In this class, I defined the test String NSString *;

currentArticle.test = string; 

A string longer than 50 characters.

But when I try to get the saved object with:

 Article *article = [fetchedResultsController objectAtIndexPath:indexPath]; 

then article.test is truncated (50 characters). But it should be longer ...

Any ideas?

+4
source share
2 answers

I just noticed the same thing.

As far as I can tell, when registering an NSManaged Object (or a basic data error), only the first 50 characters of the string attribute are printed. But the actual attribute has all the characters.

+15
source

I think you are trying to load into a TableView, and by default it is truncated to fit the width of the screen as a table.

Place a breakpoint on the line that accesses the article and sees its value.

Otherwise, you can print it on the console

 NSLog(@"my article test string is: %@", article.test); 

Edited by:

One more note: your data model can fix the Max Length property to 50.

+4
source

Source: https://habr.com/ru/post/1300974/


All Articles