Re: Modal sheet / dialog + thread == main app thread hangs ?
>From the NSApplicationDocumentation: "abortModal must be used instead of stopModal or stopModalWithCode: when you need to stop a modal event loop from anywhere other than a callout from that event loop. In other words, if you want to stop the loop in response to a user’s actions within the modal window, use stopModal; otherwise, use abortModal. For example, use abortModal when running in a different thread from the Application Kit’s main thread or when responding to an NSTimer that you have added to the NSModalPanelRunLoopMode mode of the default NSRunLoop." So, I learned something today. Nice. thanks, marc. 2009/10/18 Marc Wandschneider : > I'm in the midst of debugging an extremely unusual problem, and I was > wondering if anybody might have any insight into what might be going > wrong: > In a controller class from a NIB, I take an NSPanel I from that same > NIB, and then show it app modally on an NSWindow (that was created by > hand in code): > > [[NSApplication sharedApplication] beginSheet: myPanel > modalForWindow: window > modalDelegate: self > didEndSelector: > @selector(sheetDidEnd:returnCode:contextInfo:) > contextInfo: nil]; > [[NSApplication sharedApplication] runModalForWindow: myPanel]; > > > now, when the "finish button is clicked", i run some code to disable > some buttons an fire off a thread to make sure the user input is valid > (i have to validate with a remote service). This thread is fired from > a separate validator object I create: > > * setEnabled NO on a few controls > * setHidden NO on a control > > // validator object > validateInfo: (NSDictionary *)parms notify: (SEL)notifySelector > onObject: (id)notifyObject > { > // build up data with parms and notify info > [[NSThread detachNewThreadSelector: @selector(remotevalidate:) > toTarget: self withObject: data]; > } > > > next, when the validation is finished, the validator notifies my > controller object: > > [notifyObject performSelectorOnMainThread: notifySelector > withObject: results waitUntilDone: NO]; > > > > and then my controller object, in the method that the validator object > calls, kills the dialog: > > - (void)validationComplete: (id)data > { > [[NSApplication sharedApplication] stopModal]; > [createTwitterPanel orderOut: nil]; > [[NSApplication sharedApplication] endSheet: createTwitterPanel > returnCode: NSOKButton]; > } > > > My problem: the top runModalForWindow does not exit until some system > event is sent to the window that was showing the dialog. trying to > move, resize, or do anything to the window, or otherwise switching > away from the application suddenly causes method to exit and execution > to continue. no amount of waiting seems to help, otherwise, however. > > An even further, more interesting clue is that the dialog has two > controls, a WebView and a TextField. Even if I restart things by > clicking on the window, TABbing between the two controls remains > screwed up — it simply never works again. > > I've tried changing validationComplete: to instead post a notification > to the main thread, and I've also played with the waitUntilDone on the > performSelectorOnMainThread method, all to no effect. > > Any ideas? Things I should try looking at? > > Thanks, > marc. > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: GC and atomic getters/setters
On Sat, Oct 17, 2009 at 9:32 PM, Kyle Sluder wrote: > On Sat, Oct 17, 2009 at 6:20 PM, Ken Ferry wrote: >> The issue concerns the order of in which changes to memory are observable by >> other processors. > > Okay, and the read example is immune because you have to read the > address before you can read the thing at that address, and it's > therefore impossible to wind up in a bad situation due to read > reordering, simply because the reads have to be structured in a > particular way. > > I'm struggling to picture being able to write code that is sensitive > to write reordering under GC that is not either sensitive to write > reordering on non-GC with equivalent locking and is also not sensitive > to other concurrency problems. > > Of course, I attribute this more to my lack of imagination or > experience at the lower levels than to the lack of a good example. With correctly done locking, your code will never see read or write reordering, so it's no surprise that you can't picture such a scenario. "Correctly done locking" means that all shared data is protected by a lock, both when reading and writing. The reason this always saves you is simply because locks incorporate memory barriers, and thus force the correct ordering. Your code can still experience reordering while it's within a critical section, but no other CPU can be accessing that shared data at the same time, so it has no ill effect. Your code can still experience reordering outside of a critical section, but no other CPU can be accessing that data at all, because it's not shared. The CPU can't order reads/writes into or out of critical sections, because of the memory barriers in the locks. There's nothing GC-specific here, except for the fact that GC lets you write lockless accessor methods where in a non-GC land you *must* involve a lock on both ends. (Or write some extraordinarily complicated lockless code, which is really beyond the scope of this thread.) I was worried because Apple's guide says that GC doesn't require locks for this, because the locks are there to solve memory management. They're there for more than that, but it looks like the lockless GC approach takes care of the rest too. In short: you only have to start worrying about weird stuff like read/write reordering and memory barriers when you start trying to manipulate shared data without using locks. 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 does my font come out looking fuzzy?
On Oct 17, 2009, at 7:46 PM, Ben Haller wrote: Copied the TrueType font from Instruments into my project, added the necessary key to my Info.plist, set the font using [NSFont fontWithName:...], and hey presto, there the font is in my app. Only... it doesn't look as nice. It's less crisp. Kind of fuzzy. The corners don't look sharp. Is the point size the same? If this is a special-purpose font, it might have some hinting for the specific point size used in Instruments. You might need to compare the character heights up-close with Pixie or something. —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to retrieve the font information from TrueType font file?
On Oct 17, 2009, at 8:09 AM, Mike Wright wrote: FYI, I haven't found any of the "Font Suitcase" files that have a data fork. The font is in the 'FOND' resource -- and all of those fonts work fine under Snow Leopard. Some of this legacy stuff is probably pretty hard to eliminate without nasty repercussions. .dfont files, I believe, are suitcases in the form of data-fork-based resource files. Fonts themselves were never stored in FOND resources. The FOND is/was just an index pointing to the individual FONT or sfnt resources for the font family. And in the case of Type 1 fonts, it pointed to the filename of the 'LWFN' file with the PostScript data. (BTW, I spent 1988-90 developing a PostScript and TrueType font editor for a small foundry that went out of business.) —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Modal sheet / dialog + thread == main app thread hangs ?
I'm in the midst of debugging an extremely unusual problem, and I was wondering if anybody might have any insight into what might be going wrong: In a controller class from a NIB, I take an NSPanel I from that same NIB, and then show it app modally on an NSWindow (that was created by hand in code): [[NSApplication sharedApplication] beginSheet: myPanel modalForWindow: window modalDelegate: self didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) contextInfo: nil]; [[NSApplication sharedApplication] runModalForWindow: myPanel]; now, when the "finish button is clicked", i run some code to disable some buttons an fire off a thread to make sure the user input is valid (i have to validate with a remote service). This thread is fired from a separate validator object I create: * setEnabled NO on a few controls * setHidden NO on a control // validator object validateInfo: (NSDictionary *)parms notify: (SEL)notifySelector onObject: (id)notifyObject { // build up data with parms and notify info [[NSThread detachNewThreadSelector: @selector(remotevalidate:) toTarget: self withObject: data]; } next, when the validation is finished, the validator notifies my controller object: [notifyObject performSelectorOnMainThread: notifySelector withObject: results waitUntilDone: NO]; and then my controller object, in the method that the validator object calls, kills the dialog: - (void)validationComplete: (id)data { [[NSApplication sharedApplication] stopModal]; [createTwitterPanel orderOut: nil]; [[NSApplication sharedApplication] endSheet: createTwitterPanel returnCode: NSOKButton]; } My problem: the top runModalForWindow does not exit until some system event is sent to the window that was showing the dialog. trying to move, resize, or do anything to the window, or otherwise switching away from the application suddenly causes method to exit and execution to continue. no amount of waiting seems to help, otherwise, however. An even further, more interesting clue is that the dialog has two controls, a WebView and a TextField. Even if I restart things by clicking on the window, TABbing between the two controls remains screwed up — it simply never works again. I've tried changing validationComplete: to instead post a notification to the main thread, and I've also played with the waitUntilDone on the performSelectorOnMainThread method, all to no effect. Any ideas? Things I should try looking at? Thanks, marc. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSRulerMarker and dragging
Hello Cocoa List, My Googling reveals this question has been asked before, but no answer was given. Hopefully someone knows how to do this now. I have a vertical NSRulerView attached to an NSTextView. I have movable NSRulerMarkers and that's all working good. My only problem is that the NSRulerMarkers insist on displaying a tooltip with the current measurement values when the marker is being dragged. This is not appropriate in my application. Ideally, I would like to suppress these tooltips. I have tried intercepting various things in my NSRulerView subclass. These typically didn't work because the ruler view doesn't seem to be responsible for the generation of the tooltips. NSRulerMarker doesn't seem to have functionality to do this, and doesn't inherit from NSView either. Another way to manage this might be to provide a dynamic measurement unit. My markers are essentially pointers into the text, and really are indicating specific line numbers, like break points. Dynamic measurements would be necessary because the font of the TextView can be set by the user, and where the marker is pointing will then depend on the font size. There doesn't seem to be a way to do this either. Is there something I'm missing? Surely this is something someone has attempted before? Thanks in advance, Arved ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: correctly Controlling Garbage Collection
On Oct 17, 2009, at 18:48, Rob Keniger wrote: What happens if you explicitly disable Garbage Collection when the user starts drawing and enable it when the user finishes? That might be a practical answer, but I think maybe a key point got skipped over earlier in the thread. If the collector causes a *noticeable* pause in the mouse tracking, then presumably it has a fair amount of work to do. (Lots of unreferenced blocks to reclaim, for example, or lots of memory to scan). Unless someone wants to claim that the creation and freeing of NSEvent objects (and such like) by the framework produces such a volume of work for the collector (which I doubt, though have to evidence for), the possible implication is that the application code for handling the events is generating lots of objects with short lifetimes. In that case, the correct solution is to rearchitect the event handling to avoid creating so many objects. Of course, other possibilities include: (a) a bug in the frameworks, and (b) an unfortunate edge scenario where neither frameworks nor application is doing anything wrong, but the collector happens to perform poorly. Whatever the cause, surely the *only* reasonable way to proceed is to instrument the performance (both where the CPU time goes and what's doing allocations)? That was also suggested earlier in the thread, IIRC. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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 does my font come out looking fuzzy?
There's also the possibility that the text isn't being drawn properly aligned to the pixel grid. Sent from my iPhone On Oct 17, 2009, at 19:52, Kyle Sluder wrote: You need to post a screenshot of what you're seeing. I can think of two possibilities off the top of my head: 1) You're rendering text into a CALayer (especially a CATextLayer). Without some tweaking, CALayer can't do subpixel antialiasing (aka LCD antialiasing), because it doesn't have the existing backing store to composite against. 2) You're overdrawing the text and are therefore ruining the antialiasing, producing a distorted image. Again, screenshot is pretty much mandatory here. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com This email sent to clarkc...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Programming Style: Method Definition with or without a semicolon.
Thanks a million for this, awesome! -- yandy On Oct 17, 2009, at 10:01 PM, Rob Keniger wrote: On 17/10/2009, at 10:25 PM, Graham Cox wrote: If there is a way to disable these insertions independently and I've missed it, please someone, let me know how to do it. I can't recommend the ODCompletionDictionary plug-in for Xcode highly enough: http://www.obdev.at/products/completion-dictionary/index.html It allows you to create fully customizable macros and falls back to Xcode's auto-completion if a match can't be found. -- Rob Keniger ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/yandyr%40gmail.com This email sent to yan...@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: Manipluate Cocoa Touch keyboard mode
numbers and punctuation in IB textfield properties for keyboard type -- yandy On Oct 17, 2009, at 8:53 PM, Tron Thomas wrote: When an UITextField becomes active in a Cocoa Touch application, the device automatically displays a keyboard for character input. The keyboard always appears in alphabet mode so letters can be typed. I have an application containing a singular UITextField that is intended for entering numeric data. I would like the keyboard to come up in numeric mode and stay in that mode unless the user click the button to toggle to letter mode, even if they press the return key. How can someone accomplish this keyboard behavior? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/yandy%40me.com This email sent to ya...@me.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Using core data binary and string attributes with NSTextView
I'm new to core data and bindings and need some help. In my model, I've got an attribute called "story". This holds text, so I set the attribute type to string. I used bindings in IB to connect the story attribute to an NSTextView. When I ran my app, an exception was thrown. The message in the console indicated a conflict. It seemed core data was pulling an attributed string out of the NSTextView, and could not store in in my model's story attribute which was only a string. I worked around this my turning off the NSTextView's Rich Text checkbox in IB. Everything ran fine, NSTextView displayed my data. Then I added a search field to my app. In IB I set things up to search the story attribute. It worked great. Then I noticed that I couldn't save font styles, sizes etc in my NSTextView. I played around with the model again and made the story attribute a Binary Data type, and I turned the Rich Text setting back on for the NSTextView. This worked for saving the story text and font stuff, but broke searching. It reasons that now that the story attribute is binary, it can't be search like when it was string. Now, after a lot of googling, I'm working on a solution that involves having a new transient attribute in my model of type string (let's call it storyText) that will mirror the text held in the binary data story attribute. Instead of my search field using the "story" attribute, it will use the "storyText" attribute. To do this, I created .m and .h files for my model, and I'm implementing the accessor and setter for the storyText attribute. In the accessor method, I get, using valueForKey, the story object. The question now is, what do I do with it? It appears that this object is an NSData object. Am I correct about this? What do I do with it to get it into an NSAttributed string on which I can extract the string? Hope I've stated all the facts clearly and that someone can enlighten me. 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: How to switch the default printer?
Thanks, Scott! I had started to look at the printing prefs file as it contained information about the printers in use. Appreciate the sharing! Cheers! -Laurent. -- Laurent Daudelin AIM/iChat/Skype:LaurentDaudelin http://nemesys.dyndns.org Logiciels Nemesys Software laurent.daude...@gmail.com Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries On Oct 17, 2009, at 14:18, Scott Ribe wrote: >> Well... suppose from my application, I want to convert a Word document to >> PDF. >> How would I do that? I did quite a bit of research and the only way I found >> was to use CUPS-PDF and have Word print to that printer. Then, I can retrieve >> the converted PDF document. Is there any other way? > > You are right, this is the only way. > > So there's a couple of things you have to deal with, and in particular > things are different in 10.4 & 10.5. (I haven't actually tried this under > 10.6 yet.) A particular quirk is that using lpoptions to set the default > printer does not work if "use last printer" is the option selected for > default printer in system preferences. The below code isn't your exact > answer since it depends on my own code for executing processes, and is C++, > but I think you can read it and get the idea: [snip!]___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Probs with "BetterAuthorizationSample"-code
(Due to a misconfiguration I did send this message more than once - sorry for that to all) Hi there, thanks to your and esp. Todds hints everything works quiet fine now. Two additional detail question remain: 1- How can I set up the BAS to proceed an install process without the HelperTool called necessarily at this time? While this the admin credentials should be asked once. 2- How can I adjust the credentials life time to endless so after the install process they would not be asked anymore? To understand this let me explain what I am doing: My helper tool calls a kext written by myself which provides certain system calls (in better words: it fakes an USB HID). But from time to time the login prompt is presented, obviously after a certain time out, and that is not what I want to see because it disturbs the HID command processing. Thanks a lot again! Frank Am 04.10.2009 um 05:37 schrieb Todd Heberlein: 1. How can I debug my HelperTool? Obviously any breakpoints set in XCode won't work because the HelperTool is launched outside by the launchd. 2. My idea is to use asl to debug "barefoot". But for that I have to install aeach time when I have compiled a modified version of the HelperTool to the system. But how to do this? InstallerTool does not do this itself. I have used asl_log() messages as a substitute for printf(). The messages goes to your Console (the one under /Applications/ Utilities) and not to the "Console" in Xcode, so make sure you are looking in the right place for output. I think printf() will just cause the HelperTool to exit with error. Every time I modify any code used by my helper tool I run $ ./SampleUninstall.sh I just had to change all the references in the shell script to my application's Identifier. For example, my modified shell script has the lines: sudo launchctl unload -w /Library/LaunchDaemons/ com.netsq.ACManager.plist sudo rm /Library/LaunchDaemons/com.netsq.ACManager.plist sudo rm /Library/PrivilegedHelperTools/com.netsq.ACManager sudo rm /var/run/com.netsq.ACManager.socket And the Cocoa app's "Identifier" in the target's property window is: com.netsq.${PRODUCT_NAME:rfc1034identifier} (the Project is called ACManager) so "com.netsq.ACManager" is inserted in all the appropriate places in the script. If things are really screwed up, you can look in the directories identified in the shell script, remove the appropriate files by hand, and then logout and log back in (if that doesn't solve your launchctl errors you may need to reboot as a crude but effective step). But once you have your SampleUninstall.sh script set up correctly, running it each time you make code modifications should work. Todd -- Frank W. Tag Dahlenhöhe 3 21077 Hamburg Tel. (040) 432 774 11 Fax (040) 432 774 15 mobil (0160) 973 40 131 mailto:fr...@tag-hamburg.de ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: UTIs and readFromURL/writeToURL
On 10/17/09 10:21 PM, Alastair Houghton said: >On 17 Oct 2009, at 03:12, Sean McBride wrote: > >> On 10/10/09 11:15 AM, Sander Stoks said: >> >>> First, do I really have to add all types to my Info.plist file? If >>> the OS gets an update which adds a new file type to Image I/O, I have >>> to update my Info.plist? >> >> Since no one else replied... I'm pretty sure the answers are: yes >> and yes. :( > >Well, you *could* do a little better than doing it manually; e.g. when >you run the application, it could look at NSImage's -imageTypes method >and see if it had every one of them listed in your Info.plist, then if >there are some that aren't, update your Info.plist accordingly. Of >course, this is trickier than it sounds, because if your app is run by >a non-admin user you're going to have to use a helper tool and >Authorization Services to update the Info.plist. That's a clever idea, but, as you say, fragile. I believe it would also break code signing, would it not? Still, it could be used in debug builds to detect when new image formats are supported, then at least you'd know its time to release an update. -- 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: Why does my font come out looking fuzzy?
You need to post a screenshot of what you're seeing. I can think of two possibilities off the top of my head: 1) You're rendering text into a CALayer (especially a CATextLayer). Without some tweaking, CALayer can't do subpixel antialiasing (aka LCD antialiasing), because it doesn't have the existing backing store to composite against. 2) You're overdrawing the text and are therefore ruining the antialiasing, producing a distorted image. Again, screenshot is pretty much mandatory here. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Why does my font come out looking fuzzy?
So, I like the LCD-style font that Instruments uses to show the time counter at the top center of the window. Thought I might use it myself for an in-house project (not for release). Copied the TrueType font from Instruments into my project, added the necessary key to my Info.plist, set the font using [NSFont fontWithName:...], and hey presto, there the font is in my app. Only... it doesn't look as nice. It's less crisp. Kind of fuzzy. The corners don't look sharp. It no longer looks "LCD". What's going on here? I assume it has to do with rendering differences between different typography engines, and hinting, and TrueType (or in this case "FalseType", perhaps), and so forth. My basic question: is there a way I can get my Cocoa app to show this font as nicely as it appears in Instruments? I would have guessed that Instruments was itself a Cocoa app, so I'm surprised there's a difference. Anybody know what's going on? I am now considering taking little screenshots of each digit and rolling my own pseudo-font using image blits. Please save me from that fate. Ben Haller Stick Software ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Programming Style: Method Definition with or without a semicolon.
On Oct 17, 2009, at 2:24 AM, Uli Kusterer wrote: What do project templates have to do with code completion? The comments don't mention how to customize code completion stubs either. Did I overlook something? For controlling code completion, search for "XCCodeSenseFormattingOptions" on this page: http://developer.apple.com/mac/library/documentation/DeveloperTools/Reference/XcodeUserDefaultRef/100-Xcode_User_Defaults/UserDefaultRef.html 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: NSInvocationOperations and background Threads
On Oct 16, 2009, at 8:01 AM, John Love wrote: In my app, I have a very long for-loop It appears however, that in my app there is no background Thread that begins and the reason for that is because my app's window stays in the background until all NSOperations are complete. Any clues? I suspect your app's window isn't staying in the background until all NSOperations are complete, but rather that it's staying in the background until your long for-loop completes. You can't run a long for-loop on the main thread and expect event handling to proceed. (Well, you can, but only if your for-loop is handling events manually, itself.) It sounds like you're fundamentally misunderstanding how things like the main run loop, event processing, operation queues, your for-loop, etc. interact. 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: GC and atomic getters/setters
On Sat, Oct 17, 2009 at 6:36 PM, Ken Ferry wrote: > This is the kind of reasoning you want to avoid, actually. That's true on > most but not all architectures. That article does explain. > It's true on all architectures on which Cocoa is available, but even so, to > write clear code whose correctness is verifiable, you don't want to rely on > things like that. Indeed it does—specifically the lockless linked list lookup (*whew*) in part 2. Though I must say the terminology is not helpful; I keep seeing "reorder" as an active thing the CPUs are doing, rather than as a passive effect of something they're not doing. I much prefer the "guarantee" terminology. (Then again, I apparently have a black hole in my memory when it comes to private vs. project framework headers, so I have no reason to expect my situation with respect to memory synchronization to fare any better.) Thanks for the links. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Programming Style: Method Definition with or without a semicolon.
On 17/10/2009, at 10:25 PM, Graham Cox wrote: > If there is a way to disable these insertions independently and I've missed > it, please someone, let me know how to do it. I can't recommend the ODCompletionDictionary plug-in for Xcode highly enough: http://www.obdev.at/products/completion-dictionary/index.html It allows you to create fully customizable macros and falls back to Xcode's auto-completion if a match can't be found. -- Rob Keniger ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: correctly Controlling Garbage Collection
On 16/10/2009, at 4:17 PM, WareTo Development wrote: > Looking at this problem, we could perform better memory management, so deep > garbage collection does not happen that often. This reduces the problem, but > can never eliminate it, since sooner or later the garbage clean operation > must be done. > > So we thought the best thing would be to force a garbage collection operation > at a time of our choosing. Normally, this occurs at Mouse up, after the user > has finished his drawing. A split second of garbage collection then would be > barely noticeable by the user. What happens if you explicitly disable Garbage Collection when the user starts drawing and enable it when the user finishes? Something like: - (void)mouseDown:(NSEvent*)event { [[NSGarbageCollector defaultCollector] disable]; //other mouse down stuff } - (void)mouseUp:(NSEvent*)event { [[NSGarbageCollector defaultCollector] enable]; [[NSGarbageCollector defaultCollector] collectExhaustively]; //other mouse up stuff } That way the collector should never fire while the user is drawing. -- Rob Keniger ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: GC and atomic getters/setters
On Sat, Oct 17, 2009 at 6:32 PM, Kyle Sluder wrote: > On Sat, Oct 17, 2009 at 6:20 PM, Ken Ferry wrote: > > The issue concerns the order of in which changes to memory are observable > by > > other processors. > > Okay, and the read example is immune because you have to read the > address before you can read the thing at that address, and it's > therefore impossible to wind up in a bad situation due to read > reordering, simply because the reads have to be structured in a > particular way. > This is the kind of reasoning you want to avoid, actually. That's true on most but not all architectures. That article does explain. It's true on all architectures on which Cocoa is available, but even so, to write clear code whose correctness is verifiable, you don't want to rely on things like that. > > I'm struggling to picture being able to write code that is sensitive > to write reordering under GC that is not either sensitive to write > reordering on non-GC with equivalent locking and is also not sensitive > to other concurrency problems. > > Of course, I attribute this more to my lack of imagination or > experience at the lower levels than to the lack of a good example. > > --Kyle Sluder > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: GC and atomic getters/setters
On Sat, Oct 17, 2009 at 6:20 PM, Ken Ferry wrote: > The issue concerns the order of in which changes to memory are observable by > other processors. Okay, and the read example is immune because you have to read the address before you can read the thing at that address, and it's therefore impossible to wind up in a bad situation due to read reordering, simply because the reads have to be structured in a particular way. I'm struggling to picture being able to write code that is sensitive to write reordering under GC that is not either sensitive to write reordering on non-GC with equivalent locking and is also not sensitive to other concurrency problems. Of course, I attribute this more to my lack of imagination or experience at the lower levels than to the lack of a good example. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: GC and atomic getters/setters
On Sat, Oct 17, 2009 at 5:52 PM, Kyle Sluder wrote: > On Sat, Oct 17, 2009 at 5:35 PM, Michael Ash > wrote: > > This just leaves the writes. I assume that the GC write barrier > > includes a memory barrier, unless someone wants to tell me otherwise. > > If so, then there's no problem at all. > > Strictly speaking, this isn't really an atomicity issue, is it? What > C assignment are you thinking of that would wind up being nonatomic? > The issue concerns the order of in which changes to memory are observable by other processors. It's not actually _that_ complicated, but there's frustratingly little clear writing about this online. My favorite short article is this one: Memory Ordering in Modern Microprocessors part 1: http://www.linuxjournal.com/article/8211 part 2: http://www.linuxjournal.com/article/8212 Though this still is missing just a liiittle bit of info that I think makes things much clearer. Oh well. -Ken > --Kyle Sluder > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/cocoa-dev/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: Manipluate Cocoa Touch keyboard mode
On 17 Oct 2009, at 7:53 PM, Tron Thomas wrote: I have an application containing a singular UITextField that is intended for entering numeric data. I would like the keyboard to come up in numeric mode and stay in that mode unless the user click the button to toggle to letter mode, even if they press the return key. How can someone accomplish this keyboard behavior? By searching for "keyboard" in the documentation. One of your hits in the API will be the "keyboardType" property. It's defined in the UITextInputTraits protocol, which the documentation will tell you UITextField implements. Your exploration of the inspector for text fields in Interface Builder will have turned up a setter for this property, as well. — F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Manipluate Cocoa Touch keyboard mode
When an UITextField becomes active in a Cocoa Touch application, the device automatically displays a keyboard for character input. The keyboard always appears in alphabet mode so letters can be typed. I have an application containing a singular UITextField that is intended for entering numeric data. I would like the keyboard to come up in numeric mode and stay in that mode unless the user click the button to toggle to letter mode, even if they press the return key. How can someone accomplish this keyboard behavior? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: GC and atomic getters/setters
On Sat, Oct 17, 2009 at 5:35 PM, Michael Ash wrote: > This just leaves the writes. I assume that the GC write barrier > includes a memory barrier, unless someone wants to tell me otherwise. > If so, then there's no problem at all. Strictly speaking, this isn't really an atomicity issue, is it? What C assignment are you thinking of that would wind up being nonatomic? --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: GC and atomic getters/setters
On Sat, Oct 17, 2009 at 1:19 PM, Michael Ash wrote: > On Sat, Oct 17, 2009 at 12:18 PM, Bill Bumgarner wrote: >> >> On Oct 17, 2009, at 8:38 AM, BJ Homer wrote: >> >>> But assuming that you >>> wanted it there in the first place, why does the GC version not need the >>> synchronization? >> >> Under GC, object reference assignments -- scanned pointer assignments, >> technically -- are, in and of themselves, atomic. Note that structures will >> still require atomicity protection in GC, if desired (though, yes, property >> level atomicity is generally the wrong answer for ensuring thread safety). >> >> In non-gc, the need to send some combination of >> -retain/-release/-autorelease method calls leaves a window within which a >> caller may get a hold of an object reference that is about to be released in >> another thread. Thus, the need to use some form of locking or >> synchronization primitive to ensure that this doesn't happen. >> >> As Kai said, GC's natural atomicity in object assignment is a distinct >> advantage. In particular, it makes concurrent programming a bit less tricky >> as there is no need to play >> retain-on-one-thread-to-release-on-another-thread games. > > This discussion has me wondering about memory barriers, and I wonder > if you or someone else knowledgeable about the GC might comment on it. > > As I'm sure you already know, when assigning a pointer into a shared > memory location which is going to be read by another thread without > synchronization, it's necessary to insert a memory barrier between the > initialization of the memory that the pointer points to and the > assignment itself. Likewise, on the read end, it's necessary to insert > a memory barrier between the reading of the pointer and the reading of > what it points to. > > Without the memory barrier, it's possible that the CPU could reorder > writes so that it writes the pointer before it writes the contents, > causing the reader to see uninitialized memory. Or, likewise, it could > reorder reads so that it reads the contents before it reads the > pointer, with the same consequence. > > It seems to me that this standard GC getter is vulnerable to this > problem. The setter passes through a GC write barrier function which > could very well incorporate a memory barrier. However, as far as I > know there is no "read barrier" for GC strong pointers. It's just a > plain old read instruction generated by the compiler, with no memory > barrier. > > So it seems to me that, at least hypothetically, using the "standard" > GC atomic getter could result in the caller seeing the object's isa > pointer as still being 0 (or other things being uninitialized) when it > goes to try to use it, if it happens to hit the window of opportunity > just right, and the CPU reorders things just so. This would obviously > have a disastrous outcome. > > Have I missed something? Is there some dispatch_once-style deep magic > going on that prevents this, or something more mundane that I don't > know about? As was explained to me off list, the read involves a dependency (it must know what address it's reading before it reads it) and thus it's impossible to read them out of order without making use of a time machine. This just leaves the writes. I assume that the GC write barrier includes a memory barrier, unless someone wants to tell me otherwise. If so, then there's no problem at all. 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
Calculating a total from a collection of numeric attributes
Hi all, I have a Core Data entity that has an attribute called charge (stored as a float). So I am storing a number of records each of which has a charge. I simply want to be able to show a running total of charges as I add or remove items. I was hoping that I might be able to use a simple binding for this: I created a label and thought I might be able to bind its value to array controller.arrangedObjects.charge.sum or something like that. No luck though. I cannot see anything in the documentation or from searches. Can anyone point me towards either examples or documentation? Thanks, Ian. -- ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: standard colors
Thanks! I got close with Alastair's suggestion and I will give this a try! Michael On Oct 17, 2009, at 4:19 PM, Ross Carter wrote: static NSColor *sourceListBackgroundColor = nil; if (sourceListBackgroundColor == nil) { NSOutlineView *outlineView = [[NSOutlineView alloc] initWithFrame:NSZeroRect]; [outlineView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList ]; sourceListBackgroundColor = [outlineView backgroundColor]; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: standard colors
Thanks, Alastair, this helps a lot. Not understanding the "perceptual", "absolute" and "relative" stuff in the Color Sync util, I had to play around a bit, but I am getting closer to the right color. Michael On Oct 17, 2009, at 3:31 PM, Alastair Houghton wrote: On 17 Oct 2009, at 21:32, Michael Cinkosky wrote: Has Apple provided documentation on their standard source list background color? I haven't found it in the HIG docs, or with Google (I have not come up with the right terms to make the search specific enough). I have also tried just sampling the colors from the running applications (Mail, iTunes) but this yields a value which, when applied, looks quite different from what I sampled. Clearly I do not understand how colors work. When you sample colours, you get the values from the frame buffer. However, when you *use* colours in Cocoa, they're subject to colour management, so they're transformed according to the colour space for the screen on which your window is (mostly) present before they're written to the backing store. Anyone know where to find the official values? I'd be interested to know myself :-) You can probably convert the values to the ones you need using ColorSync Utility's "Calculator" feature; set the left hand side to the colour profile for your display (which you can look up in the Devices page), and the right hand side to "Generic RGB Profile", then set the sliders to the colour you sampled. Hopefully the right hand side will tell you the numbers you need. 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: standard colors
On Oct 17, 2009, at 5:31 PM, Alastair Houghton wrote: On 17 Oct 2009, at 21:32, Michael Cinkosky wrote: Has Apple provided documentation on their standard source list background color? I haven't found it in the HIG docs, or with Google (I have not come up with the right terms to make the search specific enough). I have also tried just sampling the colors from the running applications (Mail, iTunes) but this yields a value which, when applied, looks quite different from what I sampled. Clearly I do not understand how colors work. When you sample colours, you get the values from the frame buffer. However, when you *use* colours in Cocoa, they're subject to colour management, so they're transformed according to the colour space for the screen on which your window is (mostly) present before they're written to the backing store. Anyone know where to find the official values? I'd be interested to know myself :-) Can't remember where I got this: static NSColor *sourceListBackgroundColor = nil; if (sourceListBackgroundColor == nil) { NSOutlineView *outlineView = [[NSOutlineView alloc] initWithFrame:NSZeroRect]; [outlineView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList ]; sourceListBackgroundColor = [outlineView backgroundColor]; } IIRC, the color changes to gray when the app is deactivated. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSSpellChecker -learnWord: how to specify LocalDictionary
In 10.6, there is a spell checking dictionary named LocalDictionary that contains words learned outside the context of a particular language. How does one use NSSpellChecker -learnWord: and -unlearnWord: so that those methods write to LocalDictionary? For other language dictionaries, one can send setLanguage: before sending learnWord:. But for LocalDictionary, there does not appear to be any language string associated with LocalDictionary. I've tried sending nil, @"", and @"LocalDictionary" to setLanguage:, but -learnWord: still writes to my en dictionary. The use case is for terms such as "developer.apple.com" that should be deemed correct in any language. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: standard colors
On 17 Oct 2009, at 21:32, Michael Cinkosky wrote: Has Apple provided documentation on their standard source list background color? I haven't found it in the HIG docs, or with Google (I have not come up with the right terms to make the search specific enough). I have also tried just sampling the colors from the running applications (Mail, iTunes) but this yields a value which, when applied, looks quite different from what I sampled. Clearly I do not understand how colors work. When you sample colours, you get the values from the frame buffer. However, when you *use* colours in Cocoa, they're subject to colour management, so they're transformed according to the colour space for the screen on which your window is (mostly) present before they're written to the backing store. Anyone know where to find the official values? I'd be interested to know myself :-) You can probably convert the values to the ones you need using ColorSync Utility's "Calculator" feature; set the left hand side to the colour profile for your display (which you can look up in the Devices page), and the right hand side to "Generic RGB Profile", then set the sliders to the colour you sampled. Hopefully the right hand side will tell you the numbers you need. 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: UTIs and readFromURL/writeToURL
On 17 Oct 2009, at 03:12, Sean McBride wrote: On 10/10/09 11:15 AM, Sander Stoks said: First, do I really have to add all types to my Info.plist file? If the OS gets an update which adds a new file type to Image I/O, I have to update my Info.plist? Since no one else replied... I'm pretty sure the answers are: yes and yes. :( Well, you *could* do a little better than doing it manually; e.g. when you run the application, it could look at NSImage's -imageTypes method and see if it had every one of them listed in your Info.plist, then if there are some that aren't, update your Info.plist accordingly. Of course, this is trickier than it sounds, because if your app is run by a non-admin user you're going to have to use a helper tool and Authorization Services to update the Info.plist. 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: Selecting UITextField text
On 17 Oct 2009, at 2:14 PM, Tron Thomas wrote: How can someone programmatically select all the text in an UITextField control? Look up the UIResponderStandardEditActions informal protocol. It includes a selectAll: method. The docs say most descendants of UIResponder should implement it. I don't know whether it will do what you hope; you should experiment. — F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to switch the default printer?
> Well... suppose from my application, I want to convert a Word document to PDF. > How would I do that? I did quite a bit of research and the only way I found > was to use CUPS-PDF and have Word print to that printer. Then, I can retrieve > the converted PDF document. Is there any other way? You are right, this is the only way. So there's a couple of things you have to deal with, and in particular things are different in 10.4 & 10.5. (I haven't actually tried this under 10.6 yet.) A particular quirk is that using lpoptions to set the default printer does not work if "use last printer" is the option selected for default printer in system preferences. The below code isn't your exact answer since it depends on my own code for executing processes, and is C++, but I think you can read it and get the idea: SwitchToPrinterStk::SwitchToPrinterStk( const char *pname ) : mDidSwitch( false ), mOldDefaultPrinterIsLast( false ) { ProcessResults pr = RunProcess( "/usr/bin/lpstat", "-d", NULL ); if( pr.exited && !pr.exitval ) { int idx = pr.outstr.find( ": " ); if( idx >= 0 ) mOldPrinterName = pr.outstr.substr( idx + 2, pr.outstr.length() - idx - 3 ); } pr = RunProcess( "/usr/bin/defaults", "-currentHost", "read", "com.apple.print.PrintingPrefs", "UseLastPrinterAsCurrentPrinter", NULL ); if( pr.exited && !pr.exitval ) { mOldDefaultPrinterIsLast = pr.outstr[0] == '1'; if( mOldDefaultPrinterIsLast ) RunProcess( "/usr/bin/defaults", "-currentHost", "write", "com.apple.print.PrintingPrefs", "UseLastPrinterAsCurrentPrinter", "0", NULL ); } /* 10.5: lpoptions works to set default print iff "use last printer" is not the default defaults -currentHost read -globalDomain ColorSyncDevices look for "DefaultDevice-prtr" = 24300; */ pr = RunProcess( "/usr/bin/lpoptions", "-d", pname, NULL ); mDidSwitch = pr.exitval == 0; } SwitchToPrinterStk::~SwitchToPrinterStk() { if( mOldPrinterName != "" ) RunProcess( "/usr/bin/lpoptions", "-d", mOldPrinterName.c_str(), NULL ); if( mOldDefaultPrinterIsLast ) RunProcess( "/usr/bin/defaults", "-currentHost", "write", "com.apple.print.PrintingPrefs", "UseLastPrinterAsCurrentPrinter", "1", NULL ); } -- 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: How to retrieve the font information from TrueType font file?
On 17 Oct 2009, at 03:52, XiaoGang Li wrote: Your solution is good. At first, I think it is simple to list all the limited fonts in the plist file, and it is easy to enumerate these fonts. But, I think, when other font files are added to the bundle by other engineer, I will update my plist file at the same time. this solution seems unrobust. If you're loading the fonts from inside your bundle yourself (e.g. using CGFontCreateWithDataProvider), then it's pretty straightforward to use CGFontCopyTableForTag() or the other CGFont APIs to access the font data. 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
standard colors
Has Apple provided documentation on their standard source list background color? I haven't found it in the HIG docs, or with Google (I have not come up with the right terms to make the search specific enough). I have also tried just sampling the colors from the running applications (Mail, iTunes) but this yields a value which, when applied, looks quite different from what I sampled. Clearly I do not understand how colors work. I did find these values -- RGB(214,221,249) -- in a post about source list controls, but when I use those values I also get something very different from Main or iTunes on my machine running Snow Leopard. Anyone know where to find the official values? Michael ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
CoreData Dangling Reference
Hi all, I've started getting some dangling references which I cannot figure out. Basically, I've got the following class setup: A <-->> B <<--> C where A has-many to B, C has -many to B and B has-one to both A and C. What happens on quit is that I get the following error: "Dangling reference to an invalid object." = ;. This happens when I try to delete an instance of B (the reason for the error is that C still has a reference to B which is already deleted). Before actually deleting the object, I do: b.a = nil; (3) b.c = nil; (4) I poked around to see what's happening under the hood and noticed two things: 1) When I delete the object from the context, the delete rule doesn't get executed. So, if I leave (3) and (4) out, object instance b will still point to instances of A and C even though the delete rule is nullify. In summary, for some unknown reason, deleting the object doesn't invoke the delete rule. 2) Out of (3) and (4), only one of the statements nullifies the reverse relationship while the other one doesn't. So I setup a small project just to test out that deleting an object nullifies links and indeed it does. So now, I'm out of options on how to debug this problem. Any tips are greatly appreciate. M ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Subclassing a view class from an external framework
Wow, reading comprehension failure on my part. Apologies for the noise. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Selecting UITextField text
How can someone programmatically select all the text in an UITextField control? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
__CFServiceControllerBeginPBSLoadForLocalizations timed out error
I *just* noticed the following error in the XCode Debugger Console: __CFServiceControllerBeginPBSLoadForLocalizations timed out while talking to pbs .. and I'm getting it at the very top of -init for my NSDocument?? I have no clue as to when it started .. I kinda think maybe with upgrading to 10.6, but I really do not know?? Good grief!! John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Subclassing a view class from an external framework
On Oct 17, 2009, at 1:32 PM, Kyle Sluder wrote: On Sat, Oct 17, 2009 at 11:30 AM, Jeff Johnson wrote: After further experimentation, I've found the problem. Interface Builder doesn't find private header files in a framework. When I changed the header file from private to public, Interface Builder found it. If it's a private header, how are you using it in your code? --Kyle Sluder This has already been explained -- to you, directly, by an Apple engineer -- in the mailing lists archives. http://lists.apple.com/archives/cocoa-dev/2008/Jan/msg00665.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
Re: Triggering a Method when a Core Data Property changes.
On Sat, Oct 17, 2009 at 8:34 AM, Jerry Krinock wrote: > Now, I'm not sure if you should do that, or observing the tree controller as > recommended by Kyle. However, since I don't have a tree controller in a > project of mine, I've kind of done what you suggested. It depends on what you're trying to do. Both are logical places to put different kinds of observations. > http://mikeash.com/?page=pyblog/key-value-observing-done-right.html We've solved the problem differently from Mike Ash. See OFBinding in the OmniFoundation framework. As far as I can tell, Apple has done the same thing with NSTableBinder and family. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Subclassing a view class from an external framework
On Sat, Oct 17, 2009 at 11:30 AM, Jeff Johnson wrote: > After further experimentation, I've found the problem. Interface Builder > doesn't find private header files in a framework. When I changed the header > file from private to public, Interface Builder found it. If it's a private header, how are you using it in your code? --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Subclassing a view class from an external framework
After further experimentation, I've found the problem. Interface Builder doesn't find private header files in a framework. When I changed the header file from private to public, Interface Builder found it. Interface Builder doesn't find private headers in framework -Jeff On Oct 17, 2009, at 11:36 AM, Jeff Johnson wrote: Hi Kevin. This occurs with both IB 3.2.1 on 10.6 and IB 3.1.2 on 10.5. In the IB info window I get these warnings: 1) The 'delegate' outlet of 'AHTSessionWindow' is connected to 'File's Owner' but 'delegate' is no longer defined on AHTWindow. 2) The 'window' outlet of 'File's Owner' is connected to 'AHTSessionWindow' but 'AHTWindow' is not a kind of 'NSWindow' as specified by the outlet type. AHTWindow is a subclass of an NSWindow subclass defined in one of my frameworks. Doing "Reload All Class Files" in IB does not make the warnings go away. However, "Read Class Files..." with the particular header file from my framework does make the warnings go away. The source files themselves compile without warnings, so Xcode is certainly able to find the header file in my framework. -Jeff On Oct 15, 2009, at 6:24 PM, Kevin Cathey wrote: Although Interface Builder 3 is supposed to automatically sync with header files in your project, it seems to have trouble with headers in frameworks. Which version of Interface Builder were you seeing this on? IB 3.2.x will parse the headers for all frameworks you've linked against in your Xcode project. Kevin On 13 Oct 2009, at 07:55, Jeff Johnson wrote: Hi Mark. I had the same problem with NSWindow subclasses. Although Interface Builder 3 is supposed to automatically sync with header files in your project, it seems to have trouble with headers in frameworks. What I did was select "Read Class Files..." in the "File" menu of Interface Builder and read the header file for my framework class. The solved the problem for me. -Jeff On Oct 12, 2009, at 11:22 AM, Mark Gallegly wrote: I have an NSView subclass defined in a framework called FrameworkView. The FrameworkView class has a property like so: @property (nonatomic, retain) IBOutlet NSView* someView; This framework has the necessary code in it to work as an Interface Builder plugin, and everything seems to work fine in Interface Builder. However, if I subclass the FrameworkView in a separate project that contains my .app target, with say a class called MyFrameworkViewSubclass, I get a warning like this when building the .xib file containing MyFrameworkViewSubclass: The 'someView' outlet of 'MyFrameworkViewSubclass' is connected to 'Custom View' but 'someView' is no longer defined on MyFrameworkViewSubclass. Now, within IB the outlet shows up and I am able to make the connection, and when the app runs everything works fine, but for some reason XCode spits out this warning. Does anybody know what is going on here and how to get rid of the warning? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: UITextField formatting for IP Address
Exactly. I know. I am still working on that, but I don't want to invest too much time in any one method until i know it can solve the issue. But that's my point. I can seem to find any really good way to do this in UITextField. So i am playing around with different methods and posted the closest working idea. On desktop it's easy. So I am trying a variety of things and hoping someone has a better idea. -- CEO WebIS Sent from my phone On Oct 16, 2009, at 11:46 PM, Andrew Farmer wrote: On 16 Oct 2009, at 17:54, Alex Kac wrote: Here is my code, btw. It works OK, but it still has the issue of moving the cursor to the end. Perhaps there is no way to do this on the iPhone - I just don't want to bang my head for hours. - (void)formatForIP:(UITextField*)textField string:(NSString*)string { long long ip = [[string stringByReplacingOccurrencesOfString:@"." withString:@""] longLongValue]; NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init]; [numberFormatter setNumberStyle:NSNumberFormatterNoStyle]; [numberFormatter setPositiveFormat:@"###,###,###,###"]; [numberFormatter setGroupingSize:3]; [numberFormatter setSecondaryGroupingSize:3]; [numberFormatter setGroupingSeparator:@"."]; [numberFormatter setUsesGroupingSeparator:YES]; textField.text = [numberFormatter stringFromNumber:[NSNumber numberWithLongLong:ip]]; [numberFormatter release]; } This isn't a valid approach to formatting IP addresses - it considers "12.34.56.78" to be equal to "12.345.678", which isn't even a valid address, let alone equivalent. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: GC and atomic getters/setters
On Sat, Oct 17, 2009 at 12:18 PM, Bill Bumgarner wrote: > > On Oct 17, 2009, at 8:38 AM, BJ Homer wrote: > >> But assuming that you >> wanted it there in the first place, why does the GC version not need the >> synchronization? > > Under GC, object reference assignments -- scanned pointer assignments, > technically -- are, in and of themselves, atomic. Note that structures will > still require atomicity protection in GC, if desired (though, yes, property > level atomicity is generally the wrong answer for ensuring thread safety). > > In non-gc, the need to send some combination of > -retain/-release/-autorelease method calls leaves a window within which a > caller may get a hold of an object reference that is about to be released in > another thread. Thus, the need to use some form of locking or > synchronization primitive to ensure that this doesn't happen. > > As Kai said, GC's natural atomicity in object assignment is a distinct > advantage. In particular, it makes concurrent programming a bit less tricky > as there is no need to play > retain-on-one-thread-to-release-on-another-thread games. This discussion has me wondering about memory barriers, and I wonder if you or someone else knowledgeable about the GC might comment on it. As I'm sure you already know, when assigning a pointer into a shared memory location which is going to be read by another thread without synchronization, it's necessary to insert a memory barrier between the initialization of the memory that the pointer points to and the assignment itself. Likewise, on the read end, it's necessary to insert a memory barrier between the reading of the pointer and the reading of what it points to. Without the memory barrier, it's possible that the CPU could reorder writes so that it writes the pointer before it writes the contents, causing the reader to see uninitialized memory. Or, likewise, it could reorder reads so that it reads the contents before it reads the pointer, with the same consequence. It seems to me that this standard GC getter is vulnerable to this problem. The setter passes through a GC write barrier function which could very well incorporate a memory barrier. However, as far as I know there is no "read barrier" for GC strong pointers. It's just a plain old read instruction generated by the compiler, with no memory barrier. So it seems to me that, at least hypothetically, using the "standard" GC atomic getter could result in the caller seeing the object's isa pointer as still being 0 (or other things being uninitialized) when it goes to try to use it, if it happens to hit the window of opportunity just right, and the CPU reorders things just so. This would obviously have a disastrous outcome. Have I missed something? Is there some dispatch_once-style deep magic going on that prevents this, or something more mundane that I don't know about? 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: Subclassing a view class from an external framework
Hi Kevin. This occurs with both IB 3.2.1 on 10.6 and IB 3.1.2 on 10.5. In the IB info window I get these warnings: 1) The 'delegate' outlet of 'AHTSessionWindow' is connected to 'File's Owner' but 'delegate' is no longer defined on AHTWindow. 2) The 'window' outlet of 'File's Owner' is connected to 'AHTSessionWindow' but 'AHTWindow' is not a kind of 'NSWindow' as specified by the outlet type. AHTWindow is a subclass of an NSWindow subclass defined in one of my frameworks. Doing "Reload All Class Files" in IB does not make the warnings go away. However, "Read Class Files..." with the particular header file from my framework does make the warnings go away. The source files themselves compile without warnings, so Xcode is certainly able to find the header file in my framework. -Jeff On Oct 15, 2009, at 6:24 PM, Kevin Cathey wrote: Although Interface Builder 3 is supposed to automatically sync with header files in your project, it seems to have trouble with headers in frameworks. Which version of Interface Builder were you seeing this on? IB 3.2.x will parse the headers for all frameworks you've linked against in your Xcode project. Kevin On 13 Oct 2009, at 07:55, Jeff Johnson wrote: Hi Mark. I had the same problem with NSWindow subclasses. Although Interface Builder 3 is supposed to automatically sync with header files in your project, it seems to have trouble with headers in frameworks. What I did was select "Read Class Files..." in the "File" menu of Interface Builder and read the header file for my framework class. The solved the problem for me. -Jeff On Oct 12, 2009, at 11:22 AM, Mark Gallegly wrote: I have an NSView subclass defined in a framework called FrameworkView. The FrameworkView class has a property like so: @property (nonatomic, retain) IBOutlet NSView* someView; This framework has the necessary code in it to work as an Interface Builder plugin, and everything seems to work fine in Interface Builder. However, if I subclass the FrameworkView in a separate project that contains my .app target, with say a class called MyFrameworkViewSubclass, I get a warning like this when building the .xib file containing MyFrameworkViewSubclass: The 'someView' outlet of 'MyFrameworkViewSubclass' is connected to 'Custom View' but 'someView' is no longer defined on MyFrameworkViewSubclass. Now, within IB the outlet shows up and I am able to make the connection, and when the app runs everything works fine, but for some reason XCode spits out this warning. Does anybody know what is going on here and how to get rid of the warning? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: GC and atomic getters/setters
On Oct 17, 2009, at 8:38 AM, BJ Homer wrote: But assuming that you wanted it there in the first place, why does the GC version not need the synchronization? Under GC, object reference assignments -- scanned pointer assignments, technically -- are, in and of themselves, atomic. Note that structures will still require atomicity protection in GC, if desired (though, yes, property level atomicity is generally the wrong answer for ensuring thread safety). In non-gc, the need to send some combination of -retain/-release/- autorelease method calls leaves a window within which a caller may get a hold of an object reference that is about to be released in another thread. Thus, the need to use some form of locking or synchronization primitive to ensure that this doesn't happen. As Kai said, GC's natural atomicity in object assignment is a distinct advantage. In particular, it makes concurrent programming a bit less tricky as there is no need to play retain-on-one-thread-to-release-on- another-thread games. 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: GC and atomic getters/setters
On 17.10.2009, at 17:38, BJ Homer wrote: In the Garbage Collection Programming Guide: Architecture [1], an example is given of a set of non-GC getters and setters which use @synchronized (self) to control the access to the ivar, and in the setter to protect the releasing of the old object and retaining of the new. Then, a GC example is given in which the getters and setters have no synchronization; the getter simply returns the value, and the setter simply assigns the new value. I understand why the setter is so much simpler under GC; no retain/ release fiddling is necessary. However, I'm confused about the lack of synchronization in the GC examples. I know there's lots of skepticism as to whether synchronization at the getter/setter level is even useful (hence the general recommendation to make properties nonatomic). But assuming that you wanted it there in the first place, why does the GC version not need the synchronization? Is it simply because the setter is doing less, and thus the getter wouldn't ever catch the setter halfway through its setting? (After releaseing the old value, but before retaining the new, for example.) Basically yes. Another way to look at it is that assignment to a GC-controlled pointer variable must be thread safe anyway (because GC is running in a separate thread and because there are things like weak references), so there is no need to put extra synchronization around it. By the way, this thread safety feature of GC is another big reason to use GC over managed memory besides the automatic memory management. Kai ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
GC and atomic getters/setters
In the Garbage Collection Programming Guide: Architecture [1], an example is given of a set of non-GC getters and setters which use @synchronized(self) to control the access to the ivar, and in the setter to protect the releasing of the old object and retaining of the new. Then, a GC example is given in which the getters and setters have no synchronization; the getter simply returns the value, and the setter simply assigns the new value. I understand why the setter is so much simpler under GC; no retain/release fiddling is necessary. However, I'm confused about the lack of synchronization in the GC examples. I know there's lots of skepticism as to whether synchronization at the getter/setter level is even useful (hence the general recommendation to make properties nonatomic). But assuming that you wanted it there in the first place, why does the GC version not need the synchronization? Is it simply because the setter is doing less, and thus the getter wouldn't ever catch the setter halfway through its setting? (After releaseing the old value, but before retaining the new, for example.) -BJ [1] http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcArchitecture.html#//apple_ref/doc/uid/TP40002451 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Triggering a Method when a Core Data Property changes.
On 2009 Oct 17, at 04:55, Joshua Garnham wrote: Could I sub class NSManagedObject to make it observe objects as they are added or fetched? Well, first of all, let me rephrase your question. What you're suggesting is to add an observer of the "name" property as objects are inserted or fetched. Now, I'm not sure if you should do that, or observing the tree controller as recommended by Kyle. However, since I don't have a tree controller in a project of mine, I've kind of done what you suggested. So, if you're sure you want to do it this way, here goes Yes, any full-featured Core Data app eventually needs to subclass NSManagedObject. I use two levels of inheritance: NSManagedObject MyWhistlesAndBellsManagedObject Employee Department etc. then add the following code to make it observe objects as they are added or fetched? - (void) awakeFromFetch { [self addObserver:[NSApp delegate] forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil]; } - (void) awakeFromInsert { [self addObserver:[NSApp delegate] forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil]; } Yes. I usually do this by writing an -initializeCommon method that adds all my observers, and other stuff. Then -awakeFromFetch and - awakeFromInsert both invoke -initializeCommon. But then don't forget to implement -didTurnIntoFault in your NSApp's delegate, and in that implementation, removeObserver (and also don't forget to invoke super). But how would I trigger an action when the name property changes? If I understand correctly, this is a basic KVO question. The short answer is to implement -observeValueForKeyPath:ofObject:change:context: A better answer is that you should have already learned that by reading Apple's KVO Programming Guide: http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html And then, for even further reading, http://mikeash.com/?page=pyblog/key-value-observing-done-right.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
Re: How to retrieve the font information from TrueType font file?
On Oct 17, 2009, at 02:37 AM, Jens Alfke wrote: On Oct 16, 2009, at 10:31 PM, Mike Wright wrote: 1. Single Fonts with the ".ttf" file extension have only a data fork, and the name of the file seems to be the name of the font. Not necessarily. The filename is not part of the font, so it can be arbitrary, and a lot of the time it's not the same as the font name. b. The other style has a resource fork that includes a 'FOND' resource for each individual font, with the 'FOND' resource names being the names of the fonts. They also include 'sfnt' resources, but the 'sfnt' resources do not have names. (They just have resource IDs that match the resource IDs of the corresponding 'FOND' resources.) I don't know if the FOND resource is even used anymore. (That's all legacy stuff dating back to about 1986.) The actual font name is in the TrueType font tables making up the 'sfnt' resources. There are a number of other formats you didn't list, like .otf, .ttc and .dfnt. I think it's still possible to have raw Type 1 PostScript fonts installed, although I don't know what the filetype for those would be. (They used to be files with HFS type 'LWFN'.) You really, really don't want to mess with this stuff directly, unless you'd like to spend months learning all about the intricacies of font formats. —Jens I certainly wouldn't want to. I spent much of the period 1988-1995 writing DOS-based and Mac-based C software to convert various Mac PostScript, TrueType, and bitmapped screen font files to Windows 1.0 and later formats, and it was frustrating and terrifying, being my first programming job right out of junior college (at the age of 45, after a career as a translator in the US Army). You probably couldn't pay me enough to do that these days. Still, I managed to convert the CasadyWare (later Casady & Greene) Fluent Laser Fonts library at a time when Fontographer ran only on the Mac, and the fonts had to be essentially hand-installed on Windows. As I mentioned in my original post, I was able to examine only the third-party fonts that I have on my current system (140 "Font Suitcase" files, with and without the .suit extension, and 8 "Windows TrueType font" files, with the .ttf extension). (And, isn't it amazing that the 2002 version -- the last as far as I know -- of Resorcerer still runs under Snow Leopard about as well as it ever did under Panther.) If the publisher of the software doesn't have any control over the kinds of font files that they bundle with their own software, including the file names, then the plist option is certainly the most reliable. FYI, I haven't found any of the "Font Suitcase" files that have a data fork. The font is in the 'FOND' resource -- and all of those fonts work fine under Snow Leopard. Some of this legacy stuff is probably pretty hard to eliminate without nasty repercussions. --Mike Wright http://www.idata3.com/ http://www.raccoonbend.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: Programming Style: Method Definition with or without a semicolon.
On 17/10/2009, at 6:24 PM, Uli Kusterer wrote: What do project templates have to do with code completion? The comments don't mention how to customize code completion stubs either. Did I overlook something? I didn't say anything about code completion. I understood the OP to be talking about the stubs inserted when subclassing various classes, though now I read it again I may have got the wrong end of the stick. If that's the case, sorry for the noise - and yes, that does open up a cause for complaint here too. The code completion for language elements is annoying - I like the code completion for methods (mostly - still not as smart as they could be) but the stupid completions for, e.g. else {...} annoy the hell out of me and seemingly can't be turned off independently. That one's especially grevious because when composing code when I get to an 'else' clause I often pause to collect my thoughts (or maybe have just added a new if() clause above some existing code that becomes the 'else') and in either case get an immediate and incorrectly formatted stub than needs to be backed out using undo before I can continue. The 'return-command-Z-continue typing' is already starting to become part of my motor memory for any 'else' I type. Dumb, dumb, dumb. The preferences for code completion need to be broken down into what elements completions will be performed for - those that are just language constructions need to be a) disableable and/or b) templateable and for good measure c) much, much smarter about how they fit in with any existing code that surrounds them. The current implementation seems to assume that any code being written is new, virgin code that is being typed into blank space. I would say that that is rarely the case for most coding situations in the real world. And its brace style is just adding insult to injury since it's forcing a brace style that I don't use myself. Code completions should help, not act like some Objective-C grammar Nazi, imposing someone else's idea of good style on my code. If there is a way to disable these insertions independently and I've missed it, please someone, let me know how to do it. --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: Triggering a Method when a Core Data Property changes.
Hmm. Ok. Could I sub class NSManagedObject then add the following code to make it observe objects as they are added or fetched? - (void) awakeFromFetch { [self addObserver:[NSApp delegate] forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil]; } - (void) awakeFromInsert { [self addObserver:[NSApp delegate] forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:nil]; } But how would I trigger an action when the name property changes? Cheers, Josh. From: Kyle Sluder To: Joshua Garnham Cc: macosx-...@omnigroup.com Sent: Friday, 16 October, 2009 19:02:10 Subject: Re: Triggering a Method when a Core Data Property changes. On Fri, Oct 16, 2009 at 10:57 AM, Joshua Garnham wrote: > I am trying to trigger a method when A Core Data property is > changed, e.g A Text Fields Text in a Table (connected to Core Data) is > changed. Basically I want to be Key Value Observing the CD 'name' property of > all > the objects in my Tree Controller, so that when the 'name' property of > one of my objects is changed it triggers an action. How would I do this > though? You need to observe each object as it is added to the tree controller. This means observing the arrangedObjects property of the tree controller, using that change notification to observe the children property of the arrangedObjects proxy, using those change notifications to observe the children property of each of those objects, and so on. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Getting NSSearchField to get focus in NSStatusItem menu
Hi, I'm having difficulty getting a NSSearchField to work properly in an NSStatusItem. What I would like to do is something similar to the spotlight status bar item and the search field that pops up. After I create my view containing the NSSearchField and a also a simple menu in Interface Builder, I programmatically create my NSStatusItem, add a menu item for the NSSearchField to the previously created IB menu, add it to the menu item's view, and set the IB menu to become visible when the user clicks the status item. - (void) awakeFromNib; { NSStatusBar * bar = [NSStatusBar systemStatusBar]; statusItem = [bar statusItemWithLength:NSSquareStatusItemLength]; NSString * imageName = [[NSBundle mainBundle] pathForResource:kBBStatusBarImage ofType:@"png"]; NSImage * statusBarImage = [[NSImage alloc] initWithContentsOfFile:imageName]; [statusItem setImage:statusBarImage]; imageName = [[NSBundle mainBundle] pathForResource:kBBStatusBarAltImage ofType:@"png"]; statusBarImage = [[NSImage alloc] initWithContentsOfFile:imageName]; [statusItem setAlternateImage:statusBarImage]; [statusItem setHighlightMode:YES]; [statusItem setEnabled:YES]; searchMenuItem = [[NSMenuItem alloc] initWithTitle:@"" action:@selector(performSearch:) keyEquivalent:@""]; [searchMenuItem setView:searchView]; [searchMenuItem setTarget:self]; [statusItemMenu insertItem:searchMenuItem atIndex:0]; [statusItem setMenu:statusItemMenu]; } Since I want the app to run without a menu bar and without a doc icon, I set the Info.plist property LSUIElement to YES. When I run the program, clicking on the status item causes the menu containing the NSSearchField to display as expected, but I can't select it or enter any data in the search field. Clicking around in the search field gives me these errors in the Console: HIViewSetFocus() failed with error -30599 And this ominous looking piece of Console: 09-10-17 1:28:55 AM BuskBar[11794] HIToolbox: ignoring exception '_NSDisplayOperationStack window mismatch on pop' that raised inside Carbon event dispatch ( [...] ) It seems the problem has something to do with the NSSearchField not being able to get focus because the NSStatusBarWindow (private class?) it seems to be associated with can't become key. Has anyone experienced this or know how to get this to work? Best, Dalmazio ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Programming Style: Method Definition with or without a semicolon.
On 16.10.2009, at 11:43, Graham Cox wrote: On 16/10/2009, at 7:12 PM, Uli Kusterer wrote: But you don't have to let Xcode frustrate you like this - you can define your own templates for all of the stubs it inserts. How? Where?!!! :-D http://arstechnica.com/apple/guides/2009/04/cocoa-dev-design-your-own-xcode-project-templates.ars http://www.cocoadev.com/index.pl?XcodeProjectTemplates http://www.macresearch.org/custom_xcode_templates http://briksoftware.com/blog/?p=28 What do project templates have to do with code completion? The comments don't mention how to customize code completion stubs either. Did I overlook something? -- Uli Kusterer "The Witnesses of TeachText are everywhere..." http://www.masters-of-the-void.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