Re: deny file-read-data after launch
On Jan 8, 2015, at 2:51 PM, Steve Mills sjmi...@mac.com wrote: I'm having a problem with my app on 10.9 that I'm not sure about. The user chooses a folder via NSPathControl, then I use that to do an NSMetadataQuery for all images inside that folder. I don't have code signing turned on for this app yet, but I do have the Sandbox capability turned on. (This is my first personal project since all this stuff has been introduced.) Sandboxing requires code signing, because that’s how it associates persistent data with your app (including as you produce new versions of the binary). If I launch my app, choose a folder, I can run my search on it and everything is fine. That folder gets stored in user defaults via a binding on the path control. Make sure you’re not just storing a plain path in NSUserDefaults. To maintain access to a resource across app launches, you need to use a security-scoped bookmark. This is an NSData that is created from an NSURL via -bookmarkDataWithOptions:… Read the Security Scoped Bookmarks and Persistent Access section of the App Sandbox Design Guide for more, including what entitlements you need to enable to save the appropriate kind of bookmark (app-scoped): https://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html And then it immediately goes off with results from a completely different folder: Not sure what’s happening here; this might be Spotlight trying to do its best to fulfill your request. --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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Machine sleep wake notifications in a daemon
On Jan 8, 2015, at 4:54 PM, Andrew Keller and...@kellerfarm.com wrote: On Jan 8, 2015, at 5:20 PM, Ken Thomases k...@codeweavers.com wrote: On Jan 8, 2015, at 4:03 PM, Andrew Keller and...@kellerfarm.com wrote: https://developer.apple.com/library/mac/qa/qa1340/_index.html Yes. It looks very promising, but on the first try, I wasn't able to keep the run loop running (it exited immediately). I suspect that the problem has to do with the run loop not having any input sources. It is true that a run loop without any input sources will exit immediately. However, the code in listing 3 has added an input source to the run loop: // add the notification port to the application runloop CFRunLoopAddSource( CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notifyPortRef), kCFRunLoopCommonModes ); Also, I have a feeling that there may be something missing conceptually. Suppose I do manage to keep the run loop running using a new input source. How do the OS and the application frameworks know to route the notification there? The code creates an IONotificationPort, creates a run loop source from that, and adds that source to the run loop. That's how the system knows to route the notification there. It sends the notification to all notification ports. The notification port is tied to the run loop source. Since the source was added to the run loop, the run loop is monitoring the notification port. Did you modify the code? You might try separating out the call to IONotificationPortGetRunLoopSource() so that you can examine its result. Is it returning a non-NULL source reference? 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Machine sleep wake notifications in a daemon
On Jan 8, 2015, at 2:54 PM, Andrew Keller and...@kellerfarm.com wrote: On Jan 8, 2015, at 5:20 PM, Ken Thomases k...@codeweavers.com wrote: On Jan 8, 2015, at 4:03 PM, Andrew Keller and...@kellerfarm.com wrote: I would like to receive machine sleep and wake notifications in my daemon. In my Cocoa GUI application, I was able to easily follow the sample code under Listing 1 on the page https://developer.apple.com/library/mac/qa/qa1340/_index.html, but when I tried the same approach in my daemon, I received no errors or warnings from Xcode or in the system console, and yet the handlers also did not fire. After poking around for a while, I have a hunch that it may have something to do with the main event queue not being the same (or existing at all?) in a non-Cocoa GUI application. Is it possible to have a Cocoa-style event queue in a daemon, or is there another way to receive machine sleep and wake notifications from the OS in a daemon? Did you read further down that QA article you linked to listings 3 and 4? Yes. It looks very promising, but on the first try, I wasn't able to keep the run loop running (it exited immediately). I suspect that the problem has to do with the run loop not having any input sources. I'm currently in the middle of https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html, where it's explaining how to create run loop sources. I'm learning quite a lot here, but that also means that progress is very slow at the moment. I figured it would hurt to ping the list to see if there was a simpler solution or perhaps documentation more specialized to my objective. Also, I have a feeling that there may be something missing conceptually. Suppose I do manage to keep the run loop running using a new input source. How do the OS and the application frameworks know to route the notification there? I suspect that some additional object registration may be needed to make the run loop handle the events, or it might be a very specific input source I don't know about yet... You shouldn't need to write your own run loop source implementation. QA1340's sample code shows how it works. IORegisterForSystemPower() creates an IONotificationPort that receives power notifications. IONotificationPortGetRunLoopSource() creates a run loop source from that notification port. CFRunLoopAddSource() adds that run loop source to the run loop. Notifications sent by the OS are routed to that run loop, and when you run that run loop it calls your callback function with those notifications. You should double-check that your code is arranged the same way as QA1340's code. You should also check for errors from any of those functions; perhaps the notification port or run loop source is not created for some reason. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[MODERATOR] End of Thread: Re: Blurry is the New Sharp
Please stick to technical discussion on cocoa-dev. If there are remaining technical questions in this thread, please ask them in their own threads. (And avoid off-topic derails.) Thanks. -- Chris (cocoa-dev co-mod) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSURL resourceValuesForKeys NSURLPathKey
On Thu, 8 Jan 2015 16:31:18 -0800, Trygve Inda said: I call: NSData* bookmarkData = [url bookmarkDataWithOptions:NSURLBookmarkCreationMinimalBookmark includingResourceValuesForKeys:nil relativeToURL:nil error:inError]; And later: NSDictionary* dict = [NSURL resourceValuesForKeys:[NSArray arrayWithObject:NSURLPathKey] fromBookmarkData:[self bookmark]]; if (dict) { path = [dict objectForKey:NSURLPathKey]; } Path ends up with the correct value even though I passed nil above... When it resolves or fails to resolve? Probably only the former. includingResourceValuesForKeys:nil Is this documented behavior? Dunno, but it reminds me of this: http://lists.apple.com/archives/cocoa-dev/2012/Oct/msg00299.html I think I should be putting NSURLPathKey in the call to create the bookmark, but it does seem to work without it. Thoughts? I would put it. Cheers, -- 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSURL resourceValuesForKeys NSURLPathKey
I call: NSData* bookmarkData = [url bookmarkDataWithOptions:NSURLBookmarkCreationMinimalBookmark includingResourceValuesForKeys:nil relativeToURL:nil error:inError]; And later: NSDictionary* dict = [NSURL resourceValuesForKeys:[NSArray arrayWithObject:NSURLPathKey] fromBookmarkData:[self bookmark]]; if (dict) { path = [dict objectForKey:NSURLPathKey]; } Path ends up with the correct value even though I passed nil above... includingResourceValuesForKeys:nil Is this documented behavior? I think I should be putting NSURLPathKey in the call to create the bookmark, but it does seem to work without it. Thoughts? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSURL resourceValuesForKeys NSURLPathKey
On Jan 8, 2015, at 6:31 PM, Trygve Inda cocoa...@xericdesign.com wrote: I call: NSData* bookmarkData = [url bookmarkDataWithOptions:NSURLBookmarkCreationMinimalBookmark includingResourceValuesForKeys:nil relativeToURL:nil error:inError]; And later: NSDictionary* dict = [NSURL resourceValuesForKeys:[NSArray arrayWithObject:NSURLPathKey] fromBookmarkData:[self bookmark]]; if (dict) { path = [dict objectForKey:NSURLPathKey]; } Path ends up with the correct value even though I passed nil above... includingResourceValuesForKeys:nil Is this documented behavior? To my mind, yes. The docs for that method say In addition to the standard, system-defined resource properties, you can also request any custom properties that you provided when you created the bookmark. What this means to me is that you can always request the standard, system-defined resource properties and expect to get a result. In addition, you can request any custom properties that you provided when you created the bookmark. 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Machine sleep wake notifications in a daemon
On Jan 8, 2015, at 6:11 PM, Greg Parker gpar...@apple.com wrote: On Jan 8, 2015, at 2:54 PM, Andrew Keller and...@kellerfarm.com wrote: On Jan 8, 2015, at 5:20 PM, Ken Thomases k...@codeweavers.com wrote: On Jan 8, 2015, at 4:03 PM, Andrew Keller and...@kellerfarm.com wrote: I would like to receive machine sleep and wake notifications in my daemon. In my Cocoa GUI application, I was able to easily follow the sample code under Listing 1 on the page https://developer.apple.com/library/mac/qa/qa1340/_index.html, but when I tried the same approach in my daemon, I received no errors or warnings from Xcode or in the system console, and yet the handlers also did not fire. After poking around for a while, I have a hunch that it may have something to do with the main event queue not being the same (or existing at all?) in a non-Cocoa GUI application. Is it possible to have a Cocoa-style event queue in a daemon, or is there another way to receive machine sleep and wake notifications from the OS in a daemon? Did you read further down that QA article you linked to listings 3 and 4? Yes. It looks very promising, but on the first try, I wasn't able to keep the run loop running (it exited immediately). I suspect that the problem has to do with the run loop not having any input sources. I'm currently in the middle of https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html, where it's explaining how to create run loop sources. I'm learning quite a lot here, but that also means that progress is very slow at the moment. I figured it would hurt to ping the list to see if there was a simpler solution or perhaps documentation more specialized to my objective. Also, I have a feeling that there may be something missing conceptually. Suppose I do manage to keep the run loop running using a new input source. How do the OS and the application frameworks know to route the notification there? I suspect that some additional object registration may be needed to make the run loop handle the events, or it might be a very specific input source I don't know about yet... You shouldn't need to write your own run loop source implementation. QA1340's sample code shows how it works. IORegisterForSystemPower() creates an IONotificationPort that receives power notifications. IONotificationPortGetRunLoopSource() creates a run loop source from that notification port. CFRunLoopAddSource() adds that run loop source to the run loop. Notifications sent by the OS are routed to that run loop, and when you run that run loop it calls your callback function with those notifications. You should double-check that your code is arranged the same way as QA1340's code. You should also check for errors from any of those functions; perhaps the notification port or run loop source is not created for some reason. Ah! Looks like I was being too methodical; I didn't look ahead to where the port is created. (I didn't copy and paste all of the example at once; I was attempting to do it incrementally.) Thanks, Ken and Greg; I'll try that when I get into work tomorrow. Thanks, - Andrew Keller ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Am I Reinventing the Wheel? (Part I)
Jens is right, and I was quite mistaken. The disaster wasn’t a problem with XMLParser’s deserialization at all. When writing out my paragraphs, I create one p node for each and put the full paragraph text in. My mistake was believing XMLParser would operate the same way, reading the full text of the p node at once. So every time my delegate’s parser:foundCharacters: was called, I treated the delivered string as a full paragraph and added newlines. In fact, parser:foundCharacters: may be called repeatedly to deliver paragraph text in chunks. In my case, ampersands and curled quotes were delivered in their own chunks, and it was me botching the result up by inserting extraneous newlines. I have no excuse, because Apple’s documentation says three times that the string received by parser:foundCharacters: may be incomplete. — Charles Jenkins On Thursday, January 8, 2015 at 12:30 PM, Jens Alfke wrote: On Jan 8, 2015, at 4:43 AM, Charles Jenkins cejw...@gmail.com (mailto:cejw...@gmail.com) wrote: I'm writing data to XML. When you create a node and set its string contents, the node will happily accept whatever string you give and allow you to serialize information XML deserialization cannot then recreate. In my case, the string in question contained curled quotes. I could serialize and save the data—and if I remember correctly* the output looked good when I inspected the file on disk—but reading it back and deserializing it led to disaster! No, it's fine for XML text to contain non-ASCII Unicode characters. —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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: deny file-read-data after launch
On Jan 8, 2015, at 17:18:21, Kyle Sluder k...@ksluder.com wrote: Make sure you’re not just storing a plain path in NSUserDefaults. To maintain access to a resource across app launches, you need to use a security-scoped bookmark. This is an NSData that is created from an NSURL via -bookmarkDataWithOptions:… Read the Security Scoped Bookmarks and Persistent Access section of the App Sandbox Design Guide for more, including what entitlements you need to enable to save the appropriate kind of bookmark (app-scoped): https://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html Thanks Graham and Kyle. So since I now need to take control of securing the url chosen in the path control, I can no longer just bind its value to user defaults in the xib, right? I've added an action method that gets called when the path changes, where I create a secure bookmark and store that in user defaults instead. Then in awakeFromNib (for when the app launches and the window is created), I get the bookmark out of user defaults, resolve it securely to the url, and set the path control's url to that. Sound good so far? Now I think I'm left with being granted access to that url. It's easy enough to do that in awakeFromNib right before I use the url to set the path control's url. But I'll need to keep access to it for the entire run of the app or until the user chooses a different folder. At what point would you suggest I call stopAccessingSecurityScopedResource on it? I'd need to do it before the user chooses a new folder, but before the NSPathControl sets its url, otherwise I'll lose any references to the url I've been granted access to use. Actually, the following scheme seems to be working: -(void) awakeFromNib { if(bookmark != nil) { NSURL* url = [NSURL URLByResolvingBookmarkData:bookmark options:(NSURLBookmarkResolutionWithoutUI | NSURLBookmarkResolutionWithSecurityScope) relativeToURL:nil bookmarkDataIsStale:nil error:nil]; BOOLneedToStopAccess = [url startAccessingSecurityScopedResource]; [self.searchPathView setURL:url]; if(needToStopAccess) [url stopAccessingSecurityScopedResource]; } } Then in my method that actually does the search, do the same start/stop pair. Is that how start/stop is expected to be used? -- Steve Mills Drummer, Mac geek ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Machine sleep wake notifications in a daemon
Good day, I would like to receive machine sleep and wake notifications in my daemon. In my Cocoa GUI application, I was able to easily follow the sample code under Listing 1 on the page https://developer.apple.com/library/mac/qa/qa1340/_index.html, but when I tried the same approach in my daemon, I received no errors or warnings from Xcode or in the system console, and yet the handlers also did not fire. After poking around for a while, I have a hunch that it may have something to do with the main event queue not being the same (or existing at all?) in a non-Cocoa GUI application. Is it possible to have a Cocoa-style event queue in a daemon, or is there another way to receive machine sleep and wake notifications from the OS in a daemon? Thanks, - Andrew Keller ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: deny file-read-data after launch
On 9 Jan 2015, at 9:51 am, Steve Mills sjmi...@mac.com wrote: I'm having a problem with my app on 10.9 that I'm not sure about. The user chooses a folder via NSPathControl, then I use that to do an NSMetadataQuery for all images inside that folder. I don't have code signing turned on for this app yet, but I do have the Sandbox capability turned on. (This is my first personal project since all this stuff has been introduced.) If I launch my app, choose a folder, I can run my search on it and everything is fine. That folder gets stored in user defaults via a binding on the path control. If I quit and launch again, the path looks correct, yet I get sandbox errors on that folder and everything inside it: sandboxd: ([372]) Image Snooper(372) deny file-read-data /Volumes/Lemmy/Users/sjmills/Pictures And then it immediately goes off with results from a completely different folder: kernel: Sandbox: Image Snooper(372) deny file-read-data /Volumes/Lemmy/Library/Application Support/iPhoto/Themes/blah blah blah Note that the Pictures folder in question is NOT in my current user folder, but in a user folder NOT on the boot volume. Any ideas? For a sandboxed app, permission to read a folder outside the sandbox is granted when you use the NSOpenPanel, as you are doing on your first run. On your second run, that permission isn't there. To save a path in user defaults that works for a sandboxed app it has to be stored as a security-scoped bookmark, which you then resolve on subsequent launches. That also grants permission. --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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Blurry is the New Sharp
On Jan 7, 2015, at 7:40 PM, Michael Crawford mdcrawf...@gmail.com wrote: The last time I reported a bug of any sort to anyone, I reported quite a serious iOS security hole via Radar. The Apple engineer who responded quite angrily closed my bug as works as expected. He didn't just close the bug - he expressed a great deal of anger for having reported the exploit at all. I'm not real clear what his reasoning was. It wasn't just because of this one engineer that I stopped reporting bugs, rather that was the end of a long series of failures of vendors to fix bugs reported not just by myself but by others. To report security or privacy issues that affect Apple products or web servers, please contact product-secur...@apple.com. Security bugs reported via Radar sometimes don't get the attention they deserve. https://www.apple.com/support/security/ -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Machine sleep wake notifications in a daemon
On Jan 8, 2015, at 4:03 PM, Andrew Keller and...@kellerfarm.com wrote: I would like to receive machine sleep and wake notifications in my daemon. In my Cocoa GUI application, I was able to easily follow the sample code under Listing 1 on the page https://developer.apple.com/library/mac/qa/qa1340/_index.html, but when I tried the same approach in my daemon, I received no errors or warnings from Xcode or in the system console, and yet the handlers also did not fire. After poking around for a while, I have a hunch that it may have something to do with the main event queue not being the same (or existing at all?) in a non-Cocoa GUI application. Is it possible to have a Cocoa-style event queue in a daemon, or is there another way to receive machine sleep and wake notifications from the OS in a daemon? Did you read further down that QA article you linked to listings 3 and 4? 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
deny file-read-data after launch
I'm having a problem with my app on 10.9 that I'm not sure about. The user chooses a folder via NSPathControl, then I use that to do an NSMetadataQuery for all images inside that folder. I don't have code signing turned on for this app yet, but I do have the Sandbox capability turned on. (This is my first personal project since all this stuff has been introduced.) If I launch my app, choose a folder, I can run my search on it and everything is fine. That folder gets stored in user defaults via a binding on the path control. If I quit and launch again, the path looks correct, yet I get sandbox errors on that folder and everything inside it: sandboxd: ([372]) Image Snooper(372) deny file-read-data /Volumes/Lemmy/Users/sjmills/Pictures And then it immediately goes off with results from a completely different folder: kernel: Sandbox: Image Snooper(372) deny file-read-data /Volumes/Lemmy/Library/Application Support/iPhoto/Themes/blah blah blah Note that the Pictures folder in question is NOT in my current user folder, but in a user folder NOT on the boot volume. Any ideas? -- Steve Mills Drummer, Mac geek ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Machine sleep wake notifications in a daemon
On Jan 8, 2015, at 5:20 PM, Ken Thomases k...@codeweavers.com wrote: On Jan 8, 2015, at 4:03 PM, Andrew Keller and...@kellerfarm.com wrote: I would like to receive machine sleep and wake notifications in my daemon. In my Cocoa GUI application, I was able to easily follow the sample code under Listing 1 on the page https://developer.apple.com/library/mac/qa/qa1340/_index.html, but when I tried the same approach in my daemon, I received no errors or warnings from Xcode or in the system console, and yet the handlers also did not fire. After poking around for a while, I have a hunch that it may have something to do with the main event queue not being the same (or existing at all?) in a non-Cocoa GUI application. Is it possible to have a Cocoa-style event queue in a daemon, or is there another way to receive machine sleep and wake notifications from the OS in a daemon? Did you read further down that QA article you linked to listings 3 and 4? Yes. It looks very promising, but on the first try, I wasn't able to keep the run loop running (it exited immediately). I suspect that the problem has to do with the run loop not having any input sources. I'm currently in the middle of https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html, where it's explaining how to create run loop sources. I'm learning quite a lot here, but that also means that progress is very slow at the moment. I figured it would hurt to ping the list to see if there was a simpler solution or perhaps documentation more specialized to my objective. Also, I have a feeling that there may be something missing conceptually. Suppose I do manage to keep the run loop running using a new input source. How do the OS and the application frameworks know to route the notification there? I suspect that some additional object registration may be needed to make the run loop handle the events, or it might be a very specific input source I don't know about yet... Thanks, - Andrew Keller ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Am I Reinventing the Wheel? (Part I)
When you try to reinvent the wheel, most often what you end up with is a flat tire. I need to deal with two issues that are probably already handled in some Cocoa API I just haven't found yet. This email asks about the first of these issues. I'm writing data to XML. When you create a node and set its string contents, the node will happily accept whatever string you give and allow you to serialize information XML deserialization cannot then recreate. In my case, the string in question contained curled quotes. I could serialize and save the data—and if I remember correctly* the output looked good when I inspected the file on disk—but reading it back and deserializing it led to disaster! Right now I'm using NSString stringByAddingPercentEncoding: and having no further problems with curled quotes, but I'm sure that's a poor long-term solution. *I encountered this problem a few weeks ago and put off a final solution by using the percent encoding. Is there already a Cocoa API call that would convert a string to use HTML entities so I could safely put any string into an XML node? — Charles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Am I Reinventing the Wheel? (Part II)
This is the second issue for which I'm looking for an existing API call. I have two ranges from an NSAttributedString. I want to compare their fonts and attributes in such a way as to derive a dictonary containing only the differences. Does a font-and-attribute comparison method already exist? What I'm thinking of writing is a function to create a dictonary and toss in FamilyName, PointSize, plus everything in the range's associated attributes dictionary. Generate one of these for each attribute range, and then just write a dictionary-comparison function which will return a new dictionary containing only those attributes which differ. The purpose is to find out where characters in a paragraph differ from the paragraph's overall style, so that my XML data file can store difference ranges and attributes only where necessary to recreate the original, rather than having to store a lot of redundant information. — Charles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Saving NSAttributedString to a File
Jeffrey, FWIW, I started with RTF and then decided I'd need to switch over to using XML instead in order to have control of writing out what I needed from my NSAttributedStrings. If you're writing RTF for interoperation with another program, you may be stuck with it; but if you're working on your own app's internal data file format, XML may suit you better. Consider using XML serialization to write the data out and NSXMLParser to read it back in. The objects are very easy to use (with one exception I just asked about in my message entitled Am I Reinventing the Wheel? (Part I)). If you do an Internet search, you can find good tutorials on getting started with NSXMLParser. It took me less than a day to write something that met my needs. — Charles On Wednesday, January 7, 2015 at 18:32, Jens Alfke wrote: On Jan 7, 2015, at 1:49 PM, Jeffrey Oleander jgo...@yahoo.com (mailto:jgo...@yahoo.com) wrote: So, then the problem becomes, how do you get it to pass on those custom tags as custom attributes, or to your custom attribute processor? By writing your own RTF codec. Apple's doesn't support this. —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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSScrollView autolayout (10.10)
On 8 Jan 2015, at 00:57, Ken Thomases k...@codeweavers.com wrote: More generally, is this how you’re supposed to set up a view which has intrinsic content size inside a scroll view in IB, pin that view to the NSView IB gives you, then pin that to the clipview on 3 sides only and flip the clip (why?). I did try changing the class of the NSView I can’t delete to NSStackView and avoid the middle man, very bad things happened, constraints were generated in constraint language which didn’t parse, so I decided to put it back where it was. For what it's worth, I dragged an NSStackView into a window. Then, I chose Editor Embed In Scroll View. That resulted in: +- NSScrollview +- NSClipView +- NSStackView Then I selected Reset to Suggested Constraints for the whole window. That added leading, trailing, top, and bottom constraints for the scroll view to its superview and the same for the stack view to the clip view. The fact that the stack view was constrained on all sides meant that it would never scroll. Rather, the scroll view would grow to fit it and the window would grow to fit that. I then deleted the bottom constraint between the stack view and the clip view, similar to what you have. That resulted in what you described: the stack view was positioned at the bottom of the clip view when it was shorter than the scroll view's content height. Embed in ScrollView was something I’d forgotten about, using that does make more sense and I’ve made another version which goes that way, that removes one view. I didn't try subclassing NSClipView to make it flipped. (I had thought that clip views were flipped by default, but that may not apply with auto layout.) I assume it would fix the placement of the stack view as you described. There's another way to fix that, though. Rather than removing the bottom constraint between the stack view and the clip view, change it to an inequality. Make it so that the stack view is _at least_ as tall as the clip view (stack view bottom is greater than or equal to the clip view bottom). When the scroll view is taller than needed to show the stack view's intrinsic height, the stack view is made taller to fill the content size and thus subviews in its top section will appear at the top of the scroll view. When the scroll view is shorter than needed (either because the stack view grows or because the window is made smaller), the stack view is not forced to be shorter. Rather, it is allowed to scroll vertically, since the document (stack) view is taller than the content (clip) view. I finally did make this work when I got the constraint the right way around. I see what’s going on there. I eventually today found the WWDC video from 2013 which mentions ever so briefly how to put a stack view in a scroll view and that mentions the clip view must be flipped (and they leave out the bottom constraint as I did), but either works just fine and your way doesn’t require the subclass which is cool. Thanks for the help. Now .. animation time .. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Am I Reinventing the Wheel? (Part I)
I am not familiar with the API you are using, I use my own XML generator/parser, but it may be worth nothing something about XML. XML files are implicitly Unicode and generally UTF-8. So you cannot put an arbitrary sequence of bytes into XML as a string. A curly quote is not in the low Latin (=127) range so it must be a multibyte value. Clearly there are different API approaches possible on encoding: - convert an input encoding to UTF-8 - accept and write UTF-8 with validation, rejecting bad UTF-8 sequences - accept and write UTF-8 with validation, converting bad UTF-8 sequences silently to something else - accept and write UTF-8 without validation, potentially writing malformed XML Parsers have similar choices to make. But anyway, if your data is not valid UTF-8, it would explain why you get disastrous results. XML has no standard binary representation for anything other than Unicode strings, so symmetric encoding/decoding of such data, following your own invention or some extension to basic XML, is the only way. A low level XML API cannot be expected to offer this, especially one intended to write XML for consumption by other software. (This is in addition to the five characters prohibited in strings because they are XML markup). On Thu, Jan 8, 2015 at 12:43 PM, Charles Jenkins cejw...@gmail.com wrote: I'm writing data to XML. When you create a node and set its string contents, the node will happily accept whatever string you give and allow you to serialize information XML deserialization cannot then recreate. In my case, the string in question contained curled quotes. I could serialize and save the data—and if I remember correctly* the output looked good when I inspected the file on disk—but reading it back and deserializing it led to disaster! Right now I'm using NSString stringByAddingPercentEncoding: and having no further problems with curled quotes, but I'm sure that's a poor long-term solution. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Am I Reinventing the Wheel? (Part I)
Do you absolutely _require_ the use of Cocoa to process your XML? There are oodles of Open Source XML libraries. I myself have had great success with Xerces-C (actually C+). Michael David Crawford, Consulting Software Engineer mdcrawf...@gmail.com http://www.warplife.com/mdc/ Available for Software Development in the Portland, Oregon Metropolitan Area. On Thu, Jan 8, 2015 at 5:27 AM, Aandi Inston aa...@quite.com wrote: I am not familiar with the API you are using, I use my own XML generator/parser, but it may be worth nothing something about XML. XML files are implicitly Unicode and generally UTF-8. So you cannot put an arbitrary sequence of bytes into XML as a string. A curly quote is not in the low Latin (=127) range so it must be a multibyte value. Clearly there are different API approaches possible on encoding: - convert an input encoding to UTF-8 - accept and write UTF-8 with validation, rejecting bad UTF-8 sequences - accept and write UTF-8 with validation, converting bad UTF-8 sequences silently to something else - accept and write UTF-8 without validation, potentially writing malformed XML Parsers have similar choices to make. But anyway, if your data is not valid UTF-8, it would explain why you get disastrous results. XML has no standard binary representation for anything other than Unicode strings, so symmetric encoding/decoding of such data, following your own invention or some extension to basic XML, is the only way. A low level XML API cannot be expected to offer this, especially one intended to write XML for consumption by other software. (This is in addition to the five characters prohibited in strings because they are XML markup). On Thu, Jan 8, 2015 at 12:43 PM, Charles Jenkins cejw...@gmail.com wrote: I'm writing data to XML. When you create a node and set its string contents, the node will happily accept whatever string you give and allow you to serialize information XML deserialization cannot then recreate. In my case, the string in question contained curled quotes. I could serialize and save the data--and if I remember correctly* the output looked good when I inspected the file on disk--but reading it back and deserializing it led to disaster! Right now I'm using NSString stringByAddingPercentEncoding: and having no further problems with curled quotes, but I'm sure that's a poor long-term solution. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/mdcrawford%40gmail.com This email sent to mdcrawf...@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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Am I Reinventing the Wheel? (Part II)
On Jan 8, 2015, at 4:43 AM, Charles Jenkins cejw...@gmail.com wrote: I have two ranges from an NSAttributedString. I want to compare their fonts and attributes in such a way as to derive a dictonary containing only the differences. Does a font-and-attribute comparison method already exist? I'm 99% certain there is nothing like that in the OS; you'll need to write it yourself (or do a web search to see if there's an open source library that does it…) —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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Am I Reinventing the Wheel? (Part I)
Fantastic! I can't wait to get home and try it! — Charles On Thursday, January 8, 2015 at 11:08, Keary Suska wrote: NSDictionary *documentAttributes = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType}; NSData *htmlData = [s dataFromRange:NSMakeRange(0, s.length) documentAttributes:documentAttributes error:NULL]; NSString *htmlString = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding]; ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Am I Reinventing the Wheel? (Part I)
On Jan 8, 2015, at 4:43 AM, Charles Jenkins cejw...@gmail.com wrote: I'm writing data to XML. When you create a node and set its string contents, the node will happily accept whatever string you give and allow you to serialize information XML deserialization cannot then recreate. In my case, the string in question contained curled quotes. I could serialize and save the data—and if I remember correctly* the output looked good when I inspected the file on disk—but reading it back and deserializing it led to disaster! No, it's fine for XML text to contain non-ASCII Unicode characters. The problem in your case was probably that the doctype string at the start of the document didn't properly declare the text encoding. What you want to do is write the XML as UTF-8 and add the proper annotation to that effect in the doctype. (Sorry, it's been years since I worked with XML so I don't remember the exact syntax for doing this.) The only characters that MUST be escaped in XML text are and . —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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Displaying a scaling, relative time or date
On Jan 8, 2015, at 6:43 AM, Gary L. Wade garyw...@desisoftsystems.com wrote: When it comes to any localized date or number formatters, see if ICU supports it, especially the included version on the earlier OS you need to support. If not but a later one does, you could just include it in your app. On OS X you may need to include ICU anyway, because it's never been a supported public library for 3rd party apps. But yeah, using something like ICU is better than writing this by hand, because otherwise you need to do the I18N yourself. —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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Am I Reinventing the Wheel? (Part I)
Aandi Inston wrote: (This is in addition to the five characters prohibited in strings because they are XML markup). Minor nit. There are only 2 prohibited characters in XML, whether in a string or out. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Displaying a scaling, relative time or date
When it comes to any localized date or number formatters, see if ICU supports it, especially the included version on the earlier OS you need to support. If not but a later one does, you could just include it in your app. -- Gary L. Wade (Sent from my iPad) http://www.garywade.com/ On Jan 7, 2015, at 4:52 PM, Ken Thomases k...@codeweavers.com wrote: On Jan 7, 2015, at 6:18 PM, Graham Cox graham@bigpond.com wrote: I want a label in my interface to display a relative time using a sensible approximate scale depending on the value. I'm not sure if I can use NSDateFormatter for this - it seems it's a bit too fixed in using only the units you assign. For example, if the value is less than a minute, it should say x seconds ago, if it's in the range of 1-59 minutes, x minutes ago, about an hour ago, x hours ago, yesterday, x days ago, about a week ago, x weeks ago, about a month ago, x months ago - you get the picture. Is this possible using NSDateFormatter, or do I have to roll my own for this? If you can require 10.10 or iOS 8, there's a new class for this: NSDateComponentsFormatter. There's no class reference for it yet. It's described in the Foundation release notes https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/#10_10Formatters and in its header file. If you can't require those versions of the OSes, then I think you have to roll your own. Or find a third-party library/framework/class. 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Am I Reinventing the Wheel? (Part I)
On Jan 8, 2015, at 5:43 AM, Charles Jenkins cejw...@gmail.com wrote: I need to deal with two issues that are probably already handled in some Cocoa API I just haven't found yet. This email asks about the first of these issues. I'm writing data to XML. When you create a node and set its string contents, the node will happily accept whatever string you give and allow you to serialize information XML deserialization cannot then recreate. In my case, the string in question contained curled quotes. I could serialize and save the data—and if I remember correctly* the output looked good when I inspected the file on disk—but reading it back and deserializing it led to disaster! Right now I'm using NSString stringByAddingPercentEncoding: and having no further problems with curled quotes, but I'm sure that's a poor long-term solution. *I encountered this problem a few weeks ago and put off a final solution by using the percent encoding. Is there already a Cocoa API call that would convert a string to use HTML entities so I could safely put any string into an XML node? You can apparently route through NSAttributedString (found via StackOverflow): NSAttributedString *s = [[NSAttributedString alloc] initWithString:sourceString]; NSDictionary *documentAttributes = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType}; NSData *htmlData = [s dataFromRange:NSMakeRange(0, s.length) documentAttributes:documentAttributes error:NULL]; NSString *htmlString = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding]; HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Blurry is the New Sharp
On 2015 Jan 05, at 18:38, Graham Cox wrote: People suggested that OS X had jumped the shark with Lion. If so, we're into Jaws VIII vs. Godzilla 3D territory now. They foisted intentionally blurry text on us by 2002, but don't single out the Apple execs and management. It has infected all of the industry executives, beginning some time around 1985. Sure, it works fine, so let's do another 'face-lift' which destroys actual functionality. And that applies to their employment practices as well as frameworks, web-sites, OSes... They must have gone to DC to lobby for special favors and made the mistake of drinking the same water the delusional politicians do, and it spread like virus from there. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com