Re: Fast NSArray compare

2014-04-14 Thread Quincey Morris
On Apr 14, 2014, at 21:10 , Varun Chandramohan wrote: > I was thinking what if I want to keep this persistent? This doesn’t sound like such a good idea. There’s nothing to guarantee that your saved data will actually match the state of the file system the next time you read it back. In partic

Re: Fast NSArray compare

2014-04-14 Thread Varun Chandramohan
Thanks Guys, Yes I was not planning to use -[NSURL isEqual:]. Interestingly, Graham¹s suggestion was to use NSSet, I was thinking what if I want to keep this persistent? I would be writing this set to a file? I have used NSArray writeToFile before but I don¹t see that method for NSSet. Do I have t

Re: Fast NSArray compare

2014-04-14 Thread Graham Cox
On 15 Apr 2014, at 12:03 pm, John Brownie wrote: > think you're an order of magnitude out. Searching an array is linear with > the length of the array, O(n), whereas a set or hash should be close to > constant, O(1), if there's not a big collision in the hashes. But the > principle is correc

Re: Fast NSArray compare

2014-04-14 Thread John Brownie
Graham Cox wrote: As a general principle, if you have to check whether one of a list of things is part of another list of things, an array is the wrong container for the job, because it amounts to a worst-case O(n^2) search. Instead, use a set or hash table for the set of things that must be d

Re: Fast NSArray compare

2014-04-14 Thread Ken Thomases
On Apr 14, 2014, at 7:02 PM, Varun Chandramohan wrote: > I have a question about efficiency when trying to compare NSURL. The > requirement is quite simple. I try and iterate through a directory to all > subdirectories and files. While doing this walk-through, I need to check > against an array

Re: Fast NSArray compare

2014-04-14 Thread Graham Cox
On 15 Apr 2014, at 10:02 am, Varun Chandramohan wrote: > Lets say I walkthrough 1000 files and folders, for each file/folder I need to > compare against this array list. This might be slow or inefficient. Is there > a faster way to do something like this? As a general principle, if you have

Fast NSArray compare

2014-04-14 Thread Varun Chandramohan
Hi All, I have a question about efficiency when trying to compare NSURL. The requirement is quite simple. I try and iterate through a directory to all subdirectories and files. While doing this walk-through, I need to check against an array of NSURLs which are restricted files and folders. This

Layout-triggered animation

2014-04-14 Thread Julian
I'm animating frame changes from autolayout. Code to trigger the expand is shown here. I added QuartzCore.framework to my link libraries, and checked layer backing for the window's view. -(void) expand { [NSAnimationContext beginGrouping]; [[NSAnimationContext currentContext] setAllowsImpl

OS X iCloud open dialog flashes on app launch

2014-04-14 Thread Rick Mann
I just added iCloud and App Sandboxing entitlements to my app. I had to fix some code that autosaves a file on launch to Application Support/, so now it saves inside the Container. But now I see the very brief flash of what I think is an Open file Panel, set to some iCloud setting. It comes up

Re: Automatically resize parent view when subviews resize

2014-04-14 Thread lorenzo
On 2014-04-14 12:39, Kyle Sluder wrote: On Mon, Apr 14, 2014, at 10:20 AM, lorenzo wrote: On 2014-04-14 09:28, Fritz Anderson wrote: > > What constraints are you putting on the subviews you add dynamically to > A and B? The subviews, a subclass of NSView, are made up of three views, a vertical

Re: Automatically resize parent view when subviews resize

2014-04-14 Thread Kyle Sluder
On Mon, Apr 14, 2014, at 10:20 AM, lorenzo wrote: > On 2014-04-14 09:28, Fritz Anderson wrote: > > > > What constraints are you putting on the subviews you add dynamically to > > A and B? > > The subviews, a subclass of NSView, are made up of three views, a > vertical NSSlider, an NSTextfield r

Re: Automatically resize parent view when subviews resize

2014-04-14 Thread lorenzo
On 2014-04-14 09:28, Fritz Anderson wrote: On 13 Apr 2014, at 11:01 PM, Lorenzo Thurman wrote: I have an NSView with two subviews (A & B) placed horizontally with respect to each other. The subviews can take a variable number of uniformly sized subviews. I’ve placed these constraints on subv

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
Thanks to everyone for helping !!! Using setEnvironment made it easily. I was looking for a complicated solution when the solution was not so difficult. Le 14 avr. 2014 à 17:59, Colas a écrit : > Thanks also for the idea of -setEnvironment. I will try.

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
Unfortunately, it is not working. Gnuplot is complaining. ! Package pgfplots Error: Sorry, the gnuplot-result file ‘myFile.pgf-plot.t able' could not be found. Maybe you need to enable the shell-escape feature? Fo r pdflatex, this is '>> pdflatex -shell-escape'. You can also invoke '>> gnuplo t .g

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
Bryan, I am trying to adapt your code to pdflatex. I hope it will work!!! It seems that putting the option -l at the end was very important. Do you know why? I have to admit that I put these « -c » and « -l » options thanks to other answers, but I don’t know what they are doing. Thanks very muc

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
Le 14 avr. 2014 à 17:07, Bryan Vines a écrit : > Hi Colas, > > Pico is an interactive text editor. I don’t think NSTask is going to give you > much opportunity to interact with it. Are you using Pico as an example, or > are you actually trying to launch Pico? > > If you really *are* trying t

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Bryan Vines
Colas, If my previous code snippet doesn’t work with pdflatex, NSTask has a -setEnvironment method; it may allow you to set your task’s environment variables. — Bryan Vines On Apr 14, 2014, at 10:40 AM, Colas wrote: > My problem is that I want to launch pdflatex with the -shell-escape optio

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Bryan Vines
Colas, Bash’s -c option expects commands in a string which follows. Therefore, this will work: I’m using /usr/bin/touch as an example, rather than your example of pico, which is an interactive text editor. NSTask * myTask = [[NSTask alloc]init]; NSArray * arguments = @[@"-c", @"/us

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
> Try putting > > /usr/bin/pico /Users/colas/myfile.txt > > into separate items in the argument NSArray. I find the man page ambiguous, > and I lack direct experience, but that may be what bash expects. > > It is not working, unfortunately. > I can’t guarantee that this will solve the large

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Ken Thomases
On Apr 14, 2014, at 10:08 AM, Colas B wrote: > Without the quotes, the error is > Error opening terminal: unknown. Terminal doesn't just run the shell (which, in turn, runs pico). It provides a window and a TTY (terminal device) for the processes to use and translates the I/O to the window. T

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Fritz Anderson
On 14 Apr 2014, at 10:08 AM, Colas B wrote: > OK. > > But without the simple quotes, it also fails. > > With the quotes, the error is > /bin/bash: pico /Users/colas/myfile.txt: No such file or directory > Without the quotes, the error is > Error opening terminal: unknown. > > Thanks! > Le Lund

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas B
OK. But without the simple quotes, it also fails. With the quotes, the error is /bin/bash: pico /Users/colas/myfile.txt: No such file or directory Without the quotes, the error is Error opening terminal: unknown. Thanks! Le Lundi 14 avril 2014 16h19, Jerry Krinock a écrit : From documentation

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Bryan Vines
Colas, Do you want your app to open a Terminal window, in which Pico has opened the file at /Users/colas/myfile.txt? If that’s so, I don’t think launching it via NSTask is going to get you anything. What is the end result you want to achieve? — Bryan Vines On Apr 14, 2014, at 8:59 AM, Colas B

Re: Automatically resize parent view when subviews resize

2014-04-14 Thread Fritz Anderson
On 13 Apr 2014, at 11:01 PM, Lorenzo Thurman wrote: > I have an NSView with two subviews (A & B) placed horizontally with respect > to each other. The subviews can take a variable number of uniformly sized > subviews. I’ve placed these constraints on subviews A & B, (all done in IB): > (They sh

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Jerry Krinock
From documentation of -[NSTask setArguments:] : "The strings in arguments do not undergo shell expansion, so you do not need to do special quoting” I don’t know what they mean by “special”, but anyhow, the ‘ ' you put around your last argument will be passed to your tool and cause it to fail.

NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas B
Dear cocoa-dev, I am would like to launch a binary as if I launched it via terminal. I tried the following but it is not working.      NSTask * myTask = [[NSTask alloc] init];     NSArray * arguments = @[@"-c", @"-l", @"'/usr/bin/pico /Users/colas/myfile.txt'"];     [myTask setCurrentDirecto