Re: Dividing NSView to subviews
On 27/04/2009, at 12:16 , Naresh Kongara wrote: in the view drawing code i didn't changed any thing. After preparing the view from which i need to get the images, i just replaced the line NSImage *img = [[[NSImage alloc] initWithData:[view dataWithPDFInsideRect:sourceRect]] autorelease]; with NSImage *img = [view imageFromRect:sourceRect]; The view drawing is same for both the cases, but -(NSImage *)imageFromRect:(NSRect) is giving me a some what blurred image... My guess (and its only a guess because you haven't posted the drawing code) is that the image is being drawn at a different size to the original, and hence scaling. cacheDisplayInRect will return a bit map image which will be blurry if scaled. dataWithPDFInsideRect will (potentially at least) return a PDF image which will scale better. Check your drawing code and ensure it is drawing the image at exactly the same size as the original view bounds. You can also try writing both images to a pdf and tiff and seeing the differences. Enjoy, Peter. -- Run macros from your iPhone with Keyboard Maestro Control! or take a break with Derzle for your iPhone Keyboard Maestro http://www.keyboardmaestro.com/ Macros for your Mac Aragom Space War http://www.stairways.com/iphone/aragom Don't get killed! Derzle http://www.stairways.com/iphone/derzle Enjoy a relaxing puzzle. http://www.stairways.com/ http://download.stairways.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
Cocoa application memory leak check
Hello, list I try to check my Cocoa application memory leak issue using Instruments. here I have a question here: for example: if(conditions == true){ void *buffer1 = malloc(32); buffer1 = NULL; } else { void *buffer2 = malloc(32); buffer2 = NULL; } the Instruments (leaks) can not find out the buffer2 leak, because this part is not executed. So, how to check this kind of memory leak? Thanks. Xiaogang ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSDateFormatter bug in timeZone
On 27 Apr 2009, at 02:41, Jon wrote: it appears there is a bug in Apple's date formatter: NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init]; [inputFormatter setDateFormat:@MMM-dd-yy HH:mm:ss zzz]; NSDate *theDate = [inputFormatter dateFromString:@Apr-04-09 10:30:03 PDT]; this gives the wrong timezone in theDate??? (unless of course you happen to be in the PDT timezone)it looks like it ignores the format, and just puts in current time zone. I'm not sure that things are quite as simple as you think :-) The problem with the three-letter time zone codes is that many of them are ambiguous. For instance, you might think EST meant UTC-5, whereas an Australian would expect EST to be UTC+10. As a result, you probably need to specify a bit more information rather than just PDT; I'm not 100% certain, but the following *might* work: NSDate *theDate = [inputFormatter dateFromString:@Apr-04-09 10:30:03 PST8PDT]; also using the natural language formater properly gives me the correct time Zone, but as soon as you store it in a Data Source, it comes back out with the current time zone, and the time adjusted so that it is correct time at least... but this shouldn't happen? should it. You can't store something in a data source, at least not for the usual Cocoa meaning of data source. Data sources are a type of delegate object, usually one that you implement yourself (unless you're using bindings, in which case the system does it for you). Where are you storing the date? And in what form? Are you using bindings or Core Data, or did you implement your own data source object? Kind regards, Alastair. -- http://alastairs-place.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: figuring out which TableView I am?
On Apr 27, 2009, at 6:44 AM, Michael Ash wrote: The correct approach here is to define a property, or a set of properties, on your table view subclass to control its appearance, then set up those properties in your controller in awakeFromNib. It is entirely baffling to me that people are so reluctant to follow this approach. The tag approach offers only one advantage: the ability to set the value in IB. And this is an extremely limited advantage when the information available in IB is 3. Give me descriptive code over a 3 any day of the week. Meanwhile it offers enormous disadvantages, including but not limited to extremely opaque code, lack of extensibility, and just general code smell. Define properties for your visual differences, set them up in your controller, and be happy. Mike With all due respect, I think people have blown the tags solution out of proportion, out of a misunderstanding of the OP's needs. The OP simply wanted to be able to tell which instance of his subclass of NSTableView he was dealing with at any given moment. I suggested the tags solution as a means to do so, which I still maintain is a simple and effective solution. I forget now who it was, but someone interpreted the tags solution as if I was suggesting to overload the tag property as a container for other properties. Then, other people built upon that idea by suggesting to use the tag as a bit field (which baffled Mike above, and me as well). In the spirit of giving the OP the best advice possible, I suggest we all take a step back and look once more at his original needs. Here's a quote from the OP's original message: On Apr 25, 2009, at 6:47 PM, David Scheidt wrote: I've got a sub-class of NSTableView. I have windows that have more than one instance of this TableView in them, which need to behave slightly differently, based on which one they are. The way I understood his question, this is a problem of *identifying* instances. At some point or points in his code, he's got a pointer to an instance of his subclass of NSTableView and needs to be able to determine which of several instances that is. I still maintain that if these instances have different tag values then switch ([table tag]) { case kTable1Tag: /* table points to table1, so do what needs to be done to table1 */ break; case kTable2Tag: /* table points to table2, so do what needs to be done to table2 */ break; etc. } is a simple, effective, and scalable way to solve his problem. Note that there is only one table view pointer, table, not several, though there are several instances that pointer could be pointing to (ie, this part of the code is in some class that does not have pointers pointing specifically to table1, table2, etc). Otherwise, simple pointer comparison would have solved his problem and he wouldn't have posted the question in the first place. Note also that nowhere am I suggesting that the tags should be used for anything other than as object identifiers. In particular, I am not addressing, nor am I concerned with, which attributes his subclass needs to have in order for his subclass instances to behave slightly differently. It seems obvious to me that the best way to handle those attributes is to define them as properties in his NSTableView subclass, and NOT as some contrived mapping of sets of bits from the instances' tags (as others have suggested). As I pointed out before, there are often many ways to solve a particular programming problem, but I do think this is the simplest way to address the OP's problem. If I misunderstood his question or if there are better solutions to his problem, by all means, please weigh in. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Cocoa application memory leak check
I think you're expecting a bit too much from Instruments. I may be wrong, but I think Instruments is not a static analyzer. It only checks for leaks as they occur, that is, at runtime. Thus, if parts of your code do not execute at runtime during a given session, Instruments won't see them and won't care about them. The way to test for leaks such as the one you pointed out is to run Instruments several times, each time forcing a particular path through your code's runtime profile. In your specific example, you'd run your application under Instruments twice, the first time making sure that the condition is true, the second time making sure that the condition is false. You could force the condition to be true or false by interacting with your application at runtime (for instance, if the condition is tied to a checkbox, you'd check the box on or off), or by temporarily setting the condition to true or false in code, explicitly. Wagner On Apr 27, 2009, at 11:33 AM, XiaoGang Li wrote: Hello, list I try to check my Cocoa application memory leak issue using Instruments. here I have a question here: for example: if(conditions == true){ void *buffer1 = malloc(32); buffer1 = NULL; } else { void *buffer2 = malloc(32); buffer2 = NULL; } the Instruments (leaks) can not find out the buffer2 leak, because this part is not executed. So, how to check this kind of memory leak? Thanks. Xiaogang ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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
Scheduling application
I used launchd to schedule my application. I created plist in LaunchAgents by setting the keys Label, onDemand, ProgramArguments and startCalenderInterval. Then I loaded the plist using the terminal. It is working fine. Now I need to launch the application without using terminal. How can I do it? Thanks in advance mahaboob ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cocoa application memory leak check
.. but speaking of static analyzers, try http://clang.llvm.org/StaticAnalysis.html. I don't think it reasons about malloc and free, but it does reason about -retain and -release. -Ken On Mon, Apr 27, 2009 at 3:14 AM, WT jrca...@gmail.com wrote: I think you're expecting a bit too much from Instruments. I may be wrong, but I think Instruments is not a static analyzer. It only checks for leaks as they occur, that is, at runtime. Thus, if parts of your code do not execute at runtime during a given session, Instruments won't see them and won't care about them. The way to test for leaks such as the one you pointed out is to run Instruments several times, each time forcing a particular path through your code's runtime profile. In your specific example, you'd run your application under Instruments twice, the first time making sure that the condition is true, the second time making sure that the condition is false. You could force the condition to be true or false by interacting with your application at runtime (for instance, if the condition is tied to a checkbox, you'd check the box on or off), or by temporarily setting the condition to true or false in code, explicitly. Wagner On Apr 27, 2009, at 11:33 AM, XiaoGang Li wrote: Hello, list I try to check my Cocoa application memory leak issue using Instruments. here I have a question here: for example: if(conditions == true){ void *buffer1 = malloc(32); buffer1 = NULL; } else { void *buffer2 = malloc(32); buffer2 = NULL; } the Instruments (leaks) can not find out the buffer2 leak, because this part is not executed. So, how to check this kind of memory leak? Thanks. Xiaogang ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com This email sent to kenfe...@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: figuring out which TableView I am?
On Apr 27, 2009, at 2:10 AM, WT wrote: On Apr 27, 2009, at 6:44 AM, Michael Ash wrote: The correct approach here is to define a property, or a set of properties, on your table view subclass to control its appearance, then set up those properties in your controller in awakeFromNib. It is entirely baffling to me that people are so reluctant to follow this approach. The tag approach offers only one advantage: the ability to set the value in IB. And this is an extremely limited advantage when the information available in IB is 3. Give me descriptive code over a 3 any day of the week. Meanwhile it offers enormous disadvantages, including but not limited to extremely opaque code, lack of extensibility, and just general code smell. Define properties for your visual differences, set them up in your controller, and be happy. Mike With all due respect, I think people have blown the tags solution out of proportion, out of a misunderstanding of the OP's needs. The OP simply wanted to be able to tell which instance of his subclass of NSTableView he was dealing with at any given moment. I suggested the tags solution as a means to do so, which I still maintain is a simple and effective solution. I forget now who it was, but someone interpreted the tags solution as if I was suggesting to overload the tag property as a container for other properties. Then, other people built upon that idea by suggesting to use the tag as a bit field (which baffled Mike above, and me as well). In the spirit of giving the OP the best advice possible, I suggest we all take a step back and look once more at his original needs. Here's a quote from the OP's original message: On Apr 25, 2009, at 6:47 PM, David Scheidt wrote: I've got a sub-class of NSTableView. I have windows that have more than one instance of this TableView in them, which need to behave slightly differently, based on which one they are. The way I understood his question, this is a problem of *identifying* instances. At some point or points in his code, he's got a pointer to an instance of his subclass of NSTableView and needs to be able to determine which of several instances that is. I still maintain that if these instances have different tag values then switch ([table tag]) { case kTable1Tag: /* table points to table1, so do what needs to be done to table1 */ break; case kTable2Tag: /* table points to table2, so do what needs to be done to table2 */ break; etc. } is a simple, effective, and scalable way to solve his problem. Note that there is only one table view pointer, table, not several, though there are several instances that pointer could be pointing to (ie, this part of the code is in some class that does not have pointers pointing specifically to table1, table2, etc). Otherwise, simple pointer comparison would have solved his problem and he wouldn't have posted the question in the first place. Note also that nowhere am I suggesting that the tags should be used for anything other than as object identifiers. In particular, I am not addressing, nor am I concerned with, which attributes his subclass needs to have in order for his subclass instances to behave slightly differently. It seems obvious to me that the best way to handle those attributes is to define them as properties in his NSTableView subclass, and NOT as some contrived mapping of sets of bits from the instances' tags (as others have suggested). As I pointed out before, there are often many ways to solve a particular programming problem, but I do think this is the simplest way to address the OP's problem. If I misunderstood his question or if there are better solutions to his problem, by all means, please weigh in. Hey Wagner - That cleared things up and sounds much more reasonable. To take this a step further, if you're going to take the time to define constants like kTable1Tag, and then use them in IB, why not just use an outlet instead? It takes the same amount of typing, but is much more difficult to inadvertently break while at the same time, self document. If you really want to identify an object by its identity there's no better way than a pointer, and that's what you get with an outlet. Tags certainly have their place. An example of where they can be used successfully and clearly is to hold integer constant values for menu items in a pop up button's menu where the pop up menu is used to manipulate an attribute, and the menu items' tags hold the legal values. Jon Hess Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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
Re: figuring out which TableView I am?
On Apr 27, 2009, at 1:19 PM, Jonathan Hess wrote: That cleared things up and sounds much more reasonable. Did I sound less reasonable before? I surely hope not. :) To take this a step further, if you're going to take the time to define constants like kTable1Tag, and then use them in IB, why not just use an outlet instead? It takes the same amount of typing, but is much more difficult to inadvertently break while at the same time, self document. I think that's a matter of perspective and, possibly, also of personal taste. There are always cases where one solution is better than others, given a suitable definition of better. If you really want to identify an object by its identity there's no better way than a pointer, and that's what you get with an outlet. Sure, but it was my impression from the OP's question that he didn't have explicit pointer variables representing his NSTableView subclass instances, or else he wouldn't have asked the question in the first place because pointer comparison is the absolute obvious solution. I trusted that the OP was knowledgeable enough to have thought of that. Tags certainly have their place. An example of where they can be used successfully and clearly is to hold integer constant values for menu items in a pop up button's menu where the pop up menu is used to manipulate an attribute, and the menu items' tags hold the legal values. Yes, and identifying cells in a NSMatrix by their position in the grid is probably another good example. Look, I'm not trying to sell the tags solution as the best solution or the correct solution or the only solution or the standard solution. It's just a simple solution to a simple problem. It baffled *me* that people (a) misunderstood the OP question, (b) misunderstood my tags solution, (c) went overboard with the whole tags- as-bitfields idea, and (d) made such a big deal about such a simple solution to a simple problem. In the end, though, it doesn't really matter because the OP seems to be happy with the tags solution. It even looks like he completely ignored the ensuing discussion. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: figuring out which TableView I am?
On 27/04/2009, at 10:37 PM, WT wrote: (c) went overboard with the whole tags-as-bitfields idea Well, sorry! It was just a suggestion. Maybe it's a hangover from my hardware days trying to cram a complete OS into 32K of on-chip ROM. --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: NSDateFormatter bug in timeZone
I was not using the term Data Source properly most likely, this is what i was doing.. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:theDate forKey:@the date]; in a different Class object at a later time, i retrieve it like this. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSDate *theDate = [defaults objectForKey:@the date]; that is what i meant by storing the data... (shouldn't PDT mean just one thing? shouldn't it be that simple? I'll try your suggestion, thanks, i'll try it with zzz, and with zzz) (I'm not sure how to properly reply to the list yet, should i reply to both You and the list? as i'm doing here) thanks, Jon. On Apr 27, 2009, at 3:27 AM, Alastair Houghton wrote: it appears there is a bug in Apple's date formatter: NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init]; [inputFormatter setDateFormat:@MMM-dd-yy HH:mm:ss zzz]; NSDate *theDate = [inputFormatter dateFromString:@Apr-04-09 10:30:03 PDT]; this gives the wrong timezone in theDate??? (unless of course you happen to be in the PDT timezone)it looks like it ignores the format, and just puts in current time zone. I'm not sure that things are quite as simple as you think :-) The problem with the three-letter time zone codes is that many of them are ambiguous. For instance, you might think EST meant UTC-5, whereas an Australian would expect EST to be UTC+10. As a result, you probably need to specify a bit more information rather than just PDT; I'm not 100% certain, but the following *might* work: NSDate *theDate = [inputFormatter dateFromString:@Apr-04-09 10:30:03 PST8PDT]; also using the natural language formater properly gives me the correct time Zone, but as soon as you store it in a Data Source, it comes back out with the current time zone, and the time adjusted so that it is correct time at least... but this shouldn't happen? should it. You can't store something in a data source, at least not for the usual Cocoa meaning of data source. Data sources are a type of delegate object, usually one that you implement yourself (unless you're using bindings, in which case the system does it for you). Where are you storing the date? And in what form? Are you using bindings or Core Data, or did you implement your own data source object? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSDateFormatter bug in timeZone
oh wait, you are saying the Australia has an EST... I see. in that case, do you think Apple should have this work, which i tried, of having this line before making the final format call of just using PDT. [inputFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@en_US]]; thanks, Jon. On Apr 27, 2009, at 3:27 AM, Alastair Houghton wrote: Australian would expect EST ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSDateFormatter bug in timeZone
On 27 Apr 2009, at 15:13, jon wrote: oh wait, you are saying the Australia has an EST... I see. in that case, do you think Apple should have this work, which i tried, of having this line before making the final format call of just using PDT. [inputFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@en_US]]; Honestly, I'm not sure whether it should or not; I haven't thought about it *nearly* enough. My guess (and it is just a guess) is that Apple's date formatter (in non-natural language mode) mirrors the behaviour of the POSIX strptime() function, which is explicitly documented as only allowing the zone abbreviations of the local time zone or the value GMT, precisely because of the ambiguity. Interestingly I can't even see %Z in the allowed list of format specifiers for strptime() in SUSv3/ POSIX.1, so it would seem to be an extension (albeit an obvious one). I think it should probably take a stab at it when in natural language mode, but otherwise I'm not sure it's a good idea to do anything other than maybe try to parse a full POSIX time zone specification (ala the TZ environment variable). Put another way, I suspect a common error in Australia is to have your machine configured in the U.S. locale. It's certainly a common error here in the U.K. (which is why we get documents sent to us in U.S. Letter paper size, for instance). So there is a question over whether it is wise to behave in a highly unexpected manner in that case. However, all of this is in an off-the-cuff e-mail :-) So I could easily be persuaded to change my mind. If you don't think the current behaviour is right, file a bug report and explain what you expected and what actually happened. I'm sure someone at Apple will take a look and come to a decision one way or another. Kind regards, Alastair. -- http://alastairs-place.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: figuring out which TableView I am?
On Apr 27, 2009, at 2:10 AM, WT wrote: On Apr 25, 2009, at 6:47 PM, David Scheidt wrote: I've got a sub-class of NSTableView. I have windows that have more than one instance of this TableView in them, which need to behave slightly differently, based on which one they are. The way I understood his question, this is a problem of *identifying* instances. At some point or points in his code, he's got a pointer to an instance of his subclass of NSTableView and needs to be able to determine which of several instances that is. I still maintain that if these instances have different tag values then My understanding wants to do this from a tableview subclass, though: switch([self tag]) { case 1: return ... case 2: return ... } ...so the tag is truly being used as a container for a property, which it doesn't sound like you intended? I don't think using tags from a controller class is a bad solution, although my own preference would be to have something like Jon/Mike/Jim suggested. Using the tag from the tableview subclass seems like a poor design, IMO, and not easy to maintain or extend. -- Adam smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Scheduling application
Put the plist in /Library/LaunchDaemons, and make sure owner is root, and only owner has write access. -- 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: FSPathCopyObjectSync and symbolic links?
On 4/26/09 3:22 PM, Iceberg-Dev said: Is it possible to copy a symbolic link (the symbolic link file and not the item it references) using the FSPathCopyObjectSync API? No valuable info was found in the documentation, the list archive, google results. The carbon-dev list would be a better place to ask. Also, did you search its archives? -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSDateFormatter bug in timeZone
On 27 Apr 2009, at 14:54, jon wrote: I was not using the term Data Source properly most likely, this is what i was doing.. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:theDate forKey:@the date]; in a different Class object at a later time, i retrieve it like this. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSDate *theDate = [defaults objectForKey:@the date]; that is what i meant by storing the data... Ah, OK. You've stored it in the defaults database, which will result in it being serialised in property list format. Arguably it shouldn't lose information, but I guess it does in this particular case; that's probably a bug, in and of itself. Does this date need to be in the defaults database? i.e. is it a preference or does it need to persist in some way? If not, stick the NSDate object into a dictionary (or just a variable) instead and use it from there. If it does, you might be able to work around the problem by manually encoding the date (e.g. using NSCoder or NSKeyedArchiver), then storing the resulting NSData in the defaults database instead. If I had time, I'd try it myself and see, but I'm really busy today... (shouldn't PDT mean just one thing? shouldn't it be that simple? I'll try your suggestion, thanks, i'll try it with zzz, and with zzz) :-) I'm not sure. I expect other places (besides the west coast of the United States) have PDT as well. EST is just the example I know OTOH (and interestingly it's the one quoted in the man page for strptime() as well). (I'm not sure how to properly reply to the list yet, should i reply to both You and the list? as i'm doing here) The rule varies from list to list, but generally on cocoa-dev people reply direct *and* to the list. It's usually considered bad form to just reply direct, because those of us who contribute here do so for the benefit of the community as a whole, not just for the individuals whose questions we try to answer. Kind regards, Alastair. -- http://alastairs-place.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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
NSXMLParser attributeDict enumeration
Hi all, This might be more of a C problem than a Cocoa problem per se. Enumerating the values of an attribute dictionary in NSXMLReader I try to set some members of a currentNode object (which does not represent an XML node, confusingly): NSEnumerator *enumerator = [attributeDict keyEnumerator]; id key; while ((key = [enumerator nextObject])) { NSLog(@considering key %@,key); if([key isEqualToString:@lat]) { currentNode.lat = (double)[attributeDict objectForKey:key]; } Member 'lat' is a double. The above does not work. 'Pointer value used where float was expected'. So I should dereference? currentNode.lat = (double *)[attributeDict objectForKey:key]; does not work either: 'error: incompatible type for argument 1 of 'setLat:''. I guess it wouldn't, because I'm casting an (id) to a pointer to a double I think, but I'm not sure how I should be doing this. martijn van exel -+- mve...@gmail.com -+- http://www.schaaltreinen.nl/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: figuring out which TableView I am?
On Apr 27, 2009, at 4:42 PM, Adam R. Maxwell wrote: On Apr 27, 2009, at 2:10 AM, WT wrote: On Apr 25, 2009, at 6:47 PM, David Scheidt wrote: I've got a sub-class of NSTableView. I have windows that have more than one instance of this TableView in them, which need to behave slightly differently, based on which one they are. The way I understood his question, this is a problem of *identifying* instances. At some point or points in his code, he's got a pointer to an instance of his subclass of NSTableView and needs to be able to determine which of several instances that is. I still maintain that if these instances have different tag values then My understanding wants to do this from a tableview subclass, though: switch([self tag]) { case 1: return ... case 2: return ... } ...so the tag is truly being used as a container for a property, which it doesn't sound like you intended? I don't think using tags from a controller class is a bad solution, although my own preference would be to have something like Jon/Mike/Jim suggested. Using the tag from the tableview subclass seems like a poor design, IMO, and not easy to maintain or extend. Of course the tag is a container for *a*/*one* property, the tag itself, but it's not a container for multiple properties, as others had interpreted it. Regardless, your switch statement is returning what, exactly? If it's returning the pointers to the various NSTableView subclass instances then, yes, of course the tag solution is a poor design because, in that case, the OP already had pointers to the instances and he might as well just use pointer comparison to identify the table he's been handed at that point, as suggested by Dave deLong here: http://lists.apple.com/archives/cocoa-dev/2009/Apr/msg01803.html . But let me quote the OP's reply to Dave: On Apr 25, 2009, at 11:14 AM, David Scheidt wrote: I'm using bindings, so I don't have have any data source methods. Sorry, should have said that. It's Core Data, cocoa bindings, 10.5+ only. Now, I'll fully admit not having any experience whatsoever with Core Data and minimal experience with bindings, so I may be totally wrong in what I'm about to say, but the OP's response solidified my impression from his first post that he does NOT have pointers to the various table instances, in which case his question of how to identify them makes perfect sense. In that case, I still maintain that the tags solution is simple, effective, and maintainable. Perhaps it's time the OP clarified what exactly he had in mind. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: figuring out which TableView I am?
On Mon, Apr 27, 2009 at 5:10 AM, WT jrca...@gmail.com wrote: On Apr 27, 2009, at 6:44 AM, Michael Ash wrote: The correct approach here is to define a property, or a set of properties, on your table view subclass to control its appearance, then set up those properties in your controller in awakeFromNib. It is entirely baffling to me that people are so reluctant to follow this approach. The tag approach offers only one advantage: the ability to set the value in IB. And this is an extremely limited advantage when the information available in IB is 3. Give me descriptive code over a 3 any day of the week. Meanwhile it offers enormous disadvantages, including but not limited to extremely opaque code, lack of extensibility, and just general code smell. Define properties for your visual differences, set them up in your controller, and be happy. Mike With all due respect, I think people have blown the tags solution out of proportion, out of a misunderstanding of the OP's needs. The OP simply wanted to be able to tell which instance of his subclass of NSTableView he was dealing with at any given moment. I suggested the tags solution as a means to do so, which I still maintain is a simple and effective solution. Yes, that idea is fine. I was responding to the much crazier idea of actually using the tag as a configuration value, not an identifier. I still think that using the tag to identify the table view is a poor idea. It is much cleaner and not any harder to simply use an IBOutlet to each table in order to tell them apart. However using tags for this instead is not nearly as objectionable. 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: NSXMLParser attributeDict enumeration
According to Martijn van Exel: Hi all, This might be more of a C problem than a Cocoa problem per se. Enumerating the values of an attribute dictionary in NSXMLReader I try to set some members of a currentNode object (which does not represent an XML node, confusingly): NSEnumerator *enumerator = [attributeDict keyEnumerator]; id key; while ((key = [enumerator nextObject])) { NSLog(@considering key %@,key); if([key isEqualToString:@lat]) { currentNode.lat = (double)[attributeDict objectForKey:key]; } Member 'lat' is a double. The structure member may be a double, but the dictionary object isn't. I'm not familiar with NSXMLReader, but the dictionary probably has a string of the attribute value. The above does not work. 'Pointer value used where float was expected'. So I should dereference? currentNode.lat = (double *)[attributeDict objectForKey:key]; does not work either: 'error: incompatible type for argument 1 of 'setLat:''. I guess it wouldn't, because I'm casting an (id) to a pointer to a double I think, but I'm not sure how I should be doing this. martijn van exel -+- mve...@gmail.com -+- http://www.schaaltreinen.nl/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/drew%40furrfu.com This email sent to d...@furrfu.com -- Drew Lawson| Look! A big distracting thing! | -- Crow T. Robot. | ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: figuring out which TableView I am?
On 28/04/2009, at 1:12 AM, WT wrote: Of course the tag is a container for *a*/*one* property, the tag itself, but it's not a container for multiple properties, as others had interpreted it. In my original response suggesting bitfields, I was responding solely to the post which outlined the scheme whereby the value was used like this: I want table 1 to have a blue background, so I set its tag to 3. I want table 2 to also have a blue background, so I set its tag to 3. I want table 1 to have red text. Switch off tag, 3 == red text. I want table 2 to have green text. Oops - tag 3 already means blue background + red text. The solution to this is, quite reasonably if you were stuck with a single integer, to use bitfields to separate the properties so that the oops situation mentioned here doesn't arise. Whether it's an appropriate use of the tag field is another question entirely, since you are almost never stuck with only the tag as the only storage available. However, if you were (for some reason), then bitfields are good. I've noticed many modern programmers are afraid of bitfields. They don't seem to understand basic operations like bitwise AND, OR, NOT and XOR. Anyone who has programmed hardware will not have such qualms, but even without that background bitfields have their place. So while I stress this is a theoretical argument, let's be clear: A tag *could* store 32 entirely independent 1-bit properties if you wanted, or 4 x 8-bit properties etc. So stating that it's not a container for multiple properties is incorrect. It might be ill- advised, but you could do it. And that was the point I was trying to make. --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: NSXMLParser attributeDict enumeration
On Apr 27, 2009, at 08:10, Martijn van Exel wrote: currentNode.lat = (double)[attributeDict objectForKey:key]; ... Member 'lat' is a double. The above does not work. 'Pointer value used where float was expected'. So I should dereference? currentNode.lat = (double *)[attributeDict objectForKey:key]; Dereference is the wrong word. What you actually did was *cast*, but that was the wrong thing to do anyway. The result of [attributeDict objectForKey:key] is always an object pointer (id, NSString*, NSNumber*, etc), never a scalar (int, double, etc). There are three possibilities here: 1. It's a NSNumber object, in which case you'd use: currentNode.lat = [[attributeDict objectForKey:key] doubleValue]; 2. It's a NSString object, and you're certain that it contains a well- formatted numeric representation, in which case you'd use NSString's convenience method: currentNode.lat = [[attributeDict objectForKey:key] doubleValue]; 3. It's a NSString object, and you're *not* certain that it contains a well-formatted numeric representation, in which case you can use NSScanner's scanDouble: on the string to retrieve the number and then check that there are no characters left over. Of course, if the object is none of the above, we can't tell you how to get a double out of it. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: figuring out which TableView I am?
On Apr 27, 2009, at 11:12 AM, WT wrote: Perhaps it's time the OP clarified what exactly he had in mind. Sure. I've got a window. (Actually, there are several windows, but they're all similar.) It's got a table view along the top. that table will always have instances of an entity, call it Foo. The bottom part of the window has details about the particular Foo that are selected in the top: a bunch of text fields, a graphic, and another tableView. The tableView is entities of another type that Foo has a to-many relationship with. There are actually two of these entities, call them Bar and Quox. The user only sees one of the tables at time, they're in a TabView. The idea is that tables representing Foo entities are to have their alternating row color be FooColor; tables representing Bar entities have the row BarColor; tables representing Quox, QuoxColor. I'm setting the stripe color by overriding highlightSelectionInClipRect:. there's a case statement there switch ([self tag]){ case 0: //catches the default IB Tag evenColor = uglyColor; break; case 1: // Foo Tables evenColor = FooColor; break; default: // catches invalid tag in IB evenColor = uglyColor2; } // drawing code follows There are also secondary windows that allow the user to look at Bars and Quoxes. Their tableviews are done in BarColor or quoxColor. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: figuring out which TableView I am?
David Scheidt wrote: switch ([self tag]){ case 0: //catches the default IB Tag evenColor = uglyColor; break; case 1: // Foo Tables evenColor = FooColor; break; default: // catches invalid tag in IB evenColor = uglyColor2; } // drawing code follows Assuming the tableviews have a different delegate type for Foo, Bar, or Quox, you could put an evenColor method in the delegate. Then check it with respondsToSelector: before messaging. The choice of evenColor then always changes with the delegate-type, regardless of tag value. Just a thought. -- GG ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSTask, or threading?
Thanks Richard, that's really helpful! I seem to have it working, though I'm actually still having problems with stuttering, which I don't really understand. Any thoughts on where I should start looking? Could it be because some of the classes in my worker thread are using shared instances? Do shared instances automatically involve the main thread somehow? thanks, J. On 26-Apr-09, at 12:29 PM, Richard Frith-Macdonald wrote: On 26 Apr 2009, at 18:39, James Maxwell wrote: So, how can I put my dataThing into some process, thread, etc., in a way that keeps it totally in its own world, so to speak? There is a simple an easy way to keep it in a separate thread ... so that's probably what you want to do. You would use 'Distributed Objects' (the NSConnection class) to communicate between the main thread and the dataThing thread. The way it works is as follows: 1. your code creates a pair of NSPort objects to talk to each other. 2. it launches a second thread, and in that thread creates a server NSConnection using those ports, and registers your dataThing object as the server object for the NSConnection 3. in the main thread another (client) NSConnection is created using the same two ports, and you ask the client connection for its 'root object' From then on, the main thread sends messages to the 'root object' of the connection exactly as if it was sending them directly to the dataThing object, and the NSConnection code manages things for you so you don't have to worry about locking. There's an example of this sort of thing at http://lachand.free.fr/cocoa/Threads.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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
NSTextField notification if selection changed
How can I get notification if the Selection changed in a NSTextField. This works with a NSTextView by setting up the delegate - (void)textViewDidChangeSelection:(NSNotification *)aNotification A NSTextField uses a NSTextView for its editing. And the NSTextField is the delegate to the NSTextView. If I need to get the selection changed should I be subclassing NSTextField and placing the textViewDidChangeSelection delegate method in there. Or is there a simpler solution to this. thanks for the help -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
NSTextField notification if selection changed
How can I get notification if the Selection changed in a NSTextField. This works with a NSTextView by setting up the delegate - (void)textViewDidChangeSelection:(NSNotification *)aNotification A NSTextField uses a NSTextView for its editing. And the NSTextField is the delegate to the NSTextView. If I need to get the selection changed should I be subclassing NSTextField and placing the textViewDidChangeSelection delegate method in there. Or is there a simpler solution to this. thanks for the help -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: Strange error message when trying to print
On Apr 26, 2009, at 6:02 AM, Peter Hudson wrote: When I try to print a document ( to PDF ) the app can sometimes hang - and I get a long message which looks like debug printout from the OS in the debug console. The last section of the message seems to contain the crux of the problem : - Sun Apr 26 12:42:51 peter-hudsons-macbook-pro.local tofile[6484] Error: The function `CGPDFDocumentGetMediaBox' is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance. Please use `CGPDFPageGetBoxRect' instead. INFO: cgpdftopdf (PID 6484) exited with no errors. My code does not directly call this method. This message should be harmless (in terms of printing success) and is occurring in another process (cgpdftopdf), not your own. Probably need more context to determine why your hanging, but it is unlikely to be due to this message. -- 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: Clicking through a NSView with CALayers
On Apr 26, 2009, at 2:29 PM, Rowan Nairn wrote: Thanks for the pointers. I actually figured out a way to do it. If you [NSView setWantsLayer:NO] and render the layer yourself like so. - (void)drawRect:(NSRect)dirty { CGContextRef ctx = [[NSGraphicsContext currentContext] graphicsPort]; CGContextClipToRect(ctx, NSRectToCGRect(dirty)); [[self layer] renderInContext:ctx]; } ...then the transparent pixels end up being transparent to clicks too! Can't say I understand what's going on here exactly and I'm guess I'm using twice as much graphics memory as I need to now but it works. When you turn on Core Animation, an OpenGL context is created to host the layer tree. The window server treats all OpenGL contexts as opaque to events, so if the window receives events, then the area occupied by the layer tree will always be considered a hit for events, regardless of actual graphical transparency. While the method you've found should work for most cases (- renderToContext: does not support the full Core Animation drawing model) if your resorting to this, you will likely see better performance doing the drawing work using more traditional methods. -- 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: Removing or ignoring lineWidth property of an NSBezierPath instance
Thanks Alastair and Graham for responding, and apologies for the delay in following up. I think that, at best, the documentation is ambiguous. It would be clearer specifically saying If no value was set explicitly for the receiver, this method [lineWidth] returns the default line width -at the time the receiver was created- I may file a RADR on that. It is further confusing because the actual effect of the lineWidth property is dependent on the view in which the drawing takes place -- that is, a line width of 1.0 in one view will not necessarily appear the same width in a separate view that has a different dot-pitch, pixel ratio, etc. From: Graham Cox graham@bigpond.com Date: Thu, 23 Apr 2009 10:27:25 +1000 To: Tobias Zimmerman automa...@gmail.com Cc: cocoa-dev@lists.apple.com cocoa-dev@lists.apple.com Subject: Re: Removing or ignoring lineWidth property of an NSBezierPath instance On 23/04/2009, at 7:19 AM, Tobias Zimmerman wrote: (By way of further explanation, the project this arises in involves a set of bezier paths that are generated in one program and archived for use in a separate program. I would like the lineWidth and other drawing specifics such as line/fill colors to be controlled by the view where the reusable paths are drawn, rather than a property of the paths themselves). I don't think that's going to work. My take on what +setDefaultLineWidth: means is that this establishes the value for a path's -lineWidth when it is first created. From that instant on, the path itself has a defined line width, a copy of the default value. If you never set the default I believe it defaults to 1.0. When you dearchive the paths the line width of each will be whatever is recorded for them, which came from the default on the source machine at the time they were created. Changing the default line width on your machine will have no effect on these values. If you want to change the line width when the paths are drawn, you'll have to set each one individually prior to drawing. --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
10.4.x install for testing...
Does anyone know if Apple provides a download of the full 10.4.x install DVD for developers? I need to test 10.4 on an intel machine, but my install of 10.4 only works on PPC. Rich Collyer ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: 10.4.x install for testing...
On Apr 27, 2009, at 12:17 PM, iseecolors wrote: Does anyone know if Apple provides a download of the full 10.4.x install DVD for developers? I need to test 10.4 on an intel machine, but my install of 10.4 only works on PPC. You should see a disk image in your ADC account, under Downloads, Mac OS 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: 10.4.x install for testing...
The downloads are all Updates which assume I already have a full install of 10.4 for Intel. There is a download of 10.4, but that is for PPC only. Rich On Apr 27, 2009, at 11:33 AM, Randall Meadows wrote: On Apr 27, 2009, at 12:17 PM, iseecolors wrote: Does anyone know if Apple provides a download of the full 10.4.x install DVD for developers? I need to test 10.4 on an intel machine, but my install of 10.4 only works on PPC. You should see a disk image in your ADC account, under Downloads, Mac OS 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: 10.4.x install for testing...
On Mon, Apr 27, 2009 at 2:17 PM, iseecolors iseecol...@sbcglobal.net wrote: Does anyone know if Apple provides a download of the full 10.4.x install DVD for developers? I need to test 10.4 on an intel machine, but my install of 10.4 only works on PPC. The minimum OS requirement for any given Mac model is nearly always the OS version that was shipping at the time of its release. Thus, if your Intel Mac did not come with a 10.4 disc, then it will not run 10.4. 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: 10.4.x install for testing...
On Apr 27, 2009, at 12:44 PM, iseecolors wrote: The downloads are all Updates which assume I already have a full install of 10.4 for Intel. There is a download of 10.4, but that is for PPC only. The Intel version of 10.4.x was OEM only. It wasn't sold or distributed on ADC. Besides that, you will also need a Mac that was made prior to Leopard's launch. With only a couple of exceptions, every Macintosh Apple has ever shipped requires the currently shipping version of the OS. Unfortunately Tiger won't run in a virtual machine, either. Nick Zitzmann http://www.chronosnet.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTask, or threading?
ugh... Okay, so I got rid of all the shared instances (of my own classes, that is) but I'm still getting stuttering. Is there anything in the settings of the thread itself that I should check? Or is there some other newbie gotcha that I should be aware of? thanks in advance for any thoughts... J. On 27-Apr-09, at 10:41 AM, James Maxwell wrote: Thanks Richard, that's really helpful! I seem to have it working, though I'm actually still having problems with stuttering, which I don't really understand. Any thoughts on where I should start looking? Could it be because some of the classes in my worker thread are using shared instances? Do shared instances automatically involve the main thread somehow? thanks, J. On 26-Apr-09, at 12:29 PM, Richard Frith-Macdonald wrote: On 26 Apr 2009, at 18:39, James Maxwell wrote: So, how can I put my dataThing into some process, thread, etc., in a way that keeps it totally in its own world, so to speak? There is a simple an easy way to keep it in a separate thread ... so that's probably what you want to do. You would use 'Distributed Objects' (the NSConnection class) to communicate between the main thread and the dataThing thread. The way it works is as follows: 1. your code creates a pair of NSPort objects to talk to each other. 2. it launches a second thread, and in that thread creates a server NSConnection using those ports, and registers your dataThing object as the server object for the NSConnection 3. in the main thread another (client) NSConnection is created using the same two ports, and you ask the client connection for its 'root object' From then on, the main thread sends messages to the 'root object' of the connection exactly as if it was sending them directly to the dataThing object, and the NSConnection code manages things for you so you don't have to worry about locking. There's an example of this sort of thing at http://lachand.free.fr/cocoa/Threads.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jbmaxwell%40rubato-music.com This email sent to jbmaxw...@rubato-music.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
RED Camera SDK wrapper?
Just checking to see if anyone has created a Obj-C wrapper for the RED camera SDK before starting I start to do so Thanks in advance Todd Freese The Filmworkers Club ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSTextField notification if selection changed
On Apr 27, 2009, at 11:48 AM, David Alter wrote: How can I get notification if the Selection changed in a NSTextField. This works with a NSTextView by setting up the delegate - (void)textViewDidChangeSelection:(NSNotification *)aNotification A NSTextField uses a NSTextView for its editing. And the NSTextField is the delegate to the NSTextView. If I need to get the selection changed should I be subclassing NSTextField and placing the textViewDidChangeSelection delegate method in there. Or is there a simpler solution to this. Once you get a reference to the field editor, you can observe its NSTextViewDidChangeSelectionNotification. Best, 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: Core Data Suddenly Losing Changes
Thanks for the suggestion. I tried it, but no go. It's core data based, but not document-based I've just got the application loading all its data from core data I'm running 10.5.6 with Xcode 3.1.2 I'm relatively new to Core Data, but I've been developing this application for a few months now and things have been working fine. I'm sure I made some simple, stupid change, but for the life of me, I can't figure out what and like I said, rolling back to a previous version through subversion didn't solve the problem. - Walker Argendeli On Apr 26, 2009, at 10:41 PM, Dave Fernandes wrote: Did you try deleting your build directory and building from scratch? (Don't just do a Clean All - actually delete the Build directory by hand) Sometimes Xcode caches cause this type of problem. If this doesn't help, you should post more info such as: is it a document- based app? Is more than one file open at the same time? What version of the OS are you running? Dave On Apr 26, 2009, at 7:23 PM, Walker Argendeli wrote: I've been working on a project that uses Core Data for a while now. I recently changed the model and ran it, but I noticed an odd behavior: I wan't informed that the model had changed and was incompatible. I went ahead and deleted the old xml file and when running the application again, it created another file. The only problem is that Core Data has stopped saving. EVery time I open the application, I'm presented with a blank slate. I haven't been religiously using subversion, but I had a commit several days, so I checked out that revision. It has the exact same problem, but I'm certain this wasn't happening a few days. I'm not sure what I could've done that could have caused this, but I'm completely stuck and going crazy trying to get my app to work again. Thanks, - Walker Argendeli ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca This email sent to dave.fernan...@utoronto.ca ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Problem with 'launchAppWithBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifier:'???
Ken, That did work but I found that I had to keep providing the descriptor for some reason. Are you using a different API fro the Launch Services? My only other problem now is switching the default printer to a specific one and switching back to the original default. lpoptions seemed promising but it doesn't change it, even though on the command line, it says it did... Cheers, Ken! -Laurent. -- Laurent Daudelin AIM/iChat/Skype:LaurentDaudelin http://nemesys.dyndns.org Logiciels Nemesys Software laurent.daude...@verizon.net Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries On Apr 23, 2009, at 18:11 , Ken Thomases wrote: On Apr 23, 2009, at 7:50 PM, Laurent Daudelin wrote: I'm trying to use this NSWorkspace method to launch an application and print a document. I provide it with a FSRef-based NSAppleEventDescriptor but the only thing the workspace does is launching the app. Here is part of the code: NSURL *documentURL = [[[NSURL alloc] initFileURLWithPath: [[openPanel filenames] objectAtIndex:c]] autorelease]; NSURL *applicationURL = NULL; OSStatus resultCode = LSGetApplicationForURL((CFURLRef)documentURL, kLSRolesAll, NULL, (CFURLRef *)applicationURL); if (resultCode != noErr) { NSRunAlertPanel(NULL, [NSString stringWithFormat:@%@ '%@', NSLocalizedString(@CouldntFindAppForDocument, @), [[[openPanel filenames] objectAtIndex:c] lastPathComponent]], NULL, NULL, NULL); return ; } NSBundle *appBundle = [NSBundle bundleWithPath:[applicationURL path]]; BOOL couldLaunchApp = NO; NSAppleEventDescriptor *descriptor = [self descriptorWithPath: [[openPanel filenames] objectAtIndex:c]]; if (descriptor != NULL) couldLaunchApp = [[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:[appBundle bundleIdentifier] options:NSWorkspaceLaunchAndPrint additionalEventParamDescriptor:descriptor launchIdentifier:NULL]; if ( ! couldLaunchApp) NSRunAlertPanel(NULL, [NSString stringWithFormat:@%@ '%@', NSLocalizedString(@CouldntAddDocumentToReader, @), [[[openPanel filenames] objectAtIndex:c] lastPathComponent]], NULL, NULL, NULL); What am I doing wrong? I don't recommend using a -launchApp... method to act on a document. To print a document, I recommend using - openURLs:withAppBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifiers : passing NSWorkspaceLaunchAndPrint in the options. Also, pass nil for the application bundle identifier, since you just want to use the default. That avoids the overly complicated use of LSGetApplicationForURL - URL - path - NSBundle - bundle ID. Also, the above code snippet snippet seems to be in a loop over the array of filenames returned by an open panel. With this method, you can convert that to an array of URLs and make just one NSWorkspace method call to print them all in their appropriate applications. Don't bother passing an additionalEventParamDescriptor. It's hard to get right, and I've seen evidence that it isn't even passed properly. (I've dropped down to direct use of Launch Services, which did pass the parameter correctly.) Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data Suddenly Losing Changes
Is your call to save: the managed object context succeeding? ... what does that managed object context return for hasChanges? ... and are the objects you expect to be saved in the insertedObjects, updatedObjects, deletedObjects collections? ... is save returning an error? And when you're done saving, does the persistent store file (the one with the path you passed to addPersistentStoreWithType:...) have data in it when you examine it with your favorite text editor? - adam On Apr 27, 2009, at 1:11 PM, Walker Argendeli wrote: Thanks for the suggestion. I tried it, but no go. It's core data based, but not document-based I've just got the application loading all its data from core data I'm running 10.5.6 with Xcode 3.1.2 I'm relatively new to Core Data, but I've been developing this application for a few months now and things have been working fine. I'm sure I made some simple, stupid change, but for the life of me, I can't figure out what and like I said, rolling back to a previous version through subversion didn't solve the problem. - Walker Argendeli On Apr 26, 2009, at 10:41 PM, Dave Fernandes wrote: Did you try deleting your build directory and building from scratch? (Don't just do a Clean All - actually delete the Build directory by hand) Sometimes Xcode caches cause this type of problem. If this doesn't help, you should post more info such as: is it a document-based app? Is more than one file open at the same time? What version of the OS are you running? Dave On Apr 26, 2009, at 7:23 PM, Walker Argendeli wrote: I've been working on a project that uses Core Data for a while now. I recently changed the model and ran it, but I noticed an odd behavior: I wan't informed that the model had changed and was incompatible. I went ahead and deleted the old xml file and when running the application again, it created another file. The only problem is that Core Data has stopped saving. EVery time I open the application, I'm presented with a blank slate. I haven't been religiously using subversion, but I had a commit several days, so I checked out that revision. It has the exact same problem, but I'm certain this wasn't happening a few days. I'm not sure what I could've done that could have caused this, but I'm completely stuck and going crazy trying to get my app to work again. Thanks, - Walker Argendeli ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca This email sent to dave.fernan...@utoronto.ca ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/aswift%40apple.com This email sent to asw...@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: Core Data Suddenly Losing Changes
On Mon, Apr 27, 2009 at 4:50 PM, Walker Argendeli heckler0...@bellsouth.net wrote: All I've done is bind controls in IB to values in Core Data. (I'm not very experienced with it yet) Learn to use the debugger. Set a breakpoint on your save routine and step through the code, examining the results. We can't do anything more than guess unless you give us some more specific information about the failure. -- 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
NSTableViews Load Progressively.
Hi, I have an application that contains 2 nstableviews populated by a property list file. A selection in one changes what is displayed in the next, which in turn loads an html-file in my webview. How do I load the tableviews progressively so that when I select the item from the first tableview it loads the second tableview and then populate the webview? Presently, the webview is populated immediately when I select any item from the first tableview. /Philip ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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
Autorelease and passing by reference in background threads
All, I am using a couple of methods that use NSError ** pointers to communicate error conditions. These methods run on background threads and so have their own autorelease pools set up. I pass an NSError pointer down a couple of method calls -- by the time it comes back up, it has been dealloc'd by the autorelease pool. A simple example (this will run if you want to try it for yourself): - (void)applicationDidFinishLaunching:(UIApplication *)application { [self performSelectorInBackground:@selector(runBackgroundProcess) withObject:nil]; } - (void)runBackgroundProcess { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSError *error = nil; [self runSomethingThatWillFail:error]; if(error) { NSLog(@error: %@, error); // CRASH HERE, EXC_BAD_ACCESS due to bogus pointer } [pool release]; } - (void)runSomethingThatWillFail:(NSError **)error { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@/BOGUS error:error]; [pool release]; } So I crash in runBackgroundProcess since the error is getting wiped by the local autorelease pool. Okay, so I'll retain it... - (void)runSomethingThatWillFail:(NSError **)error { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@/BOGUS error:error]; [*error retain]; [pool release]; } Well, now I have a leak of that NSError object... so I should autorelease it, I suppose. But that autorelease needs to be outside the release of the local pool, so it becomes: - (void)runSomethingThatWillFail:(NSError **)error { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@/BOGUS error:error]; [*error retain]; [pool release]; [*error autorelease]; } Now it works and isn't leaking anymore. But factor in that I have to do some checking on the existence of the error before I dereference it, etc... this is becoming some ugly code just to get my NSError back up the chain. Am I overthinking this? Anyone else have better suggestions? Thanks... Finn ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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
click in NSButtonCell in NSTableView without selecting table row?
Hello - I've done multiple searches and seen this topic discussed, but none with a solution that doesn't feel like a hack. I have an NSTableView, and one column that contains an NSButtonCell. I would like the user to be able to interact with this cell without the selection in the table changing. In the documentation for - tableView:shouldTrackCell:forTableColumn:row: , it says For example, this allows you to have an NSButtonCell in a table which does not change the selection, but can still be clicked on and tracked, yet I'm not exactly sure how to actually achieve this end. I return YES from the delegate method, then indeed my button works correctly (the data source gets the expected setObjectValue message), but the selection of the table also changes. The obvious first solution is to override tableView:shouldSelectRow:, yet this gets sent BEFORE shouldTrackCell, so I'm not really sure where to go from here. Do I have to gawk at the current mouse event in shouldSelectRow: and return NO if it appears that the mouse went down in the button cell? This feels harder than it ought to be. Am I missing something painfully obvious? Thanks! Dan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSXMLParser attributeDict enumeration
On Mon, Apr 27, 2009 at 19:05, Quincey Morris quinceymor...@earthlink.netwrote: On Apr 27, 2009, at 08:10, Martijn van Exel wrote: currentNode.lat = (double)[attributeDict objectForKey:key]; ... Member 'lat' is a double. The above does not work. 'Pointer value used where float was expected'. So I should dereference? currentNode.lat = (double *)[attributeDict objectForKey:key]; Dereference is the wrong word. What you actually did was *cast*, but that was the wrong thing to do anyway. The result of [attributeDict objectForKey:key] is always an object pointer (id, NSString*, NSNumber*, etc), never a scalar (int, double, etc). There are three possibilities here: [...] Quincey, Thanks for the help. The 'doubleValue' is what I was looking for. Unrelated: one of the XML attributes that needed parsing was a ISO8601 style date string, for which neither NSDate nor NSDateFormatter curiously does not seem to provide a parser. Some looking around provided http://boredzo.org/iso8601parser/ which seems to do the job, but I have to read up on the ISO8601 date format to tell whether the time zone is handled correctly. Thanks again. Martijn ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
RE: Core Data Suddenly Losing Changes
Namaste! Well, if all you've done is bind controls, does unbinding the changed controls fix the issue (do your bound controls function properly is a good follow-on)? If not, then I'd suggest binding isn't the problem... Peace, Love, and Light, /s/ Jon C. Munson II -Original Message- From: cocoa-dev-bounces+jmunson=his@lists.apple.com [mailto:cocoa-dev- bounces+jmunson=his@lists.apple.com] On Behalf Of I. Savant Sent: Monday, April 27, 2009 4:54 PM To: Walker Argendeli Cc: cocoa-dev@lists.apple.com Subject: Re: Core Data Suddenly Losing Changes On Mon, Apr 27, 2009 at 4:50 PM, Walker Argendeli heckler0...@bellsouth.net wrote: All I've done is bind controls in IB to values in Core Data. (I'm not very experienced with it yet) Learn to use the debugger. Set a breakpoint on your save routine and step through the code, examining the results. We can't do anything more than guess unless you give us some more specific information about the failure. -- 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/jmunson%40his.com This email sent to jmun...@his.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: 10.4.x install for testing...
Well, this is an interesting problem, because there are still people running Tiger out there, and some with earlier OSes, and even developers who just bought a shiny new Leopard machine might wish to support them. And it has always seemed a little like tempting fate to me, just to set Xcode for an earlier OS and proceed without testing what it builds. I guess the hope is that we all have a reasonable collection of old Macs with various versions of PPC/Intel and various versions of OS X. But even so, it would be useful if there were some systematic way to identify what versions of the OS a particular machine would support, and to be able to get them from somewhere, for backward compatibility support. -- Jay Reynolds Freeman - jay_reynolds_free...@mac.com http://web.mac.com/jay_reynolds_freeman (personal web site) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: 10.4.x install for testing...
On 27 Apr 2009, at 22:20, Jay Reynolds Freeman wrote: Well, this is an interesting problem, because there are still people running Tiger out there, and some with earlier OSes, and even developers who just bought a shiny new Leopard machine might wish to support them. And it has always seemed a little like tempting fate to me, just to set Xcode for an earlier OS and proceed without testing what it builds. I guess the hope is that we all have a reasonable collection of old Macs with various versions of PPC/Intel and various versions of OS X. But even so, it would be useful if there were some systematic way to identify what versions of the OS a particular machine would support, and to be able to get them from somewhere, for backward compatibility support. http://mactracker.dreamhosters.com/ Ultimately if you have the computer, you should also have the OS disk that came with it. The machine supports the version on that disk, and everything after it (until it falls below the latest OS's min. requirements) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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
errors building framework
I am trying to create a framework out of some files that I use in a few apps. I expected this to be easy, but instead got a kazillion warnings, all of which take the form: objc_class_name_NAME referenced from some method in some file.o [MANY METHODS AND FILES LISTED] or objc_msgSendmsg referenced from some method in some file.o or NSLog referenced from some method in some file.o Since the files originally came from projects that work (and do have Cocoa.h imported), I'm at a loss as to why this error would come up. If someone knows, or knows where I could read about this issue, I'd really appreciate it. Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Autorelease and passing by reference in background threads
Symphonik wrote: Am I overthinking this? Anyone else have better suggestions? You could give it a distinct name and store the NSError* in the current NSThread's -threadDictionary. Is this better? You'll have to evaluate the tradeoffs. -- GG ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Autorelease and passing by reference in background threads
On Apr 27, 2009, at 12:17 PM, Symphonik wrote: I am using a couple of methods that use NSError ** pointers to communicate error conditions. These methods run on background threads and so have their own autorelease pools set up. I pass an NSError pointer down a couple of method calls -- by the time it comes back up, it has been dealloc'd by the autorelease pool. [...] - (void)runSomethingThatWillFail:(NSError **)error { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@/BOGUS error:error]; [*error retain]; [pool release]; [*error autorelease]; } Now it works and isn't leaking anymore. But factor in that I have to do some checking on the existence of the error before I dereference it, etc... this is becoming some ugly code just to get my NSError back up the chain. Am I overthinking this? Anyone else have better suggestions? That is the correct way to handle an autoreleased object that crosses a pool boundary; you would need to do the same thing with an ordinary autoreleased return value too. The best way to simplify your code and avoid typos is to wrap the *error handling and pool release in a single #define. #define RELEASE_POOL_KEEP_ERROR (pool, error) \ do { \ if (error) [*error retain]; \ [pool release]; \ if (error) [*error autorelease]; \ } while (0) I'm confused about one part of your description. You say that these methods have autorelease pools because they run on background threads. But either there's another autorelease pool set up outside here, in which case you don't need the local pool after all, or [*error autorelease] is a leak. The leak might be the kind that logs autorelease with no autorelease pool to the console, or the kind where there is a pool in place but it's immortal. Also, if you intend to pass that error object back to some other calling thread then you will need code to keep the object alive other than the background thread's autorelease pool; otherwise you crash when the background thread's autorelease pool is drained before the other thread retains the error for itself. There is one alternative to the retain/autorelease dance, sometimes: don't drain your pool at all. - (void)runSomethingThatWillFail:(NSError **)error { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@/BOGUS error:error]; if (!(error *error)) [pool release]; } This version lets the pool live if there is an error. It works because autorelease pools are nested: whenever any autorelease pool is destroyed, all pools created after it are also destroyed. So as long as there's some other pool outside this one, and that outer pool is expected to be drained soon enough that you don't care about letting everything in your pool live longer, then it's safe to simply drop your pool on the floor and let it be cleaned up later. This fallback cleanup of autorelease pools is intended for exception handling: the thrown object is autoreleased, and intervening pools between the throw and the catch are ignored until later. I see no reason why it couldn't be used for NSErrors too. http://sealiesoftware.com/blog/archive/2008/09/16/objc_explain_Exceptions_and_autorelease_pools.html -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: 10.4.x install for testing...
On Apr 27, 2009, at 2:20 PM, Jay Reynolds Freeman wrote: Well, this is an interesting problem, because there are still people running Tiger out there, and some with earlier OSes, and even developers who just bought a shiny new Leopard machine might wish to support them. And it has always seemed a little like tempting fate to me, just to set Xcode for an earlier OS and proceed without testing what it builds. Yes, but how many of the Tiger users are actually buying new software? Most of the random stats that I have seen have shown that users of older versions of an OS don't typically lay down $$ for software anyway. Supporting those that are already your customer is nice/ polite/good, but looking to those markets for new users is likely futile. According to Omni's site (http://update.omnigroup.com/), 87.5% of downloads are to Intel based machines, for example. 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: errors building framework
On 2009 Apr 27, at 14:31, Daniel Child wrote: I am trying to create a framework out of some files that I use in a few apps. I expected this to be easy, -- Sorry to interrupt you in mid-sentence, but your expectation is wrong -- but instead got a kazillion warnings, all of which take the form: objc_class_name_NAME referenced from some method in some file.o [MANY METHODS AND FILES LISTED] objc_msgSendmsg referenced from some method in some file.o NSLog referenced from some method in some file.o Sounds similar to what happened to me not long ago. Wrong prefix header. Read this: http://www.cocoabuilder.com/archive/message/xcode/2009/3/15/27679 But, more importantly, read this: http://talblog.info/archives/2007/05/look_ma_no_fram.html Also click on and read the linked articles in there, in particular the article by Wil Shipley. Then, after considering all the better alternatives, if you still think that you want to create a framework from your files and if you (or, I should say, WHEN you) have further trouble, you should ask over on xcode-us...@lists.apple.com since they know more about building with frameworks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: 10.4.x install for testing...
On Apr 27, 2009, at 3:18 PM, Bill Bumgarner wrote: On Apr 27, 2009, at 2:20 PM, Jay Reynolds Freeman wrote: Well, this is an interesting problem, because there are still people running Tiger out there, [snip] Yes, but how many of the Tiger users are actually buying new software? Most of the random stats that I have seen have shown that users of older versions of an OS don't typically lay down $$ for software anyway. I'm sure their cash outlay for software dwindles as there's less and less new software that runs on their older version of the OS. Supporting those that are already your customer is nice/polite/ good, but looking to those markets for new users is likely futile. Don't know about that as I understand the Tiger market to still be significant. I can imagine that changing whenever Snow Leopard ships, especially as there are people on the every-other-major- release upgrade path. Best, __jayson Circus Ponies NoteBook - Organization for a Creative Mind www.circusponies.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: NSTextView re-implementing word wrapping
After reading through the archives I learned how to turn off word wrapping in NSTextView by calling a few methods in both NSText and NSTextContainer but calling them in reverse order (reverting the effect) did not restore word wrapping properly. In particular I think the problem is setContainerSize. If I set it to a fixed width, text is wrapped but I would like it to follow the view bounds like it did originally. Is there a meta-value or something else I need to give it? I suppose you've called setWidthTracksTextView: and setHeightTracksTextView: as needed? If you post your code it would be easier to help you. ~Martin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Removing or ignoring lineWidth property of an NSBezierPath instance
On 28/04/2009, at 3:54 AM, Tobias Zimmerman wrote: I think that, at best, the documentation is ambiguous. It would be clearer specifically saying If no value was set explicitly for the receiver, this method [lineWidth] returns the default line width -at the time the receiver was created- I may file a RADR on that. Well, it didn't seem too ambiguous to me - but then again additional clarification wouldn't hurt. It is further confusing because the actual effect of the lineWidth property is dependent on the view in which the drawing takes place -- that is, a line width of 1.0 in one view will not necessarily appear the same width in a separate view that has a different dot-pitch, pixel ratio, etc. That's not the case. The whole point of Quartz is that it is resolution independent. 1.0 points always means 1.0 points, and when that's rasterized it will set as many pixels as necessary on the device it's drawing to. Of course if the resolution is such that the smallest pixel is effectively 2 points, Quartz can only fake it by drawing the 2pt pixel at half brightness. This happens when you use a line width of, say 0.5, and the smallest pixel is 1.0 points. However the appearance of the line will be consistent, within reason (very coarse resolutions obviously cause problems with this approach, but these days 72dpi is definitely a minimum). Don't confuse points and pixels. While by default without scaling, on screen there is a 1:1 correspondence between them they are completely independent. The only exception to this is when you specify a line width of 0 with NSBezierPath - that will be resolution dependent but it's a special case, and doesn't apply to the CGPath functions. If your aim is to always draw a 1-pixel wide line no matter what the target resolution is, a line width of 0 will do that. If your aim is to always draw a 2- pixel line, you'd have to calculate the necessary line width knowing the resolution of the device and scaling appropriately, as there's no built-in way to force this kind of resolution dependence. If you want to use a fixed resolution regardless, you could create a suitable bitmap and draw into that, then draw that to the target device as needed (and turn off anti-aliasing for that genuine Windows 3.1 look). Where a drawn line width will also appear differently is when a view is scaled (i.e. the view context has a scaling transform in force), but then you'd expect that I would have thought. --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
QTMovie -updateMovieFile file size issue
Hi all. I was hoping I could possibly get some quick feedback on a problem I'm having. I have a cocoa app in which I do the following: - Load a QTMovie with +movieWithFile - Ensure it is editable - Delete two segments with -deleteSegment - Update the file on disk with -updateMovieFile Everything works correctly except that the size of the file is never reduced to reflect the shortened duration. For instance if I load a 200 megabyte 5 minute movie and reduce it to a 3 second clip, even after updating, the 3 second movie is still 200 megabytes. I'm assuming I'm overlooking a necessary re-compression step, perhaps? But I can't find any information on how to go about this. Any suggestions would be greatly appreciated. Thank you in advance. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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
virtual keycode to character
in my app, i allow the user to specify keyboard shortcuts for menu items (in a manner similar to xcode). for the string passed to -[MenuItem setKeyEquivalent], i pass the string obtained from the current event via [NSEvent charactersIgnoringModifiers]. this works fine almost all the time. however, for some keyboard presses it doesn't work properly, namely for shift and some of the number keys, eg., command-! (command exclamation mark) doesn't work as a keyboard equivalent, but shift-command-1 (shift command one) does work. thus, i would like a reliable way to go from virtual keycode to the non-shifted character. in searching the archives, this topic has come up several times, but all proposed solutions that i've found make use of one or more deprecated (in leopard) api calls. eg., LMGetKBDType or GetScriptManagerVariable, etc. does anyone have a solution that doesn't rely on any deprecated api calls? short of a better solution, i may just look at the keycode obtained from the event and check to see if it corresponds to one of the constants for number keys from Events.h. thanx, 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: Cocoa application memory leak check
Thank you, WT and Ken Ferry. Yes, I also think Instruments is a static analyzer, so I am seeking a better tool for memory leak check, which support both static and dynamic checker. Hi, Ken, I have tried the static analyzers you mentioned. But it can not handle this kind of case, for example: //code start void *buffer1 = malloc(32); memset(buffer1,0,32); buffer1 = NULL; void *buffer2 = malloc(32); buffer2 = NULL; void *buffer3 = malloc(32); free(buffer3); buffer3 = NULL; //code end the results in this analysis run is werid. it only report the buffer2, the buffer1 is not checked out. Is it a bug for this tool? or do I also expect too much from this this checker. Thanks. 2009/4/27 Ken Ferry kenfe...@gmail.com .. but speaking of static analyzers, try http://clang.llvm.org/StaticAnalysis.html. I don't think it reasons about malloc and free, but it does reason about -retain and -release. -Ken On Mon, Apr 27, 2009 at 3:14 AM, WT jrca...@gmail.com wrote: I think you're expecting a bit too much from Instruments. I may be wrong, but I think Instruments is not a static analyzer. It only checks for leaks as they occur, that is, at runtime. Thus, if parts of your code do not execute at runtime during a given session, Instruments won't see them and won't care about them. The way to test for leaks such as the one you pointed out is to run Instruments several times, each time forcing a particular path through your code's runtime profile. In your specific example, you'd run your application under Instruments twice, the first time making sure that the condition is true, the second time making sure that the condition is false. You could force the condition to be true or false by interacting with your application at runtime (for instance, if the condition is tied to a checkbox, you'd check the box on or off), or by temporarily setting the condition to true or false in code, explicitly. Wagner On Apr 27, 2009, at 11:33 AM, XiaoGang Li wrote: Hello, list I try to check my Cocoa application memory leak issue using Instruments. here I have a question here: for example: if(conditions == true){ void *buffer1 = malloc(32); buffer1 = NULL; } else { void *buffer2 = malloc(32); buffer2 = NULL; } the Instruments (leaks) can not find out the buffer2 leak, because this part is not executed. So, how to check this kind of memory leak? Thanks. Xiaogang ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com This email sent to kenfe...@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: NSTableViews Load Progressively.
On Apr 27, 2009, at 7:10 AM, Philip Juel Borges wrote: Hi, I have an application that contains 2 nstableviews populated by a property list file. A selection in one changes what is displayed in the next, which in turn loads an html-file in my webview. How do I load the tableviews progressively so that when I select the item from the first tableview it loads the second tableview and then populate the webview? Presently, the webview is populated immediately when I select any item from the first tableview. Conceptually, fill up your modal as much as you want and call - reloadData on the table when appropriate. Implementation-wise, your question is too vague to offer good advice. -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: NSTextView re-implementing word wrapping
Sorry, I didn't post code because it was in Pascal, but it's easy enough to read (remember the old Inside Macintosh books?). I could re- write in Objective-C if anyone needed... setMaxSize: and setWidthTracksTextView: are the culprits here and simply reversing them doesn't work because I don't which max size would correspond to wrapping. Thanks for helping. The code: textView.setHorizontallyResizable(true); layoutSize := textView.maxSize; layoutSize.width := layoutSize.height; textView.setMaxSize(layoutSize); textView.textContainer.setWidthTracksTextView(false); textView.textContainer.setContainerSize(layoutSize); On Apr 28, 2009, at 6:55 AM, Martin Wierschin wrote: After reading through the archives I learned how to turn off word wrapping in NSTextView by calling a few methods in both NSText and NSTextContainer but calling them in reverse order (reverting the effect) did not restore word wrapping properly. In particular I think the problem is setContainerSize. If I set it to a fixed width, text is wrapped but I would like it to follow the view bounds like it did originally. Is there a meta-value or something else I need to give it? I suppose you've called setWidthTracksTextView: and setHeightTracksTextView: as needed? If you post your code it would be easier to help you. ~Martin 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: Cocoa application memory leak check
On Apr 28, 2009, at 3:05 AM, XiaoGang Li wrote: Yes, I also think Instruments is a static analyzer, so... I suppose you meant to say that you also think that it is NOT a static analyzer. :) Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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
Need guidance on data structure
Not directly a Cocoa question - apologies if that's inappropriate, but I could do with some brain power to bear on this design problem and there are lots of smart people here... I have an object that represents a road, say. It has a path that gets drawn to show the road. Typically there are several parts to the rendering of this path, for example a black stroke of say 8 points, overlaid with a grey stroke of say 7 points. This gives a 0.5 point casement to the drawn road. A road can be connected to other roads. Currently each road keeps a list of the subroads that are connected to it, which is a parent- child relationship. A parent road can have any number of child roads, but a child road can only have a maximum of two parents - one for each end. (The parent could also be the same for each end, or it could have an unconnected end which is a nil parent for that end). Roads can connect to each other in any way you like, so in some cases a child road could be the parent of its own parent, and obviously there are many other kinds of cycles possible. The only thing currently not permitted is that a road can't loop back and connect to itself. When a connected network of roads is drawn, the junctions of a parent and child road needs to be carefully handled so that the appearance is right. The casements are drawn first, then the overlaid stroke for the child road, then the overlaid stroke for the parent road which then covers the overlap of the child road stroke to give a clean join. (Child roads might have a different overlay colour from their parent road). To handle this, each junction is drawn by the parent road, including a minimal short length of the child road, with various clippings applied to limit the extent of drawing to the vicinity of the junction. The drawing of each stroke is carefully phased to ensure the desired order. This means that the overall road network can be drawn by simply iterating the list of roads and drawing each one - the order of overall drawing doesn't affect the correct drawing of junctions, because they are effectively re-ordered into the local parent-child ordering on the fly as each one is drawn. Add to this the fact that each road can be directly moved/edited by the user, which recalculates the path, repositions the junctions as needed to remain attached and cascades the path changes to the subroads as needed, and so on. This does all, somehow, manage to work quite well. The problem I'm running into is that once the number of roads multiplies up, the cascading effect becomes too slow to be usable, especially for interactive movement. I also require a couple of cycle-breaking locks to prevent infinite loops, which strikes me as indicative of an awkward design. Something tells me I'm missing a trick here. A data structure that is intended to manage exactly this sort of interconnected network of objects without the awkwardness I'm running into with this ad-hoc approach. The problem is I don't know what sort of thing I should be looking for, or what the right technical terms would be. Or there may be some completely obvious way to do this that I'm missing. The key requirement is that the connections between the parents and children are drawn properly, which requires that children are always drawn before their parents. Because of the cyclic nature of the network though, there isn't a way I can see to simply sort the objects into the right order. Any insight or pointers would be gratefully received at this point - I'm tying myself in knots trying to make this function with any scalability. --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
URL Parsing
Hello, I'm trying to parse out urls in a string and make them into html links so when I put the string into webview people can click them. Any help? Thanks, Mr. Gecko ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
On 2009 Apr 22, at 01:26, Ben Trumbull wrote: The Core Data SQL store supports only one to-many operation per query; therefore in any predicate sent to the SQL store, there may be only one operator (and one instance of that operator) from ALL, ANY, and IN. Do you have a specific scenario in which you need to perform nested to-many operations, yet you cannot use SUBQUERY or compound queries like OR ? Or is this troubling, in the sense that the universe is doomed to evaporate kind of way ? Well, I'd rather give my users NSPredicateEditor and let them make that decision. I'm sure that the code which Apple has written to generate predicates in NSPredicateEditor is better than any that I could write, not to mention that Lazy Programmer thing. However, it appears that NSPredicateEditor can produce compound predicates that violate the rule given above. For example, here's one that I just produced in my app: isAllowedDupe == 1 OR dontVerify == 1 OR shortcut CONTAINS stuff OR comments CONTAINS OR type == 3840 OR name CONTAINS M OR (url CONTAINS a AND tagsString CONTAINS apple) A much better way appears to be to fetch all objects from the store with no predicate and then use -[NSArray filteredArrayWithPredicate:]. This takes only one more line of code, solves all problems, and is supposedly cheaper too: This does not solve all problems, it most emphatically is NOT cheaper, and most assuredly does NOT scale Thank you, Ben. I understand about the scaling now. But for applications with typically small data sets, I believe that - filteredArrayWithPredicate can be a good, practical solution for developers who'd like to leverage the power of NSPredicateEditor in exchange for having a few users with not enough RAM to hold all their objects experience some hard disk access. Performance is always something that needs to be tested, anyhow. The managed objects in my app have 35 properties and I rarely see a user with more than 1500 objects. Searching is something that the average user might do once a week. I have an early 2006 Mac Mini with 2 GB RAM. Filtering an array on a test database of 5000 objects looks like it takes maybe 20 milliseconds or so. So, yes it would be nice to optimize the search, maybe doing a fetch with Core Data and then further filtering the array as someone suggested. I'll probably do some more testing, but at this point my cost/benefit analysis says to wait until, if ever, it becomes an issue for someone. Maybe Apple might provide an easier solution by then ;) (Yes, I know about the ER procedure.) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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
Repositioning the Field Editor
I have a field editor which I need to reposition in my tableView – specifically, I need to move it a few pixels to the right. The following post: http://www.cocoabuilder.com/archive/message/cocoa/2009/3/16/232513 makes two suggestions: (i) implement the move in -viewWillDraw in the field editor subclass, and (ii) reposition the field editor after calling super in -editColumn:row:withEvent:select: in the tableView subclass. Neither of these seem to make any difference to where the field editor is drawn. Here is my code with respect to (i), contained in the field editor subclass: -(void)viewWillDraw { NSRect frame = [self frame]; NSLog(@Old: %f,frame.origin.x); frame.origin.x += 50.0; [self setFrame:frame]; frame = [self frame]; NSLog(@New: %f,frame.origin.x); [super viewWillDraw]; } Now, I can confirm this method is being called, and by means of the NSLog statements, the frame is being changed prior to the call to super. Unfortunately, the field editor is drawn where is usually is drawn, with no shift in place. With respect to (ii), contained in the tableView subclass: -(void)editColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex withEvent:(NSEvent *)theEvent select:(BOOL)flag { [super editColumn:columnIndex row:rowIndex withEvent:theEvent select:flag]; NSText *fieldEditor = [[self window] fieldEditor:YES forObject:self]; NSRect fieldEditorFrame = [fieldEditor frame]; fieldEditorFrame.origin.x += 50.0; [fieldEditor setFrame:fieldEditorFrame]; } Here, it turns out that even though fieldEditor points to the custom field editor object, fieldEditorFrame turns out to be empty. And again, the field editor is drawn where it is usually drawn, with no shift in place. Any help would be greatly 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
Dockless app key bindings
Hi guys, I'm new here and I would like to ask something. I have a Cocoa application that is reduced to StatusItem - no dock, no main menu. Now there is an issue with textfields in my preferences window. Since there is no main menu, there is no Edit menu with Copy, Cut and Paste. Because of this the copy-paste shortcuts don't work on textfields. Could you please either point me to a place in documentation or explain some basic steps I should take to make this work? I know my app isn't perfect but I did in a relatively short time and I learned Obj-c and Cocoa on the go, so I'm pretty proud of it. Thank you all Miro ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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
starting positions of the windows
Hi: I am writing an app with several windows. It seems that they are randomly located when I start the app. Is it possible to line them up nicely? Thanks. Tony Wong _ Windows Live™ Hotmail®:…more than just e-mail. http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_more_042009___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: starting positions of the windows
Hey Tony - Here's a link the Interface Builder User Guide which explains the sizing of NSWindow's and where they appear at runtime. http://tuvix.apple.com/documentation/DeveloperTools/Conceptual/IB_UserGuide/Layout/Layout.html#//apple_ref/doc/uid/TP40005344-CH19-SW14 ) Hopefully you'll find that helpful - Jon Hess On Apr 27, 2009, at 7:10 PM, Tony Wong wrote: Hi: I am writing an app with several windows. It seems that they are randomly located when I start the app. Is it possible to line them up nicely? Thanks. Tony Wong _ Windows Live™ Hotmail®:…more than just e-mail. http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_more_042009___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Need guidance on data structure
On Apr 27, 2009, at 9:47 PM, Graham Cox wrote: Something tells me I'm missing a trick here. A data structure that is intended to manage exactly this sort of interconnected network of objects without the awkwardness I'm running into with this ad-hoc approach. The problem is I don't know what sort of thing I should be looking for, or what the right technical terms would be. Or there may be some completely obvious way to do this that I'm missing. The key requirement is that the connections between the parents and children are drawn properly, which requires that children are always drawn before their parents. Because of the cyclic nature of the network though, there isn't a way I can see to simply sort the objects into the right order. Any insight or pointers would be gratefully received at this point - I'm tying myself in knots trying to make this function with any scalability. I suspect your problem is the cycles. I don't really have a suggestion on how to not have them, though. What you have is directed, possibly cyclic graph. traversing cyclic graphs is a pain, and hard; however, it's pretty widely done, so some quality time with a textbook might be called for. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: virtual keycode to character
On Apr 27, 2009, at 7:46 PM, kvic...@pobox.com wrote: in my app, i allow the user to specify keyboard shortcuts for menu items (in a manner similar to xcode). for the string passed to - [MenuItem setKeyEquivalent], i pass the string obtained from the current event via [NSEvent charactersIgnoringModifiers]. this works fine almost all the time. however, for some keyboard presses it doesn't work properly, namely for shift and some of the number keys, eg., command-! (command exclamation mark) doesn't work as a keyboard equivalent, but shift-command-1 (shift command one) does work. thus, i would like a reliable way to go from virtual keycode to the non- shifted character. in searching the archives, this topic has come up several times, but all proposed solutions that i've found make use of one or more deprecated (in leopard) api calls. eg., LMGetKBDType or GetScriptManagerVariable, etc. does anyone have a solution that doesn't rely on any deprecated api calls? You can use TISCopyCurrentKeyboardLayoutInputSource to get the current keyboard input source. Then, you can query it using TISGetInputSourceProperty with kTISPropertyUnicodeKeyLayoutData to get the 'uchr' data for that keyboard layout. With that, you can call UCKeyTranslate. By the way, LMGetKbdType is not deprecated, at least according to its declaration in the headers. It is documented on a page which is, as a whole, marked as a legacy document. However, I don't know of a way to obtain the keyboard type otherwise (except in the context of a Carbon event). Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: URL Parsing
On Apr 27, 2009, at 8:57 PM, Mr. Gecko wrote: Hello, I'm trying to parse out urls in a string and make them into html links so when I put the string into webview people can click them. Any help? I haven't done any work with WebKit, but NSTextView and NSAttributedString have facilities for URL detection, so I wouldn't be surprised to find that WebView does, too. See -[NSAttributedString URLAtIndex:effectiveRange:] and -[NSTextView setAutomaticLinkDetectionEnabled:]. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Need guidance on data structure
On 28/04/2009, at 11:47 AM, Graham Cox wrote: Not directly a Cocoa question - apologies if that's inappropriate, but I could do with some brain power to bear on this design problem and there are lots of smart people here... I have an object that represents a road, say. It has a path that gets drawn to show the road. Typically there are several parts to the rendering of this path, for example a black stroke of say 8 points, overlaid with a grey stroke of say 7 points. This gives a 0.5 point casement to the drawn road. snip The key requirement is that the connections between the parents and children are drawn properly, which requires that children are always drawn before their parents. Because of the cyclic nature of the network though, there isn't a way I can see to simply sort the objects into the right order. If you treat your roads/ junctions as a graph with nodes and edges you can get the junctions to draw themselves. Since it will have references to its edges ( the roads) it can gather all the info to draw correctly. In other words you no longer have a parent/child relationship. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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
Second frontmost app?
Hey everyone, Is there a way to get the second frontmost app? For example, right now Mail.app is the frontmost, then Safari, because Safari was the active app before I switched to Mail. Is there any sort of API to that tells me that if I were to cmd-tab, that Safari would be the new frontmost app? Thanks, 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
C string constant-NSString constant without defining twice?
Is there a macro for defining an NSString constant as a previously defined C string constant without having to actually define the string in two places? I have something like the following: #define kTempQuagmireHackFilePathCString /private/tmp/quagmire.dat #define kTempQuagmireHackFilePathNSString @/private/tmp/quagmire.dat But I only want to have to define the path in the top define and then use the C string define to define the NSString define. Thanks, Erg ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: C string constant-NSString constant without defining twice?
#define kConstCString This is a const c string #define kConstNSString @kConstCString HTH, Dave On Apr 27, 2009, at 9:35 PM, Erg Consultant wrote: Is there a macro for defining an NSString constant as a previously defined C string constant without having to actually define the string in two places? I have something like the following: #define kTempQuagmireHackFilePathCString /private/tmp/quagmire.dat #define kTempQuagmireHackFilePathNSString @/private/tmp/quagmire.dat But I only want to have to define the path in the top define and then use the C string define to define the NSString define. Thanks, Erg ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: URL Parsing
One thing I can try is to put every word in a array, go through them, see if they contain http or https in the beginning, if so add a href=URLURL/a to it. On Apr 27, 2009, at 10:01 PM, Ken Thomases wrote: On Apr 27, 2009, at 8:57 PM, Mr. Gecko wrote: Hello, I'm trying to parse out urls in a string and make them into html links so when I put the string into webview people can click them. Any help? I haven't done any work with WebKit, but NSTextView and NSAttributedString have facilities for URL detection, so I wouldn't be surprised to find that WebView does, too. See -[NSAttributedString URLAtIndex:effectiveRange:] and - [NSTextView setAutomaticLinkDetectionEnabled:]. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Key Value Coding is not case-sensitive?
Hi all, I'm trying to understand how the KVC works in Objective-C. It seems to me that the 'set' method is not case-sensitive? For example, if I define a class with: @interface TestClass : NSObject { int fido; int Fido; } And have the following set methods: -(void) setfido ... -(void) setFido ... Both by calling [self setValue: ... forKey:@fido] or [self setValue:... forKey:@Fido], the runtime would call the same 'setFido' method. How could this be? Regards, DairyKnight ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Why is NSString-FSRef so hard?
I write the original STL string to a tmp file, then read it back in. The file is encoded in MacRoman. I tried UTF8 with both converting and reinterpreting but if I use UTF8 when I read it back from file, the read returns nil. If I use MacRoman, the string reads back fine, but when I go to convert it to the URL and then the FSSpec, the FSSpec is invalid and cannot be used byLSOpenApplication Here are the snippets: exePathString = [ NSString stringWithContentsOfFile:kTempQuagmireHackFilePathNSString encoding:NSMacOSRomanStringEncoding error:inError ];// - Works urlRef = [ NSURL fileURLWithPath:exePathString ]; // - Works converted = CFURLGetFSRef( (CFURLRef)urlRef, exeRef ); // - Works inAppParams.application = exeRef; // I also zero out the whole block before this. err = LSOpenApplication( inAppParams, outPSN ); // - Fails with -10810 error - Unexpected internal error From: Steve Christensen puns...@mac.com To: Erg Consultant erg_consult...@yahoo.com Cc: cocoa-dev@lists.apple.com Sent: Saturday, April 25, 2009 6:04:14 PM Subject: Re: Why is NSString-FSRef so hard? You'd said in an earlier thread that the file path characters are coming from a text file and that you're then storing those in a STL string. The STL string doesn't care what the encoding is since it's just a storage construct. When you try to create a CFString or NSString from those characters, you need to know what the character encoding is, particularly for the case where a path contains special (non-ASCII) characters, otherwise the CFStringCreate*() or [NSString stringWith*:] calls will fail. If those fail then you won't be able to successfully create a CFURL/NSURL, so CFURLGetFSRef will naturally fail. Since you haven't been able (so far) to determine what the character encoding is, have you thought about reading in the characters from the file, displaying each character in hex, and finding the value(s) that represent one of the non-ASCII characters? With those values in hand you should be able to do some online research to determine what the character encoding actually is. Once you get past that part, everything else should just work. On Saturday, April 25, 2009, at 05:28PM, Erg Consultant erg_consult...@yahoo.com wrote: I was using CFURLGetFSRef passing in the NSString which works fine as long as the path contains no special chars. If it does, CFURLGetFSRef returns nil. Erg From: Nick Zitzmann n...@chronosnet.com To: Erg Consultant erg_consult...@yahoo.com Cc: cocoa-dev@lists.apple.com Sent: Saturday, April 25, 2009 4:41:20 PM Subject: Re: Why is NSString-FSRef so hard? On Apr 25, 2009, at 5:33 PM, Erg Consultant wrote: Isn't there some easy way to get an FSRef from an NSString that is a path containing special characters? What, specifically, have you tried? I don't think I've ever had +fileURLWithPath: fail on me with a path string, even if the string contained non-ASCII characters. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Why is NSString-FSRef so hard?
FSPathMakeRef did not work - which drove me to find some other way such an NSString-CFURL-FSRef. Reading the string in from a file as an NSString does however work for making the original path string without magling the characters - reading the same string from the same file as a CFStringRef however does not work - the special characters get mangled. Erg From: Ken Thomases k...@codeweavers.com To: Erg Consultant erg_consult...@yahoo.com Cc: cocoa-dev@lists.apple.com Sent: Saturday, April 25, 2009 6:12:33 PM Subject: Re: Why is NSString-FSRef so hard? On Apr 25, 2009, at 8:03 PM, Erg Consultant wrote: On Apr 25, 2009, at 7:48 PM, Stephen J. Butler wrote: On Sat, Apr 25, 2009 at 7:28 PM, Erg Consultant erg_consult...@yahoo.com wrote: I was using CFURLGetFSRef passing in the NSString which works fine as long as the path contains no special chars. If it does, CFURLGetFSRef returns nil. CFURLGetFSRef is great if what you have originally is a CF/NSURL. But if you just have an NSString, you might as well use FSPathMakeRef with [aString fileSystemRepresentation]. No reason to create an intermediary NSURL. When I do that, the conversion from NSString to const UInt8 * path mangles the special characters in the path. What do you mean mangles? I suspect you're misinterpreting encodes as mangles. Asking a file path string for its -fileSystemRepresentation is asking it to encode the string into the form expected by various APIs which take file paths in C strings (of 8-bit characters). Of course this won't look like the original Unicode string contents; Unicode can't fit into 8-bit characters without being encoded somehow. But the question is, why do you care? Did FSPathMakeRef work, when passed such a string? It should, which is all you're interested in. 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: Why is NSString-FSRef so hard?
One other thing I should mention - the mangled char in question is the tm symbol (option-2). In its string form, the debugger shows it as the tm char. But when I convert the string to an NSURL using fileURLWithPath, and then do a CFShow, the tm is converted to *three* hex chars: %E2%84%A2 Are NSURL and CFURL not toll-free bridged? Erg From: Sean McBride cwat...@cam.org To: Erg Consultant erg_consult...@yahoo.com; cocoa-dev@lists.apple.com Sent: Sunday, April 26, 2009 2:41:20 PM Subject: Re: Why is NSString-FSRef so hard? Erg Consultant (erg_consult...@yahoo.com) on 2009-04-25 7:33 PM said: Isn't there some easy way to get an FSRef from an NSString that is a path containing special characters? You can use NDAlias: http://github.com/nathanday/ndalias/tree/master It provides an NSString category that converts to/from FSRef. Sean ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Key Value Coding is not case-sensitive?
On Tue, Apr 28, 2009 at 12:09 AM, DairyKnight dairykni...@gmail.com wrote: And have the following set methods: -(void) setfido ... -(void) setFido ... Both by calling [self setValue: ... forKey:@fido] or [self setValue:... forKey:@Fido], the runtime would call the same 'setFido' method. How could this be? -setfido is not a KVC compliant method name. Fido is not a KVC compliant iVar name. (Though generally you should be using KVC via accessor methods and not via direct iVar access anyway.) http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/Compliant.html - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Key Value Coding is not case-sensitive?
On Apr 27, 2009, at 11:09 PM, DairyKnight wrote: I'm trying to understand how the KVC works in Objective-C. It seems to me that the 'set' method is not case-sensitive? For example, if I define a class with: @interface TestClass : NSObject { int fido; int Fido; } And have the following set methods: -(void) setfido ... -(void) setFido ... Both by calling [self setValue: ... forKey:@fido] or [self setValue:... forKey:@Fido], the runtime would call the same 'setFido' method. How could this be? Because KVC computes the name of the method to invoke by capitalizing the property name. It's not completely insensitive to case, but the first letter will be uppercased. You should not have two properties which differ only in the case of the first letter of their name. In general, property names should start with a lowercase letter unless the first part of their name is an acronym/initialism, like URL. In KVC documentation, you will often see placeholders key and Key showing how method names are computed from keys. The case in those two placeholders is important. The capitalized placeholder (Key) is replaced with the capitalized form of the key name (e.g. Fido for the key fido). 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: Why is NSString-FSRef so hard?
On Apr 27, 2009, at 11:26 PM, Erg Consultant wrote: One other thing I should mention - the mangled char in question is the tm symbol (option-2). In its string form, the debugger shows it as the tm char. But when I convert the string to an NSURL using fileURLWithPath, and then do a CFShow, the tm is converted to *three* hex chars: %E2%84%A2 Right. This is to be expected. Not all characters are legal within URLs. So, URLs have to be escaped. The trademark character in UTF-8 encoding is the byte sequence 0xE2, 0x84, 0xA2. Yes, three bytes. Those bytes are then escaped using percent-sign-hex-value to make them safe for a URL. I strongly suspect your problems and your confusion about the results you're seeing are because you aren't understanding the subject of string encoding. You appear to be blindly stabbing in the dark, trying to guess why things work or don't. As somebody earlier in the thread pointed out, STL strings are not encoding aware. If you don't know the encoding of the bytes that you used to initialize those STL strings, then you're not going to have any luck interpreting them, writing them sanely to a file in a consistent way, nor reading them back in. Are NSURL and CFURL not toll-free bridged? They are toll-free bridged. What about the above made you think otherwise? 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: Cocoa application memory leak check
On Mon, Apr 27, 2009 at 9:05 PM, XiaoGang Li andrew.mac...@gmail.com wrote: Thank you, WT and Ken Ferry. Yes, I also think Instruments is a static analyzer, so I am seeking a better tool for memory leak check, which support both static and dynamic checker. Hi, Ken, I have tried the static analyzers you mentioned. But it can not handle this kind of case, for example: //code start void *buffer1 = malloc(32); memset(buffer1,0,32); buffer1 = NULL; void *buffer2 = malloc(32); buffer2 = NULL; void *buffer3 = malloc(32); free(buffer3); buffer3 = NULL; //code end the results in this analysis run is werid. it only report the buffer2, the buffer1 is not checked out. Is it a bug for this tool? or do I also expect too much from this this checker. Buffer 3 obviously is not wrong, so it doesn't show up. As for buffer 1, this is at least potentially correct as well. Without knowing what memset() does, it's possible that it holds on to the pointer you pass it and takes responsibility for freeing it. Unlike Cocoa, where reference counting means that you can have consistent semantics no matter where you pass pointers, straight malloc/free means that as soon as your pointer escapes your code, the static analyzer has to assume that something good is happening to it. In this case, memset() is a standard C function whose semantics are known, so in theory, if the static analyzer can prove that you're calling that one (and not, say, a shadowed custom version or using a #define to point it elsewhere) then it could flag this as a bug. That's pretty sophisticated, though, and since it's only useful for a limited subset of all available functions, it probably doesn't bother. 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: Why is NSString-FSRef so hard?
On Tue, Apr 28, 2009 at 12:51 AM, Erg Consultant erg_consult...@yahoo.com wrote: So why isn't it working? Why does LSOpenApplication give me an error? It is impossible to answer questions of this nature if you do not post your code. 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: errors building framework
On Mon, Apr 27, 2009 at 5:31 PM, Daniel Child wch...@hawaii.edu wrote: I am trying to create a framework out of some files that I use in a few apps. I expected this to be easy, but instead got a kazillion warnings, all of which take the form: objc_class_name_NAME referenced from some method in some file.o [MANY METHODS AND FILES LISTED] or objc_msgSendmsg referenced from some method in some file.o or NSLog referenced from some method in some file.o Since the files originally came from projects that work (and do have Cocoa.h imported), I'm at a loss as to why this error would come up. If someone knows, or knows where I could read about this issue, I'd really appreciate it. Thanks. Link your framework against Cocoa as well as importing it. 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: Autorelease and passing by reference in background threads
On Mon, Apr 27, 2009 at 3:17 PM, Symphonik sympho...@gmail.com wrote: All, I am using a couple of methods that use NSError ** pointers to communicate error conditions. These methods run on background threads and so have their own autorelease pools set up. I pass an NSError pointer down a couple of method calls -- by the time it comes back up, it has been dealloc'd by the autorelease pool. A simple example (this will run if you want to try it for yourself): - (void)applicationDidFinishLaunching:(UIApplication *)application { [self performSelectorInBackground:@selector(runBackgroundProcess) withObject:nil]; } - (void)runBackgroundProcess { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSError *error = nil; [self runSomethingThatWillFail:error]; if(error) { NSLog(@error: %@, error); // CRASH HERE, EXC_BAD_ACCESS due to bogus pointer } [pool release]; } - (void)runSomethingThatWillFail:(NSError **)error { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@/BOGUS error:error]; [pool release]; } So I crash in runBackgroundProcess since the error is getting wiped by the local autorelease pool. Okay, so I'll retain it... - (void)runSomethingThatWillFail:(NSError **)error { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@/BOGUS error:error]; [*error retain]; [pool release]; } Well, now I have a leak of that NSError object... so I should autorelease it, I suppose. But that autorelease needs to be outside the release of the local pool, so it becomes: - (void)runSomethingThatWillFail:(NSError **)error { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@/BOGUS error:error]; [*error retain]; [pool release]; [*error autorelease]; } Now it works and isn't leaking anymore. But factor in that I have to do some checking on the existence of the error before I dereference it, etc... this is becoming some ugly code just to get my NSError back up the chain. Am I overthinking this? Anyone else have better suggestions? Why does -runSomethingThatWillFail: have its own pool? You already have a pool, you don't need a second one. Get rid of that pool and suddenly everything becomes easy. If it really *must* have a pool for some reason, then the retain/autorelease dance is the standard procedure for getting returned objects out of the current pool and into the next one. Think of that error value as a return value, even though it's returned by reference and not by value. 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: Dockless app key bindings
On Mon, Apr 27, 2009 at 6:17 PM, meosoft meosofts...@gmail.com wrote: Hi guys, I'm new here and I would like to ask something. I have a Cocoa application that is reduced to StatusItem - no dock, no main menu. Now there is an issue with textfields in my preferences window. Since there is no main menu, there is no Edit menu with Copy, Cut and Paste. Because of this the copy-paste shortcuts don't work on textfields. Could you please either point me to a place in documentation or explain some basic steps I should take to make this work? I know my app isn't perfect but I did in a relatively short time and I learned Obj-c and Cocoa on the go, so I'm pretty proud of it. Put your main menu back. It will not appear on the screen, but it will still be used for keyboard shortcuts when your app is frontmost. 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: Why is NSString-FSRef so hard?
BOOLresult = YES; Booleanconverted = false; unsignedi = 0; pid_tpid = -1; NSBundle*glBundle = [ NSBundle mainBundle ]; NSDictionary*d = nil; NSDictionary*dd; NSString*z; NSString*zzz; NSMutableString*m; NSArray*arr; NSURL*urlRef = nil; NSError*inError = nil; FSRefexeRef; LSApplicationParametersinAppParams; ProcessSerialNumberoutPSN; OSStatuserr = noErr; memset( inAppParams, 0, sizeof( inAppParams ) ); memset( outPSN, 0, sizeof( outPSN ) ); if( glBundle ) { // Get main bundle info dict... d = [ glBundle infoDictionary ] if( d ) { // Get the GL bundle's path from the info dict... z = [ d objectForKey:kNSBundleInitialPathInfoDictKey ]; if( z ) { // Break the path up into a path component array... arr = [ z componentsSeparatedByString:kSlashStringKey ]; // Make a mutable path string to manipulate... m = [ NSMutableString stringWithCapacity:0 ]; } } } if( m arr ) { for(i=0; i[ arr count] - 1; i++ ) { [m appendString:[arr objectAtIndex:i] ]; [m appendString:@/ ]; } //go up one level to get at Info.plist [m appendString:@Info.plist ]; dd = [ NSDictionary dictionaryWithContentsOfFile:m ]; zzz = [ dd valueForKey:@CFBundleExecutable ]; //reset [ m setString:@ ]; //Loop again appening all path compoents to final file to launch... for(i=0; i[ arr count] - 1; i++ ) { [m appendString:[arr objectAtIndex:i] ]; [m appendString:@/ ]; } //now get full path to the file we want to actually run... [ m appendString:zzz ]; [ m appendString:@.ifn ]; urlRef = [ NSURL fileURLWithPath:m ]; if( urlRef ) { CFShow( urlRef ); converted = CFURLGetFSRef( (CFURLRef)urlRef, exeRef ); if( converted ) { // Setup launch param block... inAppParams.application = exeRef; // Launch! err = LSOpenApplication( inAppParams, outPSN ); if( !err ) { err = GetProcessPID( outPSN, pid ); if( !err ) { lppiProcInfo-dwProcessId = (DWORD)pid; result = true; } } } } From: Michael Ash michael@gmail.com To: cocoa-dev cocoa-dev@lists.apple.com Sent: Monday, April 27, 2009 9:57:33 PM Subject: Re: Why is NSString-FSRef so hard? On Tue, Apr 28, 2009 at 12:51 AM, Erg Consultant erg_consult...@yahoo.com wrote: So why isn't it working? Why does LSOpenApplication give me an error? It is impossible to answer questions of this nature if you do not post your code. 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/erg_consultant%40yahoo.com This email sent to erg_consult...@yahoo.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: Why is NSString-FSRef so hard?
On Apr 27, 2009, at 11:51 PM, Erg Consultant wrote: 4) I verified that the file I am trying to open using LSOpenApplication exists at the path the URL points to when it gets converted to an FSRef. So why isn't it working? Why does LSOpenApplication give me an error? What is the path/URL/FSRef pointing to? What is the nature of the file-system object at that location? LSOpenApplication is expecting it to be an application bundle, generally. (There are some corner cases that are extremely rare in practice.) Have you considered using one of the other Launch Services functions, like LSOpenCFURLRef? 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: Why is NSString-FSRef so hard?
I abandoned the idea of using the temp file and now I assemble the path to the file I want on the fly using the main bundle and an Info.plist file which contains the executable file name - I am still having the same problem - without the STL string, temp file, or reading any file at all. So the STL string is no longer an issue - but the problem is. Apple's doc's specifically say to stay away from using the CString routines which require encodings. So now the encoding issue goes away. The problem is LSOpenApplication() does not like the FSRef I pass it which gets created from the path NSString-CFURL-FSRef. Erg From: Michael Ash michael@gmail.com To: cocoa-dev cocoa-dev@lists.apple.com Sent: Monday, April 27, 2009 9:51:14 PM Subject: Re: Why is NSString-FSRef so hard? On Tue, Apr 28, 2009 at 12:26 AM, Erg Consultant erg_consult...@yahoo.com wrote: One other thing I should mention - the mangled char in question is the tm symbol (option-2). In its string form, the debugger shows it as the tm char. But when I convert the string to an NSURL using fileURLWithPath, and then do a CFShow, the tm is converted to *three* hex chars: %E2%84%A2 Are NSURL and CFURL not toll-free bridged? Read this: http://www.joelonsoftware.com/articles/Unicode.html And then this: http://en.wikipedia.org/wiki/UTF-8 And this: http://en.wikipedia.org/wiki/UTF-16 Then, suitably enlightened, come back and fix up your code to work with your new knowledge. One other piece of knowledge: if you're converting your std::string to an NSString by writing it to a file, you're doing it wrong. Very, very, very wrong. All you should have to do is [NSString stringWithCString:stl_string.c_str() encoding:...] with the appropriate encoding substituted at the end. If you do not know the appropriate encoding, then you must find out. If the encoding is not UTF-8, then I strongly encourage you to make whatever changes are necessary so that it *is* UTF-8, as UTF-8 is the only sensible 8-bit encoding to use these days unless you're communicating with legacy systems. 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/erg_consultant%40yahoo.com This email sent to erg_consult...@yahoo.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: Why is NSString-FSRef so hard?
LSOpenCFURLRef doesn't work either - kLSApplicationNotFoundErr. The nature of the file is the app's exe which is normally inside the MacOS dir. However, all this works perfectly fine if there are no special chars in the path - the exe launches just fine. I find it hard to believe that Apple would issue an API that executes single executable binaries only in the case that they don't have special chars in the path. Erg From: Ken Thomases k...@codeweavers.com To: Erg Consultant erg_consult...@yahoo.com Cc: cocoa-dev@lists.apple.com Sent: Monday, April 27, 2009 10:11:43 PM Subject: Re: Why is NSString-FSRef so hard? On Apr 27, 2009, at 11:51 PM, Erg Consultant wrote: 4) I verified that the file I am trying to open using LSOpenApplication exists at the path the URL points to when it gets converted to an FSRef. So why isn't it working? Why does LSOpenApplication give me an error? What is the path/URL/FSRef pointing to? What is the nature of the file-system object at that location? LSOpenApplication is expecting it to be an application bundle, generally. (There are some corner cases that are extremely rare in practice.) Have you considered using one of the other Launch Services functions, like LSOpenCFURLRef? 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: Why is NSString-FSRef so hard?
Ok, here is the code: BOOLresult = NO; Booleanconverted = false; unsignedi = 0; pid_tpid = -1; NSBundle*glBundle = [ NSBundle mainBundle ]; NSDictionary*d = nil; NSDictionary*dd = nil; NSString*z = nil; NSString*zzz = nil; NSMutableString*m = nil; NSArray*arr = nil; NSURL*urlRef = nil; NSError*inError = nil; FSRefexeRef; LSApplicationParametersinAppParams; ProcessSerialNumberoutPSN; OSStatuserr = noErr; memset( exeRef, 0, sizeof( exeRef ) ); memset( inAppParams, 0, sizeof( inAppParams ) ); memset( outPSN, 0, sizeof( outPSN ) ); if( glBundle ) { // Get main bundle info dict... d = [ glBundle infoDictionary ]; if( d ) { // Get the GL bundle's path from the info dict... z = [ d objectForKey:kNSBundleInitialPathInfoDictKey ]; if( z ) { // Break the path up into a path component array... arr = [ z componentsSeparatedByString:kSlashStringKey ]; // Make a mutable path string to manipulate... m = [ NSMutableString stringWithCapacity:0 ]; } } } if( m arr ) { for(i=0; i[ arr count] - 1; i++ ) { [m appendString:[arr objectAtIndex:i] ]; [m appendString:@/ ]; } //go up one level to get at Info.plist [m appendString:@Info.plist ]; dd = [ NSDictionary dictionaryWithContentsOfFile:m ]; zzz = [ dd valueForKey:@CFBundleExecutable ]; //reset [ m setString:@ ]; //Loop again appening all path compoents to final file to launch... for(i=0; i[ arr count] - 1; i++ ) { [m appendString:[arr objectAtIndex:i] ]; [m appendString:@/ ]; } //now get full path to the file we want to actually run... [ m appendString:zzz ]; [ m appendString:@.ifn ]; urlRef = [ NSURL fileURLWithPath:m ]; if( urlRef ) { converted = CFURLGetFSRef( (CFURLRef)urlRef, exeRef ); if( converted ) { CFURLRefqaud = NULL; err = LSOpenCFURLRef( (CFURLRef)urlRef, qaud ); // Setup launch param block... inAppParams.application = exeRef; // Launch! err = LSOpenApplication( inAppParams, outPSN ); if( !err ) { err = GetProcessPID( outPSN, pid ); if( !err ) { lppiProcInfo-dwProcessId = (DWORD)pid; result = YES; } } } } From: Ken Thomases k...@codeweavers.com To: Erg Consultant erg_consult...@yahoo.com Cc: cocoa-dev@lists.apple.com Sent: Saturday, April 25, 2009 6:12:33 PM Subject: Re: Why is NSString-FSRef so hard? On Apr 25, 2009, at 8:03 PM, Erg Consultant wrote: On Apr 25, 2009, at 7:48 PM, Stephen J. Butler wrote: On Sat, Apr 25, 2009 at 7:28 PM, Erg Consultant erg_consult...@yahoo.com wrote: I was using CFURLGetFSRef passing in the NSString which works fine as long as the path contains no special chars. If it does, CFURLGetFSRef returns nil. CFURLGetFSRef is great if what you have originally is a CF/NSURL. But if you just have an NSString, you might as well use FSPathMakeRef with [aString fileSystemRepresentation]. No reason to create an intermediary NSURL. When I do that, the conversion from NSString to const UInt8 * path mangles the special characters in the path. What do you mean mangles? I suspect you're misinterpreting encodes as mangles. Asking a file path string for its -fileSystemRepresentation is asking it to encode the string into the form expected by various APIs which take file paths in C strings (of 8-bit characters). Of course this won't look like the original Unicode string contents; Unicode can't fit into 8-bit characters without being encoded somehow. But the question is, why do you care? Did FSPathMakeRef work, when passed such a string? It should, which is all you're interested in. Regards, Ken ___
Getting Display Names
I have established for system displays the ability to retrieve numerical IDs (unit number, vendor number, display ID, etc.) for the main and auxiliary displays attached to the system; however, I cannot seem to find an ability to get the localized name associated with the display (Cinema, Cinema Display, Color LCD, etc.). Are these names only accessible from private frameworks or is there an AppKit or CoreGraphics API I have yet to stumble across that maps the display unit number or display ID to a localized (or not) display name? Thanks, Grant 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