问题标签 [nsmutableset]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
objective-c - NSMutableSet 输入与输出的顺序不同
我已使用以下代码将对象添加到 NSMutableSet 中:
为什么输出的顺序与插入的顺序不同?
objective-c - 删除核心数据对象不会取消其所有关系吗?
我有一个名为Task的实体,它与实体TaskTemplate和Occurrence具有一对一的关系。这两个实体都与Tasks有一对多的关系。删除规则设置为无效。
在Occurrence中,我尝试删除所有任务。为此,我使用以下代码:
这不起作用。以下是尝试删除之前的任务和发生:
...这是之后的结果-removeAllObjects
:
请注意,任务关系现在是空的,正如我所期望的那样。但我也希望taskType为空。我究竟做错了什么?
编辑:
我更改了代码,以便查看该任务是否标记为已删除。我现在有了:
它确实显示“Y”,表示该任务已标记为删除。fetchRequest 显示上下文中没有任务。但是如果我尝试保存,我会收到一条不一致的消息(“任务无效”)。
objective-c - NSMutableSet respondsToSelector addObject:返回 false
我在使用 NSMutableSet 的 respondsToSelector 时遇到问题。
我有一个这样的程序:
我使用./program NSMutableSet addObject: str调用它,但程序总是说 NSMutableSet 不响应 addObject:。
不知道为什么responsToSelector 总是说NSMutableSet 不响应addObject。./program NSMutableSet allObjects 也是如此。
objective-c - [NSMutableIndexSet copy] 行为不正确吗?
看下面两条语句:
我希望 rowsToDelete 是一个 NSMutableIndexSet,但它的 NSIndexSet。看起来复制没有在 NSMutableIndexSet 中实现。如果是这样,即使对于这样的基本类型,不实现复制不是一个很大的失误吗?或者我缺少 IndexSet 接口的基本内容?
iphone - 比较两个数组并在数组中取回共同值
为了比较这两个数组,我使用了 NSMutableSet,然后将这两个集合相交以获得数组中的共同结果。NSMutableSet *set1 = [NSMutableSet setWithArray:array];
它给了我完美的答案,但是当 set1 没有像 set2 那样的共同元素时它会崩溃。intersectArray 为空。如何获取 intersectArray 的 nil 值。
ios - 无法将对象添加到 NSMutableSet(错误:没有可见界面)
我在我的 iPad 应用程序上使用 XCode 5 和 iOS 7。我正在尝试保存用户选择的行索引。在 -didSelectRowAtIndexPath 中,我使用此代码标记行:
为什么我在单例的 addObject 上收到此错误?:
“SingletonSelectedCellIndexes”没有可见的@interface 声明选择器“addObject:”
这是定义单例(NSMutableSet)的代码:
更新- 这是 .h 文件:
ios - 谓词是在 NSSet 中查找对象的最有效方法吗?
阅读有关NSSet
它的文档说:
当元素的顺序不重要并且测试对象是否包含在集合中的性能是一个考虑因素时,您可以使用集合作为数组的替代方案。
这正是我所需要的,因为性能对我来说非常重要。
因此,我已经覆盖了最终将填充到 NSSet 中的类中的哈希。
换句话说,在我的情况下,recordDate 总是唯一的,我希望这里有唯一的哈希值。
根据文档,我可以在 NSSet/NSMutableSet 中查找对象的唯一方法似乎是通过谓词。
我不确定,如果我没有忽略某些东西。这是在 NSSet 中查找对象的最有效方法吗?没有像键/值这样的东西吗?
objective-c - 目标 C - NSMutableSet 无法正常工作
我有一个试图添加标签的 NSMutableSet。添加每个标签后,我检查集合的计数并返回为 0。任何帮助将不胜感激
在我的 .h 文件中:
在我的 .m 文件中:
uitableview - 需要解释(UITableView,NSMutableSet)
...
...
重绘单元格后,我希望过滤选定的单元格。
问题是为什么我在日志中只得到这个:EXIST1 EXIST2
EXIST3 在哪里?
简单测试:
结果
objective-c - How to use NSPredicate to filter NSMutableSet which contains composite object from other Class?
Newbie Questions,
I have 3 Class, 3 of them are subclass from NSOBject.
Collection Class, have 2 properties, masterSong as NSMutableSet (strong, nonatomic) and listOfPlaylists as NSMutableArray (strong, nonatomic)
Playlist Class
Have 2 properties, playListName as NSString (copy, nonatomic) and songList as NSMutableArray (strong, nonatomic)
3 . Song Class
Have 4 properties: title,artist,album, playtime as NSString (copy, nonatomic).
masterSong will contain Song object, and listOfPlaylist will contain Playlist Object.
while songList only store reference to Song Object.
I want to create removeSong method for Collection Class by looking up Song for title,artist,or album inside masterSong.
if looking up find 1, it will return NSSet, returned NSSet will take place as parameter in minusSet: method to remove the song from masterSong and all Playlist.songList.
but, I can't figure out how to write down NSPredicate syntax to filter out .title or .album or .artist from masterSong which contain Song Object.
here is what I got so far, for Collection.m
Xcode throw exception when executing lookUpTitle method by saying that Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't look for value (title:Whole point of no return ,artist: Cafe Bleu ,album: CBSB ,playtime: 3:56) in string (What Do You Know); value is not a string
I know that the main problem is at lookUpTitle method
the filter is filtering in a wrong way, while it should filtering NSString object (title, artist, or album) but masterSong is containing Song Object, how do I access title,artist,album in Song Object placed inside masterSong with NSPredicate?
any other effective way for this condition?
Predicate Programming Guide only show example set/array containing string
I found other thread which has similar topic, but block is quite confusing to read, and still won't work in my case.
Edit : additions to the partial code (Class.m method) as requested by responder #1 . here are some method in .m files related to my questions
Main.m
Collection.m
Playlist.m
Song.m