简体   繁体   English

字符串在iPhone上的Core-Data中被截断

[英]String truncated in Core-Data on iPhone

I have an Entity (Article) with an Class defined at xcdatamodel. 我有一个实体(文章),在xcdatamodel定义了一个类。 In this class i defined an String NSString *test; 在这个类中我定义了一个String NSString * test;

currentArticle.test = string;

String is more than 50 characters long. 字符串长度超过50个字符。

But when i try to fetch the Stored Object with: 但是当我尝试使用以下方式获取存储对象时:

Article *article = [fetchedResultsController objectAtIndexPath:indexPath];

then article.test is truncated (50 Characters long). 然后article.test被截断(50个字符长)。 But it should be longer... 但它应该更长......

Any ideas? 有任何想法吗?

I've just noticed the same. 我刚刚注意到了同样的事情。

As far as I can tell, when logging an NSManaged Object (or a core data error), only the first 50 or so characters of a string attribute are printed. 据我所知,当记录NSManaged Object(或核心数据错误)时,只打印字符串属性的前50个左右字符。 But the actual attribute still has all the characters. 但实际属性仍然包含所有字符。

I guess you try to load to the TableView, and it is by default truncated to fit the screen width of the table view. 我猜你试图加载到TableView,默认情况下它被截断以适应表视图的屏幕宽度。

Put a breakpoint on the line that access the article and see its' value. 在访问文章的行上放置一个断点并查看其值。

Otherwise, you may want to print it out to the console 否则,您可能希望将其打印到控制台

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

Edited: 编辑:

Another note is that your data model may fix the "Max Length" property to 50. 另一个注意事项是您的数据模型可能会将“Max Length”属性修复为50。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM