NSTextField and key event delegates
Hi all, I've got an app that presents a text field where the user can enter some text, press tab, and have the text auto-completed from a list of terms. I'm having a weird problem where the first tab triggers the expected events, the second tab gets inserted as a literal tab character without firing any events, but the third etc. tabs trigger events as expected. The text field is an NSTextField and is set up to use the NSTextInput protocol to get control:textView:doCommandBySelector: events fired for, in this case, insertTab: events. When the insertTab: selector is called, the code gets the text typed so far in the NSTextView, gets all the terms matching that prefix from a list, replaces the text with the longest unique prefix, and inserts the remainder of the first term from the list as marked text. My problem is that once insertTab: has been called once—and the NSTextView has the first completion as marked text—the insertTab: selector doesn't get called when the user presses return; a literal tab character is inserted instead. If I then hit tab again (3rd time), insertTab: does get called. I'm going slowly mad here, having sprinkled NSLog()'s every other line and checking the status of the First Responder on entry and exit of my handler[0]. [0] – Using the code example in https://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/EventOverview/EventHandlingBasics/EventHandlingBasics.html#//apple_ref/doc/uid/1060i-CH5-SW23 As far as I can tell I'm not doing anything in the handler that ought to affect this, and the First Responder is the same for both cases; and I can't see how the event chain could be different for the second (but not third) time the user presses tab. I'm at a loss as to how to continue debugging this. Can someone suggest other approaches to debugging this? This used to work under 10.4, but started exhibiting the above problems under 10.5+ (so possibly OS/Framework related, possibly compiler toolchain related). Can anyone think of any changes there that might be relevant? Something related to the planned deprecation of the NSTextInput protocol in favor of the NSTextInputClient protocol perhaps? If anyone should be inclined, the relevant code is available at the URL below[1]. The relevant methods are tab_complete: and the input_text (NSTextField) delegates following it. [1] – http://github.com/xover/xchat-aqua/blob/master/fe-aqua/ChatWindow.mm#L2031 -- “If at first you don't succeed, keep shooting.” -- monk ___ 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
window level
Hello, List, Question about the window level. I will be so appreciated for any comments. There are three kinds of windows in my application: one modal window, the window launched by NSHelperManager, and the font or color panel. For my application, there is a button in the modal window, if user click this button, I will open the helper book through NSHelperManager. Unfortunately, the helper window is ordered in the back of the modal window, I think this is not so UI-friendly. in order to put the helper book window in the front of the modal window, I set the modal window level when the this window become main or key: -(void) windowDidBecomeMain:(NSNotification*) n { [myWindow setLevel:kCGNormalWindowLevel+1]; } but this change cause another issue that, the font panel will appear in the front of the modal window, when user click the font menu. So, do you have any suggestion, I have tried other window level values defined, but all failed to reach my goal, that making the modal window be ordered in the back of the helper window, but ordered in the front of the others. Thanks very much. Andrew ___ 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
Deallocation while key value observers still registered
Hi, I'm getting the message: An instance 0x11d0ce4b0 of class NMGeneralPrintAccessoryController was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: all my observers But I have put a breakpoint on my dealloc method, and in there, I do deregister for those notifications. Dealloc is called, and I did check that it was the same object, and all the calls to deregister are there. So I don't know how it could *not* be removing the observers. Any clues where to look? Thanks Gideon ___ 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: Deallocation while key value observers still registered
what version of what operating system are you using? On 25-May-2010, at 9:14 PM, Gideon King wrote: Hi, I'm getting the message: An instance 0x11d0ce4b0 of class NMGeneralPrintAccessoryController was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: all my observers But I have put a breakpoint on my dealloc method, and in there, I do deregister for those notifications. Dealloc is called, and I did check that it was the same object, and all the calls to deregister are there. So I don't know how it could *not* be removing the observers. Any clues where to look? Thanks Gideon ___ 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/rols%40rols.org This email sent to r...@rols.org ___ 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: Deallocation while key value observers still registered
10.6.3 On 25/05/2010, at 11:17 PM, Roland King wrote: what version of what operating system are you using? On 25-May-2010, at 9:14 PM, Gideon King wrote: Hi, I'm getting the message: An instance 0x11d0ce4b0 of class NMGeneralPrintAccessoryController was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: all my observers But I have put a breakpoint on my dealloc method, and in there, I do deregister for those notifications. Dealloc is called, and I did check that it was the same object, and all the calls to deregister are there. So I don't know how it could *not* be removing the observers. Any clues where to look? Thanks Gideon ___ 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 manipulation problem
Hi All, I have a little iPhone app which has the following UI: 1. 2 buttons, use to manipulate my model object. 2. 2 switches, let's call them infoSwitch and optionSwitch respectively 3. A custom view, its subview includes 4 UILabel, those labels are used to display infomation of my model object. Let's call it infoView. 4. Another custom view, includes a slider and textfield which are used to setup some states of my model objects, and the optionSwitch mentioned above. Let's call the view as optionView. 5. Yet another custom view, it will show the drawing graph of my model object according to its state. Let's call it graphView. The layout I want to show to the user is 2 buttons on top, next line is infoSwitch, and the next line is optionSwitch. And the next line of course is my drawing graph of my model object. That's all the user can see at the beginning. Both switches are set to off when they are loaded. And both infoView and optionView are transparent. (Alpha value is 0.0). User will use those 2 buttons to change the basic state of my model object. And the user can also switch the infoSwith to be on, once this event occurs, the optionSwitch, optionView and the graphView will slip certain pixel down, and the infoView will be showed right below to the infoSwith and above to the optionSwitch. Same thing should happen to the optionView. Once the user switch the optionSwitch to be on, the graphView will slip certain pixel down, and the optionView should be showed to the user where is below to the optionSwitch and is above to the graphView. That's what I want to implement. I have a problem regarding to this. In order to make the user see what I expect, the optionView will be layout on top of the infoView at the beginning. They are overlap. Hence the optionView will become the subview of the infoView. However, I will set the infoView alpha to 0.0 in the awakeFromNib method, then its subview includes optionView will be transparent as well even I set optionView alpha to 1.0, how to fix this? And since optionView is the subview of infoView, so when I move the optionView down, it can not be moved out of optionView anyway. Same thing happen to optionSwitch because optionSwitch is overlap with infoView, so if I make infoView transparent, so is optionSwitch. If I put all of these question into one statement, I guess it will be how to make each custom view independent even they are overlap in the interface builder, that is I don't want them to be superview and subview relationship. I want to handle them separately. Do I approach it the right way? Also, if I relocate the optionView down to certain pixcel, I guess it will no be displayed on the screen because it is located outside of the infoView(its superview). Can anyone suggest me a solution for this? Thank you. best regards, ico -- == Life isn't about finding yourself. Life is about creating yourself. ___ 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: Deallocation while key value observers still registered
That's not it then, in Snow Leopard there was a change so that message was only emitted at the end of the dealloc() method instead of at the start which allowed you to deregister your observers in dealloc() and not get this error. In Leopard and in (I think still in) iPhone OS you get the message at the start of dealloc whether you are just about to deregister your observers or not. On 25-May-2010, at 9:33 PM, Gideon King wrote: 10.6.3 On 25/05/2010, at 11:17 PM, Roland King wrote: what version of what operating system are you using? On 25-May-2010, at 9:14 PM, Gideon King wrote: Hi, I'm getting the message: An instance 0x11d0ce4b0 of class NMGeneralPrintAccessoryController was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: all my observers But I have put a breakpoint on my dealloc method, and in there, I do deregister for those notifications. Dealloc is called, and I did check that it was the same object, and all the calls to deregister are there. So I don't know how it could *not* be removing the observers. Any clues where to look? Thanks Gideon ___ 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: Deallocation while key value observers still registered
On Tue, May 25, 2010 at 6:14 AM, Gideon King gid...@novamind.com wrote: An instance 0x11d0ce4b0 of class NMGeneralPrintAccessoryController was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: all my observers But I have put a breakpoint on my dealloc method, and in there, I do deregister for those notifications. Dealloc is called, and I did check that it was the same object, and all the calls to deregister are there. So I don't know how it could *not* be removing the observers. This sounds off… you're deregistering obeservers in your observee's -dealloc? It sounds like object A has observed object B, and object B is being dealloced, which is removing its observation on object C, but the framework is complaining about object A. --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: Deallocation while key value observers still registered
On May 25, 2010, at 10:54 AM, Kyle Sluder kyle.slu...@gmail.com wrote: This sounds off you're deregistering obeservers in your observee's -dealloc? In general this would sound off to me too, on the principle that observees normally don't know who their observers are. �It�only makes sense to me if the observee added the observers to itself in the first place, on the principle that whoever adds an observer should take it away. On May 25, 2010, at 09:49 AM, Roland King r...@rols.org wrote: That's not it then, in Snow Leopard there was a change so that message was only emitted at the end of the dealloc() method instead of at the start which allowed you to deregister your observers in dealloc() and not get this error. In Leopard and in (I think still in) iPhone OS you get the message at the start of dealloc whether you are just about to deregister your observers or not. Thanks for this -- I vaguely remember something about the change in Snow Leopard but it hadn't clearly registered in my mind. I had an idea for a perverse hack to deal with the problem in Leopard, which was to to override release and do the deregistering there if the retainCount is 1, thus sneaking in the deregistering just before dealloc but no sooner. --Andy On 25-May-2010, at 9:33 PM, Gideon King wrote: 10.6.3 On 25/05/2010, at 11:17 PM, Roland King wrote: what version of what operating system are you using? On 25-May-2010, at 9:14 PM, Gideon King wrote: Hi, I'm getting the message: An instance 0x11d0ce4b0 of class NMGeneralPrintAccessoryController was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: all my observers But I have put a breakpoint on my dealloc method, and in there, I do deregister for those notifications. Dealloc is called, and I did check that it was the same object, and all the calls to deregister are there. So I don't know how it could *not* be removing the observers. Any clues where to look? Thanks Gideon ___ 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/aglee%40mac.com This email sent to ag...@mac.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: Deallocation while key value observers still registered
On Tue, May 25, 2010 at 9:08 AM, aglee ag...@mac.com wrote: I had an idea for a perverse hack to deal with the problem in Leopard, which was to to override release and do the deregistering there if the retainCount is 1, thus sneaking in the deregistering just before dealloc but no sooner. I believe this was actually impossible because of where the dealloc check was implemented (right at the top of -release, IIRC; -dealloc didn't actually do the checking, just the work of cleaning up). --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
-[NSMutableSet randomObject]
I'd like to extend Apple implementation of NSMutableSet to include a randomObject method. The purpose of this method is self-explanatory and its potential use is I'm sure obvious to most of you. For my first idea I thought about simply adding a category to NSMutableSet but any obvious implementation of -randomObject would require accessing existing instance variables or adding my own in order to implement the random access I would need to for the set. I also don't know how objects are stored internally. Is it an array? Is it a key/value pair? I don't know. How am I going to correlate the random numbers I generate with the objects in the set? Next, I thought about using inheritance with NSMutableArray. I even wrote some code: + (void)initialize { if ( self == [MCRandomlyAccessedArray class] ) { srandom(time(NULL)); } } - (id)randomObject { // If the array is empty, throw an exception. The caller should know better. // If there is only one, return object zero every time. // If there are only two, alternate with every access. // If there are three or more, randomize but never provide the same object // twice in a row. if ( [self count] ) { NSUInteger index = 0; if ( [self count] 1 ) { if ( 2 == [self count] ) { index = (++lastObjectIndex % 2); } else { do { index = (random() % [self count]); } while (index == lastObjectIndex); } lastObjectIndex = index; } return [self objectAtIndex:index]; } else { [[NSException exceptionWithName:NSRangeException reason:@Array is empty userInfo:nil] raise]; } return nil; // unreachable } Come to find out at runtime that this won't work either because NSMutableArray is abstract! *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableArray addObject:]: method only defined for abstract class. Define -[MCRandomlyAccessedArray addObject:]!' This would seem to indicate that I need to write a lot more code in order to have a complete implementation. I'm not in the mood to re-invent the wheel. I'm not lazy, I just have a lot of other code that needs to be written, which pertains to the big picture. Next, I thought maybe I could simply wrap-up an NSMutableArray in my own class and let it do most of the heavy lifting when it comes to all of those existing methods. The only problem is that I'm no expert on how to duplicate all of the class and instance init methods and memory management code. So, that brings me to you lovely people. What do you recommend? Do I bite the bullet and re-implement NSMutableArray? If so, where can I find guidance on this? I love the containers provided by Apple. They simply work and I don't have to think about them. So much so, that I don't really know how they work. My expertise is/was in C/C++ and STL. Is there fourth alternative or something I missed in my brief examination as described above? Thanks. -Michael ___ 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: -[NSMutableSet randomObject]
What about something like: @implementation NSSet (Random) - (id) randomObject { NSArray * allObjects = [self allObjects]; if ([allObjects count] == 0) { @throw ...; } return [allObjects objectAtIndex:(arc4random() % [allObjects count])]; } @end On May 25, 2010, at 10:49 AM, Michael A. Crawford wrote: I'd like to extend Apple implementation of NSMutableSet to include a randomObject method. The purpose of this method is self-explanatory and its potential use is I'm sure obvious to most of you. For my first idea I thought about simply adding a category to NSMutableSet but any obvious implementation of -randomObject would require accessing existing instance variables or adding my own in order to implement the random access I would need to for the set. I also don't know how objects are stored internally. Is it an array? Is it a key/value pair? I don't know. How am I going to correlate the random numbers I generate with the objects in the set? Next, I thought about using inheritance with NSMutableArray. I even wrote some code: + (void)initialize { if ( self == [MCRandomlyAccessedArray class] ) { srandom(time(NULL)); } } - (id)randomObject { // If the array is empty, throw an exception. The caller should know better. // If there is only one, return object zero every time. // If there are only two, alternate with every access. // If there are three or more, randomize but never provide the same object // twice in a row. if ( [self count] ) { NSUInteger index = 0; if ( [self count] 1 ) { if ( 2 == [self count] ) { index = (++lastObjectIndex % 2); } else { do { index = (random() % [self count]); } while (index == lastObjectIndex); } lastObjectIndex = index; } return [self objectAtIndex:index]; } else { [[NSException exceptionWithName:NSRangeException reason:@Array is empty userInfo:nil] raise]; } return nil; // unreachable } Come to find out at runtime that this won't work either because NSMutableArray is abstract! *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableArray addObject:]: method only defined for abstract class. Define -[MCRandomlyAccessedArray addObject:]!' This would seem to indicate that I need to write a lot more code in order to have a complete implementation. I'm not in the mood to re-invent the wheel. I'm not lazy, I just have a lot of other code that needs to be written, which pertains to the big picture. Next, I thought maybe I could simply wrap-up an NSMutableArray in my own class and let it do most of the heavy lifting when it comes to all of those existing methods. The only problem is that I'm no expert on how to duplicate all of the class and instance init methods and memory management code. So, that brings me to you lovely people. What do you recommend? Do I bite the bullet and re-implement NSMutableArray? If so, where can I find guidance on this? I love the containers provided by Apple. They simply work and I don't have to think about them. So much so, that I don't really know how they work. My expertise is/was in C/C++ and STL. Is there fourth alternative or something I missed in my brief examination as described above? Thanks. -Michael ___ 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/davedelong%40me.com This email sent to davedel...@me.com smime.p7s Description: S/MIME cryptographic signature ___ 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: -[NSMutableSet randomObject]
Ah, I see; you don't want to provide the same object twice in a row. If that's the case, is it really random? ;) Dave On May 25, 2010, at 10:52 AM, Dave DeLong wrote: What about something like: @implementation NSSet (Random) - (id) randomObject { NSArray * allObjects = [self allObjects]; if ([allObjects count] == 0) { @throw ...; } return [allObjects objectAtIndex:(arc4random() % [allObjects count])]; } @end smime.p7s Description: S/MIME cryptographic signature ___ 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: -[NSMutableSet randomObject]
Hey, not bad. Does the -allObjects method always return the same sequence? Did you just cobble this up or is this running in a system somewhere? It doesn't do everything I want but it is definitely the better part of the 80/20 rule. -Michael On May 25, 2010, at 12:52 PM, Dave DeLong wrote: What about something like: @implementation NSSet (Random) - (id) randomObject { NSArray * allObjects = [self allObjects]; if ([allObjects count] == 0) { @throw ...; } return [allObjects objectAtIndex:(arc4random() % [allObjects count])]; } @end On May 25, 2010, at 10:49 AM, Michael A. Crawford wrote: I'd like to extend Apple implementation of NSMutableSet to include a randomObject method. The purpose of this method is self-explanatory and its potential use is I'm sure obvious to most of you. For my first idea I thought about simply adding a category to NSMutableSet but any obvious implementation of -randomObject would require accessing existing instance variables or adding my own in order to implement the random access I would need to for the set. I also don't know how objects are stored internally. Is it an array? Is it a key/value pair? I don't know. How am I going to correlate the random numbers I generate with the objects in the set? Next, I thought about using inheritance with NSMutableArray. I even wrote some code: + (void)initialize { if ( self == [MCRandomlyAccessedArray class] ) { srandom(time(NULL)); } } - (id)randomObject { // If the array is empty, throw an exception. The caller should know better. // If there is only one, return object zero every time. // If there are only two, alternate with every access. // If there are three or more, randomize but never provide the same object // twice in a row. if ( [self count] ) { NSUInteger index = 0; if ( [self count] 1 ) { if ( 2 == [self count] ) { index = (++lastObjectIndex % 2); } else { do { index = (random() % [self count]); } while (index == lastObjectIndex); } lastObjectIndex = index; } return [self objectAtIndex:index]; } else { [[NSException exceptionWithName:NSRangeException reason:@Array is empty userInfo:nil] raise]; } return nil; // unreachable } Come to find out at runtime that this won't work either because NSMutableArray is abstract! *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableArray addObject:]: method only defined for abstract class. Define -[MCRandomlyAccessedArray addObject:]!' This would seem to indicate that I need to write a lot more code in order to have a complete implementation. I'm not in the mood to re-invent the wheel. I'm not lazy, I just have a lot of other code that needs to be written, which pertains to the big picture. Next, I thought maybe I could simply wrap-up an NSMutableArray in my own class and let it do most of the heavy lifting when it comes to all of those existing methods. The only problem is that I'm no expert on how to duplicate all of the class and instance init methods and memory management code. So, that brings me to you lovely people. What do you recommend? Do I bite the bullet and re-implement NSMutableArray? If so, where can I find guidance on this? I love the containers provided by Apple. They simply work and I don't have to think about them. So much so, that I don't really know how they work. My expertise is/was in C/C++ and STL. Is there fourth alternative or something I missed in my brief examination as described above? Thanks. -Michael ___ 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/davedelong%40me.com This email sent to davedel...@me.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/michaelacrawford%40me.com This email sent to michaelacrawf...@me.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:
Create an NSImage using pixel (RGB) data
Hi, I would like to create an new NSImage (of a specified size) by modifying its pixel data directly. I'm assuming that I have to create/provide a representation then call [rep bitmapData], but I've been unable to come up with a working solution thus far. Does anyone know of an example I might look at? Thanks in advance, Cat ___ 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: Deallocation while key value observers still registered
Hi, I had something perhaps similar. (But have no solution, only possible further information to add). I believe that registration came in my case from InterfaceBuilder, where I had used the keyed values as entries in various textFields, using IB setup bindings in an NSPanel. (Snow Leopard). Without a solution I am just allowing the leaks by not deallocing. Would be most interested in solution. Simon On 25 May 2010, at 15:54, Kyle Sluder wrote: On Tue, May 25, 2010 at 6:14 AM, Gideon King gid...@novamind.com wrote: An instance 0x11d0ce4b0 of class NMGeneralPrintAccessoryController was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: all my observers But I have put a breakpoint on my dealloc method, and in there, I do deregister for those notifications. Dealloc is called, and I did check that it was the same object, and all the calls to deregister are there. So I don't know how it could *not* be removing the observers. This sounds off… you're deregistering obeservers in your observee's -dealloc? It sounds like object A has observed object B, and object B is being dealloced, which is removing its observation on object C, but the framework is complaining about object A. --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/simon%40richstitch.com This email sent to si...@richstitch.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: Create an NSImage using pixel (RGB) data
This is what I came up with - I hope it helps someone. #import Foundation/Foundation.h typedef struct { unsigned char red; unsigned char green; unsigned char blue; } HL_RGB; int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSSize imageSize = { 100, 100 }; NSBitmapImageRep* bitmapImageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **)NULL pixelsWide:(int)imageSize.width pixelsHigh:(int)imageSize.height bitsPerSample:(int)8 samplesPerPixel:(int)3 hasAlpha:(BOOL)NO isPlanar:(BOOL)NO colorSpaceName:(NSString *) NSDeviceRGBColorSpace bytesPerRow:(int)(imageSize.width * sizeof(HL_RGB)) bitsPerPixel:(int)0]; HL_RGB* pOutputPixel = (HL_RGB*)[bitmapImageRep bitmapData]; // Draw a red diagonal line for (NSUInteger row = 0; row imageSize.width; row++) { for (NSUInteger col = 0; col imageSize.height; col++) { if (row == col) { pOutputPixel[row * (int)imageSize.width + col].red = 0xFF; } } } // Write the data out to disk - no compression NSDictionary *imageProps = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:1.0] forKey: NSImageCompressionFactor]; NSData* outputImageData = [bitmapImageRep representationUsingType: NSJPEGFileType properties:imageProps]; [outputImageData writeToFile:@output.jpg atomically:NO]; [bitmapImageRep release]; [pool drain]; return 0; } On Tue, May 25, 2010 at 8:24 AM, Simon Raisin catx...@gmail.com wrote: Hi, I would like to create an new NSImage (of a specified size) by modifying its pixel data directly. I'm assuming that I have to create/provide a representation then call [rep bitmapData], but I've been unable to come up with a working solution thus far. Does anyone know of an example I might look at? Thanks in advance, Cat ___ 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: -[NSMutableSet randomObject]
Implementation should probably include various options for what kind of pseudo randomness is desired. On May 25, 2010, at 11:52 AM, Dave DeLong wrote: What about something like: @implementation NSSet (Random) - (id) randomObject { NSArray * allObjects = [self allObjects]; if ([allObjects count] == 0) { @throw ...; } return [allObjects objectAtIndex:(arc4random() % [allObjects count])]; } @end On May 25, 2010, at 10:49 AM, Michael A. Crawford wrote: I'd like to extend Apple implementation of NSMutableSet to include a randomObject method. The purpose of this method is self-explanatory and its potential use is I'm sure obvious to most of you. For my first idea I thought about simply adding a category to NSMutableSet but any obvious implementation of -randomObject would require accessing existing instance variables or adding my own in order to implement the random access I would need to for the set. I also don't know how objects are stored internally. Is it an array? Is it a key/value pair? I don't know. How am I going to correlate the random numbers I generate with the objects in the set? Next, I thought about using inheritance with NSMutableArray. I even wrote some code: + (void)initialize { if ( self == [MCRandomlyAccessedArray class] ) { srandom(time(NULL)); } } - (id)randomObject { // If the array is empty, throw an exception. The caller should know better. // If there is only one, return object zero every time. // If there are only two, alternate with every access. // If there are three or more, randomize but never provide the same object // twice in a row. if ( [self count] ) { NSUInteger index = 0; if ( [self count] 1 ) { if ( 2 == [self count] ) { index = (++lastObjectIndex % 2); } else { do { index = (random() % [self count]); } while (index == lastObjectIndex); } lastObjectIndex = index; } return [self objectAtIndex:index]; } else { [[NSException exceptionWithName:NSRangeException reason:@Array is empty userInfo:nil] raise]; } return nil; // unreachable } Come to find out at runtime that this won't work either because NSMutableArray is abstract! *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableArray addObject:]: method only defined for abstract class. Define -[MCRandomlyAccessedArray addObject:]!' This would seem to indicate that I need to write a lot more code in order to have a complete implementation. I'm not in the mood to re-invent the wheel. I'm not lazy, I just have a lot of other code that needs to be written, which pertains to the big picture. Next, I thought maybe I could simply wrap-up an NSMutableArray in my own class and let it do most of the heavy lifting when it comes to all of those existing methods. The only problem is that I'm no expert on how to duplicate all of the class and instance init methods and memory management code. So, that brings me to you lovely people. What do you recommend? Do I bite the bullet and re-implement NSMutableArray? If so, where can I find guidance on this? I love the containers provided by Apple. They simply work and I don't have to think about them. So much so, that I don't really know how they work. My expertise is/was in C/C++ and STL. Is there fourth alternative or something I missed in my brief examination as described above? Thanks. -Michael ___ 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/davedelong%40me.com This email sent to davedel...@me.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/jjoyce%40apple.com This email sent to jjo...@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: -[NSMutableSet randomObject]
Since an NSSet is, by definition, unordered, the allObjects method is not guaranteed to return the same ordering of objects every time. However, once you have the array, you could easily order it yourself using sortedArrayUsing(Selector/Comparator/Descriptors):. And I've used this code (or really similar code) in production stuff before. Dave On May 25, 2010, at 10:58 AM, Michael A. Crawford wrote: Hey, not bad. Does the -allObjects method always return the same sequence? Did you just cobble this up or is this running in a system somewhere? It doesn't do everything I want but it is definitely the better part of the 80/20 rule. -Michael smime.p7s Description: S/MIME cryptographic signature ___ 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: Deallocation while key value observers still registered
I have found the problem. In awakeFromNib, I have several calls like this: [self addObserver:self forKeyPath:@thingy options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew context:NULL]; And in the dealloc method, I have: [self removeObserver:self forKeyPath:@thingy]; for all the same key paths. All looked normal enough. But in the init method of the class, I was loading a nib that had my class as the file's owner, as well as being a view controller for another view. Therefore, awakeFromNib was being called twice, and although the dealloc was removing one set of registrations, the other set was being left. In my core data classes, I have all this wrapped in a boolean that avoids starting observing more than once, but I wasn't doing that in this part of my code. I found the -observationInfo method useful in tracking this down - I knew there must be some method like this, but had not found it before. Thanks for the suggestions etc. Gideon On 26/05/2010, at 2:29 AM, Kyle Sluder wrote: On Tue, May 25, 2010 at 9:08 AM, aglee ag...@mac.com wrote: I had an idea for a perverse hack to deal with the problem in Leopard, which was to to override release and do the deregistering there if the retainCount is 1, thus sneaking in the deregistering just before dealloc but no sooner. I believe this was actually impossible because of where the dealloc check was implemented (right at the top of -release, IIRC; -dealloc didn't actually do the checking, just the work of cleaning up). --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
Creating a PDFSelection...
Dear progammers, Thanks for all the help! Onto the next problem... Users need to be able to select sections of a pdfView, and I need to be able to save and analyze the selections (e.g., do they overlap). I also need to be able to restore the selections later. So the question is, can I use PDFSelection to do this. I can't seem to find a way to say create a selection with this NSRect (or part of the string). Is there a way to do this? Is there an alternative? --Matthew ___ 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: Error 134100 - Core Data models incompatible
Seriously? I let people know which versions of the OSes I was running, but I don't see how this problem has anything to do with an NDA, unless it's a bug in the dev tools. Core Data for the iPhone OS has been available for many moons now, and, for all intents and purposes, this appears to be an issue with Core Data. Furthermore, I have the dev tools for OS 4 installed, but, obviously, that's not what I'm running on the iPad, since the iPad doesn't support anything newer than 3.2, which is not under NDA. On May 20, 2010, at 4:33 PM, eric dolecki GMail wrote: Well said. Sent from my iPad On May 20, 2010, at 6:54 PM, Fritz Anderson fri...@manoverboard.org wrote: On 20 May 2010, at 4:13 PM, Brad Gibbs wrote: Mac OS X 10.6.2, iPhone OS 4.0 beta 2 (although the iPad client started life before the first OS 4 beta was released). And here is why you won't get any answers. The NDA you agreed to in order to get the 4.0 SDK forbids you, and anyone who knows the answer, to discuss it in public. The penalties can be draconian. If you have access to prerelease software, you have access to the Apple Developer Forums behind your login at developer.apple.com/iphone. Try there. — F ___ 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/edolecki%40gmail.com This email sent to edole...@gmail.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: Error 134100 - Core Data models incompatible
Seriously. I refer you to your original message: On 25 May 2010, at 12:43 PM, Brad Gibbs wrote: iPhone OS 4.0 beta 2 You asked about the behavior of an operating system. The operating system you asked about was iPhone OS 4.0. Answering a question about iPhone OS 4.0 requires discussion of iPhone OS 4.0. iPhone OS 4.0 may not be discussed on open mailing lists. If, as you say, your question was also applicable to operating system that may be discussed on an open mailing list, you could have omitted reference to iPhone OS 4.0, and responses would not, even implicitly, have to be about iPhone OS 4.0. You now imply you meant to ask about the iPhone OS 4.0 beta 2 _SDK_, not the operating system itself. The SDK is likewise under nondisclosure, so that doesn't change anything. I'm out of this thread; I've already kibitzed too much on the moderator's job. Take it up with him. — F ___ 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 View Binding, Arrays, and observeValueForKeyPath (solved)
Thanks everyone for your help on this, I found out my problem was how I was overriding -bind:toObject:withKeyPath:options:. In my implementation when adding a view as an observer I neglected to add NSKeyValueObservingOptionOld to the options. Once I did that I was able to see the old values of the array. Thank! Mazen Abdel-Rahman On May 19, 2010, at 3:00 AM, Ken Thomases wrote: On May 19, 2010, at 2:05 AM, Mazen M. Abdel-Rahman wrote: I have a custom view class with an array property. I want to bind that array property to a model - which in my case is an array that is in a container/manager object. The binding is done via a custom view controller (in it's awakeFromNib). (calendar is the model object) [calendarView bind:@events toObject:calendar withKeyPath:@events options:options]; Now whenever events in the object calendar is modified events in calendarView is modified as well. In addition - observeValueForKeyPath... is getting called as well in the calendarView. The problem is that if some items are removed from calendar's (the model) events array by the time observeValueForKeyPath in calendarView gets called its events array has already been updated to reflect the model change. I think you have two options: * Override -bind:toObject:withKeyPath:options: and don't rely on the default implementation, at all. * Use the default implementation but don't use -observeValueForKeyPath:ofObject:change:context: to be informed about the change of the view's property. Use the property's setter method, instead. I would not expect that the view's property would already be updated at the time that -observeValueForKeyPath:... is called, because by what mechanism other than that method would the binding update that property? The answer, I guess, is that the default implementation of -bind:... is actually setting some other object (not the receiver) as the key-value observer of the key path of the observableController, and that object is getting the -observeValueForKeyPath:... message and then setting the property on your view. However, if that's the case, I don't know why your view would have -observeValueForKeyPath:... invoked on it, too. So, there's a bit of a mystery there. And that's reason enough not to rely on the default implementation -- it's a black box with ill-defined behavior. Overriding -bind:... is actually the method illustrated in Apple's documentation about implementing a custom binding on a custom view. See the How Do Bindings Work? section of the Cocoa Bindings Programming Topics. Also, have a look at the Sketch+Accessibility sample code, where it implements custom binding (e.g. SKTGraphicView). It actually illustrates both approaches. Regards, Ken ___ 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: -[NSMutableSet randomObject]
If this is indeed the desired effect, you're much better off writing a - (NSArray *)arrayByRandomlyOrderingObjects in an NSArray category, and then calling [[mySet allObjects] arrayByRandomlyOrderingObjects];. Bob On 25 May 2010, at 17:54, Dave DeLong wrote: Ah, I see; you don't want to provide the same object twice in a row. If that's the case, is it really random? ;) Dave On May 25, 2010, at 10:52 AM, Dave DeLong wrote: What about something like: @implementation NSSet (Random) - (id) randomObject { NSArray * allObjects = [self allObjects]; if ([allObjects count] == 0) { @throw ...; } return [allObjects objectAtIndex:(arc4random() % [allObjects count])]; } @end ___ 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/tom.davie%40gmail.com This email sent to tom.da...@gmail.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
Crash trying to unarchive webview from IB document
I was doing a little demo to a colleague this morning and built a simple app consisting of a text field and a web view in IB. I was able to run the thing from IB but when I tried to compile it as release and launch it, it would crash with an exception: *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (WebView)' I tried to look if I did something wrong but since it was just a little demo with no code written, I'm a bit stumped. I created a new project for a Cocoa app, nothing fancy, then opened the MainWindow.xib in IB to add the text field and the webview. Anyone has any idea? -Laurent. -- Laurent Daudelin AIM/iChat/Skype:LaurentDaudelin http://nemesys.dyndns.org Logiciels Nemesys Software laurent.daude...@gmail.com Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries ___ 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: Deallocation while key value observers still registered
On Wed, 26 May 2010 03:08:31 +1000, Gideon King said: I have found the problem. In awakeFromNib, I have several calls like this: [self addObserver:self forKeyPath:@thingy options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew context:NULL]; And in the dealloc method, I have: [self removeObserver:self forKeyPath:@thingy]; for all the same key paths. All looked normal enough. But in the init method of the class, I was loading a nib that had my class as the file's owner, as well as being a view controller for another view. Therefore, awakeFromNib was being called twice, and although the dealloc was removing one set of registrations, the other set was being left. In my core data classes, I have all this wrapped in a boolean that avoids starting observing more than once, but I wasn't doing that in this part of my code. I found the -observationInfo method useful in tracking this down - I knew there must be some method like this, but had not found it before. Thanks for the suggestions etc. Glad you've tracked it down. Just a comment though: my understanding is that calling removeObserver from dealloc is, in general, discouraged. See here for some reasoning: http://www.karppinen.fi/analysistool/ -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ 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 trying to unarchive webview from IB document
On Tue, May 25, 2010 at 3:10 PM, Laurent Daudelin laurent.daude...@gmail.com wrote: I was doing a little demo to a colleague this morning and built a simple app consisting of a text field and a web view in IB. I was able to run the thing from IB but when I tried to compile it as release and launch it, it would crash with an exception: *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (WebView)' I tried to look if I did something wrong but since it was just a little demo with no code written, I'm a bit stumped. I created a new project for a Cocoa app, nothing fancy, then opened the MainWindow.xib in IB to add the text field and the webview. Anyone has any idea? Did you add WebKit.framework to your Xcode project? sherm-- -- Cocoa programming in Perl: http://www.camelbones.org ___ 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 trying to unarchive webview from IB document
On 25 maj 2010, at 13.10, Laurent Daudelin wrote: I was doing a little demo to a colleague this morning and built a simple app consisting of a text field and a web view in IB. I was able to run the thing from IB but when I tried to compile it as release and launch it, it would crash with an exception: *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (WebView)' I tried to look if I did something wrong but since it was just a little demo with no code written, I'm a bit stumped. I created a new project for a Cocoa app, nothing fancy, then opened the MainWindow.xib in IB to add the text field and the webview. Anyone has any idea? Did you remember to link your target to the WebKit framework? That's where the WebView class lives. Nick Zitzmann http://www.chronosnet.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: Crash trying to unarchive webview from IB document
On May 25, 2010, at 12:13, Sherm Pendley wrote: On Tue, May 25, 2010 at 3:10 PM, Laurent Daudelin laurent.daude...@gmail.com wrote: I was doing a little demo to a colleague this morning and built a simple app consisting of a text field and a web view in IB. I was able to run the thing from IB but when I tried to compile it as release and launch it, it would crash with an exception: *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (WebView)' I tried to look if I did something wrong but since it was just a little demo with no code written, I'm a bit stumped. I created a new project for a Cocoa app, nothing fancy, then opened the MainWindow.xib in IB to add the text field and the webview. Anyone has any idea? Did you add WebKit.framework to your Xcode project? sherm-- Stupid me! LOL. Thanks, Sherm! -Laurent. -- Laurent Daudelin AIM/iChat/Skype:LaurentDaudelin http://nemesys.dyndns.org Logiciels Nemesys Software laurent.daude...@gmail.com Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries ___ 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
reformat drive to HFS via API
I would like to be able to reformat a flash drive from control application, but it appears that there is no public API that allows this kind access. Am I missing something in the documentation? Or do I do something like call out to diskutil to make it happen? Rich Collyer ___ 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
NSOutlineView Assert
Does anyone have info on this assert: *** Assertion failure in -[MacOutlineView _expandItemEntry:expandChildren:startLevel:], /SourceCache/AppKit/AppKit-1038.29/TableView.subproj/NSOutlineView.m:969 The MacOutlineView is my class and I get this on occasion post a drag/drop. If I can get some insight as to what triggers the assert, it will help me track down my issue. Thanks. -Tony ___ 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: NSOutlineView Assert
Break on objc_exception_throw and repeat the error that hits it. That should point you to your problem. --corbin On May 25, 2010, at 12:46 PM, Tony Romano wrote: Does anyone have info on this assert: *** Assertion failure in -[MacOutlineView _expandItemEntry:expandChildren:startLevel:], /SourceCache/AppKit/AppKit-1038.29/TableView.subproj/NSOutlineView.m:969 The MacOutlineView is my class and I get this on occasion post a drag/drop. If I can get some insight as to what triggers the assert, it will help me track down my issue. 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: window level
On Tue, 25 May 2010 17:34:37 +0800, XiaoGang Li andrew.mac...@gmail.com said: For my application, there is a button in the modal window, if user click this button, I will open the helper book through NSHelperManager. Unfortunately, the helper window is ordered in the back of the modal window, I think this is not so UI-friendly What is not UI-friendly is your use of a modal window. Modal means the user can work *only* in *this* window. If that isn't you want, don't use a modal window. Or, when the user clicks the button, you should make the modal window close. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! AppleScript: the Definitive Guide - Second Edition! http://www.tidbits.com/matt/default.html#applescriptthings ___ 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
set custom formatter in IB
Hello, I am trying to associate a custom formatter with a text filed in IB. Having no luck with with either dragging out of 'Classes' or instantiating and then dragging out of the .xib window. Do I have to do this programmatically? Thanks, Rainer ___ 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: -[NSMutableSet randomObject]
On May 25, 2010, at 11:49 AM, Michael A. Crawford wrote: // If the array is empty, throw an exception. The caller should know better. // If there is only one, return object zero every time. // If there are only two, alternate with every access. // If there are three or more, randomize but never provide the same object // twice in a row. These are definitely strange rules... please note the following which describes basically all rules where n 1 In your starting state, nothing is picked. You then pick something at random from the set. But, that item is not placed back in the set. The 2nd pick comes from the new set. The original item that was picked is now put back into the set. So part of what's going on is a pick without replacement as well as pick with replacement. Having said that, depending upon your needs, I highly recommend the Mersenne Twister algorithm for your psuedo-random generator. Depending upon speed constraints, you may also want to experiment with a Fisher-Yates shuffle of the array, then grab the 0th element as the next random object. ___ Ricky A. Sharp mailto:rsh...@instantinteractive.com Instant Interactive(tm) http://www.instantinteractive.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: Layer-hosting views and layer-backed scroll views
On Mon, May 24, 2010 at 2:24 PM, Kyle Sluder kyle.slu...@gmail.com wrote: At this point, I don't think there's anything further I can do to work around this bug. Well, Tim Wood gave me the idea to call -_updateLayerGeometryFromView in an override of -viewWillDraw. This does the trick, and avoids the single frame flicker of the layer in the wrong spot. So I think it's as good as I'm going to get for now. I don't know if this workaround works on 10.5, since -viewWillDraw is documented to not be called in many cases of non-traditional drawing. But since we've publicly announced that all new major versions of our apps will be 10.6-only, I really don't care. I do hope someone at Apple takes the time to fix this bug, and I hope my workaround holds up. --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: Deallocation while key value observers still registered
Sean McBride wrote: On Wed, 26 May 2010 03:08:31 +1000, Gideon King said: Glad you've tracked it down. Just a comment though: my understanding is that calling removeObserver from dealloc is, in general, discouraged. See here for some reasoning: http://www.karppinen.fi/analysistool/ I don't believe that's actually true - although it's often stated as fact. There's nothing in any apple documentation I've ever seen which discourages it, if you run under GC it will even do this for you when your objects are cleaned up. There's a long thread on this about a year ago where we were discussing the change in Snow Leopard to move the warning to the end of the dealloc method. The only reason for doing that would be to allow you to remove observers and the wording of the release note is quite persuasive. I do this, quite often, I've never had an issue with it. ___ 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
UITabBar as a UISegmentedControl???
Hi all, Is it possible to use a UITabBar as a UISegmentedControl object? I mean, instead of changing a view when the user selects an item in the uiTabBar, send an event that tells the index of the item that was pressed and therefore execute an action. Then deselect the whole UITabBar. Any suggestions? Thank you all, aa___ 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: -[NSMutableSet randomObject]
On May 25, 2010, at 9:49 AM, Michael A. Crawford wrote: // If the array is empty, throw an exception. The caller should know better. // If there is only one, return object zero every time. // If there are only two, alternate with every access. // If there are three or more, randomize but never provide the same object // twice in a row. I don’t think you can provide this behavior as a category, because it requires extra state: each call has to remember what object was returned by the previous call. That state is per-object so it would need to live in the object. But categories don’t give you extra instance variables*. Even if you could put state into the object, I don’t think it’s a good design — what if you ended up with two clients that wanted to get random access to the same set and interleaved their calls? It sounds like what you want is the iterator (aka enumerator) design pattern, where you create a separate lightweight object that returns the “next” item each time it’s called. You can then put the state in the iterator. —Jens * I know there are ways of doing this; but I still think it’s a bad idea, as the next sentence explains.___ 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: reformat drive to HFS via API
On May 25, 2010, at 12:44 PM, r c wrote: I would like to be able to reformat a flash drive from control application, but it appears that there is no public API that allows this kind access. Am I missing something in the documentation? Or do I do something like call out to diskutil to make it happen? The line between “API” and “tool” can be blurry in the Unix world. I believe you’re right that you need to invoke a tool. (The Disk Utility app works similarly — for example, its Disk First Aid feature just runs ‘fsck’.) This is off-topic for cocoa-dev, btw. Better would be darwin-userlevel. —Jens___ 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: set custom formatter in IB
On May 25, 2010, at 4:14 PM, Rainer Standke wrote: I am trying to associate a custom formatter with a text filed in IB. Having no luck with with either dragging out of 'Classes' or instantiating and then dragging out of the .xib window. Do I have to do this programmatically? You may want to check what outlets are available... Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ 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: Creating a PDFSelection...
António, that's exactly what I needed. But it leads to my next question. The PDFSelection class as far as I can tell basically supports what in Preview.app is the text tool on the toolbar. The selection tool in Preview.app selects an arbitrary rectangle, even if there's no text behind the image. So, is there some way of changing the behavior of the given PDFSelection, or do I have to hand code this (using the Cropped image example code, for instance)? On May 25, 2010, at 11:05 AM, Antonio Nunes wrote: On 25 May 2010, at 18:32, Matthew Weinstein wrote: Thanks for all the help! Onto the next problem... Users need to be able to select sections of a pdfView, and I need to be able to save and analyze the selections (e.g., do they overlap). I also need to be able to restore the selections later. So the question is, can I use PDFSelection to do this. I can't seem to find a way to say create a selection with this NSRect (or part of the string). Is there a way to do this? Is there an alternative? From the PDFPage class reference: - (PDFSelection *)selectionForRect:(NSRect)rect - (PDFSelection *)selectionForRange:(NSRange)range etc. António There is nothing as strong as real gentleness, and there is nothing as gentle as real strength. ___ 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: UITabBar as a UISegmentedControl???
While this may be possible, it doesn't sound like a good idea. The big question it raises is why do you want to do this? As you have of course observed, we already have UISegmentedControls. What are you trying to accomplish? Luke On May 25, 2010, at 6:23 PM, Alejandro Marcos Aragón wrote: Hi all, Is it possible to use a UITabBar as a UISegmentedControl object? I mean, instead of changing a view when the user selects an item in the uiTabBar, send an event that tells the index of the item that was pressed and therefore execute an action. Then deselect the whole UITabBar. Any suggestions? Thank you all, aa___ 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/luketheh%40apple.com This email sent to luket...@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: IKImageView Question
On May 24, 2010, at 5:53 PM, Brian Postow wrote: Yeah, If you look further down in the documentation, you'll see that there IS no setImage: NSImage. I've been through this with Apple. Officially, this is a bug IN THE DOCUMENTATION. Any setImage: NSImage method that exists is undocumented and may be taken away. Doc has been corrected. Not sure when it’ll be pushed out. Not sure how this was missed during review, but it was. You could add your solution to the class as a category allowing you to set an image, but using your conversion code.___ 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: Creating a PDFSelection...
On 26 May 2010, at 03:01, Matthew Weinstein wrote: The PDFSelection class as far as I can tell basically supports what in Preview.app is the text tool on the toolbar. The selection tool in Preview.app selects an arbitrary rectangle, even if there's no text behind the image. So, is there some way of changing the behavior of the given PDFSelection, or do I have to hand code this (using the Cropped image example code, for instance)? The selection tool in Preview just creates a snapshot of the selection. A TIFF image. This has nothing to do with PDFSelection. PDFSelections deal only with text, so I think they are not rich enough for your purposes. I guess you may have to delve deeper; parsing the page streams (you can use Quartz for that), and rolling your own selections. Not a quick and easy task. António --- And you would accept the seasons of your heart, even as you have always accepted the seasons that pass over your field. --Kahlil Gibran --- ___ 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: IKImageView Question
Another solution for conversion is using -CGImage on NSBitmapImageRep. On May 24, 2010, at 5:53 PM, Brian Postow wrote: On May 24, 2010, at 5:36 PM, jyoun...@kc.rr.com jyoun...@kc.rr.com wrote: I've been trying a few tests with IKImageView to view an EPS file with zooming capabilities. Some code that Apple provides works well... however I'm getting a warning - warning: 'IKImageView' may not respond to '-setImage:'. Instead of using the NSURL (which doesn't seem to work with EPS images in my tests), I'm using NSImage. The IKImageView documentation states: --- You can provide an images for the view in any of these formats: File reference (NSURL, CFURLRef, or a path) CGImageSourceRef Data (NSData or CFDataRef) Image (NSImage, CGImageRef, or CIImage) --- Just curious why I'm getting this warning since I'm using a NSImage? My next thought was to convert the NSImage to a CGImageRef, but that looks pretty in-depth. I thought if I converted it, maybe I could use: Yeah, If you look further down in the documentation, you'll see that there IS no setImage: NSImage. I've been through this with Apple. Officially, this is a bug IN THE DOCUMENTATION. Any setImage: NSImage method that exists is undocumented and may be taken away. I use this: CGImageRef nsImageToCGImage(NSImage* image) { NSData * imgData = [image TIFFRepresentation]; CGImageRef imgRef = 0; if(imgData) { CGImageSourceRef imageSource = CGImageSourceCreateWithData((CFDataRef)imgData, NULL); imgRef = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL); } return imgRef; } Brian Postow Senior Software Engineer Acordex Imaging Systems ___ 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/scott%40cocoadoc.com This email sent to sc...@cocoadoc.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: reformat drive to HFS via API
The DiskManagement.framework is a private framework. Short of creating your own API using low-level disk access, diskutil may be your best bet. I would like to be able to reformat a flash drive from control application, but it appears that there is no public API that allows this kind access. Am I missing something in the documentation? Or do I do something like call out to diskutil to make it happen? ___ 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: Creating a PDFSelection...
Actually, I don't need the tiff; I just need the rectangle! People have to be able to sketch the rectangle over the pdf, and then my program stores and restores those rectangles (with some additional information). On May 25, 2010, at 9:15 PM, Antonio Nunes wrote: On 26 May 2010, at 03:01, Matthew Weinstein wrote: The PDFSelection class as far as I can tell basically supports what in Preview.app is the text tool on the toolbar. The selection tool in Preview.app selects an arbitrary rectangle, even if there's no text behind the image. So, is there some way of changing the behavior of the given PDFSelection, or do I have to hand code this (using the Cropped image example code, for instance)? The selection tool in Preview just creates a snapshot of the selection. A TIFF image. This has nothing to do with PDFSelection. PDFSelections deal only with text, so I think they are not rich enough for your purposes. I guess you may have to delve deeper; parsing the page streams (you can use Quartz for that), and rolling your own selections. Not a quick and easy task. António --- And you would accept the seasons of your heart, even as you have always accepted the seasons that pass over your field. --Kahlil Gibran --- ___ 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
iPad animations are backwards for some orintations.
So i have an app that I want to use the curl up UIView animation transition in. however when the iPad his held in either the upside down portrait or upside down landscape (button on right) the transitions are backwards. All controls on the views move however. ___ 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