Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSSet转换失败了 #43

Open
yupliang opened this issue Apr 23, 2015 · 11 comments
Open

NSSet转换失败了 #43

yupliang opened this issue Apr 23, 2015 · 11 comments

Comments

@yupliang
Copy link

在使用coredata的时候,系统会在生成的model中选择nsset ,像这种在转化的时候
@Property (nonatomic, retain) NSSet *marks;
这种怎么告诉MJExtension,marks里存放的是什么模型呢?

@CoderMJLee
Copy link
Owner

不能调为NSArray么?NSSet是无须的哦,应该满足不了一般的需求吧?像显示在表格上的数据都是有序的哈

@yupliang
Copy link
Author

杰哥,我是个coredata新手啊,不知core data怎么生成nsarray的属性呢?

@100mango
Copy link
Contributor

100mango commented Jun 4, 2015

你可以通过fetchRequest来获取entity的数组

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

NSEntityDescription *entity = [NSEntityDescription entityForName:@"yourEntityName" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];

NSError *error = nil;
NSArray *result = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];

@zhengbomo
Copy link

杰哥,我们拿到服务器的JSON数据后如何快速定义属性,有没有可以直接吧Json转换为Model的工具(非运行时,代码转换)

@CoderMJLee
Copy link
Owner

暂时没发现有这样的工具哈。我看看可以考虑以后做个Xcode插件,哈哈。

@zhengbomo
Copy link

在C#和JAVA上就有很方便的转换工具,不用自己一个一个敲

@CoderMJLee
Copy link
Owner

也可以自己写个OC程序去转换:字符串解析和字符串写入操作

@zhengbomo
Copy link

恩,只是自己太懒了,有空试写一下

@ValiantCat
Copy link

在CoreData 里面经常会使用到Set 发现在配合CoreData使用时非常麻烦 必须苹果建议所有的关系都要inverse 无法满足需求

@chengleyi
Copy link

杰哥求支持NSSet 55555555555

@ATMLGG
Copy link

ATMLGG commented Dec 15, 2020

杰哥,我们拿到服务器的JSON数据后如何快速定义属性,有没有可以直接吧Json转换为Model的工具(非运行时,代码转换)

这个网上很多,自己动手搜一下就有

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants