[SOLVED] Re: [noob] Best practice for creating multiple instances of a View
On Mar 20, 2009, at 11:08 AM, Stuart Malin wrote: On Mar 20, 2009, at 10:09 AM, mmalc Crawford wrote: Modulo other's comments about premature optimisation, if you want to avoid going back to the disk: http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/ApplicationKit/Classes/NSNib_Class/Reference/Reference.html initWithNibNamed:bundle: instantiateNibWithOwner:topLevelObjects: Thanks mmalc. That looks to be the way to go: You may use this method to instantiate a nib file multiple times. As a follow-up, I've implemented code in this manner, and everything works just fine. As to whether it is more efficient or not, I've no idea. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Creating UI for as of Get Info Panel
We have no idea what file you want to Get Info on, or whether you want to make your own Get Info panel or use the Finder's. For all I know this is a Get Info window in a custom application that has no relation to files on disk besides bearing the same name. http://www.whathaveyoutried.com We will not write your application for you via e-mail. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Stop NSScrollView from catching scroll events.
I have a tableview that's neatly wrapped in a scroll view by IB. I manually resize the scrollview whenever a row is added to the tableview so that all the row are always visible. Thus I basically don't need a scroll view. However even though it can't actually scroll the tableview it still eats scroll events when the mouse is over it. I tried ripping the tableview out of the scroll view programatically, but that didn't yield useable results. Is there a straight forward way to have a scroll view pass scroll events on up the responder chain? Thanks, -Ben -- Ben Lachman Acacia Tree Software http://acaciatreesoftware.com email: blach...@mac.com twitter: @benlachman mobile: 740.590.0009 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
RE: Creating UI for as of Get Info Panel
Hi Kyle, Sorry for not clearing my doubt completely. I have created an icon view in which I am showing the files and folders of the selected item by the user. And now I want to create a panel as of finders but I am not able to identify the controls of it like inside the disclosure triangle it is showing a table view for sharing and permissions option. So can you help me in sorting out the problem that how can I add the table inside the disclosure triangle. Thanks and Regards, Ankur Singhal -Original Message- From: Kyle Sluder [mailto:kyle.slu...@gmail.com] Sent: Monday, March 23, 2009 11:50 Morning To: Ankur Singhal Cc: cocoa-dev@lists.apple.com Subject: Re: Creating UI for as of Get Info Panel We have no idea what file you want to Get Info on, or whether you want to make your own Get Info panel or use the Finder's. For all I know this is a Get Info window in a custom application that has no relation to files on disk besides bearing the same name. http://www.whathaveyoutried.com We will not write your application for you via e-mail. --Kyle Sluder DISCLAIMER == This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Creating UI for as of Get Info Panel
This example should get you somewhere... http://developer.apple.com/SampleCode/Reducer/listing6.html Especially, take a look at the CollapsibleBox class. Regards, Florian. On 23 Mar 2009, at 08:54, Ankur Singhal wrote: Hi Kyle, Sorry for not clearing my doubt completely. I have created an icon view in which I am showing the files and folders of the selected item by the user. And now I want to create a panel as of finders but I am not able to identify the controls of it like inside the disclosure triangle it is showing a table view for sharing and permissions option. So can you help me in sorting out the problem that how can I add the table inside the disclosure triangle. Thanks and Regards, Ankur Singhal -Original Message- From: Kyle Sluder [mailto:kyle.slu...@gmail.com] Sent: Monday, March 23, 2009 11:50 Morning To: Ankur Singhal Cc: cocoa-dev@lists.apple.com Subject: Re: Creating UI for as of Get Info Panel We have no idea what file you want to Get Info on, or whether you want to make your own Get Info panel or use the Finder's. For all I know this is a Get Info window in a custom application that has no relation to files on disk besides bearing the same name. http://www.whathaveyoutried.com We will not write your application for you via e-mail. --Kyle Sluder DISCLAIMER == This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. ___ 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/florian.soenens%40nss.be This email sent to florian.soen...@nss.be Looking for Web-to-Print Solutions? Visit our website : http://www.vit2print.com This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information and/or information protected by intellectual property rights. If you are not the intended recipient, please note that any review, dissemination, disclosure, alteration, printing, copying or transmission of this e-mail and/or any file transmitted with it, is strictly prohibited and may be unlawful. If you have received this e-mail by mistake, please immediately notify the sender and permanently delete the original as well as any copy of any e-mail and any printout thereof. We may monitor e-mail to and from our network. NSS nv Tieltstraat 167 8740 Pittem Belgium ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to get a scroll view to recognize overflow on a custom view?
Thanks Quincey this helped. I'm getting scroll bars now. The new issue though is that when I set the size of the content view (document view?) the scroller's size changes to the new size of the content. I've checked and rechecked to make sure all the autosize parts are set up in IB correctly, but no matter what I do, I can't both set the size of the scroller content view and preserve the frame of the scroll view. Here's how I set up the autosize options in IB Scroll view options: outside: top, left, bottom, right Inside scale width, scale height Content view options: Outside: top, left, right Inside: scale width In my code, the content view recalculates it's height when the contents are refreshed with new data. The new data comes from the result of database searches and I display te results in the content view. When I change the height, the scroll view always changes as well. How can I resize the contents of a scroll view without also changing the size of the scroll view that contains it? On Mar 23, 2009, at 1:50 AM, Quincey Morris wrote: If scroll bars don't appear, there are 2 likely causes: -- You are failing to set your custom view's depth properly. The depth is determined by your custom view's frame. Make sure you're setting the frame to the correct height (and not, for example, setting just the bounds to the desired height). -- The autoresize flags for your custom view are causing it to be resized because the enclosing scroll view is being resized as part of the window setup. If you want to control the view frame height yourself, make sure the vertical autoresize widget for the custom view in IB is not set to change the view height. You may want to also turn off the scroll view's resizes subviews automatically, unless you want the width of your view to match the scroll view automatically. Note that the non-appearance of the scroll bar most likely results from the above in combination with the hides scroll bars automatically option for the scroll view in IB. If you uncheck that, you should see the scroll bar, but the scroll bar would then be inactive if you don't maintain the view height correctly. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
De-Mystifying NSCell
Hi all, I've noticed recently a few people have posted to the list in a state of uncertainty regarding NSCell, particularly in the context of NSTableView. I was in much the same boat when I started out with Cocoa; it takes a few runs through it before the scheme starts to make sense. I put together a short video to try to explain the rationale and mechanisms of NSCell: http://www.cs.loyola.edu/~ksluder/NSCell.mov . If you're confused about why NSCell exists and how it's used inside NSTableView, I hope that my video is able to shine a bit of light. If not, I hope I don't confuse you even more. If you like or dislike the video, please do let me know. Thanks, --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Binding NSMatrix to user Defaults
Hello List, I created NSMatrix contains two radio buttons. I am binding its selected index with shared user defaults. Now i want to make UI such that when user make first radio button ON it should enable one other radio button Matrix. and when user make second radio button OFF It should disable other radio button Matrix. So, how can i enable and disable the components within radio button Matrix ? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Could really use the help of a custom view expert
Hi I've been struggling with a set of complex views for my palette user interface and have literally been fighting with the same stupid issues off and on for almost a year. I've never, in my 15 years of programming come up against a problem as difficult as making a user interface using Cocoa views. Some of it is easy enough, but it's the exact placement stuff that is giving me so many headaches. I flat don't understand why perfectly logical settings don't work and need the hands-on help of someone who knows this stuff cold. The main issues I've never been able to figure out are why, despite setting views to be pinned to the top of a containing view, it ALWAYS snaps to the bottom when I change the size. Read the documentation suggestions aren't going to cut it any more as I've been doing that for a year and am not making any headway. If there is someone who would be willing to take a look at my project help me figure out what I'm doing wrong it would be hugely appreciated. I need to finish this thing and despite trying every trick and ugly hack I can think of, nothing works. This should probably be done off-list so if there are any gurus willing to help, contact me directly -Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: BOOL takeStupidRoad = NO (search app design question)
Hello, David, there is nothing wrong with your aproach. For this amount of data and for its first version the program should be ok. However, if you find out later that your search needs to be faster/ consume less memory/work with more files, you will need to optimize the application. Note that this is the correct approach. First make the application work. Optimize later, when/if necessary. If you structure your application well (ObjectOriented design), then you will be able to switch new search code and snippet generation into application without changing the rest of application. This is the main and most important design issue - how to structure your application so you can improve it with as little work as possible. Search optimization can take many forms, from using SearchKit or some other search library to build your private index, or using Spotlight API, or some other search tool (such as programmatically running the command like 'grep' and parsing its output). The software will become more complicated, because the generation of snippets may or may not be supported by the search code you will use, so you may need to generate them yourself, separately from search. izidor On 21.3.2009, at 11:24, David Yamartino wrote: Hi All, I have a general design question. I'm going through the latest Hillegass and Kochan programming books for the purpose of writing a simple search app. I think I've figured out a way to do this, but having no experience in programming, I have no idea if my approach is good or bad. I'd rather not take the stupid road if I can avoid it, so I'm hoping someone may be able to set me straight before I go too far down the road. So if you're inclined to take a few minutes to consider what I've written below, I'd appreciate it. In any case, good luck with your projects, David *APPLICATION DESCRIPTION:* I have a library of about 1,500 text files, about 93 MB total. The application window opens with two views: left view shows the hierarchy of folders/files, and when you click on a file, the text of the file appears in the right view, where you can read, scroll, etc. The user inputs a term into the search field, and when the search is executed, the folders/files on the left view disappear and the view is repopulated with a new hierarchy showing only the folders/files where the search term appears. Below each file will be snippets of where the term appears within the text. Click on a snippet and the right view will show the entire text of the file zoomed to where the snippet appears. For example, if the search term is child education: *Book X* The *child education* conference focused on two age groups: 5-7 years, and 8-10 years. . . . because the *child* wasn't receiving the needed attention in her *education*, her parents decided . . . . . . and over the years the *child education* policy was broadened to include moral education and . . . *MY APPROACH*: I can load the text of the 1,500 files into 1500 NSStrings with something like stringWithContentsOfFile Then I can search the 1,500 NSStrings to locate the position of the search term within each string, then extract a range (including some words before and some words after) to make the snippets. Using rangeOfString NSMakeRange etc. *QUESTION:* Would this be a workable approach? Or is it a really stupid idea to have to load 93 MB of files into 1,500 NSStrings every time the program starts up? If not this approach, what would be more efficient? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/ij.cocoadev%40gmail.com This email sent to ij.cocoa...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: BOOL takeStupidRoad = NO (search app design question)
Thanks, Izidor, for these suggestions. Regarding the Spotlight API, several people have suggested this, however my understanding is that Spotlight indexes at the file level - that is, it knows that the word perpendicular is contained in File X, File Y, and File Z. However, I need to know the exact 11 locations where the word appears in these files, which I don't think Spotlight does. Then again, I guess I could use Spotlight to locate the proper files, and then focus on them for finding the position of the words and then getting the words around them for the snippets, etc. OK - I'll do my best to proceed like this (or otherwise make it work) then optimize if needed. I really appreciate your help, David On Mon, Mar 23, 2009 at 8:08 PM, Izidor Jerebic ij.cocoa...@gmail.comwrote: Hello, David, there is nothing wrong with your aproach. For this amount of data and for its first version the program should be ok. However, if you find out later that your search needs to be faster/consume less memory/work with more files, you will need to optimize the application. Note that this is the correct approach. First make the application work. Optimize later, when/if necessary. If you structure your application well (ObjectOriented design), then you will be able to switch new search code and snippet generation into application without changing the rest of application. This is the main and most important design issue - how to structure your application so you can improve it with as little work as possible. Search optimization can take many forms, from using SearchKit or some other search library to build your private index, or using Spotlight API, or some other search tool (such as programmatically running the command like 'grep' and parsing its output). The software will become more complicated, because the generation of snippets may or may not be supported by the search code you will use, so you may need to generate them yourself, separately from search. izidor On 21.3.2009, at 11:24, David Yamartino wrote: Hi All, I have a general design question. I'm going through the latest Hillegass and Kochan programming books for the purpose of writing a simple search app. I think I've figured out a way to do this, but having no experience in programming, I have no idea if my approach is good or bad. I'd rather not take the stupid road if I can avoid it, so I'm hoping someone may be able to set me straight before I go too far down the road. So if you're inclined to take a few minutes to consider what I've written below, I'd appreciate it. In any case, good luck with your projects, David *APPLICATION DESCRIPTION:* I have a library of about 1,500 text files, about 93 MB total. The application window opens with two views: left view shows the hierarchy of folders/files, and when you click on a file, the text of the file appears in the right view, where you can read, scroll, etc. The user inputs a term into the search field, and when the search is executed, the folders/files on the left view disappear and the view is repopulated with a new hierarchy showing only the folders/files where the search term appears. Below each file will be snippets of where the term appears within the text. Click on a snippet and the right view will show the entire text of the file zoomed to where the snippet appears. For example, if the search term is child education: *Book X* The *child education* conference focused on two age groups: 5-7 years, and 8-10 years. . . . because the *child* wasn't receiving the needed attention in her *education*, her parents decided . . . . . . and over the years the *child education* policy was broadened to include moral education and . . . *MY APPROACH*: I can load the text of the 1,500 files into 1500 NSStrings with something like stringWithContentsOfFile Then I can search the 1,500 NSStrings to locate the position of the search term within each string, then extract a range (including some words before and some words after) to make the snippets. Using rangeOfString NSMakeRange etc. *QUESTION:* Would this be a workable approach? Or is it a really stupid idea to have to load 93 MB of files into 1,500 NSStrings every time the program starts up? If not this approach, what would be more efficient? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/ij.cocoadev%40gmail.com This email sent to ij.cocoa...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
RE: Creating UI for as of Get Info Panel
Hi Florian, I have gone through the link given by you but I am not able to open its nib file due to some missing plug-in. Can any one tell me how can I add a Table View inside a disclosure triangle and can also show it or hide it depending upon the click on it. Thanks and Regards, Ankur Singhal -Original Message- From: Florian Soenens [mailto:florian.soen...@nss.be] Sent: Monday, March 23, 2009 2:08 Afternoon To: Ankur Singhal Cc: cocoa-dev@lists.apple.com Subject: Re: Creating UI for as of Get Info Panel This example should get you somewhere... http://developer.apple.com/SampleCode/Reducer/listing6.html Especially, take a look at the CollapsibleBox class. Regards, Florian. On 23 Mar 2009, at 08:54, Ankur Singhal wrote: Hi Kyle, Sorry for not clearing my doubt completely. I have created an icon view in which I am showing the files and folders of the selected item by the user. And now I want to create a panel as of finders but I am not able to identify the controls of it like inside the disclosure triangle it is showing a table view for sharing and permissions option. So can you help me in sorting out the problem that how can I add the table inside the disclosure triangle. Thanks and Regards, Ankur Singhal -Original Message- From: Kyle Sluder [mailto:kyle.slu...@gmail.com] Sent: Monday, March 23, 2009 11:50 Morning To: Ankur Singhal Cc: cocoa-dev@lists.apple.com Subject: Re: Creating UI for as of Get Info Panel We have no idea what file you want to Get Info on, or whether you want to make your own Get Info panel or use the Finder's. For all I know this is a Get Info window in a custom application that has no relation to files on disk besides bearing the same name. http://www.whathaveyoutried.com We will not write your application for you via e-mail. --Kyle Sluder DISCLAIMER == This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. ___ 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/florian.soenens%40nss.be This email sent to florian.soen...@nss.be Looking for Web-to-Print Solutions? Visit our website : http://www.vit2print.com This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information and/or information protected by intellectual property rights. If you are not the intended recipient, please note that any review, dissemination, disclosure, alteration, printing, copying or transmission of this e-mail and/or any file transmitted with it, is strictly prohibited and may be unlawful. If you have received this e-mail by mistake, please immediately notify the sender and permanently delete the original as well as any copy of any e-mail and any printout thereof. We may monitor e-mail to and from our network. NSS nv Tieltstraat 167 8740 Pittem Belgium DISCLAIMER == This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Custom NSScroller ...
Hi, Can anyone recommend any open source projects that implement a custom NSScroller, perhaps using images ? I'd like to have a look at some examples of how this is achieved as I've had no luck so far, going it alone. What I'm looking to achieve is the look feel of the new iTunes scroller, but without the buttons, much like on the search results in the popular app Coversutra. Thanks -Mic ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
How to draw text with expanded inter-character spacing
I would like to draw some text into my custom view wider than usual but not by stretching the glyphs using a transformation but by increasing the spacing between the glyphs (like in Font Character Spacing Spacing Expanded/Condensed in MS Word). Is there an attribute for an NSAttributedString like kATSUAfterWithStreamShiftTag was in ATSUI or any other way to do that? Thanks, Geza ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Are NSNumber objects some kind of numeric literals
Hi, I noticed that NSNumber objects with the same value are all have the same address. But since they are created at runtime they must all be held in a big container - or am I mistaken? Thanks in advance Horst ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSAppleScript - what is going on here?
On Mar 23, 2009, at 12:19 AM, Adam R. Maxwell wrote: Using the MDItem C API had none of the AppleScript/Apple event problems, and was a small fraction of the code. On the other hand, MDItem will probably fail if the file is on a volume for which Spotlight is disabled or its index isn't up-to-date. --Michael ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Are NSNumber objects some kind of numeric literals
Le 23 mars 09 à 14:25, Horst Jäger a écrit : Hi, I noticed that NSNumber objects with the same value are all have the same address. But since they are created at runtime they must all be held in a big container - or am I mistaken? Thanks in advance Horst Only commonly used values are cached (integer with a value some threshold). Anyway this is an implementation details and you should neither rely on this nor have to worry about how the system choose to cached them. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Core Animation slow down
preHi all. I had some previous questions about Core Animation, this is not related to that at all (so don't take the previously mentioned code and methods into consideration). /prepreI have a transparent window, in which I create a view, and a root layer, and from then on just create and manage sublayers directly (code for that below).nbsp;/prepreMy problem is when I first run the app, it's very smooth (looking like 60fps). But when I leave it running for a while (sometimes after a couple of minutes, sometimes nbsp;after half an hour) it slows down, really really down (e.g. roughly 1fps)./preprenbsp;/prepreMy setup is very simple: I am setting up a timer: [NSTimer scheduledTimerWithTimeInterval:5nbsp;target:selfnbsp;selector:@selector(animateFired:)nbsp;userInfo:nilnbsp;repeats:YES];nbsp;/prepreanimateFired does nothing other than applies simple random implicit animation to a couple of layers (rotation, position, scale etc)./prepreMy CALayers are are drawn via delegates which load (in the delegate init) and display PDF content (in the drawLayer - code below)./prepreI can see from the console that the drawLayer is only being called once (during app init) as expected./prepreI have no other code running and have no leaks (nothing is allocated after init methods, the only code that runs is the timer callback which simply sets layer properties). /preprenbsp;/prepreI cannot understand why this slow down is, and why sometimes it's after a couple minutes, and sometimes comes in a lot later.nbsp;/prepreAlso this does not happen on my dev machine, but 3 other machines I've tested on (which all have similar but slightly lower spec)./prepreI am about to install xcode on the other machines as well, but was wondering if I am missing anything (e.g. about window/view creation, other deep system issues I need to care about. )?/preprenbsp;/preprewindow amp; view creation:/prep style=font: normal normal normal 10px/normal Monaco; margin: 0px- (span style=color: #aa0d91void/span)applicationDidFinishLaunching:(span style=color: #5c2699NSNotification/span*)aNotification {/pp style=font: normal normal normal 10px/normal Monaco; color: #c41a16; margin: 0pxspan style=color: #00span class=Apple-tab-span style=white-space: pre /span/spanspan style=color: #2e0d6eNSLog/spanspan style=color: #00(/span@quot;applicationDidFinishLaunchingquot;span style=color: #00);/span/pp style=font: normal normal normal 10px/normal Monaco; color: #2e0d6e; margin: 0pxspan style=color: #00span class=Apple-tab-span style=white-space: pre /span[[/spanspan style=color: #3f6e74TransparentWindow/spanspan style=color: #00 /spanallocspan style=color: #00] /spanspan style=color: #26474binitWithContentRect/spanspan style=color: #00:[[/spanspan style=color: #5c2699NSScreen/spanspan style=color: #00 /spanmainScreenspan style=color: #00] /spanvisibleFramespan style=color: #00]];/span/ppre}nbsp;/prep style=font: normal normal normal 10px/normal Monaco; margin: 0px-(span style=color: #aa0d91id/span) initWithContentRect:(span style=color: #5c2699NSRect/span)windowRect {/pp style=font: normal normal normal 10px/normal Monaco; color: #c41a16; margin: 0pxspan style=color: #00span class=Apple-tab-span style=white-space: pre /span/spanspan style=color: #2e0d6eNSLog/spanspan style=color: #00(/span@quot;TransparentWindow::initWithContentRectquot;span style=color: #00);/span/pp style=font: normal normal normal 10px/normal Monaco; color: #2e0d6e; margin: 0pxspan style=color: #00span class=Apple-tab-span style=white-space: pre /span/spanspan style=color: #aa0d91if/spanspan style=color: #00(/spanspan style=color: #aa0d91self/spanspan style=color: #00 = [/spanspan style=color: #aa0d91super/spanspan style=color: #00 /spaninitWithContentRectspan style=color: #00:windowRect /spanstyleMaskspan style=color: #00:/spanNSBorderlessWindowMaskspan class=Apple-style-span style=color: #00nbsp;/spanbackingspan style=color: #00:/spanNSBackingStoreBufferedspan style=color: #00 /spandeferspan style=color: #00:/spanspan style=color: #aa0d91NO/spanspan style=color: #00]) {/span/pp style=font: normal normal normal 10px/normal Monaco; color: #2e0d6e; margin: 0pxspan style=color: #00span class=Apple-tab-span style=white-space: pre /span[/spanspan style=color: #aa0d91self/spanspan style=color: #00 /spansetOpaquespan style=color: #00:/spanspan style=color: #aa0d91NO/spanspan style=color: #00];/span/pp style=font: normal normal normal 10px/normal Monaco; color: #2e0d6e; margin: 0pxspan style=color: #00span class=Apple-tab-span style=white-space: pre /span[/spanspan style=color: #aa0d91self/spanspan style=color: #00 /spansetBackgroundColorspan style=color: #00:[/spanspan style=color: #5c2699NSColor/spanspan style=color: #00 /spanclearColorspan style=color: #00]];nbsp;/span/pp style=font: normal normal normal 10px/normal Monaco; color:
Re: NSAppleScript - what is going on here?
On Mar 23, 2009, at 6:28 AM, Michael Tsai wrote: On Mar 23, 2009, at 12:19 AM, Adam R. Maxwell wrote: Using the MDItem C API had none of the AppleScript/Apple event problems, and was a small fraction of the code. On the other hand, MDItem will probably fail if the file is on a volume for which Spotlight is disabled or its index isn't up-to-date. Thanks for pointing that out; I just wrote a quick test and it does fail on my iDisk. Good thing I don't need it now that NSFileManager doesn't strip Finder comments... If anyone wants the Apple event version, let me know and I'll dig it up from svn history; it's an order of magnitude faster than using AppleScript. smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSObliquenessAttributeName, labelFontOfSize, Italic
I found this old thread: http://lists.apple.com/archives/Cocoa-dev/2007/Jan/msg00181.html which discusses the same problem I am experiencing. I need an italic version of Lucida Grande, which is the font currently returned by labelFontOfSize. But, of course, I need a generic solution since labelFontOfSize may not always return Lucida Grande. Now, I could select a font like Helvetica Neue which has all of the various traits I need, but I would rather use the font returned by labelFontOfSize since I am drawing a label. The solution proposed in the thread was to just add NSObliquenessAttributeName, which is easy enough, but I am not sure what the appropriate angle should be. Is there a standard angle which should be used in this situation? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Custom NSScroller ...
Here's some code for a scroller without arrow buttons: http://bitbucket.org/bwalkin/bwtoolkit/src/tip/BWTransparentScroller.m Cheers, Brandon On 23-Mar-09, at 9:14 AM, Mic Pringle wrote: Hi, Can anyone recommend any open source projects that implement a custom NSScroller, perhaps using images ? I'd like to have a look at some examples of how this is achieved as I've had no luck so far, going it alone. What I'm looking to achieve is the look feel of the new iTunes scroller, but without the buttons, much like on the search results in the popular app Coversutra. Thanks -Mic ___ 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/bwalkin%40gmail.com This email sent to bwal...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Stop NSScrollView from catching scroll events.
On Mon, Mar 23, 2009 at 3:46 AM, Ben Lachman blach...@mac.com wrote: I have a tableview that's neatly wrapped in a scroll view by IB. I manually resize the scrollview whenever a row is added to the tableview so that all the row are always visible. Thus I basically don't need a scroll view. However even though it can't actually scroll the tableview it still eats scroll events when the mouse is over it. I tried ripping the tableview out of the scroll view programatically, but that didn't yield useable results. Is there a straight forward way to have a scroll view pass scroll events on up the responder chain? Just subclass NSScrollView, and override -scrollWheel: to call directly through to NSResponder's implementation and bypass NSScrollView's implementation. 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 arch...@mail-archive.com
Re: Core Animation slow down
Resending this because my browser messed up the formatting, apologies Hi all. I had some previous questions about Core Animation, this is not related to that at all (so don't take the previously mentioned code and methods into consideration). I have a transparent window, in which I create a view, and a root layer, and from then on just create and manage sublayers directly (code for that below). My problem is when I first run the app, it's very smooth (looking like 60fps). But when I leave it running for a while (sometimes after a couple of minutes, sometimes after half an hour) it slows down, really really down (e.g. roughly 1fps). My setup is very simple: I am setting up a timer: [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(animateFired:) userInfo:nil repeats:YES]; animateFired does nothing other than applies simple random implicit animation to a couple of layers (rotation, position, scale etc). My CALayers are are drawn via delegates which load (in the delegate init) and display PDF content (in the drawLayer - code below). I can see from the console that the drawLayer is only being called once (during app init) as expected. I have no other code running and have no leaks (nothing is allocated after init methods, the only code that runs is the timer callback which simply sets layer properties). I cannot understand why this slow down is, and why sometimes it's after a couple minutes, and sometimes comes in a lot later. Also this does not happen on my dev machine, but 3 other machines I've tested on (which all have similar but slightly lower spec). I am about to install xcode on the other machines as well, but was wondering if I am missing anything (e.g. about window/view creation, other deep system issues I need to care about. )? Creating window and view: - (void)applicationDidFinishLaunching:(NSNotification*)aNotification { NSLog(@applicationDidFinishLaunching); [[TransparentWindow alloc] initWithContentRect:[[NSScreen mainScreen] visibleFrame]]; } -(id) initWithContentRect:(NSRect)windowRect { NSLog(@TransparentWindow::initWithContentRect); if(self = [super initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) { [self setOpaque:NO]; [self setBackgroundColor:[NSColor clearColor]]; [self setMovableByWindowBackground:NO]; [self makeKeyAndOrderFront:nil]; [self setAcceptsMouseMovedEvents:YES]; [self setContentView:[[[NSView alloc] initWithFrame:NSMakeRect(0, 0, windowRect.size.width, windowRect.size.height)] autorelease]]; } NSLog(@/TransparentWindow::initWithContentRect); return self; } Creating root layer: NSSize windowSize = [[NSApplication sharedApplication] keyWindow].frame.size; rootView= [[[NSApplication sharedApplication] keyWindow] contentView]; rootView.wantsLayer = YES; CATransform3D sublayerTransform = CATransform3DMakeTranslation(windowSize.width/2, windowSize.height/2, 0); // offset (0, 0) to center of layer sublayerTransform.m34 = -.0003; // perspective. bigger is more rootView.layer.sublayerTransform= sublayerTransform; CALayer Delegate drawRect: -(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context { NSLog(@PDFLayerDelegate::drawLayer %@, filename); CGAffineTransform m = CGPDFPageGetDrawingTransform(page, kCGPDFArtBox, CGContextGetClipBoundingBox(context), 0, NO); CGContextSaveGState(context); CGContextConcatCTM(context, m); CGContextClipToRect(context, CGPDFPageGetBoxRect(page, kCGPDFArtBox));// 4 CGContextDrawPDFPage(context, page); CGContextRestoreGState(context); } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: De-Mystifying NSCell
I put together a short video to try to explain the rationale and mechanisms of NSCell: http://www.cs.loyola.edu/~ksluder/NSCell.mov . If you're confused about why NSCell exists and how it's used inside NSTableView, I hope that my video is able to shine a bit of light. That was fantastic!! I really appreciated it. Todd ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: nstableview **very** basic question
On Mar 21, 2009, at 9:24 PM, Jerry Krinock wrote: On 2009 Mar 21, at 14:27, Michael wrote: I cannot get tableview to show columns of constant width. [tv sizeToFit]; What I get when I use the above code is the first couple of columns varying in size, then the next n columns equally space. If I have missed something in the documentation, Maybe you have. The documentation for -[NSTableView sizeToFit] says: All columns are resized to the same size, up to a column's maximum size. Yes...I did see that, but I read it slightly differently. I read it to mean that the receiver's columns will be set equal to one another up to the max size. I assumed that tableview would know the max width of the view and calculate the widths accordingly. What I was getting was unequal widths. H. What are your columns' maximum sizes? These can be set in Interface Builder, but to find out for sure, try something like this: There were some **very** weird max widths!! :-) which may have played a role here..widths with integers in the 20 to 30 figures long!! Eg (340282306073709652508363335590014353408.00) I got it to work as I expected it by doing what you suggested...I think. ie setting each column to the same max width... Thank you ...appreciated. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
IB instantiating objects
I'm working on developing a Pascal Objective-C bridge like RubyObjc and have run across a problem I can't seem to work around with IB. I very new to Cocoa btw, so I hope this makes sense. Maybe I'm asking in the wrong place also. ;) I have noticed that when a nib is loaded it must allocate an instance of the class that I added to the nib and when actions are sent to their target (by dragging connections to that class), THAT instance is used as the self parameter (the first) in the Pascal function (this parameter is hidden in Objective-C code). That means I have no opportunity to set an instance variable that contains a reference to the Pascal object, and thus access it's instance variables and methods. Is there anyone who is aware how this was accomplished by the other bridges or if I can force IB to not instantiate the classes, or maybe replace the instance with my own? It seems like I need a way to access the instances of those classes inside the nib but I don't think that can be done. Any ideas are greatly appreciated. Thank you. Regards, Josef ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Small app does not get keyboard events for alert sheet
Hello all, we have problem with a minimalistic application that opens standard alert sheet. The code looks like this: int main(int ac, char *av[]) { NSApplication *app=[NSApplication sharedApplication]; // tried to send activateIgnoringOtherApps:YES, in vain NSRect frame=NSMakeRect(100,100,600,400); NSWindow *win=[[NSWindow alloc] initWithContentRect:frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreRetained defer:NO]; [win setAlphaValue:0]; // we don't want to show the window--it's just the sheet base [win setLevel:NSNormalWindowLevel+1]; [win orderFrontRegardless]; NSBeginAlertSheet(@..., nil, nil, nil, win, nil, NULL, NULL, NULL, @...); [app runModalForWindow:[win attachedSheet]]; return 0; } The application correctly opens alert sheet but does not get any keyboard actions nor events — they are still sent to previous open app. Nevertheless, sheet could be closed by mouse. We also try to use NSRunAlertPanel with the same output, so we suspect the problem is on the Window Server side (or between WS and our app). This did not help either: @implementation Delegate:NSObject +(void)applicationDidFinishLaunching:(NSNotification*)dummy { NSRect frame=NSMakeRect(100,100,600,400); NSWindow *win=[[NSWindow alloc] initWithContentRect:frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreRetained defer:NO]; [win setAlphaValue:0]; // we don't want to show the window--it's just the sheet base [win setLevel:NSNormalWindowLevel+1]; [win orderFrontRegardless]; [NSApp activateIgnoringOtherApps:YES]; NSBeginAlertSheet(@..., nil, nil, nil, win, self, NULL, @selector(done), NULL, @...); } +(void)done { [NSApp terminate:self]; } @end int main(int ac,char *av[]) { NSApplication *app=[NSApplication sharedApplication]; [app setDelegate:[Delegate class]]; [app run]; return 0; } Does anyone know, where could be problem or what do we wrong? Thanks! Tom -- Tomáš Kolář to...@audiffex.com Audiffex - Audio Effects Applications www.audiffex.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
How to implement quick-playing and slow-playing of sound file?
Hi All, I am developing an application which implement the playing of sound file. Now I want to change the rate of the sound when it is playing.In other words ,I want to implement quick-playing and slow-playing of the sound file.Is there any API for the function? Or can any one tell me any clue about it. Please help me in solving this query. Any pointers would be appreciated. Thanks and Regards, Mac ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How can main thread be blocked in mach_msg_trap?
Thanks, guys. Michael, you almost nailed it by naming all of the stupid mistakes I could have made, but you left out one -- 5) You weren't invoking performSelectorOnMainThread::: but instead performSelector:onThread:::, and targetting a different thread (which does not have a run loop running). So the theory I stated in my first message, that mach_msg_trap means a waiting run loop, is a good one to trust. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to implement quick-playing and slow-playing of sound file?
On Mar 23, 2009, at 3:25 AM, ldl0313036 wrote: I am developing an application which implement the playing of sound file. Now I want to change the rate of the sound when it is playing.In other words ,I want to implement quick-playing and slow- playing of the sound file.Is there any API for the function? Or can any one tell me any clue about it. Please help me in solving this query. Any pointers would be appreciated. Look into QTKit and its documentation. There are ways to either change the rate (that's a good search keyword) or AudioUnits (via CoreAudio) to change the speed without bending the pitch. -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: De-Mystifying NSCell
VERY well done and informative. Thanks! Ken On Mar 23, 2009, at 3:10 AM, Kyle Sluder wrote: Hi all, I've noticed recently a few people have posted to the list in a state of uncertainty regarding NSCell, particularly in the context of NSTableView. I was in much the same boat when I started out with Cocoa; it takes a few runs through it before the scheme starts to make sense. I put together a short video to try to explain the rationale and mechanisms of NSCell: http://www.cs.loyola.edu/~ksluder/NSCell.mov . If you're confused about why NSCell exists and how it's used inside NSTableView, I hope that my video is able to shine a bit of light. If not, I hope I don't confuse you even more. If you like or dislike the video, please do let me know. Thanks, --Kyle Sluder -- Ken Worley Software Engineer, Tiberius, 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 arch...@mail-archive.com
Re: Memory leak when setting CALayer name
On Mar 22, 2009, at 4:19 AM, Gustavo Pizano wrote: So how come Im applying the M.M rules wrongly, what am I missing? :(. If your applying the memory management rules correctly and your still leaking, then there is probably a bug. You should file one at http://bugreporter.apple.com/ with a reproducible case so that it can be fixed in the future. -- David Duncan Apple DTS Animation and Printing ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSString and Leaks Instrument, False Positives?
Thanks Bill, I've reported the problem to bugreporter (#6710982). Thanks for helping figure it out! Kevin On Mar 21, 2009, at 5:33 PM, Bill Bumgarner wrote: On Mar 21, 2009, at 5:09 PM, Kevin Ross wrote: KRStarChartMO drawPortentsInRect:circleStyle:] | +[NSFont fontWithName:size:] | __NSFontFactoryWithName | + [__NSFontTypefaceInfo typefaceInfoForPostscriptName:] | TDescriptor::CreateMatchingDescriptorInternal(__CFSet const*) const | TDescriptorSourceImp ::CopyFontDescriptorPerPostscriptName(__CFString const*, unsigned int) const | ATSFontFindFromPostScriptName | _eATSFontFindFromPostScriptName | _eATSSendFontQuery | CFStringCreateWithCString | __CFStringCreateImmutableFunnel3 | _CFRuntimeCreateInstance | malloc_zone_malloc That looks an awful lot like a leak in the ATS subsystem. File a bug via http://bugreport.apple.com/ and send me the #, please. 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 arch...@mail-archive.com
Custom windows -- just curious
Hi. Does anybody know how to make totally custom windows, such as the control window in DVD Player or the minimized iTunes window? As i said in the subject -- I am just curious. Timofey. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IB instantiating objects
On Mar 22, 2009, at 6:26 PM, Gmail wrote: Is there anyone who is aware how this was accomplished by the other bridges or if I can force IB to not instantiate the classes, or maybe replace the instance with my own? It seems like I need a way to access the instances of those classes inside the nib but I don't think that can be done. Any ideas are greatly appreciated. Thank you. RubyCocoa and PyObjC work by creating the class before the NIB is loaded.From your description, it sounds like your bridge doesn't support subclassing. If so, that'll make your bridge considerably more difficult to integrate with Cocoa. 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 arch...@mail-archive.com
Re: BOOL takeStupidRoad = NO (search app design question)
Then again, I guess I could use Spotlight to locate the proper files, and then focus on them for finding the position of the words and then getting the words around them for the snippets, etc. Exactly. However, for the amount of data you're talking about, just loading it up searching it is not unreasonable at all. -- Scott Ribe scott_r...@killerbytes.com 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 arch...@mail-archive.com
Re: MacRoman - UTF8 [solved]
On Sun, Mar 22, 2009 at 5:22 AM, Uli Kusterer witness.of.teacht...@gmx.net wrote: On 22.03.2009, at 12:22, Michael Ash wrote: On Sun, Mar 22, 2009 at 3:48 AM, Ben Lachman blach...@mac.com wrote: Just for the record, this was an issue with my HTTP content type settings and the charset that the input was encoded in, not any issue with NSString. Just a general request for the list here: could we not add [solved] to the topic when the problem is solved? It breaks threading and causes confusion. Just stick it into the original thread. The act of having solved the problem is not so significant that it needs to be made evident the moment we read the subject What mail app are you using? Apple Mail shows it just fine as part of the thread it was in. So do most other mail apps. There's a header in RFC822-style mail messages that indicates the thread, the subject doesn't even begin to figure into the equation. I agree, in principle. However, many popular e-mail clients *cough*Gmail*cough* are broken in this regard. That's why I tend to avoid changing the subject; out of courtesy to people using such clients. (and yes, I've complained to google many times about the fact that it ignores the references header.) -- Clark S. Cox III clarkc...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Custom windows -- just curious
On 23 Mar 2009, at 17:13:22, Тимофей Даньшин wrote: Hi. Does anybody know how to make totally custom windows, such as the control window in DVD Player or the minimized iTunes window? As i said in the subject -- I am just curious. Timofey. Override -initWithContentRect:styleMask:backing:defer: to change the styleMask to NSBorderlessWindowMask.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to get a scroll view to recognize overflow on a custom view?
On Mar 23, 2009, at 02:33, Ken Tozier wrote: The new issue though is that when I set the size of the content view (document view?) the scroller's size changes to the new size of the content. I've checked and rechecked to make sure all the autosize parts are set up in IB correctly, but no matter what I do, I can't both set the size of the scroller content view and preserve the frame of the scroll view. At this point, step 1 is probably to log the frame rects of the scroll view, clip view and document/content view after the resize is finished, and find out for sure which one is wrong. Step 2 could be to register to receive frame-changed notifications from each of the views, and watch the sequence of changes to see where it goes wrong. Chances are, things aren't happening in the order your code thinks they are. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to draw text with expanded inter-character spacing
On Mar 23, 2009, at 7:20 AM, Fabry, Geza wrote: I would like to draw some text into my custom view wider than usual but not by stretching the glyphs using a transformation but by increasing the spacing between the glyphs (like in Font Character Spacing Spacing Expanded/Condensed in MS Word). Is there an attribute for an NSAttributedString like kATSUAfterWithStreamShiftTag was in ATSUI or any other way to do that? I think what you want is to change the font tracking, but I don't think there is a way to do that easily (no public setting for it). You could try fiddling with font kerning, but that might have an inconsistent look. There is a font manager property called font trait, but I think that requires an actual font variant for condensed, expanded, etc. I don't know if it can be faked. You could fake it by inserting space characters of determined sizes, or scrap the text view do your own thing (which is likely what Word is doing). HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to implement quick-playing and slow-playing of sound file?
On Mar 23, 2009, at 1:23 PM, mm w wrote: Hello, it depends if you have time to learn, using AudioUnits is a long way to go before beeing statisfy, I don't know your background, I am only an hobbyist musician and doing hobbyist stuff with CoreAudio, for instance you have to learn to use AU Lab or create your testing View-tool, + do you use AUGraph? , + sure it depends on what kind of sound/music... CORRECTION You *do not* have to learn to use AU Lab merely to apply this effect. It is in fact trivial to add this very effect to a QTMovie by setting the QTMovieRateChangesPreservePitchAttribute attribute on the movie. You don't even have to deal directly with the AudioUnit behind it: [movie setAttribute:[NSNumber numberWithBool:YES] forKey:QTMovieRateChangesPreservePitchAttribute]; ... done. Now changing the movie's -rate will not bend the pitch (but will cause audio artifacts to occur - especially when slowing down - if the rate is too far positive or negative of 1.0. If this limitation is acceptable, you're all set. If not, *then* you'll have to drop down to CoreAudio and write your own (better) AudioUnit to do the same processing. While this isn't quite so easy to find (it takes a few minutes of searching and cross-referencing terms), you should always start with the highest level possible (in the case of multimedia, it's QTKit), and only work deeper (CoreAudio) if necessary. In this particular scenario, it happens to not be necessary. To Mac (the OP), I hope the above code is helpful, though you really should do the searching to familiarize yourself with the parts of the documentation that are relevant to this work. It'll help you in the future. META-DISCUSSION As you included me in your reply, mm w, I must assume you read my previous post, which mentioned this solution (while leaving the research to the OP), so I'm not sure what your post adds, besides confusion and misinformation. Considering yesterday's GC thread (especially your vague, unsubstantiated assertions) and a quick search of others like it in the archives, this appears to be a habit of yours. Please, out of respect for others' time (not to mention your own pubic image), take greater care in your responses and take the time to substantiate your assertions with references. You've not been careful lately and it's demonstrably caused needless confusion and noise. APOLOGIES Apologies to the list and especially to Scott [our moderator, who art in heaven], for whom this will undoubtedly create drama. This kind of help damages our community and we shouldn't tolerate it. -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to implement quick-playing and slow-playing of sound file?
On Mar 23, 2009, at 2:09 PM, I. Savant wrote: (not to mention your own pubic image) :-D Speaking of pub[l]ic images, this is without a doubt the funniest typo I've made in awhile. Ah, irony. It's even better than when I signed an e-mail with Retards instead of Regards. Apologies for any shock. ;-) -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: OpenGL Prog Guide for OSX - override initWithFrame
On Mar 23, 2009, at 2:51AM, Ian Jackson wrote: I have an OpenGL view as a subclass of NSView. Trying to follow the OpenGL Programming Guide for Mac OS X, I created all the methods described in the Drawing to a Cocoa View section. The thing I don't quite understand is that it says to override the initWithFrame: method of the NSView class, but the sample code describes a initWIthFrame:pixelFormat: method. I initially more or less cobbled all the sample code together in my custom OpenGL view, so that the initWithFrame:pixelFormat: method was included as it is in the guide. However, there is no initWithFrame:pixelFormat method in NSView, so the method doesn't get called. I now override the initWIthFrame method, and include: _pixelFormat = [[[self class] defaultPixelFormat] retain]; but, I'd like to know what the document actually intends. The method -initWithFrame:pixelFormat: is found in NSOpenGLView not NSView. The inheritance hierarchy is NSOpenGLView : NSView : NSResponder : NSObject. Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSLevelIndicator Bindings Crash
I did some more looking and determined that it should be Item.selection.priority When i do this, however, every time I switch back to another item, the level defaults back to 1. Also, I checked that chapter in Hillegass's book, and it had an example where it used Car.selection.condition, so it seems that selection is the right controller key. The bindings in general are just really funky. I added a stepper and textbox in addition to the level indicator, and bound them to Item.selection.priority, and they too default back to 1 (the default value) every time I go to another item. The Item array controller's Content Set is bound to ItemsList.selection.Item That's the only binding, other than the managed object context. I really can't figure out what's causing this problem, which is annoying because I'm trying to focus on fixing this before I continue development. Thanks, - Walker Argendeli On Mar 22, 2009, at 10:05 AM, Richard Somers wrote: On Mar 21, 2009, at 3:41PM, Walker Argendeli wrote: I'm using Core Data, and I have an entity; we'll call it Item. It has an attribute called priority. In the xib, I have an NSLevelIndicator and NSStepper. I have a NSTableView full of Items. Depending on which item is selected in the table view, I want the level indicator and stepper to display the right values, and for me to be able to set them to a certain value for each item. There are 2 problems: If I bind the value of either one to Item.arrangedObjects.priority, the app throws an exception, whereas if I bind to Item.selection.priority, the controls don't set each item's priority individually. What should I bind to? Secondly, an NSLevelIndicator wants a float for its value, whereas an NSStepper wants a double for its value. Which should I set it to in the core data model? Cocoa Programming for Mac OS X Third Edition by Arron Hillegass Chapter 11, Basic Core Data, pages 171-182 has a NSLevelIndicator. This chapter might shed some light on your problem. Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: MacRoman - UTF8 [solved]
On 3/22/09 4:29 PM, Peter Duniho said: Of particular note is Apple's own mail archive for the mailing list. Maybe they've fixed it recently... Apple's archives are not a nice as cocoabuilder's (which I highly recommend), which seems to thread correctly even if the subject changes, see: http://www.cocoabuilder.com/archive/message/cocoa/2009/3/21/232818 (That said, I too would prefer the subjects not changing.) -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Key path for values in Shared User Defaults?
Please help me: What is the key path of a value stored in the shared user defaults? I'm using a sub-classed NSViewController to enhance the print panel with an accessory view: NSBundle *appBundle = [NSBundle bundleForClass:[self class]]; NSViewController *accessoryViewController = [[PrintOptions alloc] initWithNibName:@PrintOptions bundle:appBundle]; [[printOperation printPanel] addAccessoryController:accessoryViewController]; The view PrintOptions includes three checkboxes, all bind to the Shared User Defaults Controller. The printed view uses these values to modify its output. Everything works fine except the preview in the print panel: It isn't updated when I check / uncheck any of the boxes, although the view controller conforms to the NSPrintPanelAccessorizing protocol and should use KVO to be notified for changes. I think my keyPathsForValuesAffectingPreview implementation is wrong as I don't know how to reference a shared user default: - (NSSet *)keyPathsForValuesAffectingPreview { return [NSSet setWithObjects: @PrintFastMode, @PrintJumps, @PrintGrid, nil]; } The documentation I found only mentioned an example with document margins, but what is the key path for properties bind to the user defaults? Sorry, I'm totally lost ... Mattes ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSLevelIndicator Bindings Crash
On Mar 23, 2009, at 1:13 PM, Walker Argendeli wrote: When i do this, however, every time I switch back to another item, the level defaults back to 1. Also, I checked that chapter in Hillegass's book, and it had an example where it used Car.selection.condition, so it seems that selection is the right controller key. The bindings in general are just really funky. I added a stepper and textbox in addition to the level indicator, and bound them to Item.selection.priority, and they too default back to 1 (the default value) every time I go to another item. The Item array controller's Content Set is bound to ItemsList.selection.Item That's the only binding, other than the managed object context. I really can't figure out what's causing this problem, which is annoying because I'm trying to focus on fixing this before I continue development. Your descriptions make no sense. When referencing binding key paths, make them relative to the controller, and not to the model. I assume that when you say Item.arrangedObjects.priority you really mean NSARRAYCONTOLLER.arrangedObjects.priority. This is a critical distinction, as the two paths are nowhere near the same. Ok, so you have an entity Item, and you have an NSArrayController with Content Set bound to ItemsList.selection.Item. What is ItemsList, and why does it exist? What controller is providing content to the table view? Generally the proper approach is: 1. array controller with bound MOC that either performs its own fetch or is populated programmatically; 2. tableview bound (technically, columns are bound) to that array controller; 3. detail items (level indicator and stepper) bound to arraycontroller.selection.property (where arraycontroller is the controller specified in #1). That should be all there is to it. On Mar 22, 2009, at 10:05 AM, Richard Somers wrote: On Mar 21, 2009, at 3:41PM, Walker Argendeli wrote: I'm using Core Data, and I have an entity; we'll call it Item. It has an attribute called priority. In the xib, I have an NSLevelIndicator and NSStepper. I have a NSTableView full of Items. Depending on which item is selected in the table view, I want the level indicator and stepper to display the right values, and for me to be able to set them to a certain value for each item. There are 2 problems: If I bind the value of either one to Item.arrangedObjects.priority, the app throws an exception, whereas if I bind to Item.selection.priority, the controls don't set each item's priority individually. What should I bind to? Secondly, an NSLevelIndicator wants a float for its value, whereas an NSStepper wants a double for its value. Which should I set it to in the core data model? Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSLevelIndicator Bindings Crash
Yes, you're right, Item is an NSArrayController representing the entity Item. Sorry about that. ItemsList is an Entity and Array Controller representing an outline view of folders. Each folder can have multiple Items in it. Depending on which folder is selected in the ItemsList outline view, the right Items will appear in the Table view whose columns are bound to properties of the Item array controller. Depending on which item is selected in the Item tableview, the level indicator, which is bound to (the array controller) Item.selection.priority For some reason though, I get the odd behavior that follows: In the Item table view, if I have one item selected, then select a different one, that new Item will have the levelindicator defaulted back to 1, though it had been set to a different value previously. I hope that's not too confusing. Thanks - Walker Argendeli On Mar 23, 2009, at 3:55 PM, Keary Suska wrote: On Mar 23, 2009, at 1:13 PM, Walker Argendeli wrote: When i do this, however, every time I switch back to another item, the level defaults back to 1. Also, I checked that chapter in Hillegass's book, and it had an example where it used Car.selection.condition, so it seems that selection is the right controller key. The bindings in general are just really funky. I added a stepper and textbox in addition to the level indicator, and bound them to Item.selection.priority, and they too default back to 1 (the default value) every time I go to another item. The Item array controller's Content Set is bound to ItemsList.selection.Item That's the only binding, other than the managed object context. I really can't figure out what's causing this problem, which is annoying because I'm trying to focus on fixing this before I continue development. Your descriptions make no sense. When referencing binding key paths, make them relative to the controller, and not to the model. I assume that when you say Item.arrangedObjects.priority you really mean NSARRAYCONTOLLER.arrangedObjects.priority. This is a critical distinction, as the two paths are nowhere near the same. Ok, so you have an entity Item, and you have an NSArrayController with Content Set bound to ItemsList.selection.Item. What is ItemsList, and why does it exist? What controller is providing content to the table view? Generally the proper approach is: 1. array controller with bound MOC that either performs its own fetch or is populated programmatically; 2. tableview bound (technically, columns are bound) to that array controller; 3. detail items (level indicator and stepper) bound to arraycontroller.selection.property (where arraycontroller is the controller specified in #1). That should be all there is to it. On Mar 22, 2009, at 10:05 AM, Richard Somers wrote: On Mar 21, 2009, at 3:41PM, Walker Argendeli wrote: I'm using Core Data, and I have an entity; we'll call it Item. It has an attribute called priority. In the xib, I have an NSLevelIndicator and NSStepper. I have a NSTableView full of Items. Depending on which item is selected in the table view, I want the level indicator and stepper to display the right values, and for me to be able to set them to a certain value for each item. There are 2 problems: If I bind the value of either one to Item.arrangedObjects.priority, the app throws an exception, whereas if I bind to Item.selection.priority, the controls don't set each item's priority individually. What should I bind to? Secondly, an NSLevelIndicator wants a float for its value, whereas an NSStepper wants a double for its value. Which should I set it to in the core data model? Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSPredicate with non-string keys
Hi, I was wondering if anyone knows how to use NSPredicate on values with keys that are NSNumbers (or any non-NSString, for that matter). I've poured over the documentation and tried many things, from converting to a string to %K, %d, etc argument substitutions and nothing seems to work. If there's no way to do this, I've also tried ALLKEYS, but I can't get that to work either. Is this possible? If it matters, I'm just creating the predicate with predicateWithFormat: and sorting an array. Thanks in advance, Ben Einstein ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSPredicate with non-string keys
On Mon, Mar 23, 2009 at 5:03 PM, Ben Einstein beinst...@me.com wrote: I was wondering if anyone knows how to use NSPredicate on values with keys that are NSNumbers (or any non-NSString, for that matter). I've poured over the documentation and tried many things, from converting to a string to %K, %d, etc argument substitutions and nothing seems to work. Alphanumerics only, I'm afraid. Keypaths can't contain invalid keys, and numbers are not valid keys. If there's no way to do this, I've also tried ALLKEYS, but I can't get that to work either. Is this possible? If it matters, I'm just creating the predicate with predicateWithFormat: and sorting an array. Why aren't you using a sort descriptor? --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSPredicate with non-string keys
Sorry, typo, I meant FILTER an array. So is there any way to filter with numberic keys? I guess I could convert all they keys to strings? Urgh Is there any way to filter using all keys in a dictionary? Thanks for you help (so far!) Ben On Mar 23, 2009, at 5:13 PM, Kyle Sluder wrote: On Mon, Mar 23, 2009 at 5:03 PM, Ben Einstein beinst...@me.com wrote: I was wondering if anyone knows how to use NSPredicate on values with keys that are NSNumbers (or any non-NSString, for that matter). I've poured over the documentation and tried many things, from converting to a string to %K, %d, etc argument substitutions and nothing seems to work. Alphanumerics only, I'm afraid. Keypaths can't contain invalid keys, and numbers are not valid keys. If there's no way to do this, I've also tried ALLKEYS, but I can't get that to work either. Is this possible? If it matters, I'm just creating the predicate with predicateWithFormat: and sorting an array. Why aren't you using a sort descriptor? --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Stop NSScrollView from catching scroll events.
On Mar 23, 2009, at 10:54 AM, Michael Ash wrote: On Mon, Mar 23, 2009 at 3:46 AM, Ben Lachman blach...@mac.com wrote: I have a tableview that's neatly wrapped in a scroll view by IB. I manually resize the scrollview whenever a row is added to the tableview so that all the row are always visible. Thus I basically don't need a scroll view. However even though it can't actually scroll the tableview it still eats scroll events when the mouse is over it. I tried ripping the tableview out of the scroll view programatically, but that didn't yield useable results. Is there a straight forward way to have a scroll view pass scroll events on up the responder chain? Just subclass NSScrollView, and override -scrollWheel: to call directly through to NSResponder's implementation and bypass NSScrollView's implementation. I was thinking this was easy, but now I'm not so sure. How do you call through to some arbitrary class in a class's inheritance chain? Thanks, -Ben ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Stop NSScrollView from catching scroll events.
On Mon, Mar 23, 2009 at 5:35 PM, Ben Lachman blach...@mac.com wrote: How do you call through to some arbitrary class in a class's inheritance chain? Typically, you don't. Just hand it off to super. NSView isn't declared to implement -scrollWheel:. If you *really* need to invoke a specific class's implementation of a method, use class_getInstanceMethod to get the method's implementation, and then just invoke that implementation: // Warning: written in mail client, YMMV etc. - (void)scrollWheel:(NSEvent *)theEvent { Method theMethod = class_getMethod([NSResponder class], @selector(scrollWheel:)); IMP theImpl = method_getImplementation(theMethod); (void (*) (id, SEL, NSEvent*))(theImpl)(self, @selector(scrollWheel:), theEvent); } --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Stop NSScrollView from catching scroll events.
On Mar 23, 2009, at 2:35 PM, Ben Lachman wrote: On Mar 23, 2009, at 10:54 AM, Michael Ash wrote: On Mon, Mar 23, 2009 at 3:46 AM, Ben Lachman blach...@mac.com wrote: I have a tableview that's neatly wrapped in a scroll view by IB. I manually resize the scrollview whenever a row is added to the tableview so that all the row are always visible. Thus I basically don't need a scroll view. However even though it can't actually scroll the tableview it still eats scroll events when the mouse is over it. I tried ripping the tableview out of the scroll view programatically, but that didn't yield useable results. Is there a straight forward way to have a scroll view pass scroll events on up the responder chain? Just subclass NSScrollView, and override -scrollWheel: to call directly through to NSResponder's implementation and bypass NSScrollView's implementation. I was thinking this was easy, but now I'm not so sure. How do you call through to some arbitrary class in a class's inheritance chain? It's definitely the way to do it. Just send it on to [self nextResponder]. that's all! corbin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSPredicate with non-string keys
On Mon, Mar 23, 2009 at 5:18 PM, Ben Einstein beinst...@me.com wrote: So is there any way to filter with numberic keys? I guess I could convert all they keys to strings? Urgh First, arrays don't have keys. I'm assuming you mean you need to filter the items based on values for keypaths off those objects. And no, numbers are not valid keys. Keys must begin with a lowercase letter: http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/BasicPrinciples.html#//apple_ref/doc/uid/20002170-183455 --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSPredicate with non-string keys
I'm filtering an array of dictionaries, my usual procedure for doing this is: NSPredicate *predicate = [NSPredicate predicateWithFormat:@MyKey CONTAINS[cd] %@, searchString]; NSArray *filteredArray = [[self dataArray] filteredArrayUsingPredicate:predicate]; So your comment about lowercase keys is only true for KVC compliance (filtering non-plist objects), not when filtering arrays of dictionaries, where numbers ARE valid keys. But NSPredicate doesn't seem to think so. Ben On Mar 23, 2009, at 5:48 PM, Kyle Sluder wrote: On Mon, Mar 23, 2009 at 5:18 PM, Ben Einstein beinst...@me.com wrote: So is there any way to filter with numberic keys? I guess I could convert all they keys to strings? Urgh First, arrays don't have keys. I'm assuming you mean you need to filter the items based on values for keypaths off those objects. And no, numbers are not valid keys. Keys must begin with a lowercase letter: http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/BasicPrinciples.html#/ /apple_ref/doc/uid/20002170-183455 --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Stop NSScrollView from catching scroll events.
On Mar 23, 2009, at 5:47 PM, Corbin Dunn wrote: On Mar 23, 2009, at 2:35 PM, Ben Lachman wrote: On Mar 23, 2009, at 10:54 AM, Michael Ash wrote: On Mon, Mar 23, 2009 at 3:46 AM, Ben Lachman blach...@mac.com wrote: I have a tableview that's neatly wrapped in a scroll view by IB. I manually resize the scrollview whenever a row is added to the tableview so that all the row are always visible. Thus I basically don't need a scroll view. However even though it can't actually scroll the tableview it still eats scroll events when the mouse is over it. I tried ripping the tableview out of the scroll view programatically, but that didn't yield useable results. Is there a straight forward way to have a scroll view pass scroll events on up the responder chain? Just subclass NSScrollView, and override -scrollWheel: to call directly through to NSResponder's implementation and bypass NSScrollView's implementation. I was thinking this was easy, but now I'm not so sure. How do you call through to some arbitrary class in a class's inheritance chain? It's definitely the way to do it. Just send it on to [self nextResponder]. that's all! Ah! Thanks Corbin. Thats the right (and easy) way to do it. For the record, this works too (and supports tiger, I'm not sure if Kyle's code does): - (void)scrollWheel:(NSEvent *)theEvent { void (*responderScroll)(id, SEL, id); responderScroll = (void (*)(id, SEL, id))([NSResponder instanceMethodForSelector:@selector(scrollWheel:)]); responderScroll(self, @selector(scrollWheel:), theEvent); } Cheers, -Ben ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Limiting number of characters per line in a NSTextView
On 18 Mar 09, at 13:32, Martin Wierschin wrote: I want my NSTextView to show only 32 characters per line and the 33rd character should be shown at next line of textview. My NSTextView will have fixed font. If your font is truly fixed width, you can probably just set the NSTextView frame so it exactly fits 32 characters on a line... This approach won't behave correctly when character substitution is applied (for characters that aren't in the target font). Depending on the situation this may or may not be an issue. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: De-Mystifying NSCell
That is really excellent. (must have taken a long time to make) I wish there were more videos like that. I'd learn a lot faster. David On Mon, Mar 23, 2009 at 7:10 PM, Kyle Sluder kyle.slu...@gmail.com wrote: Hi all, I've noticed recently a few people have posted to the list in a state of uncertainty regarding NSCell, particularly in the context of NSTableView. I was in much the same boat when I started out with Cocoa; it takes a few runs through it before the scheme starts to make sense. I put together a short video to try to explain the rationale and mechanisms of NSCell: http://www.cs.loyola.edu/~ksluder/NSCell.mov . If you're confused about why NSCell exists and how it's used inside NSTableView, I hope that my video is able to shine a bit of light. If not, I hope I don't confuse you even more. If you like or dislike the video, please do let me know. Thanks, --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/david%40yamartino.com This email sent to da...@yamartino.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Remove action on NSArrayController bound to table causes index beyond bounds
I have a table bound to an NSArrayController that provides content from Core Data. This has been pretty trouble-free except that the hook up that removes the selected object/row (currently a 'minus' button under the table that uses the remove action on the controller) appears to cause an exception intermittently. The problem manifests as an index out of bounds exception (and often a subsequent CoreData error, though I think this is likely a knock-on effect). *** -[NSCFArray objectAtIndex:]: index (8) beyond bounds (8) 2009-03-23 16:17:46.118 App[17940:817] *** -[NSCFArray objectAtIndex:]: index (8) beyond bounds (8) 2009-03-23 16:17:46.132 App[17940:817] CoreData could not fulfill a fault for '0x1a57a90 x-coredata://BD1062B2-D44E-478E-8FBD-B6C62B95575F/MyManagedObject/p558 Here's the stack trace at the point the exception is raised, with the array controller's 'remove' still visible at the bottom. #0 0x93ed2c26 in -[NSException raise] #1 0x964f7571 in -[NSTableBinder _updateSelectionIndexes:] #2 0x964f6caf in -[NSTableBinder _observeValueForKeyPath:ofObject:context:] #3 0x964f69a9 in -[NSTableBinder observeValueForKeyPath:ofObject:change:context:] #4 0x94f66b0e in NSKVONotify #5 0x94ef70a5 in -[NSObject(NSKeyValueObservingPrivate) _notifyObserversForKeyPath:change:] #6 0x962d570a in -[NSController _notifyObserversForKeyPath:change:] #7 0x962d560b in -[NSController didChangeValueForKey:] #8 0x964f1920 in -[NSArrayController didChangeValuesForArrangedKeys:objectKeys:indexKeys:] #9 0x96690bb6 in -[NSArrayController _removeObjectAtArrangedObjectIndex:objectHandler:] #10 0x9668cd95 in -[NSArrayController removeObjectAtArrangedObjectIndex:] #11 0x9668d4ff in -[NSArrayController remove:] ... Now, the circumstance in which this occurs _appears_ to involve a boundary condition. If the deletion of the row is just about to cause the number of items in the table to fit vertically in the view (i.e. vertical scroll bar will disappear), then the exception can occur. I need to continue testing, but at the moment I'm confident in saying that this is a strong correlation. It may be causation. In the absence of this condition I appear to be able to add and delete items/rows quite happily using the array controller actions. At present, the array controller is configured for single selection and to preserve selection (I have tried turning the latter off, to no effect). I think I've seen some discussion in the list archives that may be related (index out of bounds when removing from a table), but I haven't read anything that gives me a bead on what to investigate next. Does anyone recognise these set of circumstances, or have any insight to why NSTableBinder's _updateSelectionIndexes might be getting upset? When the problem is not induced, the selected row correctly disappears and the table is left with no selection (which is allowed/ intended), so I'm not sure why the apparent reconfiguration of the view in its scroll view would have any different effect. However, as a rough guess it looks like something hasn't been updated with the new extent of the row indices in this case. -- 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 arch...@mail-archive.com
Re: Remove action on NSArrayController bound to table causes index beyond bounds
On Mar 23, 2009, at 7:52 PM, Luke Evans wrote: *** -[NSCFArray objectAtIndex:]: index (8) beyond bounds (8) 2009-03-23 16:17:46.118 App[17940:817] *** -[NSCFArray objectAtIndex:]: index (8) beyond bounds (8) 2009-03-23 16:17:46.132 App[17940:817] CoreData could not fulfill a fault for '0x1a57a90 x-coredata://BD1062B2-D44E-478E-8FBD-B6C62B95575F/MyManagedObject/p558 Did you try googling the CoreData error message you pasted? One result comes from this very list's archives: http://www.cocoabuilder.com/archive/message/cocoa/2005/5/12/135677 http://archives.devshed.com/forums/bsd-93/coredata-could-not-fulfill-a-fault-411453.html Check your Managed Object Model. You most likely have a relationship problem. Specifically, scrutinize your deletion rules on all relationships. -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSPredicate with non-string keys
On Mon, Mar 23, 2009 at 2:53 PM, Ben Einstein beinst...@me.com wrote: I'm filtering an array of dictionaries, my usual procedure for doing this is: NSPredicate *predicate = [NSPredicate predicateWithFormat:@MyKey CONTAINS[cd] %@, searchString]; NSArray *filteredArray = [[self dataArray] filteredArrayUsingPredicate:predicate]; So your comment about lowercase keys is only true for KVC compliance (filtering non-plist objects), NSPredicate *uses* KVC to fetch the values to test. So, the keys/keypaths you use therewith should be valid KVC keys. Therefore, the Keys must use ASCII encoding, begin with a lowercase letter, and may not contain whitespace. holds here as well. not when filtering arrays of dictionaries, where numbers ARE valid keys. But NSPredicate doesn't seem to think so. Numbers are never valid KVC keys. On Mar 23, 2009, at 5:48 PM, Kyle Sluder wrote: On Mon, Mar 23, 2009 at 5:18 PM, Ben Einstein beinst...@me.com wrote: So is there any way to filter with numberic keys? I guess I could convert all they keys to strings? Urgh First, arrays don't have keys. I'm assuming you mean you need to filter the items based on values for keypaths off those objects. And no, numbers are not valid keys. Keys must begin with a lowercase letter: http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/BasicPrinciples.html#//apple_ref/doc/uid/20002170-183455 --Kyle Sluder -- Clark S. Cox III clarkc...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: BOOL takeStupidRoad = NO (search app design question)
Yes, thank you. So that's how I'll proceed. David -- On Tue, Mar 24, 2009 at 3:18 AM, Scott Ribe scott_r...@killerbytes.comwrote: Then again, I guess I could use Spotlight to locate the proper files, and then focus on them for finding the position of the words and then getting the words around them for the snippets, etc. Exactly. However, for the amount of data you're talking about, just loading it up searching it is not unreasonable at all. -- Scott Ribe scott_r...@killerbytes.com 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 arch...@mail-archive.com
Re: IB instantiating objects
NO, it supports subclassing. Do you know what method I could override (and return my instance) before the NIB is loaded so I can control it's isntance variables? I think maybe a low-level protocol like init could perhaps work. Thanks. On Mar 24, 2009, at 12:15 AM, Bill Bumgarner wrote: On Mar 22, 2009, at 6:26 PM, Gmail wrote: Is there anyone who is aware how this was accomplished by the other bridges or if I can force IB to not instantiate the classes, or maybe replace the instance with my own? It seems like I need a way to access the instances of those classes inside the nib but I don't think that can be done. Any ideas are greatly appreciated. Thank you. RubyCocoa and PyObjC work by creating the class before the NIB is loaded.From your description, it sounds like your bridge doesn't support subclassing. If so, that'll make your bridge considerably more difficult to integrate with Cocoa. b.bum Regards, Josef ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
-hexValue for NSString?
In NSString theres -intValue, -floatValue, -doubleValue, but no - hexValue (that I can find). I'd like to convert ascii hex NSStrings (@001A4CD3 etc) into integer values. Having a -hexValue method would make that a snap. If theres no Cocoa way, I guess I could try my hand at writing a category(?) method on NSString using sscanf with %x. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IB instantiating objects
Hey Josef - When IB instantiates an object in a NIB file that has the custom class set, it will instantiate it with either init, initWithFrame:, or initWithCoder: depending on the type of object. Here's a link tot he relevant documentation: http://developer.apple.com/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#//apple_ref/doc/uid/1051i-CH4-SW19 Jon Hess On Mar 23, 2009, at 5:36 PM, Gmail wrote: NO, it supports subclassing. Do you know what method I could override (and return my instance) before the NIB is loaded so I can control it's isntance variables? I think maybe a low-level protocol like init could perhaps work. Thanks. On Mar 24, 2009, at 12:15 AM, Bill Bumgarner wrote: On Mar 22, 2009, at 6:26 PM, Gmail wrote: Is there anyone who is aware how this was accomplished by the other bridges or if I can force IB to not instantiate the classes, or maybe replace the instance with my own? It seems like I need a way to access the instances of those classes inside the nib but I don't think that can be done. Any ideas are greatly appreciated. Thank you. RubyCocoa and PyObjC work by creating the class before the NIB is loaded.From your description, it sounds like your bridge doesn't support subclassing. If so, that'll make your bridge considerably more difficult to integrate with Cocoa. b.bum Regards, Josef ___ 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/jhess%40apple.com This email sent to jh...@apple.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: -hexValue for NSString?
NSScanner has - (BOOL)scanHexInt:(unsigned *)value; // Optionally prefixed with 0x or 0X - (BOOL)scanHexLongLong:(unsigned long long *)result; so you can unsigned yourValueHere; BOOL success = [[NSScanner scannerWithString:string] scanHexInt:yourValueHere]; Ali On Mar 23, 2009, at 6:00 PM, Jonathon Kuo wrote: In NSString theres -intValue, -floatValue, -doubleValue, but no - hexValue (that I can find). I'd like to convert ascii hex NSStrings (@001A4CD3 etc) into integer values. Having a -hexValue method would make that a snap. If theres no Cocoa way, I guess I could try my hand at writing a category(?) method on NSString using sscanf with %x. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Simulating (or obtaining) menubar effect in a Cell
Hello all- I am working with an NSMatrix, and I would like one cell of the Matrix to act just like an item in the menu bar. Specifically: Single clicking should open a menu; holding the mouse down should open the menu and then close it when released; when selected the item should highlight/invert just like an item in the menubar. I have played with NSButtonCell, NSPopUpButtonCell, and other subclasses of NSCell, but I can¹t seem to hit on the right combination of options to replicate the behavior of a menubar item. Can anyone suggest the appropriate combination of elements that would achieve this effect? If it isn¹t possible to do ³out of the box², then suggestions for subclassing NSCell would be welcome. Thanks Tobias ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Small app does not get keyboard events for alert sheet
On Mar 23, 2009, at 1:03 AM, Tomas Kolar wrote: we have problem with a minimalistic application that opens standard alert sheet. [...] The application correctly opens alert sheet but does not get any keyboard actions nor events — they are still sent to previous open app. [...] Does anyone know, where could be problem or what do we wrong? This symptom is typical of trying to run an executable linked to AppKit (or Carbon) but not bundled into an application, with a proper Info.plist, etc. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IB instantiating objects
Thanks! I think that document explains everything I need to know to take control over IB. This is more Objective-C related by maybe you have a quick tip. My first tests suggest that my method for overriding is not correct because overriding init is getting invoked from all sorts of other classes (like NSFileManager to name a few) when the NIB is loading. I use class_getInstanceMethod (with the instance of the custom class I registered with the objective-c runtime) to get the method then replace the implementation with my function pointer. This method worked before for overriding drawRect: in NSView so I'm not sure what is different now. Any ideas? On Mar 24, 2009, at 8:02 AM, Jonathan Hess wrote: Hey Josef - When IB instantiates an object in a NIB file that has the custom class set, it will instantiate it with either init, initWithFrame:, or initWithCoder: depending on the type of object. Here's a link tot he relevant documentation: http://developer.apple.com/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#/ /apple_ref/doc/uid/1051i-CH4-SW19 Jon Hess On Mar 23, 2009, at 5:36 PM, Gmail wrote: NO, it supports subclassing. Do you know what method I could override (and return my instance) before the NIB is loaded so I can control it's isntance variables? I think maybe a low-level protocol like init could perhaps work. Thanks. On Mar 24, 2009, at 12:15 AM, Bill Bumgarner wrote: On Mar 22, 2009, at 6:26 PM, Gmail wrote: Is there anyone who is aware how this was accomplished by the other bridges or if I can force IB to not instantiate the classes, or maybe replace the instance with my own? It seems like I need a way to access the instances of those classes inside the nib but I don't think that can be done. Any ideas are greatly appreciated. Thank you. RubyCocoa and PyObjC work by creating the class before the NIB is loaded.From your description, it sounds like your bridge doesn't support subclassing. If so, that'll make your bridge considerably more difficult to integrate with Cocoa. b.bum Regards, Josef ___ 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/jhess%40apple.com This email sent to jh...@apple.com Regards, Josef ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
iPhone Tab bar Question
Hi All, I created a standard iPhone application using the built-in wizard and it builds and runs fine. My question is how do I modify the tab bar at the bottom to not make space for an image. I dont want to use images and I dont see how to adjust the height of the bar so I gain some extra space. Thoughts? -jason ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: -hexValue for NSString?
I think this should do the trick: @implementation NSString (HexIntValue) - (unsigned int)hexIntValue { NSScanner *scanner; unsigned int result; scanner = [NSScanner scannerWithString: self]; [scanner scanHexInt: result]; return result; } @end Note that I would expect -hexValue to be a method of NSNumber, that would return an NSString of the receiver's hex-value representation. I titled the method above 'hexValueInt' to more closely match NSString's -intValue, -floatValue, etc. David ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
XMLParser
I'm using an an NSXMLParser to parse a document. some of the elements are as follows: element property=valueSome Thing/element The problem is that I cannot seem to come up with the element's property. During the parse which callback is going to give me the property and it's value? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IB instantiating objects
On Mar 23, 2009, at 9:30 PM, Gmail wrote: Thanks! I think that document explains everything I need to know to take control over IB. This is more Objective-C related by maybe you have a quick tip. My first tests suggest that my method for overriding is not correct because overriding init is getting invoked from all sorts of other classes (like NSFileManager to name a few) when the NIB is loading. I use class_getInstanceMethod (with the instance of the custom class I registered with the objective-c runtime) to get the method then replace the implementation with my function pointer. This method worked before for overriding drawRect: in NSView so I'm not sure what is different now. Any ideas? class_getInstanceMethod searches the entire class hierarchy. So, if the class you're working with didn't override that implementation you'll be replacing the superclass' implementation. If you call class_addMethod on self with the result of class_getMethodImplemenation you'll be adding it to the subclass if it's not already overridden. After that calling method_exchangeImplementations will only affect that class. Ashley On Mar 24, 2009, at 8:02 AM, Jonathan Hess wrote: Hey Josef - When IB instantiates an object in a NIB file that has the custom class set, it will instantiate it with either init, initWithFrame:, or initWithCoder: depending on the type of object. Here's a link tot he relevant documentation: http://developer.apple.com/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#/ /apple_ref/doc/uid/1051i-CH4-SW19 Jon Hess On Mar 23, 2009, at 5:36 PM, Gmail wrote: NO, it supports subclassing. Do you know what method I could override (and return my instance) before the NIB is loaded so I can control it's isntance variables? I think maybe a low-level protocol like init could perhaps work. Thanks. On Mar 24, 2009, at 12:15 AM, Bill Bumgarner wrote: On Mar 22, 2009, at 6:26 PM, Gmail wrote: Is there anyone who is aware how this was accomplished by the other bridges or if I can force IB to not instantiate the classes, or maybe replace the instance with my own? It seems like I need a way to access the instances of those classes inside the nib but I don't think that can be done. Any ideas are greatly appreciated. Thank you. RubyCocoa and PyObjC work by creating the class before the NIB is loaded.From your description, it sounds like your bridge doesn't support subclassing. If so, that'll make your bridge considerably more difficult to integrate with Cocoa. b.bum Regards, Josef ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableView updating checkboxes
On 23/03/2009, at 12:21 PM, Jo Phils wrote: Thank you Andrew (and Graham), I think i'm finally realizing that! :-) Thank you very much. Ok I still don't have it yet but it's back to work for me and hopefully the next time I post back I'll finally have it... :-) Thanks again, Rick Hi Rick, I'm away on a trip right now so I have limited eMail access - but briefly make sure you implement BOTH methods I outlined, not just the second. It checks for membership of the set so manages the checkbox state as needed. If you leave in your call to always set NSOnState, well, that's what you'll get. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: -hexValue for NSString?
Kewl, two excellent solutions! Cocoa is pretty versatile. I have alot to learn yet but I don't quite have my head around why its more Cocoaish to invoke a class like NSScanner on an external object (Ali's approach) versus expecting the NSString object to be able to render its own contents in a format I'd like (Dave's approach)? Thanks Ali and Dave! On Mar 23, 2009, at 6:16 PM, Ali Ozer wrote: NSScanner has - (BOOL)scanHexInt:(unsigned *)value; // Optionally prefixed with 0x or 0X - (BOOL)scanHexLongLong:(unsigned long long *)result; so you can unsigned yourValueHere; BOOL success = [[NSScanner scannerWithString:string] scanHexInt:yourValueHere]; Ali On Mar 23, 2009, at 6:00 PM, Jonathon Kuo wrote: In NSString theres -intValue, -floatValue, -doubleValue, but no - hexValue (that I can find). I'd like to convert ascii hex NSStrings (@001A4CD3 etc) into integer values. Having a -hexValue method would make that a snap. If theres no Cocoa way, I guess I could try my hand at writing a category(?) method on NSString using sscanf with %x. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: XMLParser
On Tue, Mar 24, 2009 at 1:53 PM, Development developm...@fornextsoft.com wrote: I'm using an an NSXMLParser to parse a document. some of the elements are as follows: element property=valueSome Thing/element The problem is that I cannot seem to come up with the element's property. During the parse which callback is going to give me the property and it's value? Those are usually called attributes, not properties. Have a look at this delegate method: parser:foundAttributeDeclarationWithName:forElement:type:defaultValue: http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html#//apple_ref/doc/uid/20001984-BBCCIFGB Cheers, Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSObliquenessAttributeName, labelFontOfSize, Italic
From: Eric Gorr mail...@ericgorr.net Subject: NSObliquenessAttributeName, labelFontOfSize, Italic The solution proposed in the thread was to just add NSObliquenessAttributeName, which is easy enough, but I am not sure what the appropriate angle should be. Is there a standard angle which should be used in this situation? I found through trial and error that 0.15 produces the most acceptable simulation of italic. Of course, since this is an aesthetic decision, others might disagree. (Apple should include an italic version of the font if it is the default for NSTableView (it is, right?). It took me a lot of head scratching to figure out why binding a boolean to the Italic property of various cells was producing no effect whatsoever, when binding to Bold worked fine!). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IB instantiating objects
On Mar 24, 2009, at 10:01 AM, Ashley Clark wrote: On Mar 23, 2009, at 9:30 PM, Gmail wrote: Thanks! I think that document explains everything I need to know to take control over IB. This is more Objective-C related by maybe you have a quick tip. My first tests suggest that my method for overriding is not correct because overriding init is getting invoked from all sorts of other classes (like NSFileManager to name a few) when the NIB is loading. I use class_getInstanceMethod (with the instance of the custom class I registered with the objective-c runtime) to get the method then replace the implementation with my function pointer. This method worked before for overriding drawRect: in NSView so I'm not sure what is different now. Any ideas? class_getInstanceMethod searches the entire class hierarchy. So, if the class you're working with didn't override that implementation you'll be replacing the superclass' implementation. If you call class_addMethod on self with the result of class_getMethodImplemenation you'll be adding it to the subclass if it's not already overridden. After that calling method_exchangeImplementations will only affect that class. Hmmm, I overrode the superclasses implementation, i.e. NSObject, which sounds about right considering the results. So, I need to be using class_addMethod for init because my new class has no implementation for that method. I think the previous attempt to override NSView worked because drawRect: DID have an implementation for that selector already added to the runtime, which is not the case with my new class. Thank you Ashley I think you are correct. Is there anyway way to determine if a class has an implementation for a method so I can decide to add a new method or override an existing? As it stands I don't know in code when I should add or exchange implementations. Ashley On Mar 24, 2009, at 8:02 AM, Jonathan Hess wrote: Hey Josef - When IB instantiates an object in a NIB file that has the custom class set, it will instantiate it with either init, initWithFrame:, or initWithCoder: depending on the type of object. Here's a link tot he relevant documentation: http://developer.apple.com/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#/ /apple_ref/doc/uid/1051i-CH4-SW19 Jon Hess On Mar 23, 2009, at 5:36 PM, Gmail wrote: NO, it supports subclassing. Do you know what method I could override (and return my instance) before the NIB is loaded so I can control it's isntance variables? I think maybe a low-level protocol like init could perhaps work. Thanks. On Mar 24, 2009, at 12:15 AM, Bill Bumgarner wrote: On Mar 22, 2009, at 6:26 PM, Gmail wrote: Is there anyone who is aware how this was accomplished by the other bridges or if I can force IB to not instantiate the classes, or maybe replace the instance with my own? It seems like I need a way to access the instances of those classes inside the nib but I don't think that can be done. Any ideas are greatly appreciated. Thank you. RubyCocoa and PyObjC work by creating the class before the NIB is loaded.From your description, it sounds like your bridge doesn't support subclassing. If so, that'll make your bridge considerably more difficult to integrate with Cocoa. b.bum Regards, Josef Regards, Josef ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Stop NSScrollView from catching scroll events.
On Mon, Mar 23, 2009 at 6:09 PM, Ben Lachman blach...@mac.com wrote: On Mar 23, 2009, at 5:47 PM, Corbin Dunn wrote: On Mar 23, 2009, at 2:35 PM, Ben Lachman wrote: On Mar 23, 2009, at 10:54 AM, Michael Ash wrote: On Mon, Mar 23, 2009 at 3:46 AM, Ben Lachman blach...@mac.com wrote: I have a tableview that's neatly wrapped in a scroll view by IB. I manually resize the scrollview whenever a row is added to the tableview so that all the row are always visible. Thus I basically don't need a scroll view. However even though it can't actually scroll the tableview it still eats scroll events when the mouse is over it. I tried ripping the tableview out of the scroll view programatically, but that didn't yield useable results. Is there a straight forward way to have a scroll view pass scroll events on up the responder chain? Just subclass NSScrollView, and override -scrollWheel: to call directly through to NSResponder's implementation and bypass NSScrollView's implementation. I was thinking this was easy, but now I'm not so sure. How do you call through to some arbitrary class in a class's inheritance chain? It's definitely the way to do it. Just send it on to [self nextResponder]. that's all! Ah! Thanks Corbin. Thats the right (and easy) way to do it. For the record, this works too (and supports tiger, I'm not sure if Kyle's code does): - (void)scrollWheel:(NSEvent *)theEvent { void (*responderScroll)(id, SEL, id); responderScroll = (void (*)(id, SEL, id))([NSResponder instanceMethodForSelector:@selector(scrollWheel:)]); responderScroll(self, @selector(scrollWheel:), theEvent); } Right, that would be my preferred way of doing it. I like to use the NSObject methods rather than the ObjC runtime functions where I can, since the NSObject methods are usually friendlier and more broadly compatible. As to the question of doing this versus simply manually sending the message to the next responder, it's really just a question of preference here. I like letting the existing code handle things, but since this particular method is so simple, and its documentation precisely states what it does, it really makes no difference here. For something where the super-superclass does something more complex, this technique would have a significant advantage. 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 arch...@mail-archive.com
Re: -hexValue for NSString?
On Mon, Mar 23, 2009 at 9:25 PM, Dave Keck d...@docdave.com wrote: I think this should do the trick: @implementation NSString (HexIntValue) - (unsigned int)hexIntValue { NSScanner *scanner; unsigned int result; scanner = [NSScanner scannerWithString: self]; [scanner scanHexInt: result]; return result; } @end Note that I would expect -hexValue to be a method of NSNumber, that would return an NSString of the receiver's hex-value representation. I titled the method above 'hexValueInt' to more closely match NSString's -intValue, -floatValue, etc. Unless you're certain that the strings you send this message to will always contain a valid hex int representation, you'll also want to check the return value from scanHexInt: and return some prearranged value for nothing good found. For example, -intValue returns 0 if the string doesn't start with a valid integer representation. The current code will *probably* return whatever junk was on the stack (although -scanHexInt:'s docs don't say what it does with the parameter in the event of a failure, so it could end up doing something reasonable). 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 arch...@mail-archive.com
Re: IB instantiating objects
On Mar 23, 2009, at 10:31 PM, Gmail wrote: On Mar 24, 2009, at 10:01 AM, Ashley Clark wrote: On Mar 23, 2009, at 9:30 PM, Gmail wrote: Thanks! I think that document explains everything I need to know to take control over IB. This is more Objective-C related by maybe you have a quick tip. My first tests suggest that my method for overriding is not correct because overriding init is getting invoked from all sorts of other classes (like NSFileManager to name a few) when the NIB is loading. I use class_getInstanceMethod (with the instance of the custom class I registered with the objective-c runtime) to get the method then replace the implementation with my function pointer. This method worked before for overriding drawRect: in NSView so I'm not sure what is different now. Any ideas? class_getInstanceMethod searches the entire class hierarchy. So, if the class you're working with didn't override that implementation you'll be replacing the superclass' implementation. If you call class_addMethod on self with the result of class_getMethodImplemenation you'll be adding it to the subclass if it's not already overridden. After that calling method_exchangeImplementations will only affect that class. Hmmm, I overrode the superclasses implementation, i.e. NSObject, which sounds about right considering the results. So, I need to be using class_addMethod for init because my new class has no implementation for that method. I think the previous attempt to override NSView worked because drawRect: DID have an implementation for that selector already added to the runtime, which is not the case with my new class. Thank you Ashley I think you are correct. Is there anyway way to determine if a class has an implementation for a method so I can decide to add a new method or override an existing? As it stands I don't know in code when I should add or exchange implementations. You could call class_copyMethodList and iterate through that to find only methods defined directly on a class, but there's no harm in just calling class_addMethod. It will add an override of a superclass' implementation but will not replace an existing implementation if one was already defined on the class. So, there's no need to decide between add or exchange. Do both! eg. (typed in Mail, YMMV) Class klass = ... SEL selector = ... Method originalMethod = class_getInstanceMethod(klass, selector); class_addMethod(klass, selector, class_getMethodImplementation(klass, selector), method_getTypeEncoding(originalMethod)); class_replaceMethod(...); You'll get the right behavior every time, assuming right means you only want to replace the method on the class and not its' superclasses. Ashley ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Stop NSScrollView from catching scroll events.
On Mon, Mar 23, 2009 at 10:48 PM, Michael Ash michael@gmail.com wrote: Right, that would be my preferred way of doing it. I like to use the NSObject methods rather than the ObjC runtime functions where I can, since the NSObject methods are usually friendlier and more broadly compatible. For the record, I agree with Mike on this point; had I remembered the method, I would have used it too. I happened to be in the ObjC runtime docs looking up the signature for method_getImplementation, so I went with the runtime function. The advantage of using +instanceMethodForSelector: is that classes can override it to seamlessly provide forwarded method implementations, for example to a delegate. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IB instantiating objects
Great, thanks. I almost have this working but with one little problem. 1) I add the init method to my class 2) When init is invoked from the NIB I call objc_msgSend with the selector init which returns the new instance of the class (retrieved from objc_getClass) I previously registered with the runtime and added instance variables. 3) I call class_getInstanceVariable to get the instance variable I need to assign the reference to the wrapper class. Here class_getInstanceVariable returns nil which it never did before. I'm using the 1.0 runtime for now btw, but I get the class of the instance by using the isa field of the structure and give that class as the parameter to class_getInstanceVariable. This worked with other objects so I think I may have created the instance wrong. Is simply sending init to the class not enough? I tried calling alloc also but it entered into an infinite loop. Also, do I need to being the self parameter in this process that is the first parameter in the method? I find it strange I have another instance of this object I'm trying to replace, what should I do with it? Is it leaking memory? Thanks for helping with this I appreciate it. On Mar 24, 2009, at 11:22 AM, Ashley Clark wrote: You could call class_copyMethodList and iterate through that to find only methods defined directly on a class, but there's no harm in just calling class_addMethod. It will add an override of a superclass' implementation but will not replace an existing implementation if one was already defined on the class. So, there's no need to decide between add or exchange. Do both! eg. (typed in Mail, YMMV) Class klass = ... SEL selector = ... Method originalMethod = class_getInstanceMethod(klass, selector); class_addMethod(klass, selector, class_getMethodImplementation(klass, selector), method_getTypeEncoding(originalMethod)); class_replaceMethod(...); You'll get the right behavior every time, assuming right means you only want to replace the method on the class and not its' superclasses. Regards, Josef ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IB instantiating objects
I'm sorry! The light bulb just went off as soon as I sent that last message. I'm NOT supposed to init a NEW instance, but use that instance and simply modify it, which works perfectly. Please ignore that last message, this issue is solved and thank you very much for helping. Pascal users on Mac thank you also. On Mar 24, 2009, at 11:22 AM, Ashley Clark wrote: On Mar 23, 2009, at 10:31 PM, Gmail wrote: On Mar 24, 2009, at 10:01 AM, Ashley Clark wrote: On Mar 23, 2009, at 9:30 PM, Gmail wrote: Thanks! I think that document explains everything I need to know to take control over IB. This is more Objective-C related by maybe you have a quick tip. My first tests suggest that my method for overriding is not correct because overriding init is getting invoked from all sorts of other classes (like NSFileManager to name a few) when the NIB is loading. I use class_getInstanceMethod (with the instance of the custom class I registered with the objective-c runtime) to get the method then replace the implementation with my function pointer. This method worked before for overriding drawRect: in NSView so I'm not sure what is different now. Any ideas? class_getInstanceMethod searches the entire class hierarchy. So, if the class you're working with didn't override that implementation you'll be replacing the superclass' implementation. If you call class_addMethod on self with the result of class_getMethodImplemenation you'll be adding it to the subclass if it's not already overridden. After that calling method_exchangeImplementations will only affect that class. Hmmm, I overrode the superclasses implementation, i.e. NSObject, which sounds about right considering the results. So, I need to be using class_addMethod for init because my new class has no implementation for that method. I think the previous attempt to override NSView worked because drawRect: DID have an implementation for that selector already added to the runtime, which is not the case with my new class. Thank you Ashley I think you are correct. Is there anyway way to determine if a class has an implementation for a method so I can decide to add a new method or override an existing? As it stands I don't know in code when I should add or exchange implementations. You could call class_copyMethodList and iterate through that to find only methods defined directly on a class, but there's no harm in just calling class_addMethod. It will add an override of a superclass' implementation but will not replace an existing implementation if one was already defined on the class. So, there's no need to decide between add or exchange. Do both! eg. (typed in Mail, YMMV) Class klass = ... SEL selector = ... Method originalMethod = class_getInstanceMethod(klass, selector); class_addMethod(klass, selector, class_getMethodImplementation(klass, selector), method_getTypeEncoding(originalMethod)); class_replaceMethod(...); You'll get the right behavior every time, assuming right means you only want to replace the method on the class and not its' superclasses. Ashley Regards, Josef ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com