projects
/
enjoyable.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use identity rather than equality when looking for equivalent mappings.
[enjoyable.git]
/
Categories
/
NSMenu+RepresentedObjectAccessors.m
diff --git
a/Categories/NSMenu+RepresentedObjectAccessors.m
b/Categories/NSMenu+RepresentedObjectAccessors.m
index
a63f083
..
6d1c969
100644
(file)
--- a/
Categories/NSMenu+RepresentedObjectAccessors.m
+++ b/
Categories/NSMenu+RepresentedObjectAccessors.m
@@
-17,10
+17,11
@@
return nil;
}
return nil;
}
-- (void)removeItemWithRepresentedObject:(id)object {
- NSInteger idx = [self indexOfItemWithRepresentedObject:object];
- if (idx != -1)
- [self removeItemAtIndex:idx];
+- (NSMenuItem *)itemWithIdenticalRepresentedObject:(id)object {
+ for (NSMenuItem *item in self.itemArray)
+ if (item.representedObject == object)
+ return item;
+ return nil;
}
- (NSMenuItem *)lastItem {
}
- (NSMenuItem *)lastItem {
@@
-40,9
+41,18
@@
return [self.menu itemWithRepresentedObject:object];
}
return [self.menu itemWithRepresentedObject:object];
}
+- (NSMenuItem *)itemWithIdenticalRepresentedObject:(id)object {
+ return [self.menu itemWithIdenticalRepresentedObject:object];
+}
+
- (void)selectItemWithRepresentedObject:(id)object {
[self selectItemAtIndex:[self indexOfItemWithRepresentedObject:object]];
}
- (void)selectItemWithRepresentedObject:(id)object {
[self selectItemAtIndex:[self indexOfItemWithRepresentedObject:object]];
}
+- (void)selectItemWithIdenticalRepresentedObject:(id)object {
+ NSMenuItem *item = [self.menu itemWithIdenticalRepresentedObject:object];
+ [self selectItem:item];
+}
+
@end
@end