Re: Custom NSArrayController - Dynamic Class?
On Jul 18, 2009, at 22:52, BJ Homer wrote: In order to preserve the contract of NSArrayController (which is that you can add any object with addObject:), I'd recommend doing something like this: - (void)addObject:(id)object { if ([object respondsToSelector:@selector(setIndex:)] { object.index = [NSNumber numberWithInt:[[self arrangedObjects] indexOfObject:object]]; } [super addObject:object]; } Well, that won't compile, which is the horse we rode in on. Assuming that's been taken care of (via option a, b or c from earlier in the thread), then this is a valid way to write the method, but not for the reason you say. Since NSArrayController has been subclassed, the OP can set a new API contract for the subclass, possibly one that says 'addObject' must be called with an object that responds to 'setIndex:', or possibly one that says 'addObject:' may not be called from outside the subclass at all, or possibly the more liberal one that your code implements. (Note that when you get here from 'add:', the object is known to be of the class corresponding to the array controller's 'entityName' parameter.) Note that I call super's addObject: at the end. I have no idea what the implementation of NSArrayController's addObject: is, but it's always better to have things set up before you pass something along to super. Imagine, for example, that NSArrayController writes the object immediately to disk when added. Since you haven't set your index yet, it would be incorrect. (I don't think it actually writes anything to disk at that point, but you get the idea.) You're right. I at least wasn't thinking about the super-ish aspects of this. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Crash when using TableView in View managed by TabController
I have a TabBarController that has three tabs, and each view for these is kept in its own nib. One of these views has a UITableView which has its delegate and dataSource attached to the File's Owner. The nib also has TableCell objects which are returned from: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath All is well when I load the view without the tab controller. When the TabController is used to manage the view however, I get a crash: iPhone Simulator 2.2 (77.4.9), iPhone OS 2.2.1 (5H11) *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[UIViewController 0x525e10 setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key mySwitchCell.' mySwitchCell is defined in the in the nib and of course works when the TabController is not used. How can I use a TabController to manage a view that contains a TableView? Thanks, Trygve ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Crash when using TableView in View managed by TabController
I have a TabBarController that has three tabs, and each view for these is kept in its own nib. One of these views has a UITableView which has its delegate and dataSource attached to the File's Owner. The nib also has TableCell objects which are returned from: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath All is well when I load the view without the tab controller. When the TabController is used to manage the view however, I get a crash: iPhone Simulator 2.2 (77.4.9), iPhone OS 2.2.1 (5H11) *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[UIViewController 0x525e10 setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key mySwitchCell.' mySwitchCell is defined in the in the nib and of course works when the TabController is not used. How can I use a TabController to manage a view that contains a TableView? Just in case anyone else runs into this, I did figure it out... The Class of the target view has to be set in the tab as well as in the view's nib itself. T. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Mouse move messages sent to both superview and a subview
I want to display one view on top on the other view, so according to the documentation, I nest the topmost view inside the background view. It works just fine except that the mouse move messages are sent to both the subview and the superview, whereas I'd like them to be directed only to the subview when it's visible. Why is this happening? I used to think that normally the same mouse messages cannot be delivered to more than one view. What is my mistake? Thanks! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Ideas required on testing an application install
On 26 Jun 2009, at 5:30am, Bill Bumgarner wrote: It'll be interested to see what kind of performance one achieves when booting from an SD card. Given their price ($40 for a class-6 SDHC card), it would be an attractive and convenient option. Certainly, I know that when I have a moment, I'm going to prep a 16GB card with two bootable partitions; one containing an emergency Leopard boot image configured to use my user account on the internal drive and one that contains DiskWarrior and a couple of other tools. I was intrigued to read this and thought I would give it a go. I installed the latest Snow Leopard (10A411) onto a 16GB card that was hanging off my MacBook Pro using a USB2 card reader. It installed onto the card OK and it even appears as an available startup disk, but the Mac doesn't seem to want to boot off this disk: just comes up with the question-mark-in-a-folder symbol. How do you get the SD card to act as a bootable drive? Ian. -- ianpi...@mac.com 07590 685840 | 01926 811383 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [IB] - how to delete action or outlet?
On 18/07/2009, at 4:32 PM, Alexander Bokovikov wrote: Nice! And how to remove that action or at least how to rename it? For example I've done it by mistake, for testing or similar purposes. Now I can't remove such action or outlet, though I've closed IB, removed the action from the source file, then opened IB again. The action (or outlet) still exists in the object properties list. I think the only way to remove it is to edit XIB file manually - not a simple way, isn't it? Delete the actions/outlets from the source file, save, and in IB they'll show up with a yellow colour and a 'x' in the list views (right-click on the target object to show the HUD view of the connections). Then clicking the yellow x deletes the phantom connection. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSDocument Enabling and handling menu items without implementing the action method in the document class
On 19/07/2009, at 10:06 PM, Eyal Redler wrote: This works fine but it requires me to write an annoying amount such glue code every time I add an action so I'm looking for a better way to do this. Is it possible to further delegate the action methods and menu validation from the NSDocument subclass? The best way for me would be to have internalObject implement validateMenuItem and myAction and have the NSDocument pass them along without actually implementing each action method. It sure is - use invocation forwarding. You need to override the following NSObject methods: - (NSMethodSignature *) methodSignatureForSelector:(SEL) aSelector; - (BOOL)respondsToSelector:(SEL) aSelector; - (void)forwardInvocation:(NSInvocation*) invocation; The first two methods should query the object you're devolving to when super returns nil and NO respectively, and the third should invoke the invocation on the new target. The result is that the target object can act as if it were directly being targeted by the original command (action) and even implement its own validateMenuItem: etc. More on this here: http://www.cocoadev.com/index.pl?NSInvocation It's hard to find in the Apple documentation so I was unable to immediately find the right page there, but it's in there somewhere. For example, I have a target object referred to as active layer and this code exists in my view's controller: - (void)forwardInvocation:(NSInvocation*) invocation { SEL aSelector = [invocation selector]; if ([[self activeLayer] respondsToSelector:aSelector]) [invocation invokeWithTarget:[self activeLayer]]; else [self doesNotRecognizeSelector:aSelector]; } - (NSMethodSignature *) methodSignatureForSelector:(SEL) aSelector { NSMethodSignature* sig; sig = [super methodSignatureForSelector:aSelector]; if ( sig == nil ) sig = [[self activeLayer] methodSignatureForSelector:aSelector]; return sig; } - (BOOL)respondsToSelector:(SEL) aSelector { return [super respondsToSelector:aSelector] || [[self activeLayer] respondsToSelector:aSelector]; } hope this helps, --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSDocument Enabling and handling menu items without implementing the action method in the document class
Hi, In the document based application I'm working on I have a lot of methods in the document class which simply pass a command to some internal object. This requires me do do the following in my NSDocument subclass: - (BOOL)validateMenuItem:(NSMenuItem *)item { SEL action = [item action]; if (actio...@selector(myAction:)) return [internalObject shouldEnableMyAction]; else ... } - (void)myAction:(id)sender { [internalObject myAction:sender]; } This works fine but it requires me to write an annoying amount such glue code every time I add an action so I'm looking for a better way to do this. Is it possible to further delegate the action methods and menu validation from the NSDocument subclass? The best way for me would be to have internalObject implement validateMenuItem and myAction and have the NSDocument pass them along without actually implementing each action method. TIA Eyal ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iPhone runtime browser.
Le 18 juil. 09 à 11:25, John C. Randolph a écrit : For anyone who hasn't done it themselves already, I just wrote up a little Cocoa touch app that shows you all the classes in the objective-C runtime. No point in submitting it to the app store, but if anyone would like a copy, drop me a note and I'll mail it to you. It's a 36KB .zip file. Offered as-is, no help, no support, no guarantees, etc. There is also another iPhone runtime browser: http://code.google.com/p/runtimebrowser/ Here is what it dumps on iPhone OS 3.0: http://seriot.ch/resources/dynamic_iPhone_headers/3_0/ -- Nicolas Seriot http://seriot.ch ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [IB] - how to delete action or outlet?
On 19.07.2009, at 18:05, Graham Cox wrote: Delete the actions/outlets from the source file, save, and in IB they'll show up with a yellow colour and a 'x' in the list views (right-click on the target object to show the HUD view of the connections). Then clicking the yellow x deletes the phantom connection. Thanks to all, who replied, but nothing helps :( I tried to reload (synchronize) IB with sources, but without luck. All what I have now is illustrated at screenshots: http://home.bokovikov.com/etc/mac/xcode/Picture1.png http://home.bokovikov.com/etc/mac/xcode/Picture2.png As you can see, bindings panel has four outlets, two of which are connected and other two are free. At the same time Outlets panel at Info page shows only two outlets. AppController's popup menu also shows four outlets. And I don't see any way to delete two free outlets. Moreover, I don't understand, how it could happen, that IB allows existence of more than one object's outlet with the same name. I don't like the idea to clear the XIB and create it all again, but definitely I will be more careful next time I'll have a deal with it! Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [IB] - how to delete action or outlet?
On 19/07/2009, at 10:46 PM, Alexander Bokovikov wrote: On 19.07.2009, at 18:05, Graham Cox wrote: Delete the actions/outlets from the source file, save, and in IB they'll show up with a yellow colour and a 'x' in the list views (right-click on the target object to show the HUD view of the connections). Then clicking the yellow x deletes the phantom connection. Thanks to all, who replied, but nothing helps :( I tried to reload (synchronize) IB with sources, but without luck. All what I have now is illustrated at screenshots attached. As you can see, bindings panel has four outlets, two of which are connected and other two are free. At the same time Outlets panel at Info page shows only two outlets. AppController's popup menu also shows four outlets. And I don't see any way to delete two free outlets. Moreover, I don't understand, how it could happen, that IB allows existence of more than one object's outlet with the same name. I don't like the idea to clear the XIB and create it all again, but definitely I will be more careful next time I'll have a deal with it! So, have you tried what I suggested? Right-click on the target object that you've changed *in the main view*. In the HUD window that pops up, look for yellow text with a 'x' button. Click it to delete. This should update what you are seeing in the bindings panel. It may not be possible to do the same thing directly in the bindings panel's list, but I do know the above does work, I use it frequently. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
How to intercept/reroute API call in loaded plugin?
I'm sorry, if it's offtopic here, then please tell me, what should be correct list. The problem is the next. I'm working on a Cocoa app, playing Flash content from a specially structured files. The problem with SWF playback is (as I believe) is resolved by movie loading from memory rather than from file. There is no problems here. But what is the problem is FLV (Flash video) playback. It looks like its opening goes despite to all rules directly from a file, but not through plugin=host app communication interface. At least I can't detect any public plugin functions calls, when FLV file is loaded. So, the task is - how to intercept this I/O call and patch it by my own procedure, providing a file handle, as well as file pointer navigation. I'm walking around Apple's sample of mach-o module manual launching: http://developer.apple.com/SampleCode/MemoryBasedBundle/index.html It is more or less clear, how to do it, but I can't find a way to intercept the process of import table loading of the loaded module. Did anybody similar things ever? Any help would be appreciated. Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [IB] - how to delete action or outlet?
On 19.07.2009, at 19:11, Graham Cox wrote: So, have you tried what I suggested? Right-click on the target object that you've changed *in the main view*. In the HUD window that pops up, look for yellow text with a 'x' button. Click it to delete. This should update what you are seeing in the bindings panel. It may not be possible to do the same thing directly in the bindings panel's list, but I do know the above does work, I use it frequently. I'm sorry, I don't know what is HUD window, but it is what is shown in this screenshot: http://home.bokovikov.com/etc/mac/xcode/Picture3.png If so, I don't see any yellow text here. Could you please provide a similar screenshot? You could email it to me directly, but not to the public list. Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Custom NSArrayController - Dynamic Class?
On Jul 18, 2009, at 11:52 PM, BJ Homer bjho...@gmail.com wrote: On Sat, Jul 18, 2009 at 4:23 PM, Quincey Morris quinceymor...@earthlink.net wrote: On Jul 18, 2009, at 15:07, Kyle Sluder wrote: I would instead recommend using -setValue:forKey: like this: [object setValue:[NSNumber numberWithInteger:[[self arrangedObjects] indexOfObject:object]] forKey:@index] Yes, it's more sensible. But now that I think about it, the performSelector approach has one *slight* advantage to the developer. If you ever use Xcode's refactoring to change the name of the property, it will miss the property name in the string. With @selector, the method name still doesn't change, but the refactor window does give a warning that it's not going to change automatically. Perhaps the best option is option (c): create a IndexedObject abstract superclass (if there isn't one already) and use 'object.index = ...' after all. In order to preserve the contract of NSArrayController (which is that you can add any object with addObject:), I'd recommend doing something like this: - (void)addObject:(id)object { if ([object respondsToSelector:@selector(setIndex:)] { object.index = [NSNumber numberWithInt:[[self arrangedObjects] indexOfObject:object]]; } [super addObject:object]; } Note that I call super's addObject: at the end. I have no idea what the implementation of NSArrayController's addObject: is, but it's always better to have things set up before you pass something along to super. Imagine, for example, that NSArrayController writes the object immediately to disk when added. Since you haven't set your index yet, it would be incorrect. (I don't think it actually writes anything to disk at that point, but you get the idea.) -BJ Actually, use [object setIndex:] instead, and cast it as an IndexedObject*. That will get rid of your compiler warnings. -BJ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re[2]: Ideas required on testing an application install
Hello Ian, Sunday, July 19, 2009, 12:45:50 PM, you wrote: On 26 Jun 2009, at 5:30am, Bill Bumgarner wrote: It'll be interested to see what kind of performance one achieves when booting from an SD card. Given their price ($40 for a class-6 SDHC card), it would be an attractive and convenient option. Certainly, I know that when I have a moment, I'm going to prep a 16GB card with two bootable partitions; one containing an emergency Leopard boot image configured to use my user account on the internal drive and one that contains DiskWarrior and a couple of other tools. I was intrigued to read this and thought I would give it a go. I installed the latest Snow Leopard (10A411) onto a 16GB card that was hanging off my MacBook Pro using a USB2 card reader. It installed onto the card OK and it even appears as an available startup disk, but the Mac doesn't seem to want to boot off this disk: just comes up with the question-mark-in-a-folder symbol. How do you get the SD card to act as a bootable drive? It does boot from a USB2 hard disk, and the install CD will boot from a USB2 connected DVDROM too. Perhaps the Mac EFI boot module doesnt simply boot off anything USB Mass Storage Device, but only from certain types of mass storage device. It's a bit silly if that's the case, but there we are. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/darkmatter%40blueyonder.co.uk This email sent to darkmat...@blueyonder.co.uk -- Best regards, Petermailto:darkmat...@blueyonder.co.uk ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Custom NSArrayController - Dynamic Class?
On Jul 18, 2009, at 11:52 PM, BJ Homer bjho...@gmail.com wrote: Actually, use [object setIndex:] instead, and cast it as an IndexedObject*. That will get rid of your compiler warnings. -BJ We're talking about the case in which you don't have a managed object subclass, and therefore there is nothing to cast to. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
View in Tab can't reference parent controller (iPhone)
I have an AppController in my main nib. Also in this nib is a TabBarController and several custom subclasses of UIViewController. The TabBarController manages the custom subclasses of UIViewController. However, these subcalsses need to be able to get back to the AppController . So for each subclass I have created an IBOutlet for the AppController and linked them up in my main nib. When a button action happens for example in one of the views, my IBOutlet from the custom view class back to the AppController is nil. Why... And how can I get a value here so that the view can call a method in the AppController? Even if I have the AppController pass self to a view controller and the viewController stores it, later on, the value has reset to nil. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Ideas required on testing an application install
On Jul 19, 2009, at 7:45 AM, Ian Piper wrote: How do you get the SD card to act as a bootable drive? Did you try Google? A search for boot sd card macbook turned up this as the first hit: http://arstechnica.com/apple/news/2009/06/boot-from-the-sd-card-slot-in-new-macbook-pros.ars Did you set the SD card's default partition table to GUID? If that didn't work I'd submit a bug. --Andy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Ideas required on testing an application install
On 19 Jul 2009, at 6:46pm, Andy Lee wrote: On Jul 19, 2009, at 7:45 AM, Ian Piper wrote: How do you get the SD card to act as a bootable drive? Did you try Google? A search for boot sd card macbook turned up this as the first hit: http://arstechnica.com/apple/news/2009/06/boot-from-the-sd-card-slot-in-new-macbook-pros.ars Did you set the SD card's default partition table to GUID? If that didn't work I'd submit a bug. --Andy Yes, I set it to GUID. It wouldn't even install on the SD card until I did that. I'm afraid I don't know the procedure for submitting a bug - presumably you mean to Apple? Ian. -- ianpi...@mac.com 07590 685840 | 01926 811383 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Changing the background of a NSScrollView
Folks I'm trying to draw into the background of a NSScrollView - specifically I have custom content I want to fill up the space with other than a solid colo(u)r. I'm slightly at a loss as to how to do this. Has anyone solved this problem already? Thanks in advance. Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Changing the background of a NSScrollView
On Jul 19, 2009, at 12:43, Richard Bannister wrote: I'm trying to draw into the background of a NSScrollView - specifically I have custom content I want to fill up the space with other than a solid colo(u)r. I'm slightly at a loss as to how to do this. Has anyone solved this problem already? I'd guess the easiest way would be to make the scroll view a subview of your custom view that draws the required background content, and set the scroll view not to draw its own background (setDrawsBackground:). You'd likely also set your custom view's autoresizing flags to whatever you currently have for the scroll view, and set the scroll view to autoresize to match its enclosing custom view. All of that can be done in IB, once you've written your custom view class. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: View in Tab can't reference parent controller (iPhone)
On Jul 19, 2009, at 10:38, Trygve Inda wrote: I have an AppController in my main nib. Also in this nib is a TabBarController and several custom subclasses of UIViewController. The TabBarController manages the custom subclasses of UIViewController. However, these subcalsses need to be able to get back to the AppController . So for each subclass I have created an IBOutlet for the AppController and linked them up in my main nib. When a button action happens for example in one of the views, my IBOutlet from the custom view class back to the AppController is nil. Why... And how can I get a value here so that the view can call a method in the AppController? Even if I have the AppController pass self to a view controller and the viewController stores it, later on, the value has reset to nil. This sort of inexplicable behavior is almost always the result of creating two sets of objects, one set unarchived from the nib with the correct connections, and one created as a result of some of your code that doesn't have any connections. Excuse me if I'm restating what you already know, but objects in nib files are real objects (re-created when the nib file is loaded), not placeholders that automatically match up with other objects. (Except of course for File's Owner, Application and First Responder, which *are* placeholders that automatically match up with other objects.) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Ideas required on testing an application install
On Jul 19, 2009, at 12:24 PM, Ian Piper wrote: On 19 Jul 2009, at 6:46pm, Andy Lee wrote: On Jul 19, 2009, at 7:45 AM, Ian Piper wrote: How do you get the SD card to act as a bootable drive? Did you try Google? A search for boot sd card macbook turned up this as the first hit: http://arstechnica.com/apple/news/2009/06/boot-from-the-sd-card- slot-in-new-macbook-pros.ars Did you set the SD card's default partition table to GUID? If that didn't work I'd submit a bug. Yes, I set it to GUID. It wouldn't even install on the SD card until I did that. I'm afraid I don't know the procedure for submitting a bug - presumably you mean to Apple? http://bugreport.apple.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Custom NSArrayController - Dynamic Class?
On Jul 19, 2009, at 11:21 AM, Kyle Sluder kyle.slu...@gmail.com wrote: On Jul 18, 2009, at 11:52 PM, BJ Homer bjho...@gmail.com wrote: Actually, use [object setIndex:] instead, and cast it as an IndexedObject*. That will get rid of your compiler warnings. -BJ We're talking about the case in which you don't have a managed object subclass, and therefore there is nothing to cast to. --Kyle Sluder Oh, right. Cast it to (id) then. Though if it's already passed in as an id, that's obviously unnecessary. Point is, calling setIndex: instead of object.index= will let it compile w/o warnings, in certain situations. Thanks for the correction. -BJ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Ideas required on testing an application install
On Jul 19, 2009, at 3:24 PM, Ian Piper wrote: Yes, I set it to GUID. It wouldn't even install on the SD card until I did that. I'm afraid I don't know the procedure for submitting a bug - presumably you mean to Apple? Yup, http://bugreport.apple.com. Maybe it's a Snow Leopard thing? Have you tried with Leopard? Also, I notice the Apple tech note mentioned in the Ars article says to use Mac OS Extended -- did you use that rather than the default Mac OS Extended (Journaled)? If only I had one of those spiffy new MacBooks I'd love to try this myself. Anyway, this has veered off-topic. --Andy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
RE: Core Data design patterns
Thanks for these wonderful answer and tips. I like how you have designed this stuff. Gladly, it is similar to what I've been doing. Based on this I can now refine my own stuff, e.g. by doing a subclass for each entity like you are doing. Two more things though: * About your error handling, how do you do it? My code differs in this respect, because in my CoreDataHelper I mentioned I have up until now had this handleError: method that takes in an NSError and whenever the error occurs, the model just calls this method and handles it internally. This means that I don't have to do any error handling in my Controller classes, making development easier. Does this, however, break any design principles? I may afford to do this because all my error handling did was to terminate the app using [NSApp terminate:self] and doing some NSLogs of the error information. (In fact, doing even that sometimes didn't terminate my application; how can I guarantee my app terminates? [NSApp terminate:self]; didn't seem to do the trick actually.) However, when you want to show some feedback at the UI level of errors, my method of handling errors in the model might not be such a good idea. * Finally an unrelated and basic Core Data question: Where do you paste the code you copy using the Copy Method Declarations/Implementations feature in the data modeling tool? I really want to use those things because it is, according to docs, faster than valueForKey, setValueForKey, etc. Up until now, I have tended to make a subclass of each of my managed objects and pasted the declarations/implementations in there. Do you think this is a good idea? --. From: je...@ieee.org To: cocoa-dev@lists.apple.com Date: Sat, 18 Jul 2009 22:43:59 -0700 Subject: Re: Core Data design patterns On 2009 Jul 17, at 09:26, Squ Aire wrote: Throughout my application I have to do fetching. I have simplified my code by making a helper class called CoreDataHelper... In fact, I can think of another variation of my method. Namely, to not have class methods in CoreDataHelper, but rather instance methods and initialize the CoreDataHelper with the MOC. The advantage of this would be that I would not have to pass the MOC into each method call. The drawback is that I have to create a CoreDataHelper instance each time I want to use its methods. This is what I've done, except I've taken it a step further. I've created helpers like this for several different entities. Each entity is a subclass of SSYMojo. SSYMojo has a moc and an entity. See my @interface for SSYMojo below. A third variation would be to simply do either of the two variations above, but not pass in MOC anywhere and instead just use [[NSApp delegate] managedObjectContext] whenever I need it within CoreDataHelper. I don't think you want to do that because all ^real^ Core Data apps, sooner or later, end up having multiple mocs. A more general closing question: How do you make your code more organized? ... Any antidotes? I believe you mean anecdotes. To avoid disorganized code, sit down with a pencil and big piece of paper, or a diagramming tool like OmniOutliner, and draw some class diagrams and flow charts. I've heard that some people even do this before they start on a project :)) The Holy Grail is to write a software specification which lays out everything so perfectly that you can hand it to a chimpanzee to write the code. In practice, there's always alot of back-and-forth between the spec and the code, and in the interest of getting the job done before the market moves on, you'll tend to write specs and diagrams for the more difficult parts, but just write code for the easy parts that you've had prior experience with. It's always a tradeoff between spending the time up front to plan and diagram, versus the risk of having to go back and do it later and rewrite code if your intuition turned out to be insufficient. Maybe reading some good design principles book will help? Great. Or getting a degree in CS? Wonderful if you've got the time. How did you guys learn this stuff? The hard way, except it's not learn, it's learning ;) --- #import #import SSYErrorHandler.h /*! @brief A class for putting and fetching -- managing -- managed objects of a particular entity in a particular managed object context. @details I wanted to make this a subclass of NSManagedObjectContext. However, the documentation for NSManagedObjectContext says that you are highly discouraged from subclassing it. So, what I did instead was to make this class be a wrapper around an managed object context which is an instance variable. */ @interface SSYMojo : NSObject { NSManagedObjectContext* managedObjectContext ; NSString* entityName ; NSObject * errorHandler ; } /*! @brief The built-in managed object context which the receiver will use. */ @property
Re: Custom NSArrayController - Dynamic Class?
On Jul 19, 2009, at 1:52 PM, BJ Homer bjho...@gmail.com wrote: Oh, right. Cast it to (id) then. Though if it's already passed in as an id, that's obviously unnecessary. Point is, calling setIndex: instead of object.index= will let it compile w/o warnings, in certain situations. Except the compiler needs a definition of -setIndex: somewhere or else it can't generate code. Your solution does not work in the general case. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data design patterns
On 2009 Jul 19, at 13:59, Squ Aire wrote: Thanks for these wonderful answer and tips. I like how you have designed this stuff. Gladly, it is similar to what I've been doing. Based on this I can now refine my own stuff, e.g. by doing a subclass for each entity like you are doing. Don't get too excited yet. If you can find something else to do today it might be good to wait until someone with more experience (and maybe one of those CS degrees) chimes in. * About your error handling, how do you do it? My code differs in this respect, because in my CoreDataHelper I mentioned I have up until now had this handleError: method that takes in an NSError and whenever the error occurs, the model just calls this method and handles it internally. This means that I don't have to do any error handling in my Controller classes, making development easier. and the product cheesier :) Does this, however, break any design principles? Well, I wouldn't call it a design principle, it's more of a desirable goal that errors should be bubbled up to the highest level and presented to the user. It makes for a much cleaner high-level design, and you should always consider doing this. But sometimes it makes the code a little too pedantic if every damned low-level method has an (NSError**)error_p parameter. The case in point here is that -[NSManagedObjectContext executeFetchRequest:error:] returns an NSError if something goes wrong. Well, say that this fetch request is not actually for fetching data to the user interface but to implement some other business logic, so there might be 3 methods on the call stack. And then by the time you build a predicate you're going to get several more. I mean, something as low level as a fetch request might have ten methods above it in the call stack, and I don't want to be carrying an NSError** parameter through all of them. To handle that, as you can see, my SSYMojo's initializer takes this parameter: (NSObject SSYErrorHandler *) errorHandler The formal protocol SSYErrorHandler declares an 'error' property. So when an error occurs in, for example, a fetch request, the SSYMojo sends setError: to its errorHandler. The errorHandler is something at a higher level, for example, my Core Data document, which checks that its 'error' property is nil after doing anything significant. I may afford to do this because all my error handling did was to terminate the app using [NSApp terminate:self] and doing some NSLogs of the error information. Great for in-house work! But I don't think my users would like that ;) (In fact, doing even that sometimes didn't terminate my application; how can I guarantee my app terminates? [NSApp terminate:self]; didn't seem to do the trick actually.) I've never seen this not work. Post some code. However, when you want to show some feedback at the UI level of errors, my method of handling errors in the model might not be such a good idea. Yes, but Apple's -presentError: is not very user-friendly, and also it discards most of the goodies in the error's userInfo dictionary. Ultimately, you'll want to override -willPresentError: and present the error in a custom sheet or dialog, while you copy the goodies into a full error report that users can send to you. * Finally an unrelated and basic Core Data question: Where do you paste the code you copy using the Copy Method Declarations/ Implementations feature in the data modeling tool? I really want to use those things because it is, according to docs, faster than valueForKey, setValueForKey, etc. Up until now, I have tended to make a subclass of each of my managed objects and pasted the declarations/implementations in there. Do you think this is a good idea? That's where I put them. Of course, you are heeding the You do not need any of these warning and only using these implementations if you ^really^ need to override an accessor. (Unfortunately this occurs quite often due to the skimpy information you get from NSManagedObjectContextObjectsDidChangeNotification -- Apple Bug 6624874). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iPhone runtime browser.
On Jul 19, 2009, at 5:33 AM, Nicolas Seriot wrote: There is also another iPhone runtime browser: http://code.google.com/p/runtimebrowser/ Here is what it dumps on iPhone OS 3.0: http://seriot.ch/resources/dynamic_iPhone_headers/3_0/ Looks like they got rather more elaborate about it than I did. I just added a bit to mine, it lists ivars and methods now, too. Anyone who wants the later version, ping me at j...@mac.com -jcr ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
popup in table column
I am confused by what seem to be two possible approaches to placing popup button cells into a table. If I understand the documentation, one can: a) set the popup button cell as the data cell of the (subclassed) column OR b) return the popup button cell in the table datasource method: - (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) tableColumn row: (int) row Which is considered the correct approach? Is there a basic tutorial on this? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
intelligent flexible popup
As a follow-up to the previous question on popups in a table, I am wondering what APIs you can use to implement the kind of intelligent popups one finds, for example, when filling out the State field in forms needing an address. You start typing Ma and Maine or Maryland come up. But you also have the choice to type something not in the list of choices. This seems to be a combination text field / popup menu. Again, either an API hint or link to a tutorial would be very helpful. Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: popup in table column
On Jul 19, 2009, at 7:38 PM, Daniel Child wrote: I am confused by what seem to be two possible approaches to placing popup button cells into a table. If I understand the documentation, one can: a) set the popup button cell as the data cell of the (subclassed) column OR b) return the popup button cell in the table datasource method: - (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) tableColumn row: (int) row Which is considered the correct approach? A isn't quite right. Not exactly. It depends on what you're trying to accomplish. Columns tend to show one kind of data, so you set the data cell of a table column (you don't need to subclass NSTableColumn) in code or in Interface Builder. B is absolutely wrong. The -tableView:objectValueForTableColumn:row: datasource method is a way for you to return the **objectValue** as the name suggests (and the document clearly states), not the cell to use to display this data. You might be confusing this (B) with the NSTableView delegate method -tableView:willDisplayCell:forTableColumn:row: where you can substitute cells at will. This probably less efficient, especially if your entire column will always use one kind of cell (ie, the Employee Department column is always a popup, populated with all the departments). All that to say this: You need to re-read the documentation because you've misunderstood some important concepts. Is there a basic tutorial on this? Dozens. Use Google. -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: intelligent flexible popup
On Jul 19, 2009, at 7:43 PM, Daniel Child wrote: As a follow-up to the previous question on popups in a table, I am wondering what APIs you can use to implement the kind of intelligent popups one finds, for example, when filling out the State field in forms needing an address. You start typing Ma and Maine or Maryland come up. But you also have the choice to type something not in the list of choices. This seems to be a combination text field / popup menu. Again, either an API hint or link to a tutorial would be very helpful. Thanks. ... also known as an NSComboBox. -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: intelligent flexible popup
On Jul 19, 2009, at 16:43, Daniel Child wrote: As a follow-up to the previous question on popups in a table, I am wondering what APIs you can use to implement the kind of intelligent popups one finds, for example, when filling out the State field in forms needing an address. You start typing Ma and Maine or Maryland come up. But you also have the choice to type something not in the list of choices. This seems to be a combination text field / popup menu. Again, either an API hint or link to a tutorial would be very helpful. Thanks. You're possibly looking for NSComboBox. But keep in mind that there's an essential difference between NSPopUpButton and NSComboBox. A popup button is a kind of *menu*, which a combo box is a kind of *text field*. The popup button tells you which of the menu choices is in effect (a selection index). The combo box gives you arbitrary text, typing- assisted by the popup list and (optionally) autocompletion. There isn't a standard control that allows you to make a menu choice by typing a partial name. (NSComboBox has some support for finding out this information, but I doubt it's feasible in the context of a table view, and you'd *still* have to prevent the table view from treating it like a text field.) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: intelligent flexible popup
On Jul 19, 2009, at 7:58 PM, Quincey Morris wrote: ... and you'd *still* have to prevent the table view from treating [NSComboBoxCell] like a text field. In what way? Are you referring to the fact that a menu can represent an object, whereas a combo box is just a (possibly-pre-baked-chosen-from-the- menu) string? In both cases it's not the NSTableView but your custom data source that would make these decisions (ie, what that new object that was set really means in that context). -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data design patterns
On Jul 19, 2009, at 3:15 PM, Jerry Krinock wrote: The case in point here is that -[NSManagedObjectContext executeFetchRequest:error:] returns an NSError if something goes wrong. This is misleading. The fundamental behaviour is that method returns NO if something goes wrong. In addition, if the error parameter is non-NULL and something goes wrong, the parameter contains an NSError that describes the problem. mmalc ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data design patterns
On Jul 19, 2009, at 1:59 PM, Squ Aire wrote: * Finally an unrelated and basic Core Data question: Where do you paste the code you copy using the Copy Method Declarations/ Implementations feature in the data modeling tool? I really want to use those things because it is, according to docs, faster than valueForKey, setValueForKey, etc. Up until now, I have tended to make a subclass of each of my managed objects and pasted the declarations/implementations in there. Do you think this is a good idea? Yes, this is fine. If you really want to avoid multiple NSManagedObject subclasses, you may also create categories of NSManagedObject that declare the various properties, but in general I find that using custom classes feels better. mmalc ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: intelligent flexible popup
On Jul 19, 2009, at 17:05, I. Savant wrote: On Jul 19, 2009, at 7:58 PM, Quincey Morris wrote: ... and you'd *still* have to prevent the table view from treating [NSComboBoxCell] like a text field. In what way? Are you referring to the fact that a menu can represent an object, whereas a combo box is just a (possibly-pre-baked-chosen-from-the- menu) string? In both cases it's not the NSTableView but your custom data source that would make these decisions (ie, what that new object that was set really means in that context). I meant, if you used the NSComboBox methods that told you which item of the popup list was chosen (e.g. indexOfSelectedItem), you'd know what was chosen -- if something *was* chosen from the list -- as a selection index, but the table view would nevertheless set the underlying string as the value of the property bound to the column. Storing or using such combo box selection indexes is tricky to do with a table view, because they don't fit into the bindings *or* the data source patterns. Even knowing where you might usefully call these selected item methods is puzzling. So yes, if you understand that the value corresponding to the column is a string which *may* match (isEqualToString:, not ==) a list of strings you separately maintain, then there's no problem. The easy-to-fall-into pitfall is having the data model property be an index into an array of (say) state names, but returning the string name of the state in place of the index when supplying data to the table view. In that case, changing the string for one row changes that string everywhere it's used, which is usually not what's intended. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSDocument Enabling and handling menu items without implementing the action method in the document class
Thank you very much Graham! Looks just like what I was looking for. Eyal On Jul 19, 2009, at 3:46 PM, Graham Cox wrote: On 19/07/2009, at 10:06 PM, Eyal Redler wrote: This works fine but it requires me to write an annoying amount such glue code every time I add an action so I'm looking for a better way to do this. Is it possible to further delegate the action methods and menu validation from the NSDocument subclass? The best way for me would be to have internalObject implement validateMenuItem and myAction and have the NSDocument pass them along without actually implementing each action method. It sure is - use invocation forwarding. You need to override the following NSObject methods: - (NSMethodSignature *) methodSignatureForSelector:(SEL) aSelector; - (BOOL)respondsToSelector:(SEL) aSelector; - (void)forwardInvocation:(NSInvocation*) invocation; The first two methods should query the object you're devolving to when super returns nil and NO respectively, and the third should invoke the invocation on the new target. The result is that the target object can act as if it were directly being targeted by the original command (action) and even implement its own validateMenuItem: etc. More on this here: http://www.cocoadev.com/index.pl?NSInvocation It's hard to find in the Apple documentation so I was unable to immediately find the right page there, but it's in there somewhere. For example, I have a target object referred to as active layer and this code exists in my view's controller: - (void)forwardInvocation:(NSInvocation*) invocation { SEL aSelector = [invocation selector]; if ([[self activeLayer] respondsToSelector:aSelector]) [invocation invokeWithTarget:[self activeLayer]]; else [self doesNotRecognizeSelector:aSelector]; } - (NSMethodSignature *) methodSignatureForSelector:(SEL) aSelector { NSMethodSignature* sig; sig = [super methodSignatureForSelector:aSelector]; if ( sig == nil ) sig = [[self activeLayer] methodSignatureForSelector:aSelector]; return sig; } - (BOOL)respondsToSelector:(SEL) aSelector { return [super respondsToSelector:aSelector] || [[self activeLayer] respondsToSelector:aSelector]; } hope this helps, --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: intelligent flexible popup
Daniel Child wrote: As a follow-up to the previous question on popups in a table, I am wondering what APIs you can use to implement the kind of intelligent popups one finds, for example, when filling out the State field in forms needing an address. You start typing Ma and Maine or Maryland come up. But you also have the choice to type something not in the list of choices. This seems to be a combination text field / popup menu. Again, either an API hint or link to a tutorial would be very helpful. Thanks. If I understand what you're asking for, it's just an NSComboBox(Cell). Look at either of those classes, depending on your need, and look at the setCompletes: method (and then NSComboBoxCell's completedString:). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data design patterns
On Jul 19, 2009, at 5:05 PM, mmalc Crawford wrote: The fundamental behaviour is that method returns NO if something goes wrong. As Jerry kindly pointed out off-list, this method of course returns nil -- not NO -- if something goes wrong. The important issue (and one which has given rise to several threads in the past, which is why the pattern warrants clarification) is that you should check the method's return value, not the error parameter, to determine whether the operation was successful. mmalc ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[iPhone] get iPhone's IP address...
Hi all, I found this code snipet that's supposed to return the iPhone's IP address. I am wondering if anyone can confirm the method for me. As i am told that this method works in an actual iPhone and not on the simulator. But i won't have an iPhone until Aug 9th All i am getting in the simulator is something like : fe80::21e: 52ff:fec6:b7401.618407e-303n1 I am wondering if anyone can confirm the method works (ie, returns an actual ip address) on an actual iPhone for me The code: - (NSString*) getNetAddr { char iphone_ip[255]; strcpy(iphone_ip,127.0.0.1); // if everything fails NSHost *myhost =[NSHost currentHost]; //NSHost *myhost = [[NSHost alloc] init]; if (myhost) { NSLog(@myhost exits); NSString *ad = [myhost address]; if (ad) strcpy(iphone_ip, [ad cStringUsingEncoding: NSISOLatin1StringEncoding]); } return [NSString stringWithFormat:@%s, iphone_ip]; } Thank you in advance... James ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com