Calling fcntl() and friends from Swift?

2014-10-18 Thread Rick Mann
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

Re: Table of TextViews

2014-10-18 Thread Ken Thomases
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

Re: Calling fcntl() and friends from Swift?

2014-10-18 Thread Roland King
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

DOMDocument in 10.10

2014-10-18 Thread Gerriet M. Denkmann
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

Document style programming

2014-10-18 Thread Luther Baker
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

Re: Document style programming

2014-10-18 Thread Mike Abdullah
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 -

Saving a Document style app

2014-10-18 Thread Luther Baker
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

Re: Document style programming

2014-10-18 Thread Luther Baker
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

Re: Saving a Document style app

2014-10-18 Thread Mike Abdullah
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

Re: Document style programming

2014-10-18 Thread Mike Abdullah
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

One more Document app style question

2014-10-18 Thread Luther Baker
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

Re: Saving a Document style app

2014-10-18 Thread Luther Baker
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.

Re: Document style programming

2014-10-18 Thread Luther Baker
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

Re: Passing a swift function to objective-c

2014-10-18 Thread Kevin Meaney
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

Re: Document style programming

2014-10-18 Thread Mike Abdullah
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

Re: Passing a swift function to objective-c

2014-10-18 Thread Kevin Meaney
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:

Re: DOMDocument in 10.10

2014-10-18 Thread Jens Alfke
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

How does the Swift Darwin module work?

2014-10-18 Thread Rick Mann
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

Set UICollectionView UIScrollViewDelegate delegate

2014-10-18 Thread Mazzaroth M.
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.

Re: How does the Swift Darwin module work?

2014-10-18 Thread Jean-Daniel Dupas
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

Re: Set UICollectionView UIScrollViewDelegate delegate

2014-10-18 Thread Kyle Sluder
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

Clear NSSearchField

2014-10-18 Thread Randy Widell
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

Re: Clear NSSearchField

2014-10-18 Thread Randy Widell
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

Toolbar icons, yosemite

2014-10-18 Thread Alex Kac
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

Re: Clear NSSearchField

2014-10-18 Thread Kyle Sluder
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

Re: How does the Swift Darwin module work?

2014-10-18 Thread Roland King
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

Re: Clear NSSearchField

2014-10-18 Thread Randy Widell
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

Re: Toolbar icons, yosemite

2014-10-18 Thread Randy Widell
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

Re: Toolbar icons, yosemite

2014-10-18 Thread SevenBits
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

Re: Toolbar icons, yosemite

2014-10-18 Thread Randy Widell
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

Re: Toolbar icons, yosemite

2014-10-18 Thread Randy Widell
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

Re: How does the Swift Darwin module work?

2014-10-18 Thread Rick Mann
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

Re: How does the Swift Darwin module work?

2014-10-18 Thread Marco S Hyman
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

Re: How does the Swift Darwin module work?

2014-10-18 Thread Roland King
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

Re: How does the Swift Darwin module work?

2014-10-18 Thread Rick Mann
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

Re: How does the Swift Darwin module work?

2014-10-18 Thread Rick Mann
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

Re: How does the Swift Darwin module work?

2014-10-18 Thread Rick Mann
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

Re: How does the Swift Darwin module work?

2014-10-18 Thread Roland King
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

Subclassing NSWindowController in Swift

2014-10-18 Thread Rick Mann
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

bundleForClass in Swift

2014-10-18 Thread Rick Mann
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

Re: Subclassing NSWindowController in Swift

2014-10-18 Thread Graham Cox
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.

Re: bundleForClass in Swift

2014-10-18 Thread Rick Mann
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

Re: bundleForClass in Swift

2014-10-18 Thread Graham Cox
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

Re: Subclassing NSWindowController in Swift

2014-10-18 Thread Rick Mann
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

Re: bundleForClass in Swift

2014-10-18 Thread Rick Mann
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

Re: bundleForClass in Swift

2014-10-18 Thread Graham Cox
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.

Re: bundleForClass in Swift

2014-10-18 Thread Rick Mann
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)

NSComboBox in the tab ring

2014-10-18 Thread Luther Baker
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

Re: DOMDocument in 10.10

2014-10-18 Thread Gerriet M. Denkmann
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

Re: bundleForClass in Swift

2014-10-18 Thread Graham Cox
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