Re: Swift and parameter names

2015-06-25 Thread Britt Durbrow
IMHO, named parameters at call sites are one of the things that makes 
Objective-C great; and I am VERY happy that Swift-2 enforces this.

It is not any additional burden in any modern IDE to have this; as the IDE’s 
autocomplete fills in the parameter names for you.

Also, consider a body of code that has inferred parameters in it… and now you 
need to add a new function; which makes the inferred call sites ambiguous.  At 
best this will require some complicated regex replacement operations across the 
whole code base before it will compile again; at worst it will be unfixable (if 
you don’t have the source code and the binary that you are trying to link 
against doesn’t have enough information for the linker to resolve the ambiguity 
(I don’t know enough about Swift’s intermediate format to say if it does or 
not); or for some reason you do have the source code but are forbidden from 
modifying 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: Scripting Bridge Questions

2015-06-25 Thread Dave

 On 25 Jun 2015, at 12:34, Sandor Szatmari admin.szatmari@gmail.com 
 wrote:
 
 I wrote an interface to a third party app using the Scripting Bridge.  It 
 worked pretty good but I had to test the SBApplication object for nil before 
 accessing it.  Periodically it would return nil unexpectedly.  Don't know if 
 that was a bug in the app's implementation or something I was doing wrong.  
 But other than that it worked great.
 
 I did what you described, first use sdef and sdp to create the header.  
 Include the header and then create an instance of SBApplication using the 
 third party app's bundle identifier 'com.name.whatever'.  I have definitely 
 seen apps that are broken too.  They support AppleScript but not fully or 
 something so the scripting bridge is broken for them.
 
 Sandor Szatmari

That’s the problem, “sdef and/or “sdp barf when I try to generate the header 
file and without the header file you are pretty much dead in the water.

Cheers
Dave


___

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: Scripting Bridge Questions

2015-06-25 Thread Dave

 On 25 Jun 2015, at 13:33, Bill Cheeseman wjcheese...@gmail.com wrote:
 
 
 On Jun 25, 2015, at 8:09 AM, Dave d...@looktowindward.com wrote:
 
 That’s the problem, “sdef and/or “sdp barf when I try to generate the 
 header file and without the header file you are pretty much dead in the 
 water.
 
 
 I haven't noticed a specific description of the failure you're experiencing. 
 Do you get a partial header file, or a header file that contains errors or 
 that causes errors in your Scripting Bridge implementation? I have found in 
 the past that I can manually edit header files generated by sdef/sdp, at 
 least by removing irrelevant declarations that aren't needed or that cause 
 problems, and when I do it right the edited header files work with Scripting 
 Bridge.
 

I get this error:

sdp: enumerator of enumeration e183: missing required name attribute.

and an (very) incomplete file, e.g. most of it is missing.

All the Best
Dave


___

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: Scripting Bridge Questions

2015-06-25 Thread Dave

 On 25 Jun 2015, at 14:48, Bill Cheeseman wjcheese...@gmail.com wrote:
 
 
 On Jun 25, 2015, at 9:13 AM, Dave d...@looktowindward.com wrote:
 
 I get this error:
 
 sdp: enumerator of enumeration e183: missing required name attribute.
 
 
 Can you generate the sdef file separately, then manually edit it to supply 
 the missing required 'name' attribute, and then run sdp on the edited sdef 
 file? You will presumably have to give more than a little thought to what the 
 missing name attribute should be, but maybe you'll hit pay dirt.

I’m looking into doing that now, but I can’t seem to find an editor that will 
open it, at the moment it’s ONE giant line of text, I renamed it to .xml and 
tried to open in XCode - same.

Cheers
Dave



___

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: Scripting Bridge Questions

2015-06-25 Thread Dave
On further investigation, the App doesn’t have an .sdef, so, the “sdef” tool, 
must generate it from the old style ‘aete’ resources. So, the fault could be in 
either “sdef” or “sdp”.

I’ve trying to look at the output from “sdef” but it’s in a horrible format - 
no line endings, so it’s hard to read. If I try to open it as an xml in XCode 
all I get is a one HUGE line of text and XCode struggles to deal with it (slow 
as a very slow thing on a cold morning).

Cheers
Dave

 On 25 Jun 2015, at 14:29, Dave d...@looktowindward.com wrote:
 
 
 On 25 Jun 2015, at 14:24, Jean-Daniel Dupas mail...@xenonium.com wrote:
 That just means you wrote an invalid sdef file in the first place. 
 
 Really? No kidding?!?!? lol
 
 The .sdef file comes with the App I am trying to generate the header file 
 for!
 
 
 
 ___
 
 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/dave%40looktowindward.com
 
 This email sent to d...@looktowindward.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: Scripting Bridge Questions

2015-06-25 Thread Jean-Daniel Dupas

 Le 25 juin 2015 à 15:13, Dave d...@looktowindward.com a écrit :
 
 
 On 25 Jun 2015, at 13:33, Bill Cheeseman wjcheese...@gmail.com wrote:
 
 
 On Jun 25, 2015, at 8:09 AM, Dave d...@looktowindward.com wrote:
 
 That’s the problem, “sdef and/or “sdp barf when I try to generate the 
 header file and without the header file you are pretty much dead in the 
 water.
 
 
 I haven't noticed a specific description of the failure you're experiencing. 
 Do you get a partial header file, or a header file that contains errors or 
 that causes errors in your Scripting Bridge implementation? I have found in 
 the past that I can manually edit header files generated by sdef/sdp, at 
 least by removing irrelevant declarations that aren't needed or that cause 
 problems, and when I do it right the edited header files work with Scripting 
 Bridge.
 
 
 I get this error:
 
 sdp: enumerator of enumeration e183: missing required name attribute.
 
 and an (very) incomplete file, e.g. most of it is missing.
 

That just means you wrote an invalid sdef file in the first place. 


___

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: Scripting Bridge Questions

2015-06-25 Thread Dave
Hi,

Is the source code of “sdp” available anywhere? Just a thought.

All the Best
Dave


___

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: Scripting Bridge Questions

2015-06-25 Thread Bill Cheeseman

 On Jun 25, 2015, at 8:09 AM, Dave d...@looktowindward.com wrote:
 
 That’s the problem, “sdef and/or “sdp barf when I try to generate the 
 header file and without the header file you are pretty much dead in the water.


I haven't noticed a specific description of the failure you're experiencing. Do 
you get a partial header file, or a header file that contains errors or that 
causes errors in your Scripting Bridge implementation? I have found in the past 
that I can manually edit header files generated by sdef/sdp, at least by 
removing irrelevant declarations that aren't needed or that cause problems, and 
when I do it right the edited header files work with Scripting Bridge.

-- 

Bill Cheeseman - b...@cheeseman.name

___

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: Scripting Bridge Questions

2015-06-25 Thread Bill Cheeseman

 On Jun 25, 2015, at 9:13 AM, Dave d...@looktowindward.com wrote:
 
 I get this error:
 
 sdp: enumerator of enumeration e183: missing required name attribute.


Can you generate the sdef file separately, then manually edit it to supply the 
missing required 'name' attribute, and then run sdp on the edited sdef file? 
You will presumably have to give more than a little thought to what the missing 
name attribute should be, but maybe you'll hit paydirt.

-- 

Bill Cheeseman - b...@cheeseman.name

___

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: Scripting Bridge Questions

2015-06-25 Thread Dave

 On 25 Jun 2015, at 14:24, Jean-Daniel Dupas mail...@xenonium.com wrote:
 That just means you wrote an invalid sdef file in the first place. 

Really? No kidding?!?!? lol

The .sdef file comes with the App I am trying to generate the header file 
for!



___

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: Swift and parameter names

2015-06-25 Thread Roland King

 On 25 Jun 2015, at 16:50, dangerwillrobinsondan...@gmail.com wrote:
 
 
 On 2015/06/25, at 15:49, Britt Durbrow 
 bdurb...@rattlesnakehillsoftworks.com wrote:
 
 IMHO, named parameters at call sites are one of the things that makes 
 Objective-C great; and I am VERY happy that Swift-2 enforces this.
 
 I agree whole heartedly. 
 But will call out that it is a considered and thoughtful design by Cocoa and 
 Foundation Framework engineers. Objective-C doesn't require it. 
 Look at the old Next manual... There were a few obtuse methods. 
 
 The IDE takes the burden of typing away. 
 The conventions established help promote good coding practices that enable 
 clarity and reduce mistakes and confusion. 
 The (general) consistency and effort towards consistency those folks work 
 towards is for everyone who codes to do it better. 
 For themselves to more easily support developers consuming the APIs and end 
 customers to have better quality products. 

I like where it ended up with Swift 2.0. In a vacuum I would possibly have gone 
for all parameters named and not 'all but the first one’ (with some exceptions 
for constructors) but I see how we got there and it does fit the 
transliteration of API from ObjC to Swift. And that standard transliteration, 
especially in the latest Swift, has made switching from ObjC to Swift much 
easier so I’m all for bringing that function naming convention over. 

I think one of the patterns I had to learn to make it work was naming functions 
like you do in objective C. I had no problem in that language doing

-(Felony*)doSomethingWithJello:(Jello*)jello 
peaShooter:(PeaShooter*)peaShooter batmanMask:(BatmanMask*)batmanMask;

when I first started writing Swift it looked like C to me, so my function name 
just became the verb and I got this

func doSomething( jello : Jello, peaShooter : PeaShooter, batmanMask : 
BatmanMask )-Felony

and when you have that it does’t make sense you don’t need to name the Jello. 
Once I started naming the functions in the same way I would have done the 
original objC one, it all made more sense

func doSomethingWithJello( jello : Jello,  peaShooter : PeaShooter, 
batmanMask : BatmanMask )-Felony

On the odd occasion that I write more C-name-like functions then I usually 
double up the first parameter so they are all named when you call them. And if 
I have an initialiser which can only obviously take one argument, especially 
with generics where the argument is often ‘initialValue’, I underscore it away. 

95% of the time I find I follow the conventions however and code is pretty 
readable. Similarly so is other people’s. 


___

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: Scripting Bridge Questions

2015-06-25 Thread Willeke
Hi,

Can you open the dictionary in Scripteditor?
Is the application launched when you run sdef or open the dictionary in 
Scripteditor?

 I can’t seem to find an editor that will open it
Try Xcode or TextWrangler with soft wrap switched on in the preferences. Or 
Sdef Editor, ignore the warnings and save as….

Willeke
___

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: Scripting Bridge Questions

2015-06-25 Thread Jean-Daniel Dupas

 Le 25 juin 2015 à 15:57, Dave d...@looktowindward.com a écrit :
 
 
 On 25 Jun 2015, at 14:48, Bill Cheeseman wjcheese...@gmail.com wrote:
 
 
 On Jun 25, 2015, at 9:13 AM, Dave d...@looktowindward.com wrote:
 
 I get this error:
 
 sdp: enumerator of enumeration e183: missing required name attribute.
 
 
 Can you generate the sdef file separately, then manually edit it to supply 
 the missing required 'name' attribute, and then run sdp on the edited sdef 
 file? You will presumably have to give more than a little thought to what 
 the missing name attribute should be, but maybe you'll hit pay dirt.
 
 I’m looking into doing that now, but I can’t seem to find an editor that will 
 open it, at the moment it’s ONE giant line of text, I renamed it to .xml and 
 tried to open in XCode - same.
 

You can pretty format it using xmllint command line tool.

xmllint --pretty 1 yourfile.xml  your_formatted_file.xml

 Cheers
 Dave
 
 
 
 ___
 
 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

___

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: Scripting Bridge Questions

2015-06-25 Thread Dave

 On 25 Jun 2015, at 17:14, Jean-Daniel Dupas mail...@xenonium.com wrote:
 
 
 You can pretty format it using xmllint command line tool.
 
 xmllint --pretty 1 yourfile.xml  your_formatted_file.xml
 

I knocked up a utility to do it but thanks anyway.

Once I could see where the problem was, I fixed the output from “sdef” quite 
easily and then ran this file through “sdp”, e.g.

sdef .app  .txt

// reformat and edit .txt

and then:

cat .txt | sdp -fh --basename App

When I included the generated header file in my project, here were a few 
duplicate definitions which I fixed and it compiled ok!

That was a really good hack!

Many Thanks to everyone that helped on this.

All the Best
Dave



___

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

Another AppleScriptObjC Bridge Question

2015-06-25 Thread Dave
Hi,

I’ve added some .applescript files to my project which get called using the 
AppleScriptObjC Bridge. 

I was wondering if there was a way to specify in the project somehow that I 
want to use the terminology from a particular application when compiling the 
script?

All the Best
Dave




___

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: Generic Bitmap to NSImage

2015-06-25 Thread Graham Cox

 On 26 Jun 2015, at 9:10 am, Raglan T. Tiger r...@crusaderrabbit.net wrote:
 
 I have a list of generic bitmaps that are to be transformed to NSImages.  The 
 list can be long, I haven limits on it.
 
 Here is the code I use to populate an NSMenu that gets set into an 
 NSPopUpButton.
 
 I need to speed this process up ... any suggestions?


Instead of creating a CGBitmapContext to wrap your pixel buffer, then turning 
it into a CGImage, then copying it to an NSImage, why not create a 
NSBitmapImageRep directly wrapping the original buffer? Then it can be added to 
an NSImage as a rep without any copying being necessary at any point. The 
slowness here (which you imply is a problem) is very likely due to the fact 
that you are having to copy each bitmap twice (once when you create the 
CGImage, the second time when you blit that into the NSImage).

—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

Generic Bitmap to NSImage

2015-06-25 Thread Raglan T. Tiger
I have a list of generic bitmaps that are to be transformed to NSImages.  The 
list can be long, I haven limits on it.

Here is the code I use to populate an NSMenu that gets set into an 
NSPopUpButton.

I need to speed this process up ... any suggestions?

NSMenu *comboMenu = [[[NSMenu alloc] init] autorelease];
   POSITION pos = listOfBBitmaps.GetHeadPosition();
while ( pos )
{
BBitmap *image = listOfBBitmaps.GetNext ( pos );

CGColorSpaceRef colorSpace;
colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
CGContextRefcontext;
context = CGBitmapContextCreate (image-m_array, image-m_pixelsx, 
image-m_pixelsy, 8, image-m_pixelsx * 4, colorSpace, 
kCGImageAlphaNoneSkipFirst|kCGBitmapByteOrder32Host);

CGImageRef cgImage = CGBitmapContextCreateImage (context);

CGContextRelease(context);
CGColorSpaceRelease(colorSpace);

size_t width = CGImageGetWidth( cgImage );
size_t height = CGImageGetHeight( cgImage );
NSRect imageRect = NSMakeRect(0, 0, width, height);
NSImage *nsImage = [[[NSImage alloc] initWithSize:imageRect.size] 
autorelease];
  
if ( [nsImage respondsToSelector:@selector(lockFocusFlipped:)] )
{
[nsImage lockFocusFlipped:YES];
}
else
{
[nsImage setFlipped:YES];
[nsImage lockFocus];
}
CGContextRef imageContext = (CGContextRef)[[NSGraphicsContext 
currentContext] graphicsPort];
CGContextDrawImage(imageContext, *(CGRect*)imageRect, cgImage);

[nsImage unlockFocus];

NSMenuItem *menuItem = [[[NSMenuItem alloc] init] autorelease];
[menuItem setImage: nsImage];

[menuItem setTitle:[NSString stringWithFormat:@untitled]];

[comboMenu addItem:menuItem];

m_imageCount++;

}





-rags



___

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: Generic Bitmap to NSImage

2015-06-25 Thread Ken Thomases

 On Jun 25, 2015, at 6:10 PM, Raglan T. Tiger r...@crusaderrabbit.net wrote:
 
 I have a list of generic bitmaps that are to be transformed to NSImages.  The 
 list can be long, I haven limits on it.
 
 Here is the code I use to populate an NSMenu that gets set into an 
 NSPopUpButton.
 
 I need to speed this process up ... any suggestions?
 
NSMenu *comboMenu = [[[NSMenu alloc] init] autorelease];
   POSITION pos = listOfBBitmaps.GetHeadPosition();
while ( pos )
{
BBitmap *image = listOfBBitmaps.GetNext ( pos );
 
CGColorSpaceRef colorSpace;
colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
CGContextRefcontext;
context = CGBitmapContextCreate (image-m_array, image-m_pixelsx, 
 image-m_pixelsy, 8, image-m_pixelsx * 4, colorSpace, 
 kCGImageAlphaNoneSkipFirst|kCGBitmapByteOrder32Host);
 
CGImageRef cgImage = CGBitmapContextCreateImage (context);
 
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
 
size_t width = CGImageGetWidth( cgImage );
size_t height = CGImageGetHeight( cgImage );
NSRect imageRect = NSMakeRect(0, 0, width, height);
NSImage *nsImage = [[[NSImage alloc] initWithSize:imageRect.size] 
 autorelease];
 
if ( [nsImage respondsToSelector:@selector(lockFocusFlipped:)] )
{
[nsImage lockFocusFlipped:YES];
}
else
{
[nsImage setFlipped:YES];
[nsImage lockFocus];
}
CGContextRef imageContext = (CGContextRef)[[NSGraphicsContext 
 currentContext] graphicsPort];
CGContextDrawImage(imageContext, *(CGRect*)imageRect, cgImage);
 
[nsImage unlockFocus];
 
NSMenuItem *menuItem = [[[NSMenuItem alloc] init] autorelease];
[menuItem setImage: nsImage];
 
[menuItem setTitle:[NSString stringWithFormat:@untitled]];
 
[comboMenu addItem:menuItem];
 
m_imageCount++;
 
}

First suggestion is to cache the results so you don't have to convert every 
time.

Second is to start the process in the background as soon as you think you'll 
need the images rather than doing it synchronously.

Third is to avoid using drawing to create the NSImage.  There are two separate 
approaches:

1) Create the image by creating an NSBitmapImageRep from the bitmap 
data and then creating an NSImage and adding that rep to it.  You would call 
-initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:
 to create the NSBitmapImageRep.  You would use -initWithSize: to create the 
NSImage.  You would add the image rep to the image using -addRepresentation:.

2) Create a CGImage using CGImageCreate().  Create an NSImage using 
-initWithCGImage:size:.

I doubt there's significant performance difference between the two methods, so 
choose whichever seems most natural.

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

Any way around the 'typealias' requirement here

2015-06-25 Thread Roland King
Trying to have a delegate pattern with a typealias requirement. I can define 
the protocol, I can make a class conform to it, but I can’t declare a variable 
of that type as a member of another class because it has associated type 
information. Is there a way to do this, or is there a very good reason what I’m 
trying to do doesn’t make sense? 

public protocol Foo : class
{
typealias Key
func foo( k : Key )-()
}

public class FooClass : Foo
{
typealias Key = Int

public func foo( k : Int )-()  // satisfies the protocol 
requirement
{
print( Satisfies Foo )
}
}


public class BarKey
{
var delegate : Foo  // Protocol ‘Foo’ can only be used as a 
generic constraint because … 
}


You see what I’m trying to mean here right, that the Foo here is a Foo with 
associated type ‘Key’. 

I really want to be able to qualify the Foo with a where clause like

var delegate : Foo where Foo.Key == Key

but you can’t use where clauses like that. Is there a way to write this or is 
this something which cannot be written. 
___

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: Overlapping NSViews and mouseDown Events

2015-06-25 Thread Thomas Wetmore
Graham,

Xcode 6.3.2; OS X 10.10.3; Base SDK 10.10; Deployment Target 10.10; Swift 1.2; 
iMac 24” early 2009.

I think we have to go back to around 10.5 to get to the time of no assumptions 
about z-order of overlapping sibling views.

Thanks,

Tom Wetmore

 On Jun 25, 2015, at 12:22 AM, Graham Cox graham@bigpond.com wrote:
 
 
 On 25 Jun 2015, at 2:08 pm, Thomas Wetmore t...@verizon.net wrote:
 
 I assume the quirks of dealing with overlapping views have long been ironed 
 out.
 
 
 What SDK and minimum target version do you have?
 
 I’m just wondering if there’s a compatibility thing kicking in for older 
 systems, which did not make any guarantees about Z-order of overlapping views.
 
 —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: Swift and parameter names

2015-06-25 Thread dangerwillrobinsondanger

 On 2015/06/25, at 15:49, Britt Durbrow 
 bdurb...@rattlesnakehillsoftworks.com wrote:
 
 IMHO, named parameters at call sites are one of the things that makes 
 Objective-C great; and I am VERY happy that Swift-2 enforces this.

I agree whole heartedly. 
But will call out that it is a considered and thoughtful design by Cocoa and 
Foundation Framework engineers. Objective-C doesn't require it. 
Look at the old Next manual... There were a few obtuse methods. 

The IDE takes the burden of typing away. 
The conventions established help promote good coding practices that enable 
clarity and reduce mistakes and confusion. 
The (general) consistency and effort towards consistency those folks work 
towards is for everyone who codes to do it better. 
For themselves to more easily support developers consuming the APIs and end 
customers to have better quality products. 
___

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: Scripting Bridge Questions

2015-06-25 Thread Dave

 On 25 Jun 2015, at 00:30, Graham Cox graham@bigpond.com wrote:
 
 
 On 24 Jun 2015, at 9:22 pm, Dave d...@looktowindward.com wrote:
 
 I was wondering if I should just give up now and forget using the Bridge or 
 if there’s any chance that I might get a usable header file generated 
 somehow. My instincts tell me to give up, but if anyone knows better or they 
 know a better solution I’d really appreciate a pointer…..
 
 
 Scripting Bridge worked for me to implement a programmatic interface to Mail. 
 Long time since I did it, forget what, if any, issues I had, but don’t recall 
 any particular problems.

Yes, it seems to work with all Apple Apps I’ve tested with, (which is all it 
mentions in the examples), but not with third party apps.

It probably is also dependant when when the application was created too.

Dave


___

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