Bridging CFArrayRef and NSArray

2015-06-29 Thread Dave
Hi, Is the following ok for getting a CFArrayRef and retaining it until dealloc time? Whenever refreshGlobalWindowArray is called I want the existing copy to be released and the new value to be retained. This is a Mac Project using manual memory management. All the Best Dave @property

File Permissions - NSFileManager Swift

2015-06-29 Thread Arved von Brasch
Dear Cocoa List, I’m trying to remove an application package using NSFileManager.defaultManager().removeItemAtPath(self.appPackage, error: error) The application package was put at this location using NSFileManager.defaultManager().copyItemAtURL(pathURL as! NSURL, toURL: self.appPackage,

Subclassing a Subclass of SBApplication

2015-06-29 Thread Dave
Hi, I’m using the Scripting Bridge, and I was wondering if it ok to subclass SBXXX classes. Basically, I have a header file generated by the “sdp” tool with definitions as below: And I’d like to subclass this to add some extra wrapping to hide some of the nastiness from the rest of the app

re Swift 2.0

2015-06-29 Thread Michael de Haan 
var currentValue = 1 let newNewGenerator = anyGenerator { ()-Int? in let previousValue = currentValue currentValue *= 2 return ( previousValue 20 ) ? nil : previousValue } let newGeneratedArray = Array( newNewGenerator ) For some reason you have to specify

Re: Cheating a synchronous call on the main thread

2015-06-29 Thread Jens Alfke
On Jun 29, 2015, at 9:14 AM, Gavin Eadie ga...@umich.edu wrote: Can anyone, with more knowledge than we have, suggest a trick that allows an apparently synchronous call on the main thread without impacting performance? Not without some nasty hacks that I wouldn’t recommend. The simplest

Re: NSUserDefaults allocation size and CALayer memory usage

2015-06-29 Thread Jens Alfke
On Jun 28, 2015, at 11:35 PM, Henrik Granaas-Helmers helm...@me.com wrote: 1. NSUserDefaults seems to allocate 16 MB memory at load. I can't see myself using a megabyte—let alone 16 of those. It would be very interesting to know why it allocates so much, and if there is a way to encourage

Re: NSUserDefaults allocation size and CALayer memory usage

2015-06-29 Thread David Duncan
On Jun 28, 2015, at 11:35 PM, Henrik Granaas-Helmers helm...@me.com wrote: Hi there, I am new to Apple development, and new to this list. I have two questions about memory on OS X. 1. NSUserDefaults seems to allocate 16 MB memory at load. I can't see myself using a megabyte—let

Cheating a synchronous call on the main thread

2015-06-29 Thread Gavin Eadie
It’s standard knowledge that any operation which causes an app’s main thread to wait is bad, and that diverting such delays off the main thread allows the app to remain optimally responsive to external events. That diversion can happen via a couple of mechanisms: ‘callbacks’ (delegation and

Re: Open program from custom schema link

2015-06-29 Thread Jens Alfke
On Jun 28, 2015, at 9:59 PM, Juanjo Conti jjco...@carouselapps.com wrote: Is it is suppose to call MyApp with something as argument? How do I read something from the run app? Your app delegate will be called and given the URL, although it’s been a long time since I implemented this

Re: Cheating a synchronous call on the main thread

2015-06-29 Thread Scott Ribe
On Jun 29, 2015, at 10:14 AM, Gavin Eadie ga...@umich.edu wrote: While it seems clear to me and my friend that this in an inescapable fact of life, we have a counterexample in the form of the Canon ED-SDK, which somehow does accomplish this. I seriously doubt that. It's probably performing

Re: Cheating a synchronous call on the main thread

2015-06-29 Thread Michael David Crawford
Use a background task to do the real work then deliver the result on a queue. mUseba synchronous call to fetch the result from the queue or return an error result if the queue is empty. -- Michael David Crawford, Consulting Software Engineer mdcrawf...@gmail.com http://www.warplife.com/mdc/

Re: File Permissions - NSFileManager Swift

2015-06-29 Thread Jens Alfke
It always helps people answer questions if you post the exact error you get. Generally when there are mysteriously un-deletable files, it has something to do with filesystem extended attributes like ‘immutable’. You can display these by using “ls -l@“. —Jens

Re: Open program from custom schema link

2015-06-29 Thread Juanjo Conti
Found it Jens: func applicationWillFinishLaunching(aNotification: NSNotification?) { var appleEventManager:NSAppleEventManager = NSAppleEventManager.sharedAppleEventManager() appleEventManager.setEventHandler(self, andSelector: handleGetURLEvent:withReplyEvent:, forEventClass:

Re: Cheating a synchronous call on the main thread

2015-06-29 Thread Jens Alfke
On Jun 29, 2015, at 10:13 AM, Gavin Eadie ga...@umich.edu wrote: The problem with the callback to “after” is that “after” is just the continuation of the program and possibly nothing to do with what happens in “fakeSyncrony” .. Yeah, I don’t think you have any alternative but to

Re: Cheating a synchronous call on the main thread

2015-06-29 Thread Gavin Eadie
On Jun 29, 2015, at 12:28 PM, Scott Ribe scott_r...@elevated-dev.com wrote: […] we have a counterexample in the form of the Canon ED-SDK, which somehow does accomplish this. I seriously doubt that. It's probably performing the work on a background thread, then using some callback to

Re: Cheating a synchronous call on the main thread

2015-06-29 Thread Quincey Morris
On Jun 29, 2015, at 10:13 , Gavin Eadie ga...@umich.edu wrote: I suppose the first thing “fakeSyncrony” could do is grab the address of the next instruction and make it the address to call back to. This sounds a little like Jens’ “crazy runtime manipulation of the stack The mechanism you

Re: Cheating a synchronous call on the main thread

2015-06-29 Thread Scott Ribe
On Jun 29, 2015, at 11:13 AM, Gavin Eadie ga...@umich.edu wrote: The problem with the callback to “after” is that “after” is just the continuation of the program and possibly nothing to do with what happens in “fakeSyncrony” .. Then why does it need to wait? This is really sounding like

Re: Simple Swift question

2015-06-29 Thread Charles Srstka
On Jun 29, 2015, at 5:53 PM, Rick Mann rm...@latencyzero.com wrote: If you are using Swift 2.0, you can use the new `guard let` to get optional checking without the cascade of indentation. guard let url = NSURL(string: some url) else { /* handle failure and either halt or return */ }

Re: Cheating a synchronous call on the main thread

2015-06-29 Thread Gavin Eadie
On Jun 29, 2015, at 1:19 PM, Scott Ribe scott_r...@elevated-dev.com wrote: The problem with the callback to “after” is that “after” is just the continuation of the program and possibly nothing to do with what happens in “fakeSyncrony” .. Then why does it need to wait? This is really

Re: Cheating a synchronous call on the main thread

2015-06-29 Thread Scott Ribe
On Jun 29, 2015, at 12:22 PM, Gavin Eadie ga...@umich.edu wrote: Q: “Can anyone suggest a trick that allows an apparently synchronous call on the main thread without impacting performance?” The problem is that the requirement is self-contradictory: synchronous means wait, and without

Re: Cheating a synchronous call on the main thread

2015-06-29 Thread Quincey Morris
On Jun 29, 2015, at 13:50 , Gavin Eadie ga...@umich.edu wrote: The main thread is not involved in the above, but the idea of an “asynchronous-that-waits” == “apparently synchronous” call is demonstrated. Yes, but you achieved that by blocking a background thread. It works because you don’t

Re: Simple Swift question

2015-06-29 Thread Quincey Morris
On Jun 29, 2015, at 15:23 , Rick Mann rm...@latencyzero.com wrote: Oh, I think I figured it out. NSURL(string:) is optional, but NSURLRequest(URL:) can't. Very unexpected, and the error message I was getting did not clue me in. - How are you supposed to do simple things like

Re: Simple Swift question

2015-06-29 Thread Rick Mann
On Jun 29, 2015, at 15:43 , Greg Parker gpar...@apple.com wrote: On Jun 29, 2015, at 3:18 PM, Rick Mann rm...@latencyzero.com wrote: How are you supposed to do simple things like this, succinctly? let url = NSURL(string: some url) let req = NSURLRequest(URL: url)

Re: Cheating a synchronous call on the main thread

2015-06-29 Thread Gavin Eadie
Somewhere in this email a lightbulb gets turned on! On Jun 29, 2015, at 2:49 PM, Scott Ribe scott_r...@elevated-dev.com wrote: The problem is that the requirement is self-contradictory: synchronous means wait, and without impacting performance means don't wait. While the real requirement

Re: Simple Swift question

2015-06-29 Thread Jens Alfke
On Jun 29, 2015, at 3:23 PM, Rick Mann rm...@latencyzero.com wrote: Oh, I think I figured it out. NSURL(string:) is optional, but NSURLRequest(URL:) can't. Very unexpected Creating an NSURL from a string can fail, since not all strings are valid URLs. But creating an NSURLRequest isn’t

Re: Simple Swift question

2015-06-29 Thread Greg Parker
On Jun 29, 2015, at 3:18 PM, Rick Mann rm...@latencyzero.com wrote: How are you supposed to do simple things like this, succinctly? let url = NSURL(string: some url) let req = NSURLRequest(URL: url) self.webView.loadRequest(req) This, obviously, doesn't work, since the

Simple Swift question

2015-06-29 Thread Rick Mann
Oh, I think I figured it out. NSURL(string:) is optional, but NSURLRequest(URL:) can't. Very unexpected, and the error message I was getting did not clue me in. - How are you supposed to do simple things like this, succinctly? let url = NSURL(string: some url) let req =

Re: Swift and parameter names

2015-06-29 Thread Greg Parker
On Jun 29, 2015, at 3:42 PM, Rick Mann rm...@latencyzero.com wrote: Here's an example (and this is what I frequently encounter) where requiring parameter names adds nothing but clutter: let config = WKWebViewConfiguration() self.webView = WKWebView(frame:

Simple Swift question

2015-06-29 Thread Rick Mann
How are you supposed to do simple things like this, succinctly? let url = NSURL(string: some url) let req = NSURLRequest(URL: url) self.webView.loadRequest(req) This, obviously, doesn't work, since the results are optionals, and so need to be unwrapped. But it gets rapidly

Re: Simple Swift question

2015-06-29 Thread Charles Srstka
On Jun 29, 2015, at 5:18 PM, Rick Mann rm...@latencyzero.com wrote: But it gets rapidly ridiculous with a bunch of nested if-lets (imagine you had more than just two operations to get from here to there). Have you looked at Swift 2.0 yet? It addresses that forced Arrow Anti-Pattern issue

Re: Simple Swift question

2015-06-29 Thread Rick Mann
On Jun 29, 2015, at 15:36 , Charles Srstka cocoa...@charlessoft.com wrote: On Jun 29, 2015, at 5:18 PM, Rick Mann rm...@latencyzero.com wrote: But it gets rapidly ridiculous with a bunch of nested if-lets (imagine you had more than just two operations to get from here to there). Have

Re: Swift and parameter names

2015-06-29 Thread Rick Mann
On Jun 29, 2015, at 15:50 , Greg Parker gpar...@apple.com wrote: Perhaps you would prefer a different whitespace convention, one with no spaces around the colon in actual parameters. That's a popular convention in Objective-C. Otherwise there is no difference between Objective-C and Swift

Re: Simple Swift question

2015-06-29 Thread Rick Mann
On Jun 29, 2015, at 15:35 , Jens Alfke j...@mooseyard.com wrote: The unsightly nesting of the if-lets can be avoided with the nifty new ‘guard’ statement in Swift 2. Ah, yes, that's what I should be using. Thanks! -- Rick Mann rm...@latencyzero.com

Re: Swift and parameter names

2015-06-29 Thread Rick Mann
Here's an example (and this is what I frequently encounter) where requiring parameter names adds nothing but clutter: let config = WKWebViewConfiguration() self.webView = WKWebView(frame: self.webViewContainer.frame, configuration: config); If Code Completion worked 100% of the time,

Re: Cheating a synchronous call on the main thread

2015-06-29 Thread Scott Ribe
On Jun 29, 2015, at 2:50 PM, Gavin Eadie ga...@umich.edu wrote: The main thread is not involved in the above, but the idea of an “asynchronous-that-waits” == “apparently synchronous” call is demonstrated. That's simply not asynchronous. -- Scott Ribe scott_r...@elevated-dev.com

Re: Cheating a synchronous call on the main thread

2015-06-29 Thread Jens Alfke
On Jun 29, 2015, at 1:50 PM, Gavin Eadie ga...@umich.edu wrote: This is all true for a “really synchronous” call, but my suggestion is that an “apparently synchronous” call only appears to wait; using a semaphore can stop the return, while things keep working on other threads. I don’t

NSUserDefaults allocation size and CALayer memory usage

2015-06-29 Thread Henrik Granaas-Helmers
Hi there, I am new to Apple development, and new to this list. I have two questions about memory on OS X. 1. NSUserDefaults seems to allocate 16 MB memory at load. I can't see myself using a megabyte—let alone 16 of those. It would be very interesting to know why it allocates so much, and if

Swift 2.0 difficulty

2015-06-29 Thread Michael de Haan 
Hi All I am looking at Swift 2.0. The compiler has converted the code below to the “latest” Swift syntax. This causes the error shown. I have spent a few days trying to get this to compile. What is confusing to me, is that the code, listed last (func removeAnElemen…..) does compile ( all in

Re: NSUserDefaults allocation size and CALayer memory usage

2015-06-29 Thread Quincey Morris
On Jun 28, 2015, at 23:35 , Henrik Granaas-Helmers helm...@me.com wrote: 1. NSUserDefaults seems to allocate 16 MB memory at load. I can't see myself using a megabyte—let alone 16 of those. It would be very interesting to know why it allocates so much, and if there is a way to encourage

Re: Swift 2.0 difficulty

2015-06-29 Thread Roland King
On 29 Jun 2015, at 14:37, Michael de Haan  m...@comcast.net wrote: Hi All I am looking at Swift 2.0. The compiler has converted the code below to the “latest” Swift syntax. This causes the error shown. I have spent a few days trying to get this to compile. What is confusing to me, is

Re: Swift and parameter names

2015-06-29 Thread Rick Mann
On Jun 29, 2015, at 16:06 , Quincey Morris quinceymor...@rivergatesoftware.com wrote: Please stop Nice. -- Rick Mann rm...@latencyzero.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or

Re: Simple Swift question

2015-06-29 Thread Rick Mann
On Jun 29, 2015, at 16:30 , Jens Alfke j...@mooseyard.com wrote: On Jun 29, 2015, at 4:23 PM, Rick Mann rm...@latencyzero.com wrote: http://pastebin.com/Q7sBWBnN url is unwrapped already, and I'm (wrongly) trying to unwrap the NSURLRequest. But it's not complaining about the

Re: Swift and parameter names

2015-06-29 Thread Quincey Morris
On Jun 29, 2015, at 15:42 , Rick Mann rm...@latencyzero.com wrote: Here's an example (and this is what I frequently encounter) where requiring parameter names adds nothing but clutter: let config = WKWebViewConfiguration() self.webView = WKWebView(frame: self.webViewContainer.frame,

Re: Simple Swift question

2015-06-29 Thread Rick Mann
On Jun 29, 2015, at 16:30 , Jens Alfke j...@mooseyard.com wrote: The error I get with Xcode 7 beta 2 is error: operand of postfix '?' should have optional type; type is 'NSURLRequest' if let req = NSURLRequest(URL: url)? ~~^ So it looks like

Re: Simple Swift question

2015-06-29 Thread Roland King
On 30 Jun 2015, at 09:35, Rick Mann rm...@latencyzero.com wrote: On Jun 29, 2015, at 16:30 , Jens Alfke j...@mooseyard.com wrote: The error I get with Xcode 7 beta 2 is error: operand of postfix '?' should have optional type; type is 'NSURLRequest' if let req = NSURLRequest(URL:

Re: Simple Swift question

2015-06-29 Thread Rick Mann
On Jun 29, 2015, at 16:17 , Jens Alfke j...@mooseyard.com wrote: On Jun 29, 2015, at 3:53 PM, Rick Mann rm...@latencyzero.com wrote: The compiler's message was, Could not find an overload for 'init' that accepts the supplied arguments. Could it instead say NSURLRequst.init(URL:) does

Re: Simple Swift question

2015-06-29 Thread Jens Alfke
On Jun 29, 2015, at 4:23 PM, Rick Mann rm...@latencyzero.com wrote: http://pastebin.com/Q7sBWBnN http://pastebin.com/Q7sBWBnN url is unwrapped already, and I'm (wrongly) trying to unwrap the NSURLRequest. But it's not complaining about the arguments to NSURLRequest.init(URL:).

Re: Why would scroll events not arrive?

2015-06-29 Thread Martin Wierschin
After further investigation, I've discovered what code is responsible for globally breaking scrolling my app. I have an NSScrollView subclass with the following override: - (void) scrollWheel:(NSEvent*)event { BOOL isScrollEnclosing = // YES if the receiver has scrolled to its very