Re: Using a string as filepath
Am 27.11.2008 um 01:22 schrieb Kiel Gillard: Can you use NSSavePanel? It handles all that detail for you. Unfortunately not. Alternatively, try using NSString's stringByAppendingPathComponent: method, it may validate the path component you're trying to add. Tried that, but stringByAppendingPathComponent: does not appear to validate the added path. Thanks, Knut ___ 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 [EMAIL PROTECTED]
Re: Using a string as filepath
Am 27.11.2008 um 06:11 schrieb Michael Ash: There really isn't, because it's a pretty hard problem. Mike, thanks for your detailed reply. My case (one or two files a week or so) does not justify more than a few lines of code and string length is not a problem either. I think I'll simply try replacing all illegal characters with an underscore and let the user edit the filename in Finder if something looks wrong. Thanks, Knut ___ 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 [EMAIL PROTECTED]
Re: NSTrackingArea strange requirement
On Nov 26, 2008, at 7:02 PM, Quincey Morris wrote: On Nov 26, 2008, at 06:30, rajesh wrote: I have Custom NSView with set of boxes arranged in some pattern ( boxes with some extra UI elements like , text fields and stuff). I am using the gaps between the boxes a.k.a the visible custom NSView to add the NStrackingAreas for cursor updates and as well for resizing the subviews (i.e the NSBox) As an obvious fact , when ever I try to resize the subviews I need to as well set the frame for the NSTrackingArea elements and here I is no such thing as setFrame I googled around and found that , everybody is alloc-init ' ng and then set the tracking area to 'nil' or release and create a new NSTrackingArea then – initWithRect:options:owner:userInfo: and use it. I don't have fixed number of subviews or as a fact no fixed gaps , hence the tracking areas count might shoot up to anything. I think following the general approach will have a serious affect on efficiency , memory and other factors . I can't use SplitView to manage the resizing of subviews ( I iterate, no fixed subview , and I need to collapse or expand a particular subview ) Assuming you have a custom NSView and the NSBox views are its subviews, you can set *one* tracking area on the custom view, and one tracking area on each of the subviews. (Use the NSTrackingInVisibleRect option on all the tracking areas, if you can. Then you don't even have to update the tracking areas yourself when the views change size or position.) I should have made my query bit clear , I need the cursor updates only for certain portion of the visible area ( only horizontal gaps , its like horizontal split view but no split view in use ) . but I can use the above technique for something else I am working on , thanks :) I think I am still hanging with same problem It's not a problem that the tracking areas of the subviews overlap the tracking area of the parent custom view. For cursor updates, a tracking area doesn't send the cursorUpdate event to its owner, or even to its view. Instead, it sends the event to the view under the mouse (that is, the view that would respond to hitTest: at the current mouse location). So, only one view gets the event, and it's the right view -- if the mouse just entered a NSBox, the subview would get it; if the mouse just exited the NSBox, the parent view would get it. If you need different cursors depending on which gap the mouse is in (e.g. sometimes a horizontal-resize cursor, sometimes a vertical- resize cursor), I'd suggest doing it by having your cursorUpdate: method work out which gap the mouse location is in, and not try to use multiple tracking areas. ___ 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/rajesh%40vangennep.nl This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Private frameworks in a bundle
I've had a need, for the first time, to have a private framework in a bundle that gets loaded into an app. Now, I've done a bit of framework wrangling in the past, and thought it might involve getting the installation path in the framework build/ packaging right in order to do this. When the usual @executable_path/../Frameworks didn't work (presumably because I'm in a bundle now, loaded from a location elsewhere in the files system than the app bundle), I read about @loader_path and assumed that an installation path of @loader_path/../Frameworks would do the job here. Indeed this causes the bundle to load properly, whereas before I was getting an error about finding the framework's executable image. However, when I first make a call to a framework things crash and burn. So, it _looks_ like the private framework is found at bundle load time, but the dynamic linking is broken (silently) until I make a call. For now, I have rebuilt the framework with a fixed installation path (/ Library/Frameworks) with no other changes, and things works just fine. This looks awfully like I'm not educated enough on the subject of installation paths in some more exotic situations (if you can call being in a bundle 'exotic'). The dyld 10.5 rel notes talk, ever so briefly, about @loader_path and a thing called @rpath, implying that these are used together. So I may be missing half of the equation to getting this working. Can anyone enlighten me? Cheers Luke ___ 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 [EMAIL PROTECTED]
Re: NSTextView
Le 27 nov. 08 à 11:34, Graham Cox a écrit : On 27 Nov 2008, at 9:27 pm, Mahaboob wrote: Hi all, I need to check whether the NSTextView contains any data. For an NSTextField, [[txtName stringValue] length] should work. Is there any method like this for a textView? [[[myTextView textStorage] string] length]; NSAttributedString (a parent of NSTextStorage) has a -length method. [[myTextView textStorage] length] --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/devlists%40shadowlab.org This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: set position of Alert panel
On 27/11/2008, at 8:48 PM, Nishad Kumar wrote: Hi all,how can i set the position of alert panel at centre of window rather than centre of screen.With thanks,Nishad You probably don't want to do that. If you have a window-specific alert, you should use a sheet: http://developer.apple.com/documentation/Cocoa/Conceptual/Sheets/Tasks/UsingAlertSheets.html -- Rob Keniger ___ 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 [EMAIL PROTECTED]
Re: NSTrackingArea strange requirement
On 27/11/2008, at 7:17 PM, rajesh wrote: I should have made my query bit clear , I need the cursor updates only for certain portion of the visible area ( only horizontal gaps , its like horizontal split view but no split view in use ) . but I can use the above technique for something else I am working on , thanks :) I think I am still hanging with same problem... In the -updateTrackingAreas method of NSView, you must remove the existing tracking areas using -removeTrackingArea:, create new ones in the correct positions and then add them using -addTrackingArea:. -- Rob Keniger ___ 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 [EMAIL PROTECTED]
Re: how to set up nextKeyView, full keyboard access etc, for custom subviews set up in code (rather than nib)
On Nov 26, 2008, at 9:47 PM, Rua Haszard Morris wrote: I have a dialog that has a few controls as well as a complex custom view that itself contains other controls as subviews. The custom view (for various good reasons) is instantiated and added as a subview in code. A template view and NSView's replaceSubview:with is used so the positioning etc can be set in the nib. To fully support keyboard access, I need to somehow set things up so that the user can tab from the nib-instantiated controls to the controls within the custom view and then back out again. How can I achieve this? I'll also (presumably) need to set up the nextKeyView-chain for the controls within the custom view (composed of a hierarchy of subviews with their own subcontrols...), but I think I have an idea of how to do this. While I don't manually set up any UI as you're doing, I found that in some cases, I still needed to programatically rewire the key loop. This was especially so for complex screens involving nested tabless tab views. To manually rewire controls, look into the setNextKeyView: API. If you then have tab views, you may need to provide an implementation of tabView:didSelectTabViewitem: and rewire controls based upon the new selected tab. Also inside of tabView:didSelectTabViewItem:, I had to sometimes reset the window's firstResponder. But, make sure to first ask the view if it can be the first responder using canBecomeKeyView. ___ Ricky A. Sharp mailto:[EMAIL PROTECTED] 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 [EMAIL PROTECTED]
Re: Memory management puzzle
Am 27.11.2008 um 03:49 schrieb DKJ: I've got something this in my code, which is run several times by the app: UIView *subView = [[MyView alloc] initWithFrame:frame]; [theView addSubview:subView]; [subView release]; Later on this happens: [subView removeFromSuperView]; subView = nil; These two code snippets are in different controller methods. I'm certain they're called the same number of times. The docs say that subView gets a release message when removeFromSuperview is called. But the NSLog statement I put in the dealloc method for MyView is never called. The ObjectAlloc instrument shows the count of MyView instances increasing by 1 each time the code is run. And the Leaks instrument shows no leaks at all. Enable refcount tracking (Record reference counts option for the ObjectAlloc instrument) and see who retains and releases your MyView instance. This will get you a nice stacktrace for each call to retain, release or dealloc... There might be other objects holding on to the view. HTH, /jum ___ 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 [EMAIL PROTECTED]
NSTextView
Hi all, I need to check whether the NSTextView contains any data. For an NSTextField, [[txtName stringValue] length] should work. Is there any method like this for a textView? Thanks in advance mahaboob ___ 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 [EMAIL PROTECTED]
Re: Scheme for efficiently archiving images.
Am 27.11.2008 um 07:54 schrieb Graham Cox: On 27 Nov 2008, at 2:00 pm, Ken Thomases wrote: First, it seems to me like you don't want an NSImage in your model. You want the original source of the image. Either a file path or a blob of data with some meta-data (e.g. UTI) describing it and what it is. You'd use NSImage as a view-enabling technology. Yep, this is precisely how I'm coming to see it. One kink is that I need to keep old-format stuff working, which isn't too hard, but it means I need to be a little careful about how I eliminate NSImage from the archived model. One minor difficulty is that for old-format files, all I get is an archived NSImage, with no original data. That means that it's probably going to be impossible to convert those files to a more efficient approach. Well, you _can_ ask the NSImage or it's rep for a certain bitmap representation (see e.g. http://markmail.org/message/ urbmcjwh5vixoxfd). Even if the NSImage can't provide that data, you could still use the BSD layer to convert to e.g. a JPEG: man sips HTH, /jum ___ 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 [EMAIL PROTECTED]
Re: Private frameworks in a bundle
Le 27 nov. 08 à 10:35, Luke Evans a écrit : I've had a need, for the first time, to have a private framework in a bundle that gets loaded into an app. Now, I've done a bit of framework wrangling in the past, and thought it might involve getting the installation path in the framework build/packaging right in order to do this. When the usual @executable_path/../Frameworks didn't work (presumably because I'm in a bundle now, loaded from a location elsewhere in the files system than the app bundle), I read about @loader_path and assumed that an installation path of @loader_path/../Frameworks would do the job here. Indeed this causes the bundle to load properly, whereas before I was getting an error about finding the framework's executable image. However, when I first make a call to a framework things crash and burn. Could you detail a little more crash and burn ? (crash log, message, anything usefull…) ___ 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 [EMAIL PROTECTED]
Can I split an implementation file?
One of my implementation files is getting kind of long and I would like to split it into two. I have a lot of custom getters and setters and I was wondering if there was a way I could put them in a separate file but keep a common interface file? Can I do that? What is the syntax for doing this? Thanks Greg ___ 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 [EMAIL PROTECTED]
Re: Killing a Thread
Thanks for your valuable comments. The thread is not exit and now it working for another threads. I used one progress window to display the delivery progress of the mail. When I'm calling the thread for second time, the animation speed of progress bar get increased. And also some times I'm getting the error like: objc[2568]: FREED(id): message sendMessage sent to freed object=0x5eba400 Thanks Mahaboob On 11/26/08 10:50 PM, Scott Ribe [EMAIL PROTECTED] wrote: It occurs to me that maybe you do not know about or understand the use of the pause button in the debugger. Get your application to the state where it's hung up. Then hit the pause button in the debugger. Then use the thread popup to examine the stack of each thread. Once you know where each thread is locked up, you should have a much better chance of figuring out the problem. Note that there may be threads you don't expect--this is normal as the frameworks sometimes create their own threads for their own background processing. You should at first ignore threads not running any of your 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 [EMAIL PROTECTED]
set position of Alert panel
Hi all,how can i set the position of alert panel at centre of window rather than centre of screen.With thanks,Nishad _ Register once and play all contests. Increase your scores with bonus credits for logging in daily on MSN. http://specials.msn.co.in/msncontest/index.aspx___ 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 [EMAIL PROTECTED]
Re: NSTextView
[[textView string]length]; Thats because NSTextView inherits from NSText which has string method. On 27-Nov-08, at 3:57 PM, Mahaboob wrote: Hi all, I need to check whether the NSTextView contains any data. For an NSTextField, [[txtName stringValue] length] should work. Is there any method like this for a textView? Thanks in advance mahaboob ___ 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/chaitanya%40expersis.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: NSTextView
On 27 Nov 2008, at 9:27 pm, Mahaboob wrote: Hi all, I need to check whether the NSTextView contains any data. For an NSTextField, [[txtName stringValue] length] should work. Is there any method like this for a textView? [[[myTextView textStorage] string] length]; --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 [EMAIL PROTECTED]
Re: set position of Alert panel
If you ask the same question again you will get the same answer again: Use a sheet! atze Am 27.11.2008 um 11:48 schrieb Nishad Kumar: Hi all,how can i set the position of alert panel at centre of window rather than centre of screen.With thanks,Nishad ___ 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 [EMAIL PROTECTED]
Re: NSTrackingArea strange requirement
That seems to be the only solution for my case I started with the same and was wondering if I was doing some redundant work. but I see a kind of problem with above approach as well. Since we are updating the TrackingAreas in updateTrackingAreas (removing and adding track areas) , my cursor (which is set to resizeUpDownCursor mouseEntered: ) seems to flicker when ever try updating/resizing my view due to the fact that trackAreas are changed every time. ~Rajesh On Nov 27, 2008, at 12:44 PM, Rob Keniger wrote: On 27/11/2008, at 7:17 PM, rajesh wrote: I should have made my query bit clear , I need the cursor updates only for certain portion of the visible area ( only horizontal gaps , its like horizontal split view but no split view in use ) . but I can use the above technique for something else I am working on , thanks :) I think I am still hanging with same problem... In the -updateTrackingAreas method of NSView, you must remove the existing tracking areas using -removeTrackingArea:, create new ones in the correct positions and then add them using -addTrackingArea:. -- Rob Keniger ___ 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/rajesh%40vangennep.nl This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Can I split an implementation file?
Yes, something like this should do you In file MyObj.h @interface MyObj : NSObject{ Foo* _foo; } -(Foo) foo; -(void) setFoo:(Foo)aFoo; -(void) solveWorldFinancialCrisis; @end; In file MyObj+GetSetters.m: #import MyObj.h @implementation MyObj (GetSetters) -(Foo) foo {} -(void) setFoo:(Foo)aFoo {} @end In file MyObj.m: #import MyObj.h @implementation MyObj -(void) solveWorldFinancialCrisis { // Good luck with this one :) } @end Matt On 27 Nov 2008, at 14:30, Greg Robertson wrote: One of my implementation files is getting kind of long and I would like to split it into two. I have a lot of custom getters and setters and I was wondering if there was a way I could put them in a separate file but keep a common interface file? Can I do that? What is the syntax for doing this? Thanks Greg ___ ___ 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 [EMAIL PROTECTED]
Re: Can I split an implementation file?
You can learn more about category in the Obj-C language guide: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_6_section_3.html Le 27 nov. 08 à 15:04, Matt Gough a écrit : Yes, something like this should do you In file MyObj.h @interface MyObj : NSObject{ Foo* _foo; } -(Foo) foo; -(void) setFoo:(Foo)aFoo; -(void) solveWorldFinancialCrisis; @end; In file MyObj+GetSetters.m: #import MyObj.h @implementation MyObj (GetSetters) -(Foo) foo {} -(void) setFoo:(Foo)aFoo {} @end In file MyObj.m: #import MyObj.h @implementation MyObj -(void) solveWorldFinancialCrisis { // Good luck with this one :) } @end Matt On 27 Nov 2008, at 14:30, Greg Robertson wrote: One of my implementation files is getting kind of long and I would like to split it into two. I have a lot of custom getters and setters and I was wondering if there was a way I could put them in a separate file but keep a common interface file? Can I do that? What is the syntax for doing this? Thanks Greg ___ ___ 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/devlists%40shadowlab.org This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
[MEET] Aachen CocoaHeads TODAY (November 27, 2008)
Hi everyone, Aachen CocoaHeads is today (November 27, 2008) at 7PM. Talks: (1) Amin Negm-Awad, Dispatching in Objective-C, (2) Stefan Hafeneger, Distributed Objects Please visit http://www.cocoaheads.de/ for location information. See you there! Stefan 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 [EMAIL PROTECTED]
Re: Core Data modeling question
Am 26.11.2008 um 22:08 schrieb Markus Schneider: Shall I use a MO class DAY and model the list as a to-many relationship? TASK - startDate - endDate - exceptions - DAY - date Is this really necessary or is there a more elegant way? This IS the elegant way. If you need an array use an own table for the destination and connect it 1-n. atze ___ 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 [EMAIL PROTECTED]
What is the best way to get an NSSlider to respond to the mouse scroll wheel?
I assume I can sub-class the control but I wondering if there is a better way. I'm using a circular slider and would like it to rotate when I roll the scroll wheel up or down. -Michael -- There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. -- C.A.R. Hoare 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 [EMAIL PROTECTED]
Re: Killing a Thread
When I'm calling the thread for second time, the animation speed of progress bar get increased. It seems pretty clear that your function never terminates. As we all have been telling you, if the function returns the thread will exit. You need to examine things in the debugger and determine what the function is doing and why it does not end. -- Scott Ribe [EMAIL PROTECTED] http://www.killerbytes.com/ (303) 722-0567 voice ___ 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 [EMAIL PROTECTED]
Re: Can I split an implementation file?
On Thu, Nov 27, 2008 at 8:30 AM, Greg Robertson [EMAIL PROTECTED] wrote: One of my implementation files is getting kind of long and I would like to split it into two. I have a lot of custom getters and setters and I was wondering if there was a way I could put them in a separate file but keep a common interface file? Can I do that? What is the syntax for doing this? Others have answered the direct question, I thought I would wander off into the realm of potentially unwanted advice. If your class is getting this large, then it may be a sign that your design is becoming unwieldy and you should actually be splitting it into multiple classes. Personally I try to keep my classes under 2000 lines whenever possible, and under 1000 if I can. When I can't avoid them getting larger, then I try to see if I can split them up nicely. Often when they become that large, it's because they're doing 2-3 distinct tasks, and each of those distinct tasks can generally be split into a separate class. Anyway, just a thought on design, obviously you don't have to listen. :-) Mike ___ 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 [EMAIL PROTECTED]
Re: Can I split an implementation file?
If I declare foo and setFoo as properties instead of methods in the interface would that be the same for the example you posted? Thanks Greg On Thu, Nov 27, 2008 at 9:04 AM, Matt Gough [EMAIL PROTECTED] wrote: Yes, something like this should do you In file MyObj.h @interface MyObj : NSObject{ Foo* _foo; } -(Foo) foo; -(void) setFoo:(Foo)aFoo; -(void) solveWorldFinancialCrisis; @end; In file MyObj+GetSetters.m: #import MyObj.h @implementation MyObj (GetSetters) -(Foo) foo {} -(void) setFoo:(Foo)aFoo {} @end In file MyObj.m: #import MyObj.h @implementation MyObj -(void) solveWorldFinancialCrisis { // Good luck with this one :) } @end Matt On 27 Nov 2008, at 14:30, Greg Robertson wrote: One of my implementation files is getting kind of long and I would like to split it into two. I have a lot of custom getters and setters and I was wondering if there was a way I could put them in a separate file but keep a common interface file? Can I do that? What is the syntax for doing this? Thanks Greg ___ ___ 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 [EMAIL PROTECTED]
Re: What is the best way to get an NSSlider to respond to the mouse scroll wheel?
On 28 Nov 2008, at 3:18 am, Michael A. Crawford wrote: I assume I can sub-class the control but I wondering if there is a better way. I'm using a circular slider and would like it to rotate when I roll the scroll wheel up or down. You can just implement the -scrollWheel: method in a category. For example: @implementation NSSlider (Scrollwheel) - (void)scrollWheel:(NSEvent*) event { [self setFloatValue:[self floatValue] + [event deltaY]]; [self sendAction:[self action] to:[self target]]; } @end hth, 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 [EMAIL PROTECTED]
Re: Can I split an implementation file?
Thanks for the link, one last question (I hope) if I declare foo as a property and synthesize then I could use a category to override the foo and setFoo. But I was wondering if I could just skip the synthesize? Thanks Greg On Thu, Nov 27, 2008 at 9:07 AM, Jean-Daniel Dupas [EMAIL PROTECTED] wrote: You can learn more about category in the Obj-C language guide: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_6_section_3.html Le 27 nov. 08 à 15:04, Matt Gough a écrit : Yes, something like this should do you In file MyObj.h @interface MyObj : NSObject{ Foo* _foo; } -(Foo) foo; -(void) setFoo:(Foo)aFoo; -(void) solveWorldFinancialCrisis; @end; In file MyObj+GetSetters.m: #import MyObj.h @implementation MyObj (GetSetters) -(Foo) foo {} -(void) setFoo:(Foo)aFoo {} @end In file MyObj.m: #import MyObj.h @implementation MyObj -(void) solveWorldFinancialCrisis { // Good luck with this one :) } @end Matt On 27 Nov 2008, at 14:30, Greg Robertson wrote: One of my implementation files is getting kind of long and I would like to split it into two. I have a lot of custom getters and setters and I was wondering if there was a way I could put them in a separate file but keep a common interface file? Can I do that? What is the syntax for doing this? Thanks Greg ___ ___ 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/devlists%40shadowlab.org This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Can I split an implementation file?
On Nov 27, 2008, at 09:09, Greg Robertson wrote: Thanks for the link, one last question (I hope) if I declare foo as a property and synthesize then I could use a category to override the foo and setFoo. But I was wondering if I could just skip the synthesize? Matt's suggestion is going to produce a compiler warning in MyObj.m (foo and setFoo: are declared but not defined in the class). It sounds like you tried to eliminate the warning by putting a @synthesize in MyObj.m, which happens to solve the compiler warning but kind of obscurifies the whole thing. Try this instead: @interface MyObj : NSObject{ Foo* _foo; } -(void) solveWorldFinancialCrisis; @end @interface MyObj (GetSetters) -(Foo) foo; -(void) setFoo:(Foo)aFoo; @end or declare the category like this if you prefer: @interface MyObj (GetSetters) @property Foo foo; @end Le 27 nov. 08 à 15:04, Matt Gough a écrit : Yes, something like this should do you In file MyObj.h @interface MyObj : NSObject{ Foo* _foo; } -(Foo) foo; -(void) setFoo:(Foo)aFoo; -(void) solveWorldFinancialCrisis; @end; In file MyObj+GetSetters.m: #import MyObj.h @implementation MyObj (GetSetters) -(Foo) foo {} -(void) setFoo:(Foo)aFoo {} @end In file MyObj.m: #import MyObj.h @implementation MyObj -(void) solveWorldFinancialCrisis { // Good luck with this one :) } @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/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Can I split an implementation file?
On Nov 27, 2008, at 9:09 AM, Greg Robertson wrote: Thanks for the link, one last question (I hope) if I declare foo as a property and synthesize then I could use a category to override the foo and setFoo. But I was wondering if I could just skip the synthesize? If your intent is to provide custom implementations of the accessors, then use @dynamic in the main implementation block. mmalc MyClass.h - @interface MyClass : NSObject { NSString *title; } @property (nonatomic, copy) NSString *title; @end MyClass.m - #import MyClass.h @implementation MyClass @dynamic title; - (void)dealloc { [title release]; [super dealloc]; } @end MyClass+Title.m --- #import MyClass.h @implementation MyClass (Title) - (NSString *)title { NSLog(@Someone asked for my title); return title; } - (void)setTitle:(NSString *)newTitle { if (newTitle != title) { [title release]; title = [[newTitle uppercaseString] retain]; } } @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/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
cString
Hi All.Recently I've installed the new Xcode 3.1.2 and I've removed my old Xcode 2.5.I've compiled with Xcode 3.1.2 (using the optional compiler GCC 4.2) one of the my Objective-C++ project. No problem, but I've got a warning about the code line: string elem = [[[gridArrayObjc objectAtIndex:i] stringValue] cString];The warning is: Warning: 'cString' is deprecated [...]. Well, in which way can I modify my code line in order to eliminate the deprecated cString?Thanks in advance for any answer.Luca.www.mitosrl.com _ Win £1000 John Lewis shopping sprees with BigSnapSearch.com http://clk.atdmt.com/UKM/go/117442309/direct/01/___ 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 [EMAIL PROTECTED]
Re: cString
On Thu, Nov 27, 2008 at 20:48, Luca Ciciriello [EMAIL PROTECTED] wrote: Hi All.Recently I've installed the new Xcode 3.1.2 and I've removed my old Xcode 2.5.I've compiled with Xcode 3.1.2 (using the optional compiler GCC 4.2) one of the my Objective-C++ project. No problem, but I've got a warning about the code line: string elem = [[[gridArrayObjc objectAtIndex:i] stringValue] cString];The warning is: Warning: 'cString' is deprecated [...]. Well, in which way can I modify my code line in order to eliminate the deprecated cString? Hi Luca, Have you noticed that you can hold down the ALT modifier key and double click on a method name to bring up the relevant documentation for that method? If you do that on cString, you'll see something like this: Returns a representation of the receiver as a C string in the default C-string encoding. (Deprecated in Mac OS X v10.4. Use cStringUsingEncoding: or UTF8String instead.) Regards Mattias ___ 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 [EMAIL PROTECTED]
RE: cString
Thanks Mattias, UTF8String has solved my problem.Bye.Luca Date: Thu, 27 Nov 2008 20:54:11 +0100 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: cString CC: cocoa-dev@lists.apple.com On Thu, Nov 27, 2008 at 20:48, Luca Ciciriello [EMAIL PROTECTED] wrote: Hi All.Recently I've installed the new Xcode 3.1.2 and I've removed my old Xcode 2.5.I've compiled with Xcode 3.1.2 (using the optional compiler GCC 4.2) one of the my Objective-C++ project. No problem, but I've got a warning about the code line: string elem = [[[gridArrayObjc objectAtIndex:i] stringValue] cString];The warning is: Warning: 'cString' is deprecated [...]. Well, in which way can I modify my code line in order to eliminate the deprecated cString? Hi Luca, Have you noticed that you can hold down the ALT modifier key and double click on a method name to bring up the relevant documentation for that method? If you do that on cString, you'll see something like this: Returns a representation of the receiver as a C string in the default C-string encoding. (Deprecated in Mac OS X v10.4. Use cStringUsingEncoding: or UTF8String instead.) Regards Mattias _ See the most popular videos on the web http://clk.atdmt.com/GBL/go/115454061/direct/01/___ 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 [EMAIL PROTECTED]
Re: cString
Depending on you neeeds you can use cStringUsingEncoding: or if you are ok using UTF8 encoded strings -UTF8String. The NSString documentation clearly states this. Scott On Nov 27, 2008, at 11:48 AM, Luca Ciciriello wrote: Hi All.Recently I've installed the new Xcode 3.1.2 and I've removed my old Xcode 2.5.I've compiled with Xcode 3.1.2 (using the optional compiler GCC 4.2) one of the my Objective-C++ project. No problem, but I've got a warning about the code line: string elem = [[[gridArrayObjc objectAtIndex:i] stringValue] cString];The warning is: Warning: 'cString' is deprecated [...]. Well, in which way can I modify my code line in order to eliminate the deprecated cString? Thanks in advance for any answer.Luca.www.mitosrl.com _ Win £1000 John Lewis shopping sprees with BigSnapSearch.com http://clk.atdmt.com/UKM/go/117442309/direct/01/___ 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/scottandrew%40roadrunner.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
registerDefaults error and NSCoding protocol
Hi, Question about registering defaults - I'd assumed the following would be valid, assuming that GuideSettings implements the NSCoding protocol - but my app doesn't like this and throws a bad access exception in CFRetain when I run this code: The bit that falls over is the registerDefaults: call - the stack track being: #0 0x96fc52d4 in CFRetain #1 0x96f94a54 in CFDictionarySetValue #2 0x97029dd3 in -[CFXPreferencesSource setValue:forKey:] #3 0x9702acce in __CFXPreferencesSetValuesInSource #4 0x9702e30d in _CFXPreferencesRegisterDefaultValues #5 0x92b90a98 in -[NSUserDefaults(NSUserDefaults) registerDefaults:] #6 0x000ae543 in -[DataModelDefaults init] at DataModelDefaults.m:90 - (id) init { self = [super init]; _defs = [NSUserDefaults standardUserDefaults]; NSArray* defaultGuides = [DataModelDefaults defaultGuideSettings]; NSDictionary* defs = [NSDictionary dictionaryWithObjectsAndKeys: defaultGuides, kGuideSettings, [NSNumber numberWithFloat:2], kEffectDefaultsDurationSeconds, 0]; // this goes BOM [_defs registerDefaults:defs]; return self; } + (NSArray *) defaultGuideSettings { // simply return a list of the guide objects we want to have as defaults NSMutableArray* array = [[NSMutableArray new] autorelease]; [array addObject:[GuideSetting guideSettingNamed:@Standard width: 640 height:480]]; [array addObject:[GuideSetting guideSettingNamed:@Standard width: 800 height:600]]; [array addObject:[GuideSetting guideSettingNamed:@YouTube width:848 height:480]]; return array; } Am I forgetting something? I thought as long as my object could encode/ decode itself, all would be OK - anyone know what I'm doing wrong? Thanks -- John Clayton Skype: johncclayton ___ 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 [EMAIL PROTECTED]
Re: registerDefaults error and NSCoding protocol
From the documentation: ... A default’s value must be a property list, that is, an instance of (or for collections a combination of instances of): NSData,NSString, NSNumber, NSDate, NSArray, or NSDictionary. If you want to store any other type of object, you should typically archive it to create an instance of NSData. For more details, see User Defaults Programming Topics for Cocoa. ... So, no, ensuring that a class conforms to NSCoding will not make instances of said class compatible with NSUserDefaults. b.bum ___ 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 [EMAIL PROTECTED]
Garbage collection leak in simple Core Data application
Hi Cocoa developers, I created a simple garbage collected Core Data application using the Xcode template. I did not change much except that I added an empty window controller for my window, which is the file's owner of my .xib. I added logs in the init and finalize methods to make sure that each object created was eventually finalized. However, I realized that even if the document is always finalized when I close the window, its window controller is not. Let's say I open a new document and close it right away and repeat the operation a few dozen times, I end up with all documents collected, but a few window controller still to be collected. Even if I force the collector, they are not collected. Even stranger, if I delete my only entity from my .xcdatamodel (which does nothing), then everything gets collected as it should. How can a entity prevent an object from being collected? Am I missing something obvious here? Or should I consider it a garbage collection bug? I made a copy of my project available if someone would like to take a look at it. It is quite simple. http://www.rogue-research.com/vtk/GC_Test.zip Thanks a lot! Mathieu ___ Mathieu Coursolle Rogue Research Inc. ___ 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 [EMAIL PROTECTED]
Re: Garbage collection leak in simple Core Data application
On 28/11/2008, at 7:13 AM, Mathieu Coursolle wrote: Hi Cocoa developers, I created a simple garbage collected Core Data application using the Xcode template. I did not change much except that I added an empty window controller for my window, which is the file's owner of my .xib. I added logs in the init and finalize methods to make sure that each object created was eventually finalized. However, I realized that even if the document is always finalized when I close the window, its window controller is not. Let's say I open a new document and close it right away and repeat the operation a few dozen times, I end up with all documents collected, but a few window controller still to be collected. Even if I force the collector, they are not collected. Even stranger, if I delete my only entity from my .xcdatamodel (which does nothing), then everything gets collected as it should. How can a entity prevent an object from being collected? You are adding the NSWindowController to your document using - addWindowController:, which retains the window controller. You must then release the window controller using -removeWindowController: so that the collector frees the object. Do this in MyDocument.h: #import Cocoa/Cocoa.h @class MyWindowController; @interface MyDocument : NSPersistentDocument { MyWindowController* newWindowController; } @end and change these methods in MyDocument.m: - (void)makeWindowControllers { // Create the project window controller and keep a reference to it. newWindowController = [[MyWindowController alloc] init]; [newWindowController setShouldCloseDocument:YES]; // Add it to the list of window controllers for this document. [self addWindowController:newWindowController]; } - (void)finalize { [self removeWindowController:newWindowController]; NSLog(@Document finalized); UpdateDocumentCount(0); [super finalize]; } -- Rob Keniger ___ 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 [EMAIL PROTECTED]
Re: Garbage collection leak in simple Core Data application
On Nov 28, 2008, at 8:42 AM, Rob Keniger wrote: You are adding the NSWindowController to your document using - addWindowController:, which retains the window controller. You must then release the window controller using -removeWindowController: so that the collector frees the object. Do this in MyDocument.h: #import Cocoa/Cocoa.h @class MyWindowController; @interface MyDocument : NSPersistentDocument { MyWindowController* newWindowController; } @end and change these methods in MyDocument.m: - (void)makeWindowControllers { // Create the project window controller and keep a reference to it. newWindowController = [[MyWindowController alloc] init]; [newWindowController setShouldCloseDocument:YES]; // Add it to the list of window controllers for this document. [self addWindowController:newWindowController]; } - (void)finalize { [self removeWindowController:newWindowController]; NSLog(@Document finalized); UpdateDocumentCount(0); [super finalize]; } That shouldn't be necessary unless the document is also sticking around. The collector handles disconnected cyclic sub graphs just fine; there is no such thing as a retain cycle under GC. What is rooting the window controller? I.e. if you can grab the address of the window controller, then break in gdb and 'info gc-roots address'. It should tell you why the window controller hasn't been reaped. Or you can use the Object Graph instrument in the Instruments application. b.bum ___ 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 [EMAIL PROTECTED]
Re: What is the best way to get an NSSlider to respond to the mouse scroll wheel?
On Thu, Nov 27, 2008 at 12:08 PM, Graham Cox [EMAIL PROTECTED] wrote: On 28 Nov 2008, at 3:18 am, Michael A. Crawford wrote: I assume I can sub-class the control but I wondering if there is a better way. I'm using a circular slider and would like it to rotate when I roll the scroll wheel up or down. You can just implement the -scrollWheel: method in a category. For example: @implementation NSSlider (Scrollwheel) - (void)scrollWheel:(NSEvent*) event { [self setFloatValue:[self floatValue] + [event deltaY]]; [self sendAction:[self action] to:[self target]]; } @end Please don't do this! It will apply to every single slider in your process, even ones you didn't create yourself, and if at some point Apple adds their own -scrollWheel: implementation, it will end up fighting with yours and it's not guaranteed whose will win. It's much better to simply subclass NSSlider and use your subclass anywhere you want a scroll-wheelable slider. I'm not sure why the OP is averse to subclassing, unless he's just asking if there's any built-in functionality already there. It's going to be perhaps ten lines of code and will get the job done. Mike ___ 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 [EMAIL PROTECTED]
Re: What is the best way to get an NSSlider to respond to the mouse scroll wheel?
On 28 Nov 2008, at 4:08 am, Graham Cox wrote: On 28 Nov 2008, at 3:18 am, Michael A. Crawford wrote: I assume I can sub-class the control but I wondering if there is a better way. I'm using a circular slider and would like it to rotate when I roll the scroll wheel up or down. You can just implement the -scrollWheel: method in a category. Playing with this, the code below gives a nice feel for a big variety of sliders in my app and wraps properly with circular ones too. I was skeptical at first that this was a good idea but trying it out in the app I've quickly come to appreciate how usable it is in practice! @implementation NSSlider (Scrollwheel) - (void)scrollWheel:(NSEvent*) event { float range = [self maxValue] - [self minValue]; float increment = (range * [event deltaY]) / 100; float val = [self floatValue] + increment; BOOL wrapValue = ([[self cell] sliderType] == NSCircularSlider); if( wrapValue ) { if ( val [self minValue]) val = [self maxValue] - fabs(increment); if( val [self maxValue]) val = [self minValue] + fabs(increment); } [self setFloatValue:val]; [self sendAction:[self action] to:[self target]]; } @end Please don't do this! It will apply to every single slider in your process, even ones you didn't create yourself, Well, that is potentially a feature. I guess the point would be to test your UI thoroughly and make sure it was what you wanted *everywhere*. But if that was what you wanted, doing it in a subclass would be more awkward, since you might not be able to get at every instance in the UI (e.g. the opacity slider in NSColorPanel) to set its class, especially now that -poseAsClass: is out of bounds. and if at some point Apple adds their own -scrollWheel: implementation, it will end up fighting with yours and it's not guaranteed whose will win. Yep, that's a potentially more serious issue. It would be nice if a category had a way to check for an existing implementation and quietly no-op itself. Just checking respondsToSelector: doesn't work of course, always returning YES. Right now, overriding methods in a category is not only legal, but documented as supported. Either Apple should come right out and say this is not allowed or rig the runtime to prevent it. As long as it's legal and documented as such, the judgement as to whether to add functionality in this manner rests with the developer. What's the point of a runtime feature you can't ever use? It's much better to simply subclass NSSlider and use your subclass anywhere you want a scroll-wheelable slider. I'm not sure why the OP is averse to subclassing, unless he's just asking if there's any built-in functionality already there. It's going to be perhaps ten lines of code and will get the job done. I agree, subclassing is definitely the safer option and amounts to the exactly same code, but a little bit more effort to set the class in IB. --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 [EMAIL PROTECTED]
Re: Can I split an implementation file?
On Nov 27, 2008, at 8:34 AM, Michael Ash wrote: Others have answered the direct question, I thought I would wander off into the realm of potentially unwanted advice. If your class is getting this large, then it may be a sign that your design is becoming unwieldy and you should actually be splitting it into multiple classes. Personally I try to keep my classes under 2000 lines whenever possible, and under 1000 if I can. When I can't avoid them getting larger, then I try to see if I can split them up nicely. Often when they become that large, it's because they're doing 2-3 distinct tasks, and each of those distinct tasks can generally be split into a separate class. Yet another option is to split the large class into subclasses. If you have a class ThingThatDoesFooAndBar, it might make sense to have: @interface ThingThatDoesFoo : NSObject ...stuff related to Foo... @end @interface ThingThatDoesBar : ThingThatDoesFoo ...stuff related to Bar... @end Even if you never expect to create any other subclasses of ThingThatDoesFoo, splitting the code along these lines can make the code easier to manage. Your particular class may not be amenable to this kind of split, but it's worth at least considering. Anyway, just a thought on design, obviously you don't have to listen. :-) Ditto. :) --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 [EMAIL PROTECTED]
Re: What is the best way to get an NSSlider to respond to the mouse scroll wheel?
On Nov 28, 2008, at 11:24 AM, Graham Cox wrote: Playing with this, the code below gives a nice feel for a big variety of sliders in my app and wraps properly with circular ones too. I was skeptical at first that this was a good idea but trying it out in the app I've quickly come to appreciate how usable it is in practice! @implementation NSSlider (Scrollwheel) Do Not Do This. Down this path lies pain and madness. Implement a subclass and use it throughout your application. The first software update or major Mac OS X release where Apple adds said method, if Apple were to ever add said method, and you'll be quite thoroughly unhappy. At best, your app's standard sliders will behave in a decidedly non-standard fashion. At worst, your app's standard sliders will crash. Categories are great for dividing a class's implementation (sometimes across frameworks -- NSAttributedString in Foundation and AppKit, for example) and great for adding new functionality to existing classes in isolation. But they are not meant for and not good for overriding existing behavior or modifying an existing class to respond to existing behaviors in a new way. b.bum ___ 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 [EMAIL PROTECTED]
Re: What is the best way to get an NSSlider to respond to the mouse scroll wheel?
On 28 Nov 2008, at 11:46 am, Bill Bumgarner wrote: Categories are great for dividing a class's implementation (sometimes across frameworks -- NSAttributedString in Foundation and AppKit, for example) and great for adding new functionality to existing classes in isolation. But they are not meant for and not good for overriding existing behavior or modifying an existing class to respond to existing behaviors in a new way. In which case Apple should a) explicitly document this as a no-no, and b) disallow categories to install methods that already exist. I would have thought b) was possible, as when loading a category, I assume what's really happening is that the method table for the class is being populated. If the slot is already occupied, just don't install that method. What use is it, if it's such a bad idea? --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 [EMAIL PROTECTED]
Re: What is the best way to get an NSSlider to respond to the mouse scroll wheel?
On Nov 28, 2008, at 11:52 AM, Graham Cox wrote: In which case Apple should a) explicitly document this as a no-no, and b) disallow categories to install methods that already exist. I would have thought b) was possible, as when loading a category, I assume what's really happening is that the method table for the class is being populated. If the slot is already occupied, just don't install that method. From the documentation: ... A category can also override methods declared in the class interface. However, it cannot reliably override methods declared in another category of the same class. A category is not a substitute for a subclass. It’s best if categories don’t attempt to redefine methods that are explicitly declared in the class’s @interface section. ... The underlying problem is one of legacy. There is a bunch of code out there that relies upon replacing existing methods when loading categories. Removing this particular misfeature will not be without its pain. Apple goes to great lengths to ensure binary compatibility between releases. What use is it, if it's such a bad idea? They have lots of uses: - dividing class implementations across multiple files for organizational purposes - dividing a class implementation across multiple frameworks with appropriate layering (See NSAttributedString) - adding isolated/orthogonal functionality to existing classes, including universal functionality to NSObject - making a class modular across different compilation/link units (Example: I used to split classes apart such that I could have one version that could render w/o underlying infrastructure in an IB palette and the real version that relied upon infrastructure for use in the app. The piece of the view that interfaced to the control/ model layer was contained in a category and could be swapped w/one that could generate its own data for the purposes of IB.) b.bum ___ 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 [EMAIL PROTECTED]
Re: What is the best way to get an NSSlider to respond to the mouse scroll wheel?
On 28 Nov 2008, at 11:46 am, Bill Bumgarner wrote: At best, your app's standard sliders will behave in a decidedly non- standard fashion. At worst, your app's standard sliders will crash. Could you explain how that's a real possibility? I don't see that. If Apple's implementation of -scrollWheel: does something different from mine then, yes, the behaviour would change. It might not change significantly, since presumably Apple wouldn't implement this to play The Star-Spangled Banner or make the control flash red, white and blue, but instead to just drive its value up and down. Secondly, if my category takes effect then it will override Apple's implementation anyway, so I'd see no difference *in my app*. It might differ from other apps, but it already does in that other apps' sliders don't respond to the scrollwheel. Also, if Apple were to add this method to NSSlider, surely it would just be part of the class definition for it, rather than in a separate category? If so, my category would always prevail. If it were added in a category, it would be pot-luck whose version prevailed, which is certainly undesirable, but not exactly unsafe, as such. I can't envisage a realistic scenario where a crash could occur, but do enlighten me as I'm certainly not familiar with every pitfall here. What use is it, if it's such a bad idea? They have lots of uses: Sure, I'm aware of the general utility of categories. I was referring to the specific case where a category is permitted to override a method. You call it a misfeature, but Apple don't - it's still documented, albeit with a number of caveats. Even if they couldn't remove the functionality for legacy reasons they could start documenting it in a much more strongly worded fashion to state that this is simply not permitted. As long as they don't do that, and as long as the developer is aware of the consequences, I take it as permitted. I'd still agree that subclassing is the better option, but I don't see the category approach is necessarily completely off-limits either. BTW, subclass or not, the code I posted also needs to do a check for - isEnabled. --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 [EMAIL PROTECTED]
Quick Look with native types?
I might be missing something obvious here but I'm reading the Quick Look companion guide and I can't seem to find any info about implementing QuickLook in my app for native types (only images actually)... All I can find is info about writing my own preview generators etc, do I need to do that for native types too? It seems so complex I might just end up writing my own preview class and forget quick look Jean-Nicolas Jolivet [EMAIL PROTECTED] http://www.silverscripting.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 [EMAIL PROTECTED]
Re: What is the best way to get an NSSlider to respond to the mouse scroll wheel?
On 28 Nov 2008, at 12:19 pm, Graham Cox wrote: Even if they couldn't remove the functionality for legacy reasons they could start documenting it in a much more strongly worded fashion to state that this is simply not permitted. Just to emphasise the point, the full paragraph you quoted part of states: The methods added in a category can be used to extend the functionality of the class or override methods the class inherits. A category can also override methods declared in the class interface. However, it cannot reliably override methods declared in another category of the same class. A category is not a substitute for a subclass. It’s best if categories don’t attempt to redefine methods that are explicitly declared in the class’s @interface section. Also note that a class can’t define the same method more than once. Particularly the first sentence - ...can be used to [] override methods the class inherits. Not must never be used, or even should only be used with extreme caution. There is no possible reading of can be used that can be taken to mean not permitted. Seems to me Apple need to revise this wording if they don't want people doing this. --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 [EMAIL PROTECTED]
Re: Scheme for efficiently archiving images.
On 28 Nov 2008, at 12:30 am, Jens Miltner wrote: Well, you _can_ ask the NSImage or it's rep for a certain bitmap representation (see e.g. http://markmail.org/message/ urbmcjwh5vixoxfd). Even if the NSImage can't provide that data, you could still use the BSD layer to convert to e.g. a JPEG: man sips Though I'd expect that JPEG-bitmap-JPEG could incur quite a bit of quality loss over the original data. Might be able to live with it for the few legacy files that would be affected. --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 [EMAIL PROTECTED]
Capturing the mouse and working out the mouse position
Hi guys. Although I've subscribed to this list for months, this is my first post. I'm in the process of migrating from Windows development, so my questions may have a windows centric bent, in terms of my thinking in terms of how I'd do stuff under that platform. Basically, I have an NSTableView in which each row contains an icon and some text. I have it so when I click on an item, a thumbnail animates up of the image that the item refers to. So far, so good. I need to achieve two things: 1 - I need to work out if the mouse is over the icon rather than the text, b/c I only want the popup to occur if it is. This means I need to know the mouse pos relative to the control. I can't find a way to work that out. I am using the shouldSelectRow event, which doesn't get passed a mouse pos. 2 - right now, I hide my popup based on a timer, but what I want to do, is to 'capture' the mouse, so that no matter where the user clicks when the popup is visible, the program closes the popup window in response. Any advice on how to find out the mouse position, how to translate it to be relative to a control and how to capture the mouse, would be recieved with much appreciation. Thank you Christian ___ 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 [EMAIL PROTECTED]
Re: Capturing the mouse and working out the mouse position
On 28 Nov 2008, at 2:02 pm, Christian Graus wrote: Hi guys. Although I've subscribed to this list for months, this is my first post. I'm in the process of migrating from Windows development, so my questions may have a windows centric bent, in terms of my thinking in terms of how I'd do stuff under that platform. Basically, I have an NSTableView in which each row contains an icon and some text. I have it so when I click on an item, a thumbnail animates up of the image that the item refers to. So far, so good. I need to achieve two things: 1 - I need to work out if the mouse is over the icon rather than the text, b/c I only want the popup to occur if it is. This means I need to know the mouse pos relative to the control. I can't find a way to work that out. I am using the shouldSelectRow event, which doesn't get passed a mouse pos. 2 - right now, I hide my popup based on a timer, but what I want to do, is to 'capture' the mouse, so that no matter where the user clicks when the popup is visible, the program closes the popup window in response. Any advice on how to find out the mouse position, how to translate it to be relative to a control and how to capture the mouse, would be recieved with much appreciation. Thank you I'm assuming the icon and text are in different columns, otherwise you'd have had to implement a custom cell, in which case your cell has all the mouse tracking information passed to it. So in the normal case, you can just use -clickedRow and -clickedColumn to get the row/column that was clicked. Given the column index you can get the column using [[table tableColumns] objectAtIndex:[table clickedColumn]] but this is only valid in the action method of the table's target. Alternatively, you could implement the delegate method: tableView:didClickTableColumn: which passes you the column directly, which saves a lot of hassle. Given the column, you can call methods on it to make sure it's the one you expect, then do whatever. Bear in mind the user can drag columns into any order, so you need to be ready to ask the column for more info (such as its identifier, typically) to know whether it's the icon or the text column. In other words don't test the mouse position to tell columns apart, since columns move. However, it also sounds like what you might really want is a custom icon cell, since special behaviours that are part of the actual content of a table row are usually handled that way. Cell subclassing can be a bit of a chore though - see NSCell. hth, 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 [EMAIL PROTECTED]
Re: Quick Look with native types?
On 28/11/2008, at 11:29 AM, Jean-Nicolas Jolivet wrote: I might be missing something obvious here but I'm reading the Quick Look companion guide and I can't seem to find any info about implementing QuickLook in my app for native types (only images actually)... All I can find is info about writing my own preview generators etc, do I need to do that for native types too? It seems so complex I might just end up writing my own preview class and forget quick look QuickLook supports HTML, PDF, RTF, bitmap images and plain text. You can't have a more complex preview than that, although you can use graphics contexts to create these formats on the fly: http://developer.apple.com/documentation/userexperience/Conceptual/Quicklook_Programming_Guide/QLDrawGraphContext/chapter_6_section_1.html I'm not sure I understand your comment about writing your own preview class. What is your preview for but for display in the Finder and QuickLook? How is writing a QuickLook generator difficult or inadequate for that task? -- Rob Keniger ___ 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 [EMAIL PROTECTED]
Re: Capturing the mouse and working out the mouse position
Thanks for the reply. As it stands, we're using a single cell ( someone else actually wrote that part, but neither of us knows how to handle the mouse stuff that's cropping up now ). So, there's an event I can plug into that would give me the mouse position over the cell ? If you're saying I should read up on NSCell, does that mean I need to write some code per cell, not for the table as a whole ? Thanks for the help... Christian ___ 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 [EMAIL PROTECTED]
Re: NSTrackingArea strange requirement
On 27/11/2008, at 10:22 PM, rajesh wrote: but I see a kind of problem with above approach as well. Since we are updating the TrackingAreas in updateTrackingAreas (removing and adding track areas) , my cursor (which is set to resizeUpDownCursor mouseEntered: ) seems to flicker when ever try updating/resizing my view due to the fact that trackAreas are changed every time. You shouldn't be using -mouseEntered: to set the cursor. You should init the tracking area with the NSTrackingCursorUpdate option and then implement the -cursorUpdate: method. -- Rob Keniger ___ 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 [EMAIL PROTECTED]
Re: What is the best way to get an NSSlider to respond to the mouse scroll wheel?
On Thu, Nov 27, 2008 at 7:24 PM, Graham Cox [EMAIL PROTECTED] wrote: Please don't do this! It will apply to every single slider in your process, even ones you didn't create yourself, Well, that is potentially a feature. I guess the point would be to test your UI thoroughly and make sure it was what you wanted *everywhere*. But if that was what you wanted, doing it in a subclass would be more awkward, since you might not be able to get at every instance in the UI (e.g. the opacity slider in NSColorPanel) to set its class, especially now that -poseAsClass: is out of bounds. It's a feature so long as it works properly. The problem is when Apple makes some change that conflicts with your own. Suddenly you get weird behavior that's out of your control. Also, -poseAsClass: is only out of bounds because it's been replaced by a more general mechanism that's even more powerful. Look up the method_exchangeImplementations() function for more information. and if at some point Apple adds their own -scrollWheel: implementation, it will end up fighting with yours and it's not guaranteed whose will win. Yep, that's a potentially more serious issue. It would be nice if a category had a way to check for an existing implementation and quietly no-op itself. Just checking respondsToSelector: doesn't work of course, always returning YES. There is. Implement your category method with a different name that you know will not conflict, for example by adding a prefix. Then at runtime, check to see if the class already has such a method, and swap in yours if not. Right now, overriding methods in a category is not only legal, but documented as supported. Either Apple should come right out and say this is not allowed or rig the runtime to prevent it. As long as it's legal and documented as such, the judgement as to whether to add functionality in this manner rests with the developer. What's the point of a runtime feature you can't ever use? Overriding methods in a category is supported, yes, and a category will always win over a method that's implemented directly in a class. The problem is that you have no guarantee that Apple's hypothetical future implementation will be directly in a class. They might put it in a category too. At that point, you have no guarantee who wins. It could change from one release to the next, or even from one run to the next. It's simply not safe to override methods in classes you don't control because you can't ensure that the necessary preconditions are met. By all means override methods in your own classes, but if you do it to classes you don't control, you cannot guarantee which one will take precedence. Mike ___ 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 [EMAIL PROTECTED]
Re: Quick Look with native types?
That's not really what I'm getting from Quick Look's programming guide... in the very first paragraph it says: For documents of common content types—notably HTML, RTF, plain text, TIFF, PNG, JPEG, PDF, and QuickTime movies—this support is automatic. However, applications with documents that are of less common or even private content types can still take advantage of the Quick Look feature. And then later: Quick Look supports the display of document thumbnails and previews if the format is one of its native types (JPG, PDF, PNG QuickTime movies). [...] However, if a document is not in one of the native types, the document’s application must include a Quick Look generator if it wants to take advantage of the Quick Look feature. So from that, am I wrong to think that I need to write a generator IF I want to use quicklook with non-native type ?... But what about if I want to use quick look for native types? My point was... I already have some kind of preview class that I wrote for another app (that would basically display an image in a HUD window and size it accordingly etc..) ... So, if using quicklook with native types is more complex than just calling a method or two.. I will use my own class instead... I guess I didn't formulated in a clear way... On 27-Nov-08, at 10:32 PM, Rob Keniger wrote: On 28/11/2008, at 11:29 AM, Jean-Nicolas Jolivet wrote: I might be missing something obvious here but I'm reading the Quick Look companion guide and I can't seem to find any info about implementing QuickLook in my app for native types (only images actually)... All I can find is info about writing my own preview generators etc, do I need to do that for native types too? It seems so complex I might just end up writing my own preview class and forget quick look QuickLook supports HTML, PDF, RTF, bitmap images and plain text. You can't have a more complex preview than that, although you can use graphics contexts to create these formats on the fly: http://developer.apple.com/documentation/userexperience/Conceptual/Quicklook_Programming_Guide/QLDrawGraphContext/chapter_6_section_1.html I'm not sure I understand your comment about writing your own preview class. What is your preview for but for display in the Finder and QuickLook? How is writing a QuickLook generator difficult or inadequate for that task? -- Rob Keniger ___ 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/silvertab%40videotron.ca This email sent to [EMAIL PROTECTED] Jean-Nicolas Jolivet [EMAIL PROTECTED] http://www.silverscripting.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 [EMAIL PROTECTED]
Re: Quick Look with native types?
mmm just in case I wasn't clear (I realize I might be looking at this from the wrong angle): I would want to use Quick Look to show preview of images in my app, I dont want to write a Quick Look plugin so that my custom document type can be previewed in the finder or anythign like that... What I want to do is basically what Mail.app does with attachment...There's the save button, and next to it there's a little Quick Look button that will show the attachment in a quick look window... I would like to do that in my app, with bitmap images that are already on the file system... On 27-Nov-08, at 11:02 PM, Jean-Nicolas Jolivet wrote: That's not really what I'm getting from Quick Look's programming guide... in the very first paragraph it says: For documents of common content types—notably HTML, RTF, plain text, TIFF, PNG, JPEG, PDF, and QuickTime movies—this support is automatic. However, applications with documents that are of less common or even private content types can still take advantage of the Quick Look feature. And then later: Quick Look supports the display of document thumbnails and previews if the format is one of its native types (JPG, PDF, PNG QuickTime movies). [...] However, if a document is not in one of the native types, the document’s application must include a Quick Look generator if it wants to take advantage of the Quick Look feature. So from that, am I wrong to think that I need to write a generator IF I want to use quicklook with non-native type ?... But what about if I want to use quick look for native types? My point was... I already have some kind of preview class that I wrote for another app (that would basically display an image in a HUD window and size it accordingly etc..) ... So, if using quicklook with native types is more complex than just calling a method or two.. I will use my own class instead... I guess I didn't formulated in a clear way... On 27-Nov-08, at 10:32 PM, Rob Keniger wrote: On 28/11/2008, at 11:29 AM, Jean-Nicolas Jolivet wrote: I might be missing something obvious here but I'm reading the Quick Look companion guide and I can't seem to find any info about implementing QuickLook in my app for native types (only images actually)... All I can find is info about writing my own preview generators etc, do I need to do that for native types too? It seems so complex I might just end up writing my own preview class and forget quick look QuickLook supports HTML, PDF, RTF, bitmap images and plain text. You can't have a more complex preview than that, although you can use graphics contexts to create these formats on the fly: http://developer.apple.com/documentation/userexperience/Conceptual/Quicklook_Programming_Guide/QLDrawGraphContext/chapter_6_section_1.html I'm not sure I understand your comment about writing your own preview class. What is your preview for but for display in the Finder and QuickLook? How is writing a QuickLook generator difficult or inadequate for that task? -- Rob Keniger ___ 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/silvertab%40videotron.ca This email sent to [EMAIL PROTECTED] Jean-Nicolas Jolivet [EMAIL PROTECTED] http://www.silverscripting.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/silvertab%40videotron.ca This email sent to [EMAIL PROTECTED] Jean-Nicolas Jolivet [EMAIL PROTECTED] http://www.silverscripting.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 [EMAIL PROTECTED]
Re: Quick Look with native types?
On 28/11/2008, at 2:07 PM, Jean-Nicolas Jolivet wrote: mmm just in case I wasn't clear (I realize I might be looking at this from the wrong angle): I would want to use Quick Look to show preview of images in my app, I dont want to write a Quick Look plugin so that my custom document type can be previewed in the finder or anythign like that... What I want to do is basically what Mail.app does with attachment...There's the save button, and next to it there's a little Quick Look button that will show the attachment in a quick look window... I would like to do that in my app, with bitmap images that are already on the file system... There's no public API to do this at present. You'd need to create a temporary file and use the qlmanage -p /path/to/thefile tool via NSTask. Of course, you'd need to write a QuickLook generator in order for the temporary file to be previewed correctly. If it were me, I'd just use a custom preview class as you have already done. -- Rob Keniger ___ 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 [EMAIL PROTECTED]
Re: What is the best way to get an NSSlider to respond to the mouse scroll wheel?
On Nov 28, 2008, at 12:19 PM, Graham Cox wrote: On 28 Nov 2008, at 11:46 am, Bill Bumgarner wrote: At best, your app's standard sliders will behave in a decidedly non- standard fashion. At worst, your app's standard sliders will crash. Could you explain how that's a real possibility? I don't see that. Sure. Secondly, if my category takes effect then it will override Apple's implementation anyway, so I'd see no difference *in my app*. It might differ from other apps, but it already does in that other apps' sliders don't respond to the scrollwheel. Also, if Apple were to add this method to NSSlider, surely it would just be part of the class definition for it, rather than in a separate category? If so, my category would always prevail. If it were added in a category, it would be pot-luck whose version prevailed, which is certainly undesirable, but not exactly unsafe, as such. I can't envisage a realistic scenario where a crash could occur, but do enlighten me as I'm certainly not familiar with every pitfall here. You are assuming that the implementation of the method is fully self contained. There are any number of reason's why the implementation of such a method may rely upon state maintained by other methods or, more importantly, might adjust some internal state in the object that is later required. This may be done for optimization reasons or it could be done to support some new bit of hardware (the growing pool of multiple finger trackpad gestures come to mind). The bottom line is that you cannot safely assume that method -x of class Y has zero dependencies the behavior of other methods in the class. Nor is there any way for you to know, short of disassembling specific versions that may change in the future, that you have discovered and are correctly handling all such dependencies. Even if you could, it can change in future implementations. This isn't just fear mongering. In the nearly 20 years (sheesh! I'm old!) that I have been actively writing / maintaining / debugging Objective-C applications, I have seen a number of situations where crashes and misbehaviors were due to categories overriding methods provided by system classes. It doesn't happen often, but it definitely does happen and, worse, when it does happen the resulting behavior is often really really bad. Data loss kind of bad. What use is it, if it's such a bad idea? They have lots of uses: Sure, I'm aware of the general utility of categories. I was referring to the specific case where a category is permitted to override a method. You call it a misfeature, but Apple don't - it's still documented, albeit with a number of caveats. Even if they couldn't remove the functionality for legacy reasons they could start documenting it in a much more strongly worded fashion to state that this is simply not permitted. As long as they don't do that, and as long as the developer is aware of the consequences, I take it as permitted. You are correct. The documentation does not fully discuss the risks inherent therein. rdar://problem/6405779 Emphasize the risks of and discourage developers from categorically overriding methods Thanks for pointing this out. Michael Ash pointed wrote There is. Implement your category method with a different name that you know will not conflict, for example by adding a prefix. Then at runtime, check to see if the class already has such a method, and swap in yours if not. That still assumes that your method is compatible with the class. A class may [frequently, as it turns out] have a relatively heavily optimized implementation internally that relies upon certain state maintenance and state transitions across its own methods. When subclassed, the class's method may revert to a behavior that is designed to support subclassing. Michael's approach is certainly more defensive and robust, but it will still potentially cause -- and has -- problems when adding one of the standard responder methods to a class that didn't implement it before. Keep in mind that, for NSControl subclasses specifically, a class can handle events through several different methods, including manually tracking the event in one of the raw methods (like the mouse tracking methods). It's simply not safe to override methods in classes you don't control because you can't ensure that the necessary preconditions are met. By all means override methods in your own classes, but if you do it to classes you don't control, you cannot guarantee which one will take precedence. Exactly. b.bum ___ 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:
Re: What is the best way to get an NSSlider to respond to the mouse scroll wheel?
On Nov 27, 2008, at 7:24 PM, Graham Cox wrote: Yep, that's a potentially more serious issue. It would be nice if a category had a way to check for an existing implementation and quietly no-op itself. Just checking respondsToSelector: doesn't work of course, always returning YES. Build your category methods into a loadable bundle. Check with respondsToSelector:, and if it returns NO, load the bundle. sherm-- ___ 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 [EMAIL PROTECTED]
Re: Core Data modeling question
On 2008 Nov, 27, at 8:11, Alexander Spohr wrote: Am 26.11.2008 um 22:08 schrieb Markus Schneider: Shall I use a MO class DAY and model the list as a to-many relationship? TASK - startDate - endDate - exceptions - DAY - date Is this really necessary or is there a more elegant way? This IS the elegant way. If you need an array use an own table for the destination and connect it 1-n. I'd like to offer another view on this. Yes, you could model the list as a to-many relationship and yes this is the elegant way. And it would also be the best way if all tasks had the same exceptions/ holidays, or if you might ever have a need to process exception/ holidays as entities on their own. I thought on having a list of date objects containing the exceptions. But how should I model this? I cannot create a NSMutableArray to store the dates in the persistent store. I wouldn't say cannot. Certainly you cannot create a ^mutable^ array in a persistent store. But, although I have not tested this yet, I believe that you can create an (immutable) array of dates by setting its type to transformable, and the default transformer should work just fine. This might be a reasonable design if neither of the conditions I stated in my first paragraph are true. So, I believe you can model your exception/holidays as ^either^ attributes or relationships. But the latter is more elegant and more amenable to adding new features in the future, while probably costing about the same in design time and in program execution. ___ 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 [EMAIL PROTECTED]
Binding : NSArrayController does not reflect changes to NSMutableArray
First, I am new to Cocoa, so I apologize if this question is super simple. I am currently reading through Cocoa Programming for Max OS X, and am trying to create a simple example of a NSTableView that is bound to an NSArrayController which is bound to an NSMutableArray in my application controller class. However, when I change (i.e. add) data in the NSMutableArray the changes are not reflected in the NSArrayController. If I modify the NSArrayController directly, I can see the changes in the NSTableView After a lot of searching, I found this post: http://chanson.livejournal.com/85659.html which basically says changes to NSMutableArray will not automatically be picked up by the NSArrayController. However, even If I implement the solutions in that post, it is still not working for me. For example: - -(id)init { if(![super init]) { return nil; } broadcasts = [[NSMutableArray alloc] init]; return self; } -(void)awakeFromNib { NSLog(@hello); Broadcast *b = [[Broadcast init] alloc]; b.startTime = @1000; //[broadcasts addObject:b]; [self insertObject:b intoBroadcastsAtIndex:[self countOfBroadcasts]]; } -(void)insertObject:(Broadcast *)b intoBroadcastsAtIndex:(int)index { [broadcasts insertObject:b atIndex:index]; } -(int)countOfBroadcasts { return [broadcasts count]; } --- So, I have two questions: 1. Should I just manipulate NSArrayController directly? (I am populating data from a tab delimited file). 2. Does anyone have an example of how to get the NSArrayController to notice the changes to the NSMutableArray that it is bound to? 3. Should I just skip all of the data binding, and glue up everything myself? Thanks for any help and input... mike ___ 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 [EMAIL PROTECTED]
Re: Binding : NSArrayController does not reflect changes to NSMutableArray
fyi I figured out the issue. I had mispelled one of the properties in my nib which was causing the problem. mike On Thu, Nov 27, 2008 at 12:12 AM, Mike Chambers [EMAIL PROTECTED] wrote: First, I am new to Cocoa, so I apologize if this question is super simple. I am currently reading through Cocoa Programming for Max OS X, and am trying to create a simple example of a NSTableView that is bound to an NSArrayController which is bound to an NSMutableArray in my application controller class. However, when I change (i.e. add) data in the NSMutableArray the changes are not reflected in the NSArrayController. If I modify the NSArrayController directly, I can see the changes in the NSTableView After a lot of searching, I found this post: http://chanson.livejournal.com/85659.html which basically says changes to NSMutableArray will not automatically be picked up by the NSArrayController. However, even If I implement the solutions in that post, it is still not working for me. For example: - -(id)init { if(![super init]) { return nil; } broadcasts = [[NSMutableArray alloc] init]; return self; } -(void)awakeFromNib { NSLog(@hello); Broadcast *b = [[Broadcast init] alloc]; b.startTime = @1000; //[broadcasts addObject:b]; [self insertObject:b intoBroadcastsAtIndex:[self countOfBroadcasts]]; } -(void)insertObject:(Broadcast *)b intoBroadcastsAtIndex:(int)index { [broadcasts insertObject:b atIndex:index]; } -(int)countOfBroadcasts { return [broadcasts count]; } --- So, I have two questions: 1. Should I just manipulate NSArrayController directly? (I am populating data from a tab delimited file). 2. Does anyone have an example of how to get the NSArrayController to notice the changes to the NSMutableArray that it is bound to? 3. Should I just skip all of the data binding, and glue up everything myself? Thanks for any help and input... mike ___ 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 [EMAIL PROTECTED]
I am trying to update the cfbundleversion key with agvtool and it does not seem to work
Greetings all, I am noticing that when I try to upgrade my application using my installer, the upgrading application is skipped. It seems that the value in the dfbundleversion key value pair is not being updated when I run agvtool and the version held in cfbundleversion is quite old. I am running agvtool from a bourne script with the following line: agvtool new-version -all $VERSiON Is there a bug in agvtool that could account for cfbundleversion not being updated? Is there any known workaround that I could implement? I hope that this question is clear. Thanks for any and all suggestions. Happy Thanksgiving! Regards, Steve O'Sullivan ___ 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 [EMAIL PROTECTED]
Library Woes
I've been trying to add the freeimage library to my application but i keep getting this error. any ideas? dyld: Library not loaded: libfreeimage-3.11.0.dylib-i386 Referenced from: /Users/bob1/Documents/Quickpic/build/Debug/Quickpic.app/Contents/MacOS/Quickpic Reason: image not found ___ 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 [EMAIL PROTECTED]
IKImageBrowserView and mouseDragged event
Greetings, In my app I have an IKImageBrowserView, and I want to make this an drag source. I have followed thedragging source docshttp://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/Concepts/dragsource.html#//apple_ref/doc/uid/2976 but to no avail. In my view class the mouseDragged never gets called. Any help on making the IKImageBrowserView a drag source or making it respond to mouseDragged even is appreciated. Thanks. -- Sandeep ___ 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 [EMAIL PROTECTED]
Re: Binding : NSArrayController does not reflect changes to NSMutableArray
On Nov 27, 2008, at 2:12 AM, Mike Chambers wrote: First, I am new to Cocoa, so I apologize if this question is super simple. No, it's something that bites a lot of people. I am currently reading through Cocoa Programming for Max OS X, and am trying to create a simple example of a NSTableView that is bound to an NSArrayController which is bound to an NSMutableArray in my application controller class. Just as a pedantic point of clarification: you are not binding anything to an NSMutableArray. You are binding to a _property_ of your controller object. That property is represented by the methods in your controller class's interface. It so happens that, with the way you've chosen to implement your controller class, the property is backed by an NSMutableArray. This is an important distinction and once you grok it, KVO and bindings will make more sense. However, when I change (i.e. add) data in the NSMutableArray the changes are not reflected in the NSArrayController. If I modify the NSArrayController directly, I can see the changes in the NSTableView After a lot of searching, I found this post: http://chanson.livejournal.com/85659.html which basically says changes to NSMutableArray will not automatically be picked up by the NSArrayController. That's because KVO and bindings are hooked into your controller object and its methods. They are not hooked into the NSMutableArray at all! So, only mutations of the property done through certain specific methods of your controller object will be noticed. However, even If I implement the solutions in that post, it is still not working for me. That post led you a bit astray with a simple typographical error. The methods should have in in their names, not into. See the Apple docs that that post referenced: http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#/ /apple_ref/doc/uid/20002174-178830-BAJEDEFB Also see the docs for -mutableValueForKey:. Actually, better is to read the comments at the declaration for that method in NSKeyValueCoding.h, because it has some details which the docs are (still!) missing. Besides the insertObject:inKeyAtIndex: method, you may need to implement the corresponding remove method, too. Even if you don't have to, you should. Cheers, 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 [EMAIL PROTECTED]