Calling fcntl() and friends from Swift?
So far, my foray into Swift is going decently well. But I'm trying to re-write some code that uses IOKit and sys/fcntl.h, and while the IOKit calls are fine, it doesn't like me trying to call fcntl(). It says, Use of unresolved identifier 'fcntl'. I've tried including sys/fcntl.h in my bridging header, I tried a few imports like import sys or import fcntl with no luck. I also haven't found anything by googling. Even searching for Swift printf didn't give me good results. Any ideas on how I can call these things? Thanks! -- Rick Mann rm...@latencyzero.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: Table of TextViews
On Oct 15, 2014, at 6:40 AM, Charles Jenkins cejw...@gmail.com wrote: Thanks for looking it over. :-) I guess I misunderstood the documentation. I thought if you dragged out a table view from the palette into a NIB, you got a full hierarchy of objects (including the extra scroll view I specifically don’t want), but if you created it programmatically you had to create all the individual text objects and link them up programmatically. Dragging a text view in IB does give you an enclosing scroll view, which is almost always what one wants, so it's probably a good default, but it can be a bit annoying. However, the documentation clearly explains that there are two approaches when creating on programmatically. If you use -initWithFrame:, NSTextView creates all of the appropriate objects of the text system. If you use -initWithFrame:textContainer:, the NSTextView assumes you are taking responsibility for creating those objects. The two approaches also result in different ownership semantics for the various objects. I’ll use the debugger to scope out what I actually get via initWithFrame:, and if the other objects are already there, I’ll leave them alone instead of wasting code space recreating them. You can poke around with the debugger if you like, but the docs are clear. Just look at the docs for the initializer methods in the NSTextView class reference. Or see the Creating an NSTextView Object Programmatically article in the Text System User Interface Layer Programming Guide: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/TextUILayer/Tasks/CreateTextViewProg.html As for reporting the size the way I do, I tried that because of the craziness that happens when I use text views in a table. I originally started out having the table delegate watch for the size change notification. When my table delegate is notified of a text view’s size change, it logs the event and makes these calls: NSIndexSet* ixs = [NSIndexSet indexSetWithIndex:row]; [self.theTableView noteHeightOfRowsWithIndexesChanged:ixs]; And things go nuts. Are you using the text view as the _direct_ cell view in the table? Don't do that. The outline view is in charge of the frame of the cell views. So, it will call (or cause to be called by, for example, auto layout) the -setFrame… methods, which will cause the text view to re-layout the text, which will cause the layout manager to change the size of the text view, etc. Put the text view into another view. Probably easiest to make that containing view flipped, since you want the text view's top-left corner, not its bottom-left, to be anchored in place as it changes size. If you're using auto layout, leave the text view's translatesAutoresizingMaskIntoConstraints property as YES and don't set any constraints on it. Position it using -setFrame: and let the autoresizingMask take it from there. The outline view can resize the container view as it likes. That won't have a direct effect on the text view's height. It will affect its width, as desired, because of the autoresizingMask. If the text view changes height such that it is taller or shorter than the container view, that should be corrected after you inform the outline view that the row's height has changed, so it queries your delegate for the new height, at which point your delegate would inform it and the outline view will resize the container view so that the text view shows and is not clipped. 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: Calling fcntl() and friends from Swift?
On 18 Oct 2014, at 5:25 pm, Rick Mann rm...@latencyzero.com wrote: So far, my foray into Swift is going decently well. But I'm trying to re-write some code that uses IOKit and sys/fcntl.h, and while the IOKit calls are fine, it doesn't like me trying to call fcntl(). It says, Use of unresolved identifier 'fcntl'. I've tried including sys/fcntl.h in my bridging header, I tried a few imports like import sys or import fcntl with no luck. I also haven't found anything by googling. Even searching for Swift printf didn't give me good results. Any ideas on how I can call these things? Thanks! -- Rick Mann rm...@latencyzero.com fcntl() wasn’t mapped in earlier versions of Swift, possibly still isn’t. If you can’t get to it with Darwin.fcntl() (and I don’t think you can) then you can’t get to it. You can wrap it in a piece of objc and export it via a bridging header .. which is pretty ugh. Bits of libdispatch were missing in earlier versions, I filed a bug against it and they eventually did show up. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
DOMDocument in 10.10
WebFrame *mainFrame = [ webView mainFrame ]; DOMDocument *domDoc = [ mainFrame DOMDocument ]; When I print domDoc, I get with 10.9 something like: DOMHTMLDocument [#document]: 0x105df8400 '' with 1 children DOMHTMLHtmlElement [HTML]: 0x10401c660 '' with 3 children [ 0] DOMHTMLHeadElement [HEAD]: 0x10401c2a0 '' with 15 children [ 0] DOMText = ** white ** [ 1] DOMHTMLMetaElement [ 2] DOMText = ** white ** [ 3] DOMHTMLMetaElement [ 4] DOMText = ** white ** [ 5] DOMHTMLTitleElement [TITLE]: 0x10404c9a0 '' with 1 children [ 0] DOMText = พจนานุกรม ฉบับราชบัณฑิตยสถาน พ.ศ. ๒๕๕๔ [--] DOMHTMLTitleElement - [ 6] DOMText = ** white ** [ 7] DOMHTMLScriptElement [SCRIPT]: 0x10400d750 '' with 1 children [ 0] DOMText = function is_mobile() [--] DOMHTMLScriptElement - [ 8] DOMText = ** white ** [ 9] DOMHTMLLinkElement [10] DOMText = ** white ** [11] DOMHTMLScriptElement [12] DOMText = ** white ** [13] DOMHTMLScriptElement [SCRIPT]: 0x10400d3f0 '' with 1 children [ 0] DOMText = function checkForm(f) ... [--] DOMHTMLScriptElement - [14] DOMText = ** white ** [--] DOMHTMLHeadElement - [ 1] DOMText = ** white ** [ 2] DOMHTMLBodyElement [BODY]: 0x10401c480 '' with 5 children ... [--] DOMHTMLBodyElement - DOMHTMLHtmlElement - DOMHTMLDocument - which looks about right. Safaris Web Inspector shows similar structure. But with 10.10 I get (for the same document): DOMHTMLDocument [#document]: 0x105df8400 '' with 1 children [ 0] DOMHTMLHtmlElement [HTML]: 0x105e189c0 '' with 1 children [ 0] DOMHTMLHeadElement [HEAD]: 0x105e18a20 '' with 12 children [ 0] DOMText = ** white ** [ 1] DOMHTMLMetaElement [ 2] DOMText = ** white ** [ 3] DOMHTMLMetaElement [ 4] DOMText = ** white ** [ 5] DOMHTMLTitleElement [TITLE]: 0x105e19a10 '' with 1 children [ 0] DOMText = พจนานุกรม ฉบับราชบัณฑิตยสถาน พ.ศ. ๒๕๕๔ [--] DOMHTMLTitleElement - [ 6] DOMText = ** white ** [ 7] DOMHTMLScriptElement [SCRIPT]: 0x105dc03f0 '' with 1 children [ 0] DOMText = function is_mobile [--] DOMHTMLScriptElement - [ 8] DOMText = ** white ** [ 9] DOMHTMLLinkElement [10] DOMText = ** white ** [11] DOMHTMLScriptElement [--] DOMHTMLHeadElement - [--] DOMHTMLHtmlElement - DOMHTMLDocument - Note: the head has only 12 children (the first 10 are identical to 10.9), and there is no body at all. What am I doing wrong? Or, if this is a known 10.10 bug: how to work around this - I really need the body of the page. Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Document style programming
Hi, I am creating a Desktop issue tracking app using core data and the NSDocument framework - so yes, the Xcode wizard extended NSPersistentDocument which provides me with an NSManagedObjectContext. My question is - if I start working in the app, creating issues for instance ... when I go to actually persist the context I get an error This NSPersistentStoreCoordinator has no persistent stores. It cannot perform a save operation. So, does this imply that for NSDocument style programming, most folks aren't 'saving' their context right away? Do we wait for the user to actually save the document the first time? IE: there is not in memory store that the Document manages until the user formally saves to the file system? And does it follow then that on subsequent changes, we formally persist the context only when the user actually 'Saves'? Does anyone force the user to 'find' a file location right away, upon opening a new document, and then persist everything happily in the background? I tend to this this is really just a Desktop paradigm question more than anything else. Thanks, -Luther ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Document style programming
When using NSPersistentDocument it takes over responsibility for saving the context. You should not save the context yourself. On 18 Oct 2014, at 17:00, Luther Baker lutherba...@gmail.com wrote: Hi, I am creating a Desktop issue tracking app using core data and the NSDocument framework - so yes, the Xcode wizard extended NSPersistentDocument which provides me with an NSManagedObjectContext. My question is - if I start working in the app, creating issues for instance ... when I go to actually persist the context I get an error This NSPersistentStoreCoordinator has no persistent stores. It cannot perform a save operation. So, does this imply that for NSDocument style programming, most folks aren't 'saving' their context right away? Do we wait for the user to actually save the document the first time? IE: there is not in memory store that the Document manages until the user formally saves to the file system? And does it follow then that on subsequent changes, we formally persist the context only when the user actually 'Saves'? Does anyone force the user to 'find' a file location right away, upon opening a new document, and then persist everything happily in the background? I tend to this this is really just a Desktop paradigm question more than anything else. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Saving a Document style app
I'd like to save my Document based app in the bundle style format. IE: I'd like to save things in a directory - like apps like OmniOutliner do. Out of the box, I get the option to save as sqlite, binary or XML. What I'd like is to save a 'bundle' with my own extension and nest things like the the sqlite database inside of it. Is this type of functionality provided for me by another Cocoa framework or is this a strictly manual process that has been passed down as convention from dev to dev? Is anyone aware of an Apple example app that would demonstrate this? Or any suggestions regarding an Open Source Cocoa App by anyone here that would be worth browsing through for this type of stuff? Thanks, -Luther ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Document style programming
Thanks Mike. Let me ask another question ... what if I need to create a temporary, thread specific NSManagedObjectContext? Let's say I'm interacting with a RESTful API ala AFNetworking and I need to parse and save data on a background response thread. How do I tie my thread specific context into the Document's datastore? Thanks, -Luther On Sat, Oct 18, 2014 at 11:03 AM, Mike Abdullah mabdul...@karelia.com wrote: When using NSPersistentDocument it takes over responsibility for saving the context. You should not save the context yourself. On 18 Oct 2014, at 17:00, Luther Baker lutherba...@gmail.com wrote: Hi, I am creating a Desktop issue tracking app using core data and the NSDocument framework - so yes, the Xcode wizard extended NSPersistentDocument which provides me with an NSManagedObjectContext. My question is - if I start working in the app, creating issues for instance ... when I go to actually persist the context I get an error This NSPersistentStoreCoordinator has no persistent stores. It cannot perform a save operation. So, does this imply that for NSDocument style programming, most folks aren't 'saving' their context right away? Do we wait for the user to actually save the document the first time? IE: there is not in memory store that the Document manages until the user formally saves to the file system? And does it follow then that on subsequent changes, we formally persist the context only when the user actually 'Saves'? Does anyone force the user to 'find' a file location right away, upon opening a new document, and then persist everything happily in the background? I tend to this this is really just a Desktop paradigm question more than anything else. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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 a Document style app
On 18 Oct 2014, at 17:06, Luther Baker lutherba...@gmail.com wrote: I'd like to save my Document based app in the bundle style format. IE: I'd like to save things in a directory - like apps like OmniOutliner do. Out of the box, I get the option to save as sqlite, binary or XML. What I'd like is to save a 'bundle' with my own extension and nest things like the the sqlite database inside of it. Is this type of functionality provided for me by another Cocoa framework or is this a strictly manual process that has been passed down as convention from dev to dev? Is anyone aware of an Apple example app that would demonstrate this? Or any suggestions regarding an Open Source Cocoa App by anyone here that would be worth browsing through for this type of stuff? https://github.com/karelia/BSManagedDocument ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Document style programming
On 18 Oct 2014, at 17:09, Luther Baker lutherba...@gmail.com wrote: Thanks Mike. Let me ask another question ... what if I need to create a temporary, thread specific NSManagedObjectContext? Let's say I'm interacting with a RESTful API ala AFNetworking and I need to parse and save data on a background response thread. How do I tie my thread specific context into the Document's datastore? These days, I daresay Apple would like you to split off a temporary child context that saves directly into its parent context (rather than the old way of two contexts sharing a persistent store coordinator). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
One more Document app style question
Coming from an iOS background, I'm used to seeing (and encapsulating) the creation of key Core Data components (persistent store, location, contexts). Everything is pretty explicit and consequently easy to follow. When I use Xcode to generate a desktop Document based app for me, that functionality is hidden from me. No problem ... but, I don't like the class name Document - I'd like to change it so something specific ... MyAppDocument. Maybe that is easy enough ... but then there's the Document.xib file ... and Document.xcdatamodel. So, how does the app specific Document class know which datamodel to instantiate? Is the rule simply that the name of the NSDocument's subclass must match the name of the datamodel file (similar to the default behavior for xib matching)? -- or is there something I need to update in the plist file as well? Thanks, -Luther ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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 a Document style app
Awesome! Thanks Mike. By the way, I'm a happy Hit List user! -Luther On Sat, Oct 18, 2014 at 11:10 AM, Mike Abdullah mabdul...@karelia.com wrote: On 18 Oct 2014, at 17:06, Luther Baker lutherba...@gmail.com wrote: I'd like to save my Document based app in the bundle style format. IE: I'd like to save things in a directory - like apps like OmniOutliner do. Out of the box, I get the option to save as sqlite, binary or XML. What I'd like is to save a 'bundle' with my own extension and nest things like the the sqlite database inside of it. Is this type of functionality provided for me by another Cocoa framework or is this a strictly manual process that has been passed down as convention from dev to dev? Is anyone aware of an Apple example app that would demonstrate this? Or any suggestions regarding an Open Source Cocoa App by anyone here that would be worth browsing through for this type of stuff? https://github.com/karelia/BSManagedDocument ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Document style programming
As an aside, I'm sure it is well-known, there is some funny caching going on. If I open the app the first time (and pre-populate the context with data) - I cannot actually SAVE. If I formally shut the app down by quitting the app and choosing Don't Save, then subsequent restarts exhibit the same behavior. BUT, if I simply rerun the app from Xcode (with the app still running) -- then subsequent SAVES on the context actually work --- or at least they don't complain about not having an attached datastore. In fact, the block of code that creates the temp data is based on the existence of data in the database and it doesn't run on subsequent Xcode restarts ... which implies that when restarting the app from Xcode, the environment tries to remember data I've created (and not yet saved). Something was cached in the restart and now there is a persistent store of some sort, albeit still nothing that I explicitly saved anywhere. Sort of trippy unless you expect or understand why. At any rate, thanks for the clarifications! -Luther On Sat, Oct 18, 2014 at 11:11 AM, Mike Abdullah mabdul...@karelia.com wrote: On 18 Oct 2014, at 17:09, Luther Baker lutherba...@gmail.com wrote: Thanks Mike. Let me ask another question ... what if I need to create a temporary, thread specific NSManagedObjectContext? Let's say I'm interacting with a RESTful API ala AFNetworking and I need to parse and save data on a background response thread. How do I tie my thread specific context into the Document's datastore? These days, I daresay Apple would like you to split off a temporary child context that saves directly into its parent context (rather than the old way of two contexts sharing a persistent store coordinator). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Passing a swift function to objective-c
Hi Roland, Thanks for the followup. I've created a proper git rep on github rather than just a gist. Most of my github reps seem to be this kind of mini demonstration project and I was trying to avoid yet another one. https://github.com/SheffieldKevin/swift-objectivec What version of Xcode are you using by the way, Swift is so flux-y at the moment it probably makes a difference. I'm now running release Yosemite and release Xcode 6.1. That appears to me to make no difference. I still can't assign to the optional property of my protocol. You can ignore the ImageProvider2 class, I've just included it for completeness. It doesn't have a protocol and just declares the property itself. So with my protocol I've done something similar to what you did if I've interpreted your discussion correctly. I've got two properties, one that is required and one that is optional. Everything works fine for the required property. But I still can't get the optional one to work. In ImageProvider.m you'll see that the MakeImageProvider function assigns a block to the optional property and in SupplyCreateImage.swift I've commented out the assignment. I've provided the example this way so that it can be seen that it works when done using objective-c. But if you comment out the assignment to the optional property of the block, and uncomment the line in the swift file you'll see that the command line tool no longer compiles. Like you I've tried the use of the optional and playing around with casting but I've not actually got the code to compile this way. Kevin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Document style programming
On 18 Oct 2014, at 17:33, Luther Baker lutherba...@gmail.com wrote: As an aside, I'm sure it is well-known, there is some funny caching going on. If I open the app the first time (and pre-populate the context with data) - I cannot actually SAVE. If I formally shut the app down by quitting the app and choosing Don't Save, then subsequent restarts exhibit the same behavior. BUT, if I simply rerun the app from Xcode (with the app still running) -- then subsequent SAVES on the context actually work --- or at least they don't complain about not having an attached datastore. In fact, the block of code that creates the temp data is based on the existence of data in the database and it doesn't run on subsequent Xcode restarts ... which implies that when restarting the app from Xcode, the environment tries to remember data I've created (and not yet saved). Something was cached in the restart and now there is a persistent store of some sort, albeit still nothing that I explicitly saved anywhere. Sort of trippy unless you expect or understand why. To re-iterate: do NOT save the context yourself. That is the document’s job. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Passing a swift function to objective-c
I've now found an acceptable solution. Rather than a property I've added an optional method to the protocol which then in its implementation assigns using the property, pretty much to make sure that the function/block is copied. I declared the method like so: -(void)applyMyCreateImageFunction:(CGImageRef (^)(NSDictionary *))createImageFunction And when calling it from the swift code I call it like so: imageProvider.applyMyCreateImageFunction?(makeImage) The question mark was necessary to evaluate whether the optional protocol method had been implemented or not. Kevin On 18 Oct 2014, at 18:18, Kevin Meaney k...@yvs.eu.com wrote: Hi Roland, Thanks for the followup. I've created a proper git rep on github rather than just a gist. Most of my github reps seem to be this kind of mini demonstration project and I was trying to avoid yet another one. https://github.com/SheffieldKevin/swift-objectivec What version of Xcode are you using by the way, Swift is so flux-y at the moment it probably makes a difference. I'm now running release Yosemite and release Xcode 6.1. That appears to me to make no difference. I still can't assign to the optional property of my protocol. You can ignore the ImageProvider2 class, I've just included it for completeness. It doesn't have a protocol and just declares the property itself. So with my protocol I've done something similar to what you did if I've interpreted your discussion correctly. I've got two properties, one that is required and one that is optional. Everything works fine for the required property. But I still can't get the optional one to work. In ImageProvider.m you'll see that the MakeImageProvider function assigns a block to the optional property and in SupplyCreateImage.swift I've commented out the assignment. I've provided the example this way so that it can be seen that it works when done using objective-c. But if you comment out the assignment to the optional property of the block, and uncomment the line in the swift file you'll see that the command line tool no longer compiles. Like you I've tried the use of the optional and playing around with casting but I've not actually got the code to compile this way. Kevin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/ktam%40yvs.eu.com This email sent to k...@yvs.eu.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: DOMDocument in 10.10
On Oct 18, 2014, at 5:33 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: Note: the head has only 12 children (the first 10 are identical to 10.9), and there is no body at all. Weird! Are you sure that the page has finished loading by the time you made the call? Maybe your code is running at a point when only the head part of the document has yet been loaded. —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
How does the Swift Darwin module work?
I need access to fcntl, so I thought I'd do what Apple does with Darwin. But I don't actually see how to do that. They create Darwin.stdio.fopen(), for example. But then how do they call the underlying C fopen()? For that matter, Swift can call C functions directly in some cases, and not at all in others. OH! Is it because fcntl is special? Check out its declaration: int fcntl(int, int, ...) __DARWIN_ALIAS_C(fcntl); __DARWIN_ALIAS_C is: #define __DARWIN_ALIAS_C(sym) __asm(_ __STRING(sym) __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03) So, is there some magic module I can create in Swift to make that accessible to my Swift code? -- Rick Mann rm...@latencyzero.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
Set UICollectionView UIScrollViewDelegate delegate
Hi, I have a parent view controller that has two UICollectionViewController subclasses as children in its view controller hierarchy. I'd like to set the parentViewController as the Subclass1CollectionViewController and Subclass2CollectionViewControllers' .colllectionView UIScrollView delegate. However when I set the delegate, the compiler assumes I'm trying to assign it as the UICollectionViewDelegate. UICollectionView is a subclass of UIScrollView.. how do refer to its scrollview delegate pointer? Xcode 6.0.1 iOS8. self.bodyCollectionViewController.collectionView.backgroundColor = UIColor.clearColor; self.bodyCollectionViewController.collectionView.showsHorizontalScrollIndicator = NO; self.bodyCollectionViewController.collectionView.showsVerticalScrollIndicator = NO; self.bodyCollectionViewController.collectionView.delegate = self; // warning -- Assigning to 'idUICollectionViewDelegate' from incompatible type 'SCRPreviewViewController *const __strong' @interface SCRPreviewViewController : UIViewController UIScrollViewDelegate ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: How does the Swift Darwin module work?
AFAIK, variadic C functions are not (yet) callable from swift code. Le 18 oct. 2014 à 20:37, Rick Mann rm...@latencyzero.com a écrit : I need access to fcntl, so I thought I'd do what Apple does with Darwin. But I don't actually see how to do that. They create Darwin.stdio.fopen(), for example. But then how do they call the underlying C fopen()? For that matter, Swift can call C functions directly in some cases, and not at all in others. OH! Is it because fcntl is special? Check out its declaration: int fcntl(int, int, ...) __DARWIN_ALIAS_C(fcntl); __DARWIN_ALIAS_C is: #define __DARWIN_ALIAS_C(sym) __asm(_ __STRING(sym) __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03) So, is there some magic module I can create in Swift to make that accessible to my Swift code? -- Rick Mann rm...@latencyzero.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/mailing%40xenonium.com This email sent to mail...@xenonium.com -- Jean-Daniel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Set UICollectionView UIScrollViewDelegate delegate
On Oct 18, 2014, at 2:22 PM, Mazzaroth M. taomaili...@gmail.com wrote: Hi, I have a parent view controller that has two UICollectionViewController subclasses as children in its view controller hierarchy. I'd like to set the parentViewController as the Subclass1CollectionViewController and Subclass2CollectionViewControllers' .colllectionView UIScrollView delegate. However when I set the delegate, the compiler assumes I'm trying to assign it as the UICollectionViewDelegate. UICollectionView is a subclass of UIScrollView.. how do refer to its scrollview delegate pointer? There is only one delegate property. UICollectionView redeclares the property it inherits from UIScrollView and retypes it as UICollectionViewDelegate, which extends UIScrollViewDelegate. Any object you assign as the collection view’s delegate *must* conform to UICollectionViewDelegate. The good news is that every member of UICollectionViewDelegate is optional, so this is a trivial change. --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
Clear NSSearchField
It looks like a couple of people have asked about this in the past, but none of the answers are working for me. I am trying to clear the contents of a NSSearchField and have it go back to its empty state. I don’t have a pre-Yosemite Mac handy to check if this is a bug / new behavior in Yosemite, however Apple Mail seems to be able to do it just fine. Most of the solutions I have seen are old and center around doing things like: [[searchField.cell cancelButtonCell] performClick: self]; …or... searchField.stringValue = @“”; [searchField validateEditing]; Both of these methods do clear the NSSearchField’s string value, however the Cancel button remains visible and the search field does not go back to its empty state (magnifying glass centered, gray “Search” text placeholder, and Cancel button not visible). I have had some marginal success by modifying outlineViewSelectionDidChange: to set the search field’s stringValue to @“”, do what needs to be done to update the other views, set the search field to the first responder, and then set the outline view back to the first responder. That works somewhat, but not really. Half the time the search field remains the first responder as if the call to set the outline view as the first responder never happened. Any ideas? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Clear NSSearchField
Yeah, I tried that initially. An invalid parameter exception comes flying out of NSCell’s setStringValue. On Oct 18, 2014, at 14:59, Gerd Knops ge...@bitart.com wrote: Did you try to set it ti nil instead of an empty string? Gerd On Oct 18, 2014, at 4:51 PM, Randy Widell randy.wid...@gmail.com wrote: It looks like a couple of people have asked about this in the past, but none of the answers are working for me. I am trying to clear the contents of a NSSearchField and have it go back to its empty state. I don’t have a pre-Yosemite Mac handy to check if this is a bug / new behavior in Yosemite, however Apple Mail seems to be able to do it just fine. Most of the solutions I have seen are old and center around doing things like: [[searchField.cell cancelButtonCell] performClick: self]; …or... searchField.stringValue = @“”; [searchField validateEditing]; Both of these methods do clear the NSSearchField’s string value, however the Cancel button remains visible and the search field does not go back to its empty state (magnifying glass centered, gray “Search” text placeholder, and Cancel button not visible). I have had some marginal success by modifying outlineViewSelectionDidChange: to set the search field’s stringValue to @“”, do what needs to be done to update the other views, set the search field to the first responder, and then set the outline view back to the first responder. That works somewhat, but not really. Half the time the search field remains the first responder as if the call to set the outline view as the first responder never happened. Any ideas? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/gerti-cocoadev%40bitart.com This email sent to gerti-cocoa...@bitart.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
Toolbar icons, yosemite
I’m learning about toolbar buttons/icons on Yosemite (probably not much different than before, but…I’m an iOS guy so its new for me). I have a few basic, 101-style questions that I hope somebody can point me to the right place for: 1. How do you do a popup menu button like the sidebar icon within Preview or other system apps? https://www.dropbox.com/s/37ec5us2f91j0k3/Screenshot%202014-10-18%2016.12.49.png?dl=0 2. Does anyone have a good set of assets either free or for purchase for non-system provided, but standard icons like the sidebar icon used in Preview and in other places throughout OS X? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Clear NSSearchField
On Sat, Oct 18, 2014, at 04:51 PM, Randy Widell wrote: That works somewhat, but not really. Half the time the search field remains the first responder as if the call to set the outline view as the first responder never happened. Have you tried forcing the text field to give up first responder via [textField.window makeFirstResponder:nil] ? --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: How does the Swift Darwin module work?
On 19 Oct 2014, at 5:23 am, Jean-Daniel Dupas mail...@xenonium.com wrote: AFAIK, variadic C functions are not (yet) callable from swift code. They aren’t - I didn’t remember fnctl() was varidadic. I shall quote an Apple engineer then .. This is not possible in Swift. C variadics are inherently unsafe, and not compatible with Swift variadics. You're encouraged to provide alternate versions of your collection-y variadics that take an array. Your format-y variadics (like this one?) can use Swift's String's variadic initializers ahead of time. So you get to go wrap fcntl() in something else it seems. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Clear NSSearchField
Yeah, that doesn’t work either. I’m clearing the search field in response to a change in selection in an outline view. Which means the search field is already not the first responder. So, setting the first responder to nil just makes the outline view give up first responder without affecting the search field. On Oct 18, 2014, at 15:19, Kyle Sluder k...@ksluder.com wrote: On Sat, Oct 18, 2014, at 04:51 PM, Randy Widell wrote: That works somewhat, but not really. Half the time the search field remains the first responder as if the call to set the outline view as the first responder never happened. Have you tried forcing the text field to give up first responder via [textField.window makeFirstResponder:nil] ? --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/randy.widell%40gmail.com This email sent to randy.wid...@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: Toolbar icons, yosemite
1) This is pretty easy. Just create a Pop Up Button, then switch its style to “Pull Down”. This will give you a push button with the single down arrow on the right. Then just edit the Pop Up Button’s menu. You can give it an icon, and then size it down horizontally so that only the icon is visible. 2) I was actually looking for this the other day. I found this site… http://flaticons.net/ http://flaticons.net/ The have some pretty good two-color, flat icons that you can use to make template images for toolbars. On Oct 18, 2014, at 15:12, Alex Kac a...@webis.net wrote: I’m learning about toolbar buttons/icons on Yosemite (probably not much different than before, but…I’m an iOS guy so its new for me). I have a few basic, 101-style questions that I hope somebody can point me to the right place for: 1. How do you do a popup menu button like the sidebar icon within Preview or other system apps? https://www.dropbox.com/s/37ec5us2f91j0k3/Screenshot%202014-10-18%2016.12.49.png?dl=0 2. Does anyone have a good set of assets either free or for purchase for non-system provided, but standard icons like the sidebar icon used in Preview and in other places throughout OS X? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/randy.widell%40gmail.com This email sent to randy.wid...@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: Toolbar icons, yosemite
On Oct 18, 2014, at 8:31 PM, Randy Widell randy.wid...@gmail.com wrote: 1) This is pretty easy. Just create a Pop Up Button, then switch its style to “Pull Down”. This will give you a push button with the single down arrow on the right. Then just edit the Pop Up Button’s menu. You can give it an icon, and then size it down horizontally so that only the icon is visible. 2) I was actually looking for this the other day. I found this site… http://flaticons.net/ http://flaticons.net/ The have some pretty good two-color, flat icons that you can use to make template images for toolbars. I second this site. It’s really useful for finding icons. Just be warned that some of them don’t look like Apple icons and may feel out of place, even with the new flat design style. On Oct 18, 2014, at 15:12, Alex Kac a...@webis.net wrote: I’m learning about toolbar buttons/icons on Yosemite (probably not much different than before, but…I’m an iOS guy so its new for me). I have a few basic, 101-style questions that I hope somebody can point me to the right place for: 1. How do you do a popup menu button like the sidebar icon within Preview or other system apps? https://www.dropbox.com/s/37ec5us2f91j0k3/Screenshot%202014-10-18%2016.12.49.png?dl=0 2. Does anyone have a good set of assets either free or for purchase for non-system provided, but standard icons like the sidebar icon used in Preview and in other places throughout OS X? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/randy.widell%40gmail.com This email sent to randy.wid...@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/sevenbitstech%40gmail.com This email sent to sevenbitst...@gmail.com signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Toolbar icons, yosemite
Sorry, forgot that giving the Pop Up Button an icon isn’t exactly straightforward. You want to create an menu item at the top of the menu that has the icon but no text. Then add the rest of your menu items below it. The Pop Up Button will display with the icon, but the first menu item will not display in the menu during run time. On Oct 18, 2014, at 17:31, Randy Widell randy.wid...@gmail.com wrote: 1) This is pretty easy. Just create a Pop Up Button, then switch its style to “Pull Down”. This will give you a push button with the single down arrow on the right. Then just edit the Pop Up Button’s menu. You can give it an icon, and then size it down horizontally so that only the icon is visible. 2) I was actually looking for this the other day. I found this site… http://flaticons.net/ http://flaticons.net/ The have some pretty good two-color, flat icons that you can use to make template images for toolbars. On Oct 18, 2014, at 15:12, Alex Kac a...@webis.net mailto:a...@webis.net wrote: I’m learning about toolbar buttons/icons on Yosemite (probably not much different than before, but…I’m an iOS guy so its new for me). I have a few basic, 101-style questions that I hope somebody can point me to the right place for: 1. How do you do a popup menu button like the sidebar icon within Preview or other system apps? https://www.dropbox.com/s/37ec5us2f91j0k3/Screenshot%202014-10-18%2016.12.49.png?dl=0 https://www.dropbox.com/s/37ec5us2f91j0k3/Screenshot%202014-10-18%2016.12.49.png?dl=0 2. Does anyone have a good set of assets either free or for purchase for non-system provided, but standard icons like the sidebar icon used in Preview and in other places throughout OS X? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/randy.widell%40gmail.com This email sent to randy.wid...@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: Toolbar icons, yosemite
I second this site. It’s really useful for finding icons. Just be warned that some of them don’t look like Apple icons and may feel out of place, even with the new flat design style. Agreed. They work well for the application I am working on, but, yeah, that might not be the case for him. I should have just posted this: http://mashable.com/2013/08/14/flat-design-icons/ http://mashable.com/2013/08/14/flat-design-icons/ Pretty much everything you could want there, including some Apple-native looking stuff. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: How does the Swift Darwin module work?
On Oct 18, 2014, at 16:40 , Roland King r...@rols.org wrote: On 19 Oct 2014, at 5:23 am, Jean-Daniel Dupas mail...@xenonium.com wrote: AFAIK, variadic C functions are not (yet) callable from swift code. They aren’t - I didn’t remember fnctl() was varidadic. I shall quote an Apple engineer then .. This is not possible in Swift. C variadics are inherently unsafe, and not compatible with Swift variadics. You're encouraged to provide alternate versions of your collection-y variadics that take an array. Your format-y variadics (like this one?) can use Swift's String's variadic initializers ahead of time. So you get to go wrap fcntl() in something else it seems. So, how would I do that, exactly? I suppose I have to pass Objective-C collection types to a method (which could be a straight C function) from a Swift call? That is, can a Swift variadic call translate into a C function call that accepts Obj-C collections? -- Rick Mann rm...@latencyzero.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: How does the Swift Darwin module work?
So you get to go wrap fcntl() in something else it seems. So, how would I do that, exactly? I suppose I have to pass Objective-C collection types to a method (which could be a straight C function) from a Swift call? That is, can a Swift variadic call translate into a C function call that accepts Obj-C collections? I don't think you need collections. fcntl's third argument varies according to the command. It is not always needed. Write a c file containing wrappers that can be called from swift for the various commands you need. I'm thinking something like this (untested). int fcntl_dupfd(int fildes, int arg) { return fcntl(fildes, F_DUPFD, arg); } int fcntl_getlk(int fildes, struct flock *arg) { return fcntl(fildes, F_GETLK, arg) } etc. Will that work? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: How does the Swift Darwin module work?
On 19 Oct 2014, at 9:03 am, Rick Mann rm...@latencyzero.com wrote: On Oct 18, 2014, at 16:40 , Roland King r...@rols.org wrote: On 19 Oct 2014, at 5:23 am, Jean-Daniel Dupas mail...@xenonium.com wrote: AFAIK, variadic C functions are not (yet) callable from swift code. They aren’t - I didn’t remember fnctl() was varidadic. I shall quote an Apple engineer then .. This is not possible in Swift. C variadics are inherently unsafe, and not compatible with Swift variadics. You're encouraged to provide alternate versions of your collection-y variadics that take an array. Your format-y variadics (like this one?) can use Swift's String's variadic initializers ahead of time. So you get to go wrap fcntl() in something else it seems. So, how would I do that, exactly? I suppose I have to pass Objective-C collection types to a method (which could be a straight C function) from a Swift call? That is, can a Swift variadic call translate into a C function call that accepts Obj-C collections? Write a simple c wrapper around the thing you’re trying to do and that bridges across to swift. You could probably try to write something really generic which wraps fcntl() using an UnsafeMutablePtrUInt8 as a final argument and then massaging stuff in Swift to poke it over and back, but that really would be a horror. You’re probably better off just shimming the actual operations you really actually need into a set of specialized c calls, each one should take 2-3 lines of code only for that. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: How does the Swift Darwin module work?
On Oct 18, 2014, at 18:22 , Roland King r...@rols.org wrote: Write a simple c wrapper around the thing you’re trying to do and that bridges across to swift. You could probably try to write something really generic which wraps fcntl() using an UnsafeMutablePtrUInt8 as a final argument and then massaging stuff in Swift to poke it over and back, but that really would be a horror. You’re probably better off just shimming the actual operations you really actually need into a set of specialized c calls, each one should take 2-3 lines of code only for that. That's what I ended up doing (setNonblocking(int inFileDescriptor)), but, I was asking for the sake of learning the language. It would be nice to have generic replacements for fcntl() and ioctl(). -- Rick Mann rm...@latencyzero.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: How does the Swift Darwin module work?
Wait, if variadic calls aren't supported, how is it that NSLog() can be called? On Oct 18, 2014, at 18:22 , Roland King r...@rols.org wrote: On 19 Oct 2014, at 9:03 am, Rick Mann rm...@latencyzero.com wrote: On Oct 18, 2014, at 16:40 , Roland King r...@rols.org wrote: On 19 Oct 2014, at 5:23 am, Jean-Daniel Dupas mail...@xenonium.com wrote: AFAIK, variadic C functions are not (yet) callable from swift code. They aren’t - I didn’t remember fnctl() was varidadic. I shall quote an Apple engineer then .. This is not possible in Swift. C variadics are inherently unsafe, and not compatible with Swift variadics. You're encouraged to provide alternate versions of your collection-y variadics that take an array. Your format-y variadics (like this one?) can use Swift's String's variadic initializers ahead of time. So you get to go wrap fcntl() in something else it seems. So, how would I do that, exactly? I suppose I have to pass Objective-C collection types to a method (which could be a straight C function) from a Swift call? That is, can a Swift variadic call translate into a C function call that accepts Obj-C collections? Write a simple c wrapper around the thing you’re trying to do and that bridges across to swift. You could probably try to write something really generic which wraps fcntl() using an UnsafeMutablePtrUInt8 as a final argument and then massaging stuff in Swift to poke it over and back, but that really would be a horror. You’re probably better off just shimming the actual operations you really actually need into a set of specialized c calls, each one should take 2-3 lines of code only for that. -- Rick Mann rm...@latencyzero.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: How does the Swift Darwin module work?
On Oct 18, 2014, at 19:17 , Roland King r...@rols.org wrote: On 19 Oct 2014, at 10:11 am, Rick Mann rm...@latencyzero.com wrote: Wait, if variadic calls aren't supported, how is it that NSLog() can be called? Probably has a version which takes a va_list. type import Swift at the top of your swift file then Cmd Click on ‘Swift’ and you’ll find all sorts of interesting stuff. In this case see CVarArgType and friends. s Ah, interesting. Makes sense. Yeah, pity fcntl() and friends don't have va_list versions. -- Rick Mann rm...@latencyzero.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: How does the Swift Darwin module work?
That's what I ended up doing (setNonblocking(int inFileDescriptor)), but, I was asking for the sake of learning the language. It would be nice to have generic replacements for fcntl() and ioctl(). The best replacement would be to have a set of functions which took the Swiss Army knife which is fcntl() and split it up from fcntl( filedes, cmd, … ) into a series of fnctl_cmd( filedes, typed_argument ) much as Marco suggested. Then you have something which does import nicely into Swift and is typesafe, even the structures are then properly bridged across for you. Something totally generic would be a c wrapper like this (and I haven’t tested it, just for the sake of discussion) int fcntl_wrap( int filedes, int cmd, void *arg ) { return fcntl( filedes, cmd, arg ); } which bridges into Swift as func fcntl_wrap(filedes: Int32, cmd: Int32, arg: UnsafeMutablePointerVoid) - Int32 You can manipulate that final arg in many very un-typesafe ways to get what you want. If there’s no argument, pass nil, that’s easy. In the case of the F_GETPATH create yourself a buffer of Char or UInt8 or whatever chars are called these days and cast that backwards and forwards. But see how vile this is, how about F_RDAHEAD, the man page for that says Turn read ahead off/on. A zero value in arg disables read ahead. A non-zero value in arg turns read ahead on. that doesn’t actually tell you what ‘arg’ is. Is it a byte, an int, a long, bool .. what? It’s probably an int, but you don’t really know and it’s important, if the function just reads one byte of arg that’s the one needs to be non-zero. So now you have to create a thing which looks like an int but is an UnsafeMutablePointerVoid so it can be passed into the function let really_dangerous_variable : UnsafeMutablePointerVoid = UnsafeMutablePointer( bitPattern:1 ) So that’s how you could do it if you really wanted to, doing so probably means you have a crash in your future. Marco’s idea of separating out into separate functions per-command and stubbing each into C is a cleaner way of getting something which bridges back into Swift vaguely nicely, and it’s not that much work either, and you can add functions as you need them to a module you write. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Subclassing NSWindowController in Swift
In Obj-C, I typically subclass NSWindowController and override -init to call -initWithNibName:. I do this so the caller doesn't have to worry about how to make one of these window controllers: @implementation MyWindowController - (id) init { self = [super initWithWindowNibName: MyWindow owner: self] ... return self; } I can't figure out how to do the same in Swift. NSWindowController makes initWithWindow() the only designated initializer, which I must call, which makes it seem like I can't use any of the convenience methods. Apple's own guidance on designated inititalizers is that they should be the ones that take the most parameters. So, I can load the nib myself, and make the window, and pass that up, but this seems broken. Is it? -- Rick Mann rm...@latencyzero.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
bundleForClass in Swift
In an NSWindowController subclass init method, I want to call -loadNibNamed:owner:topLevelObjects, but that requires I have a bundle. I can get the main bundle, but I'd rather get the bundle for this class (makes it useable in unit tests). But, inside an init method, I'm not allowed to reference self until super.init is called. So, how do I do this? -- Rick Mann rm...@latencyzero.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: Subclassing NSWindowController in Swift
Hi Rick, According to the latest documentation pack that arrived on Thursday, Swift has: convenience init(windowNibName windowNibName: String, owner owner: AnyObject) So just use this. Like C++, Swift has overloaded method names, so 'init' can take various parameter combinations. Also, in general I think what you're saying about designated initializers is incorrect - the designated initializer MUST be called, but not necessarily by you. All it means is that the other init... methods must call it. The guideline about it being the one with the most parameters is not a rule - typically that's true but it's not a requirement and for many classes, definitely not true. --Graham On 19 Oct 2014, at 2:08 pm, Rick Mann rm...@latencyzero.com wrote: In Obj-C, I typically subclass NSWindowController and override -init to call -initWithNibName:. I do this so the caller doesn't have to worry about how to make one of these window controllers: @implementation MyWindowController - (id) init { self = [super initWithWindowNibName: MyWindow owner: self] ... return self; } I can't figure out how to do the same in Swift. NSWindowController makes initWithWindow() the only designated initializer, which I must call, which makes it seem like I can't use any of the convenience methods. Apple's own guidance on designated inititalizers is that they should be the ones that take the most parameters. So, I can load the nib myself, and make the window, and pass that up, but this seems broken. Is it? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: bundleForClass in Swift
I realize, in this case, I should be loading in loadWindow(), but it still seems problematic. On Oct 18, 2014, at 20:25 , Rick Mann rm...@latencyzero.com wrote: In an NSWindowController subclass init method, I want to call -loadNibNamed:owner:topLevelObjects, but that requires I have a bundle. I can get the main bundle, but I'd rather get the bundle for this class (makes it useable in unit tests). But, inside an init method, I'm not allowed to reference self until super.init is called. So, how do I do this? -- Rick Mann rm...@latencyzero.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/rmann%40latencyzero.com This email sent to rm...@latencyzero.com -- Rick Mann rm...@latencyzero.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: bundleForClass in Swift
On 19 Oct 2014, at 2:25 pm, Rick Mann rm...@latencyzero.com wrote: In an NSWindowController subclass init method, I want to call -loadNibNamed:owner:topLevelObjects, but that requires I have a bundle. I can get the main bundle, but I'd rather get the bundle for this class (makes it useable in unit tests). But, inside an init method, I'm not allowed to reference self until super.init is called. So, how do I do this? I think my other reply will make this a moot point, but since [NSBundle bundleForClass:] takes a Class, and you know what your class is, just pass it that, you don't have to reference self. [NSBundle bundleForClass:[MyGroovySubclass class]]; --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: Subclassing NSWindowController in Swift
On Oct 18, 2014, at 20:33 , Graham Cox graham@bigpond.com wrote: According to the latest documentation pack that arrived on Thursday, Swift has: convenience init(windowNibName windowNibName: String, owner owner: AnyObject) So just use this. Like C++, Swift has overloaded method names, so 'init' can take various parameter combinations. I tried this: 16 override 17 init() 18 { 19 init(windowNibName: foo, owner: self); 20 } 21 But I get: /Users/rmann/Projects/XCAM/repo/XNC/trunk/XNC/CommConfig.swift:19:7: Initializers may only be declared within a type /Users/rmann/Projects/XCAM/repo/XNC/trunk/XNC/CommConfig.swift:19:23: Expected parameter type following ':' /Users/rmann/Projects/XCAM/repo/XNC/trunk/XNC/CommConfig.swift:19:23: Expected ',' separator /Users/rmann/Projects/XCAM/repo/XNC/trunk/XNC/CommConfig.swift:21:1: 'required' initializer 'init(coder:)' must be provided by subclass of 'NSWindowController' If I instead call super.init(...), I get: /Users/rmann/Projects/XCAM/repo/XNC/trunk/XNC/CommConfig.swift:19:3: Must call a designated initializer of the superclass 'NSWindowController' Also, in general I think what you're saying about designated initializers is incorrect - the designated initializer MUST be called, but not necessarily by you. All it means is that the other init... methods must call it. The guideline about it being the one with the most parameters is not a rule - typically that's true but it's not a requirement and for many classes, definitely not true. In this case, it might've solved the problem (except that I can't refer to self yet). --Graham On 19 Oct 2014, at 2:08 pm, Rick Mann rm...@latencyzero.com wrote: In Obj-C, I typically subclass NSWindowController and override -init to call -initWithNibName:. I do this so the caller doesn't have to worry about how to make one of these window controllers: @implementation MyWindowController - (id) init { self = [super initWithWindowNibName: MyWindow owner: self] ... return self; } I can't figure out how to do the same in Swift. NSWindowController makes initWithWindow() the only designated initializer, which I must call, which makes it seem like I can't use any of the convenience methods. Apple's own guidance on designated inititalizers is that they should be the ones that take the most parameters. So, I can load the nib myself, and make the window, and pass that up, but this seems broken. Is it? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/rmann%40latencyzero.com This email sent to rm...@latencyzero.com -- Rick Mann rm...@latencyzero.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: bundleForClass in Swift
On Oct 18, 2014, at 20:36 , Graham Cox graham@bigpond.com wrote: On 19 Oct 2014, at 2:25 pm, Rick Mann rm...@latencyzero.com wrote: In an NSWindowController subclass init method, I want to call -loadNibNamed:owner:topLevelObjects, but that requires I have a bundle. I can get the main bundle, but I'd rather get the bundle for this class (makes it useable in unit tests). But, inside an init method, I'm not allowed to reference self until super.init is called. So, how do I do this? I think my other reply will make this a moot point, but since [NSBundle bundleForClass:] takes a Class, and you know what your class is, just pass it that, you don't have to reference self. [NSBundle bundleForClass:[MyGroovySubclass class]]; Sorry, I was conflating Obj-C and Swift syntax. I'm trying to do this all in swift, in which case it's: NSBundle(forClass: self.dynamicType) But you can't call this in an initializer before calling super init. -- Rick Mann rm...@latencyzero.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: bundleForClass in Swift
On 19 Oct 2014, at 2:43 pm, Rick Mann rm...@latencyzero.com wrote: Sorry, I was conflating Obj-C and Swift syntax. I'm trying to do this all in swift, in which case it's: NSBundle(forClass: self.dynamicType) But you can't call this in an initializer before calling super init. Well, I'm not working in Swift so it may not have parity with Obj-C in some ways that I haven't understood, but isn't there a way to just name the class, rather than asking self what it is? Also, there's no rule about executing code before calling super init, as long as it does not rely on the state of the object being inited. You can certainly call into NSBundle at that time, just not using [self class] (or its Swift equivalent) but [MyClass class] (or its Swift equivalent). --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: bundleForClass in Swift
On Oct 18, 2014, at 20:47 , Graham Cox graham@bigpond.com wrote: On 19 Oct 2014, at 2:43 pm, Rick Mann rm...@latencyzero.com wrote: Sorry, I was conflating Obj-C and Swift syntax. I'm trying to do this all in swift, in which case it's: NSBundle(forClass: self.dynamicType) But you can't call this in an initializer before calling super init. Well, I'm not working in Swift so it may not have parity with Obj-C in some ways that I haven't understood, but isn't there a way to just name the class, rather than asking self what it is? Also, there's no rule about executing code before calling super init, as long as it does not rely on the state of the object being inited. You can certainly call into NSBundle at that time, just not using [self class] (or its Swift equivalent) but [MyClass class] (or its Swift equivalent). You're probably right about that, but in this case, you wouldn't be able to pass self for owner: -- Rick Mann rm...@latencyzero.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
NSComboBox in the tab ring
Is it possible to keep an NSComboBox in the tabbing ring if I set its Behavior to Selectable. Tabbing reaches the control if the textfield is editable but I don't want to allow the user to type randomly into the text field ... but unfortunately, once I remove its editability, the tabbing cycle skips the control. I'm just doing this in Xcode's IB but programmatically, I think it invokes something like [NSCell setEditable:NO] and [NSCell setSelectable:YES]. Thanks, -Luther ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: DOMDocument in 10.10
On 19 Oct 2014, at 00:52, Jens Alfke j...@mooseyard.com wrote: On Oct 18, 2014, at 5:33 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: Note: the head has only 12 children (the first 10 are identical to 10.9), and there is no body at all. Weird! Are you sure that the page has finished loading by the time you made the call? Maybe your code is running at a point when only the head part of the document has yet been loaded. Excellent idea indeed. Old way (does NOT work on 10.10, works on all OS X before 10): NSString *ss = ... some html ... WebFrame *mainFrame = [ self.webView mainFrame ]; [ mainFrame loadHTMLString: ss baseURL: nil ]; [ self performSelector: @selector(parsData) withObject: nil afterDelay: 0 ]; This performSelector:afterDelay: was used exactly for the reason you mentioned. I changed the delay from 0 to 10 seconds - and it works perfectly on 10.10. But of course this is a very silly hack. So, finally I changed the code so that parsData is called from webView:didFinishLoadForFrame: Thanks for pointing me in the right direction! Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: bundleForClass in Swift
On 19 Oct 2014, at 2:54 pm, Rick Mann rm...@latencyzero.com wrote: You're probably right about that, but in this case, you wouldn't be able to pass self for owner: True, but since Swift has the other form of init anyway, you don't have to do this yourself... --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