Re: More elegance than a long if/else

2017-03-10 Thread Bryan Vines
Would integer division work better than the modulus operator?

batteryIcon.image = UIImage(named:"\(min(10, (Int(_myBatteryLevel) / 10) + 1))")

--
Bryan Vines

> On Mar 10, 2017, at 9:54 AM, Jeff Kelley  wrote:
> 
> I realized after sending that 100 won’t be correct, so you’ll need
> something like this:
> 
> batteryIcon.image = UIImage(named: "\(min(10, (_myBatteryLevel % 10) + 1))")
> 
> 
> Jeff Kelley
> 
> slauncha...@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> |
> jeffkelley.org


___

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: What the actual heck?

2014-04-15 Thread Bryan Vines
Lee Ann,

Ah, OK. It’s kind of creepy/scary/funny all at the same time.
Thanks for the reassurance.
—
Bryan


On Apr 15, 2014, at 11:22 PM, Lee Ann Rucker  wrote:

> This happened a while back too, IIRC it's bogus and nothing will happen.

___

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

What the actual heck?

2014-04-15 Thread Bryan Vines
Hi folks.

So I just got a “Mailing list removal confirmation notice” which said the list 
had received a request from a 17.x.x.x address for the removal of my email 
address from this list.

Anyone else getting something like this?

Plot twist: The 17.x.x.x netblock belongs to Apple. “The call is coming from 
INSIDE THE HOUSE!”

Any idea why someone inside Apple wants to pull me off the list?

Very confusing.
—
Bryan Vines


___

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: 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 option. 
> This option allows pdflatex to launch itself other programs. But, when 
> pdflatex, in this context (I mean, launched via NSTask), tries to launch gnu 
> plot, it fails. Whereas the same commands, typed in a terminal, succeed.
> 
> My guess (and others’) is that it is a problem of environment variables.

___

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: 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", @"/usr/bin/touch 
/Users/colas/touchedFile.txt", @"-l"];

[myTask setCurrentDirectoryPath:@"/"];
[myTask setLaunchPath:@"/bin/bash"];
[myTask setArguments:arguments];

[myTask launch];

This will touch a file named “touchedFile.txt” at the root of your home 
directory.

—
Bryan


On Apr 14, 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 Lundi 14 avril 2014 16h19, Jerry Krinock  a écrit :
> 
> 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.
> ___
> 
> 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/bkvines%40me.com
> 
> This email sent to bkvi...@me.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: 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  wrote:

> 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 setCurrentDirectoryPath:@"/"];
>[myTask setLaunchPath:@"/bin/bash"];
>[myTask setArguments:arguments];
> 
>[myTask launch] ;
> 
> If I execute the same commands in a terminal, it works !!
> 
> $ /bin/bash -c -l '/usr/bin/pico /Users/colas/myfile.txt'
> 
> 
> Any remark will be appreciated !!
> Thanks,
> 
> Colas
> ___
> 
> 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/bkvines%40me.com
> 
> This email sent to bkvi...@me.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: MP4 video playback on Mavericks - Where's a good place to start?

2013-11-12 Thread Bryan Vines
Thanks to Karl Moskowski, Jean-Daniel Dupas, and Stuart Rogers for confirming 
AVFoundation and AVKit as the modern way forward. After reviewing Apple's 
sample code, the slides from WWDC 2013 session 606, and a couple more Google 
searches, the task of playing an MP4 video was pretty straightforward.

Thanks again!
--
Bryan Vines


___

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

MP4 video playback on Mavericks - Where's a good place to start?

2013-11-12 Thread Bryan Vines
Good morning all,

I'm toying with a project to play short video, stored in my app's bundle. I had 
thought to use QTKit and a QTMovieView, but I can't locate the QTMovieView in 
Interface Builder.

Apple has a QTKit tutorial, "Creating a Simple QTKit Media Player Application," 
but this is built around Xcode 3.2 and makes use of QTMovieView, which again 
I'm not seeing. Is AVKit and the AVPlayerView the way to do this in Mavericks?

Unfortunately I've only had one cup of coffee today and as a result my 
Google-fu is weak. I appreciate any guidance as to which way I should go, and 
where to start looking.

Thanks!
--
Bryan Vines
___

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: Why IBOutlet don't work under NSTableCellView?

2013-11-08 Thread Bryan Vines
Hello,

I'm just beginning to explore view-based tableviews myself.

When I build and run this project, Xcode shows two warnings of interest:
  - Outlet 'ref' of 'My Image' is connected to 'My Reference,' an invalid 
destination (Objects inside view based table views may only be connected to the 
table view's delegate.)
  - Outlet 'delegate' of 'Text Field - Table View Cell' is connected to 'My 
Reference,' an invalid destination (Objects inside view based table views may 
only be connected to the table view's delegate.)

The linked tutorial, below, has helped me a great deal with regard to 
view-based tableviews.


http://gentlebytes.com/blog/2011/08/30/view-based-table-views-in-lion-part-1-of-2/

Hope that helps!
--
Bryan Vines

On Oct 30, 2013, at 4:49 AM, 周章林  wrote:

> Hi, all,
> 
> I am trying to use NSTableView in our project, and I customized class which
> inherit NSImageView, that's MyImage. In MyImage, I declared a property
> (IBOutlet) "ref". Then I insert this customized view to NSTableCellView in
> Interface Builder, and I connect "ref" with a customized
> class-"MyReference" object . The problem is "ref" is always nil in the
> MyImage instance.
> 
> I have tried to set breakpoint in the -[MyImage initWithFrame:] and
> -[MyImage setRef:], and found the former method is invoked 2 times, but the
> later only once. Can anybody explain why this happen? And I want to make
> the "ref" outlet work, what should I do?
> 
> I also attached the sample project in attachment.

___

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: [OT] iTunes 11.1 Beta

2013-09-18 Thread Bryan Vines
I think Apple's just messing with me -- When I download it, I get a 708-byte 
disk image. Either the compression of disk images has really advanced, or 
something's wrong.

On Sep 18, 2013, at 11:24 AM, Koen van der Drift  
wrote:

> The official version has just been released: 
> http://www.apple.com/itunes/download/
> 
> - Koen.

___

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: Dismissing Open dlog before doc actually opens

2013-08-14 Thread Bryan Vines
Steve,

Using Graham's NSRunLoop solution, it looks like you don't even need to send 
-orderOut to the panel.

--
Bryan Vines

On Aug 14, 2013, at 11:02 AM, Steve Mills  wrote:

> On Aug 14, 2013, at 10:52:55, Graham Cox 
> wrote:
> 
>> [[NSRunLoop mainRunLoop] runUntilDate:[NSDate 
>> dateWithTimeIntervalSinceNow:1.0]];
> 
> 
> I just tried your method of runUntilDate with a time of 0.1 in the future and 
> so far it's working every time. Thanks for that - I wasn't aware of this 
> method. We'll give it a thorough testing.
> 
> --
> Steve Mills

___

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: Dismissing Open dlog before doc actually opens

2013-08-13 Thread Bryan Vines
Steve,

Could you use a boolean property such as fileIsBeingRead? Set that to YES when 
you start the file read on the background thread, then set it back to NO when 
the file read has completed.

I used this technique in a proof-of-concept app. The app has a status label in 
its window; the label's value and "hidden" properties are bound to an NSString 
property and a BOOL property in the app delegate.

When the user clicks File > Open, I run the open panel modally [myOpenPanel 
runModal]. When the user selects a file and clicks the panel's Open button, I 
set the NSString property something like @"Reading File…" and set the 
fileIsBeingRead property to YES. Then I call a method to open the file on a 
background thread.

When the "open a file" method finishes reading the file, it resets the NSString 
and fileIsBeingRead properties, then shows an alert to let the user know the 
file has been read.

You are welcome to the Xcode project for the app I referenced. It's 36K, zipped.

TL;DR: You can set a property to indicate the file is being read, and by 
observing that property, you'll know when the read has finished.

Hope that helps.
--
Bryan Vines


On Aug 13, 2013, at 1:02 PM, Steve Mills  wrote:

> On Aug 12, 2013, at 21:22:07, Bryan Vines  wrote:
> 
>> Can you run an NSOpenPanel with a completion handler block, and in that 
>> block, call a method on a background thread to actually perform the file 
>> read operation?
> 
> Well, this won't work. The current code runs the dlog with runModal instead 
> of beginWithCompletionHandler. If I change it to beginWithCompletionHandler, 
> it returns right away and falls out of our semi-portable code for opening 
> files before the dlog is even presented. We expect the Open dlog to be modal, 
> not modeless. Any other ideas? I also tried calling orderOut after runModal 
> returned, but it didn't make it go away.
> 
> --
> Steve Mills
> office: 952-818-3871
> home: 952-401-6255
> cell: 612-803-6157

___

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: Dismissing Open dlog before doc actually opens

2013-08-12 Thread Bryan Vines
Steve,

Can you run an NSOpenPanel with a completion handler block, and in that block, 
call a method on a background thread to actually perform the file read 
operation?

As a test, I put this together. I called the selectAFile method and chose a 4GB 
text file. The open panel was dismissed after about a second, the file read 
completed after four seconds:

-(void)selectAFile
{
// Get and configure an open panel.
NSOpenPanel * myOpenPanel = [NSOpenPanel openPanel];
[myOpenPanel setCanChooseDirectories:NO];
[myOpenPanel setAllowedFileTypes:[NSArray arrayWithObject:@"txt"]];

// Run the panel.
[myOpenPanel  beginWithCompletionHandler:^(NSInteger result)
 {
 if (result==NSFileHandlingPanelOKButton)
 {
 // User clicked OK, do the actual file read in a background thread.
 [self performSelectorInBackground:@selector(openAFileURL:) 
withObject:myOpenPanel.URL];
 }
 }];
}

-(void)openAFileURL:(NSURL *)aFileURL
{
// Read the contents of the file at aFileURL into a string.
NSString * fileString = [NSString stringWithContentsOfURL:aFileURL 
encoding:NSUTF8StringEncoding error:nil];

// Log the result.
if (fileString) {
NSLog(@"Successfully read file: %@", [aFileURL lastPathComponent]);
} else {
NSLog(@"Could not load file: %@", [aFileURL lastPathComponent]);
}
}

--
Bryan Vines

On Aug 12, 2013, at 6:27 PM, "Mills, Steve"  wrote:

> I haven't been able to find any info about this, but I might be searching for 
> the wrong thing. How can we get rid of the Open dlog so it doesn't hang 
> around while the document is being read? It's an incredibly annoying design.
> 
> Steve via iPad
___

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: full screen

2013-07-17 Thread Bryan Vines
Hi,

It sounds like you're saying when the screen resolution changes (in this case, 
because the Mac mini detects the display), your application stays at whatever 
resolution the Mac mini defaulted to. So would it be correct to say your 
application isn't responding to changes in screen resolution?

--
Bryan Vines


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Displaying "Trebuchet MS" font

2013-05-14 Thread Bryan Vines
I think we're going off topic, but I think iTunes uses Helvetica Neue these 
days. It seems like iTunes is generally the forerunner of changes to come in 
the OS X GUI. Stuff seems to happen *there* before it happens to the OS at 
large.
--
Bryan Vines

On May 13, 2013, at 2:43 PM, Steve Mills  wrote:

> On May 13, 2013, at 14:29, Alex Zavatone  wrote:
> 
>> A perfect example of this is in the new iTunes.  The main window display 
>> font was changed from Helvetica to Arial, and to people who have expected a 
>> uniform appearance in apps coming from Apple, this is a drastic departure 
>> from what is expected.  I'm sure you've heard the cries about people hating 
>> the new iTunes GUI.  This is a big part of it.
> 
> You sure about that? Looks like Helvetica to me, and it used to be Lucida 
> Grande, same as everything else, didn't it? Regardless it's the reason why 
> iTunes 11 looks like hell. If they needed to fit more information in, just 
> use a smaller font size, not an uglier font that doesn't match the rest of 
> the OS.
> 
> Steve via iPad

___

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