Re: Variable Number of Parameters in Method

2013-08-22 Thread Dave
Hi,

It's not much good to me since I don't have a problem passing objects but with 
passing a mixed set.

Type passing, 1,2,3,5.6,@hello,nil to the arrayWithObjects and you will see 
what I mean

Cheers
Dave


On 21 Aug 2013, at 20:04, Alex Zavatone z...@mac.com wrote:

 Just in case the styled text is stripped, here is the line I'm referring to 
 from the header file:
 
 + (id)arrayWithObjects:(id)firstObj, ... NS_REQUIRES_NIL_TERMINATION;
 
 Sent from my iPad
 
 On Aug 21, 2013, at 2:58 PM, Alex Zavatone z...@mac.com wrote:
 
 The approach I mentioned is what NSArray uses to allow an arbitrary amount 
 of objects in this call to init it.  Supplying nil tells the runtime that 
 there are no more parameters.
 
 NSArray *myArray;
 myArray = [NSArray alloc] initWithObjects: @my String, @another, 
 @more, nil];
 
 It's the nil termination of the parameters approach.
 
 How you do this is that bold line that I outlined earlier.
 
 Sent from my iPad
 
 On Aug 21, 2013, at 1:17 PM, Stephen J. Butler stephen.but...@gmail.com 
 wrote:
 
 On Wed, Aug 21, 2013 at 4:22 AM, Dave d...@looktowindward.com wrote:
 
  if ([myType isEqualToString:@NSInteger] )
  {
  myNSInteger = va_arg(myArgumentList,NSInteger*);
 //  do something with myNSInteger
  [myFormattedString appendFormat:@myNSInteger = %d ,
 myNSInteger];
  }
 
  else if ([myType isEqualToString:@CGFloat] )
  {
  myCGFloat = va_arg(myArgumentList, CGFloat*);
 //  do something with myCGFloat
  [myFormattedString appendFormat:@myCGFloat = %f ,
 myCGFloat];
  }
 
 
 This is better, however... if you pass an actual NSInteger or CGFloat to
 the method, va_arg() should have a type of NSInteger or CGFloat, not
 pointers to those types. Your code examples with it's printf style formats
 is using the former, not the latter. Just to be clear, you can have all
 these cases:
 
 if ([myType isEqualToString:@NSInteger] ) {
 myNSInteger = va_arg(myArgumentList,NSInteger);
 } else if ([myType isEqualToString:@NSInteger*] ) {
 pMyNSInteger = va_arg(myArgumentList,NSInteger*);
 } else if ([myType isEqualToString:@CGFloat]) {
 myCGFloat = va_arg(myArgumentList, CGFloat);
 } else if ([myType isEqualToString:@CGFloat*]) {
 pMyCGFloat = va_arg(myArgumentList, CGFloat*);
 } ... etc
 ___
 
 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/zav%40mac.com
 
 This email sent to z...@mac.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/zav%40mac.com
 
 This email sent to z...@mac.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/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: Variable Number of Parameters in Method

2013-08-22 Thread Maxthon Chan
This is actually an ABI issue. Objective-C method calls are essentially C 
function calls:

[NSArray arrayWithObjects:@1, @2, @3, nil];

is really (C function symbol name is guessed from a common name mangling scheme)

__objc_c_NSArray_arrayWithObjects_([NSArray class], 
@selector(arrayWithObjects:), @1, @2, @3, nil); // Prototype: id imp(id self, 
SEL _cmd, id, …);

So the problem is how the parameter is passed from the caller function to the 
callee. I am not so familiar with ARM so I am going to use amd64 as an example:

amd64 sysv ABI passes initial six integer and pointer parameters in registers 
rsi, rdi, r8, r9, r10, r11, r12, r13, r14 and remainders on stack. Float point 
parameters is, instead, first in SSE registers and then stack. That is why 
floats will cause issue.

On Aug 22, 2013, at 14:37, Dave d...@looktowindward.com wrote:

 Hi,
 
 It's not much good to me since I don't have a problem passing objects but 
 with passing a mixed set.
 
 Type passing, 1,2,3,5.6,@hello,nil to the arrayWithObjects and you will see 
 what I mean
 
 Cheers
 Dave
 
 
 On 21 Aug 2013, at 20:04, Alex Zavatone z...@mac.com wrote:
 
 Just in case the styled text is stripped, here is the line I'm referring to 
 from the header file:
 
 + (id)arrayWithObjects:(id)firstObj, ... NS_REQUIRES_NIL_TERMINATION;
 
 Sent from my iPad
 
 On Aug 21, 2013, at 2:58 PM, Alex Zavatone z...@mac.com wrote:
 
 The approach I mentioned is what NSArray uses to allow an arbitrary amount 
 of objects in this call to init it.  Supplying nil tells the runtime that 
 there are no more parameters.
 
 NSArray *myArray;
 myArray = [NSArray alloc] initWithObjects: @my String, @another, 
 @more, nil];
 
 It's the nil termination of the parameters approach.
 
 How you do this is that bold line that I outlined earlier.
 
 Sent from my iPad
 
 On Aug 21, 2013, at 1:17 PM, Stephen J. Butler stephen.but...@gmail.com 
 wrote:
 
 On Wed, Aug 21, 2013 at 4:22 AM, Dave d...@looktowindward.com wrote:
 
 if ([myType isEqualToString:@NSInteger] )
 {
 myNSInteger = va_arg(myArgumentList,NSInteger*);
 //  do something with myNSInteger
 [myFormattedString appendFormat:@myNSInteger = %d ,
 myNSInteger];
 }
 
 else if ([myType isEqualToString:@CGFloat] )
 {
 myCGFloat = va_arg(myArgumentList, CGFloat*);
 //  do something with myCGFloat
 [myFormattedString appendFormat:@myCGFloat = %f ,
 myCGFloat];
 }
 
 
 This is better, however... if you pass an actual NSInteger or CGFloat to
 the method, va_arg() should have a type of NSInteger or CGFloat, not
 pointers to those types. Your code examples with it's printf style formats
 is using the former, not the latter. Just to be clear, you can have all
 these cases:
 
 if ([myType isEqualToString:@NSInteger] ) {
 myNSInteger = va_arg(myArgumentList,NSInteger);
 } else if ([myType isEqualToString:@NSInteger*] ) {
 pMyNSInteger = va_arg(myArgumentList,NSInteger*);
 } else if ([myType isEqualToString:@CGFloat]) {
 myCGFloat = va_arg(myArgumentList, CGFloat);
 } else if ([myType isEqualToString:@CGFloat*]) {
 pMyCGFloat = va_arg(myArgumentList, CGFloat*);
 } ... etc
 ___
 
 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/zav%40mac.com
 
 This email sent to z...@mac.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/zav%40mac.com
 
 This email sent to z...@mac.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/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/xcvista%40me.com
 
 This email sent to xcvi...@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 

Re: -[NSProxy doesNotRecognizeSelector: error

2013-08-22 Thread Shane Stanley
On 22/08/2013, at 3:42 PM, Graham Cox graham@bigpond.com wrote:

 Is there is any possibility that 'self' is not what you think it is? If 
 that's confused, then the proxy is simply reflecting the fact that the object 
 'self' points to doesn't respond to the selector (since its own 
 -respondsToSelector: method just calls the target's).

Not that I can see. Unless...
 
 It's called in a block using:
 
 [[NSOperationQueue mainQueue] addOperationWithBlock:^{
 
 Is there a good reason to do this? Adding an operation to the main queue 
 doesn't really give you much. Blocks complicate things. If you can just call 
 your undo manager -prepare… directly at the point where it's needed, it might 
 flush out the problem, or even fix it.

The process takes a fair amount of time -- it could even be a minute or more -- 
so I'm doing it on a background operation queue. Only if that first part goes 
fine do I update the UI with the result in an undoable fashion, using the 
above. I'm not sure there's a better way.


-- 
Shane Stanley sstan...@myriad-com.com.au
'AppleScriptObjC Explored' www.macosxautomation.com/applescript/apps/


___

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: -[NSProxy doesNotRecognizeSelector: error

2013-08-22 Thread Graham Cox

On 22/08/2013, at 9:43 AM, Shane Stanley sstan...@myriad-com.com.au wrote:

 Not that I can see. Unless…

I suggest logging 'self' at the point you set up your undo. If you can trigger 
the bug, then this will tell you what the real object responsible for the 
exception is - at the moment NSProxy is hiding it from you.


 The process takes a fair amount of time -- it could even be a minute or more 
 -- so I'm doing it on a background operation queue. Only if that first part 
 goes fine do I update the UI with the result in an undoable fashion, using 
 the above. I'm not sure there's a better way.

Maybe post the code that's in the block - someone might spot something iffy.


--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: -[NSProxy doesNotRecognizeSelector: error

2013-08-22 Thread Shane Stanley
On 22/08/2013, at 5:59 PM, Graham Cox graham@bigpond.com wrote:

 I suggest logging 'self' at the point you set up your undo. If you can 
 trigger the bug, then this will tell you what the real object responsible for 
 the exception is - at the moment NSProxy is hiding it from you.

Thanks, I'm trying that, although the app also hijacks stderr. The problem is 
that it only seems to happen very rarely -- not since I started trying to hunt 
it down. Maybe if I say I've fixed it, it'll turn up on, um, queue ;-)

 The process takes a fair amount of time -- it could even be a minute or more 
 -- so I'm doing it on a background operation queue. Only if that first part 
 goes fine do I update the UI with the result in an undoable fashion, using 
 the above. I'm not sure there's a better way.
 
 Maybe post the code that's in the block - someone might spot something iffy.

Nothing exotic:

[[NSOperationQueue mainQueue] addOperationWithBlock:^{
NSUndoManager *undoMan = [[self window] undoManager];
[undoMan beginUndoGrouping];
[[undoMan prepareWithInvocationTarget:self] unCompileWith:[[doc 
scriptViewContents] copy] at:sel1 and:sel2];
if (![undoMan isUndoing]) {
[undoMan setActionName:@Compile];
}
[undoMan setActionIsDiscardable:YES];
// make the changes
[undoMan endUndoGrouping];
}];



-- 
Shane Stanley sstan...@myriad-com.com.au
'AppleScriptObjC Explored' www.macosxautomation.com/applescript/apps/


___

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: handleGetURLEvent getting called after applicationDidFinishLaunching

2013-08-22 Thread Uli Kusterer
On Aug 22, 2013, at 1:08, Jens Alfke j...@mooseyard.com wrote:
 Basically it sounds like the bug is that someone is doing (in pseudocode)
   app = app_for_url_scheme(url.scheme)
   launch_app(app)
   send_url_to_app(url)
 instead of the correct way:
   app = app_for_url_scheme(url.scheme)
   launch_app_with_url(app, url)

The notion of one of these being ‘more correct’ than the other is ridiculous. 
The second case is simply a performance optimization from the classic MacOS 
days that was carried over to OS X. Since a GURL Apple Event (which is what is 
used to send URLs to applications in both cases) can occur at any time, and 
your app may be already running or may need to be launched to be possible to 
send an Apple Event to it, you can never rely on a particular order.

If you need your data to be set up before the GURL Apple Event, write your code 
so it enforces that. E.g. by writing a lazy-loading getter for whatever data 
you currently load in applicationDidFinishLaunching:, and calling it in your 
GURL Apple Event. That decouples it from the (completely unrelated) 
notification.

Cheers,
-- Uli Kusterer
“The Witnesses of TeachText are everywhere...”
http://zathras.de


___

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: handleGetURLEvent getting called after applicationDidFinishLaunching

2013-08-22 Thread Uli Kusterer
On Aug 22, 2013, at 10:34 AM, Uli Kusterer witness.of.teacht...@gmx.net wrote:
 The notion of one of these being ‘more correct’ than the other is ridiculous.

 Maybe ridiculous is a bit too harsh a choice of word, sorry. Let's say I think 
that one of them being 'more correct' makes no difference in practice, and is 
not supported by documentation.

Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de


___

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: Fastest way to replace characters in string

2013-08-22 Thread Diederik Meijer | Ten Horses
Thanks Esteban and Wim,

Indeed, using javascript or jQuery can also be an option.

What actually speeds things up significantly is to revert back to NSString and 
use NSRegularExpression.

I now needs seven seconds on iPad3 to handle 600 replacement actions. This is, 
in itself a VERY long time, but since it is handled by an async task and we 
notify the user that for large law documents this action may take a few 
seconds, the UX should be acceptable, hopefully (up to test group to decide).

Additionally, I can show a progress bar to give visual feedback.

Moreover, less than 5% of the laws included in the app are that large. Most 
laws are handled and updated within two seconds.

Thanks again for thinking with me, I hugely appreciate it.



Best regards,

Diederik



Op Aug 22, 2013, om 1:57 AM heeft Wim Lewis w...@omnigroup.com het volgende 
geschreven:

 
 On 21 Aug 2013, at 4:44 PM, Diederik Meijer | Ten Horses wrote:
 The web service returns the list lightning fast, but in order to get the 
 count number added to each of the 300 articles html h4 header, I am 
 looping through the list and call NSString's 
 stringByReplacingOccurancesOfString:withString: on each item.
 
 There must be a more efficient way to update the html string loaded from the 
 local file, obviously doing more than 300 of these replace actions is slow 
 and inefficient.
 
 The -stringByReplacing... method has to copy the entire string each time you 
 do a replacement. You might be able to get a significant speedup making a 
 mutable copy of the original string, calling 
 -replaceOccurrencesOfString:withString: repeatedly, and (possibly) calling 
 -copy to make a final immutable copy.
 
 Depending on what you're doing, though, it might make more sense to load the 
 original string into the WebView and manipulate the WebView's DOM to update 
 all of the counts and things.
 
 
 
 ___
 
 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/diederik%40tenhorses.com
 
 This email sent to diede...@tenhorses.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: Fastest way to replace characters in string

2013-08-22 Thread Marcel Weiher
Hi Diederik,


On Aug 22, 2013, at 1:44 , Diederik Meijer | Ten Horses 
diede...@tenhorses.com wrote:

 The content is quite large, about 1MB, it is the full text of a law.

Hmm…that isn’t really that large, we have GHz computing buzz-saws!

 The web service returns the list lightning fast, but in order to get the 
 count number added to each of the 300 articles html h4 header, I am 
 looping through the list and call NSString's 
 stringByReplacingOccurancesOfString:withString: on each item.
 
 There must be a more efficient way to update the html string loaded from the 
 local file, obviously doing more than 300 of these replace actions is slow 
 and inefficient.

The reason this is slow and inefficient is that you are making repeated (small) 
changes to a (somewhat) large data set, so your running time is n*m, where n is 
the size of the string and m is the number of substitutions.  Probably the 
simplest way of handling this within the current setup is to aggregate the 
result incrementally, rather than mutating the original repeatedly, which makes 
this process linear in n and roughly independent of the number of 
substitutions.  For example, as a rough sketch consider the following:

—— snip ——
NSString *addNumbers( NSString *inhtml ) {
NSMutableString *target=[NSMutableString string];
int inlen=[inhtml length];
int startPos=0;
int done=NO;
int currentNo=1;
do {

  NSRange r=[inhtml rangeOfString:@h4 options:NSCaseInsensitiveSearch 
range:NSMakeRange(startPos,inlen-
  if ( r.length  0 ) {
int curPos=r.location;
[target appendString:[inhtml 
substringWithRange:NSMakeRange(startPos,curPos-startPos)]];
[target appendFormat:@h4%d ,currentNo++];
startPos=curPos+4;
  } else {
done=YES;
  }
} while (!done);
[target appendString:[inhtml 
substringWithRange:NSMakeRange(startPos,inlen-startPos)]];
return target;
}
—— snip ——

This processes a 2.8MB sample file with upwards of 30K substitutions in 70ms on 
my MacBook Pro, or pretty much exactly 25 ms per MB.  On your iPad 3, my guess 
is that you’ll get it processed in around 1/4 second or so.  

If you need to go faster, switching to byte processing instead of string 
processing (using NSData and C string processing functions) gets you another 
factor of 5, for 5ms per MB on my MacBook Pro or around 1/20 second on an iPad.

Cheers,

Marcel

___

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

repeating timer with run now

2013-08-22 Thread Torsten Curdt
I have some piece of code that I want to run every x seconds but I
also want to be able to trigger a run now that will reset the
upcoming cycle.

I think I would know plenty of ways to implement this (ranging from
simple NSTimer to select() style signaling to threading with
conditions) but I am looking for the most elegant way - preferably
with GCD.

Scheduling a block is easy with GCD - but can you also notify that
block for immediate execution later on?

Just would love to hear opinions on how you would tackle this
admittedly easy problem the most elegant way.

cheers,
Torsten
___

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: repeating timer with run now

2013-08-22 Thread Jean-Daniel Dupas

Le 22 août 2013 à 15:36, Torsten Curdt tcu...@vafer.org a écrit :

 I have some piece of code that I want to run every x seconds but I
 also want to be able to trigger a run now that will reset the
 upcoming cycle.
 
 I think I would know plenty of ways to implement this (ranging from
 simple NSTimer to select() style signaling to threading with
 conditions) but I am looking for the most elegant way - preferably
 with GCD.
 
 Scheduling a block is easy with GCD - but can you also notify that
 block for immediate execution later on?
 
 Just would love to hear opinions on how you would tackle this
 admittedly easy problem the most elegant way.


Why not just keeping a reference on your scheduled block and simply call 
dispatch_async when you want to execute it immediately ?

-- Jean-Daniel





___

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: repeating timer with run now

2013-08-22 Thread Torsten Curdt
 Why not just keeping a reference on your scheduled block and simply call 
 dispatch_async when you want to execute it immediately ?

It would not re-schedule the timer. So the block could potentially be
run twice without much of the desired delay in between.

The logic should be something along the lines of

  def run_now
invalidate timer (if there is one running)
run block
schedule timer to run block in x seconds
  end

Just to explain the desire behaviour.
___

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: repeating timer with run now

2013-08-22 Thread Jean-Daniel Dupas

Le 22 août 2013 à 16:08, Torsten Curdt tcu...@vafer.org a écrit :

 Why not just keeping a reference on your scheduled block and simply call 
 dispatch_async when you want to execute it immediately ?
 
 It would not re-schedule the timer. So the block could potentially be
 run twice without much of the desired delay in between.
 
 The logic should be something along the lines of
 
  def run_now
invalidate timer (if there is one running)
run block
schedule timer to run block in x seconds
  end
 
 Just to explain the desire behaviour.


OK, so I think you can just call dispatch_source_set_timer() each time you want 
to immediately execute your timer and reschedule it, passing 'now' as 'start' 
argument and your interval as 'interval' argument.

-- Jean-Daniel





___

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

A little tip for those searching the docs now that developer.apple.com has been rebuilt.

2013-08-22 Thread Alex Zavatone
I know we touched on the topic of some links to developer.apple.com being 
broken after the site rebuild, but I hope that this is the answer to most of 
the broken link issues.

I was looking for some concurrency info and in a post about it, there was a 
link to this URL in the dev docs:

http://developer.apple.com/library/ios/#documentation/General/Conceptual/ConcurrencyProgrammingGuide/Introduction/Introduction.html

It's no longer valid and resolves to a URL which is not what I was looking for:

https://developer.apple.com/library/ios/navigation/

Not fun.

What appears to be the change (and solution) is nice and simple though.  The # 
character in the URL is no longer needed.  Removing it loads the URL, redirects 
to HTTPS and the content loads as expected.

http://developer.apple.com/library/ios/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Introduction/Introduction.html

If any of you encounter broken links to URLs in the docs at 
developer.apple.com, try checking the URL for that # char.  Hopefully, just 
removing that will solve any broken link issues.

Cheers.
___

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: handleGetURLEvent getting called after applicationDidFinishLaunching

2013-08-22 Thread Jens Alfke

On Aug 22, 2013, at 1:34 AM, Uli Kusterer witness.of.teacht...@gmx.net wrote:

 The notion of one of these being ‘more correct’ than the other is ridiculous. 
 The second case is simply a performance optimization from the classic MacOS 
 days that was carried over to OS X.

Nope. (And not to pull rank, but I was on the AppleEvents/AppleScript team at 
the time we figured this stuff out [1991] and added the seemingly-useless 
‘oapp’ event in response to developer complaints.)

Many apps have a different behavior when launched with no docs/URLs (e.g. the 
app itself is double-clicked). For example, Apple’s iWork apps open a 
new-document assistant. The only reliable way an app can tell whether it was 
launched without a doc/URL is if it gets the ‘oapp’ event instead, and the way 
that event gets sent is when LaunchServices is told to launch the app but not 
given any other AppleEvent to launch it with. Thus there is a valuable semantic 
difference between the two cases.

 Since a GURL Apple Event (which is what is used to send URLs to applications 
 in both cases) can occur at any time, and your app may be already running or 
 may need to be launched to be possible to send an Apple Event to it, you can 
 never rely on a particular order.

Sure, an app has to be prepared to receive ‘odoc' or ‘GURL’ events while 
running. But that’s a different case from at launch, as I explained.

—Jens
___

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: Fastest way to replace characters in string

2013-08-22 Thread Jens Alfke

On Aug 22, 2013, at 3:05 AM, Diederik Meijer | Ten Horses 
diede...@tenhorses.com wrote:

 What actually speeds things up significantly is to revert back to NSString 
 and use NSRegularExpression.
 I now needs seven seconds on iPad3 to handle 600 replacement actions. This 
 is, in itself a VERY long time

Indeed.; that’s incredibly slow. You should be able to do this in a handful of 
milliseconds. Don’t make your users suffer through a progress meter because you 
couldn’t find the right optimization :)

The right way to do this is by scanning through the original string and writing 
to a new mutable string. Using replaceCharacters on a mutable string isn’t much 
of a speedup because it keeps copying characters in the mutable string over and 
over (and copying the entire string if its buffer needs to grow.)

create the empty output mutable string with sufficient capacity (i.e. maybe 2x 
the input string length)
set pos to 0
repeat
find next instance of marker in original string starting from index 
‘pos’
if none found
break
append input characters from ‘pos’ to start of marker to output string
append replacement characters to output string
advance ‘pos’ to end of marker
end

I would guess that most algorithms textbooks describe things like this in more 
detail.

—Jens
___

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: handleGetURLEvent getting called after applicationDidFinishLaunching

2013-08-22 Thread Kyle Sluder
On Aug 22, 2013, at 8:00 AM, Jens Alfke j...@mooseyard.com wrote:

 
 On Aug 22, 2013, at 1:34 AM, Uli Kusterer witness.of.teacht...@gmx.net 
 wrote:
 
 The notion of one of these being ‘more correct’ than the other is 
 ridiculous. The second case is simply a performance optimization from the 
 classic MacOS days that was carried over to OS X.
 
 Nope. (And not to pull rank, but I was on the AppleEvents/AppleScript team at 
 the time we figured this stuff out [1991] and added the seemingly-useless 
 ‘oapp’ event in response to developer complaints.)
 
 Many apps have a different behavior when launched with no docs/URLs (e.g. the 
 app itself is double-clicked). For example, Apple’s iWork apps open a 
 new-document assistant. The only reliable way an app can tell whether it was 
 launched without a doc/URL is if it gets the ‘oapp’ event instead, and the 
 way that event gets sent is when LaunchServices is told to launch the app but 
 not given any other AppleEvent to launch it with. Thus there is a valuable 
 semantic difference between the two cases.

In your example, the difference doesn't matter. If the app is sitting at the 
new doc assistant, or has a default blank document open, it should close that 
assistant or document and open the one requested via URL. Apps have been doing 
this for decades.

--Kyle Sluder
___

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: handleGetURLEvent getting called after applicationDidFinishLaunching

2013-08-22 Thread Bradley O'Hearne
On Aug 22, 2013, at 9:00 AM, Kyle Sluder k...@ksluder.com wrote:

 On Aug 22, 2013, at 8:00 AM, Jens Alfke j...@mooseyard.com wrote:
 
 
 On Aug 22, 2013, at 1:34 AM, Uli Kusterer witness.of.teacht...@gmx.net 
 wrote:
 
 The notion of one of these being ‘more correct’ than the other is 
 ridiculous. The second case is simply a performance optimization from the 
 classic MacOS days that was carried over to OS X.
 
 Nope. (And not to pull rank, but I was on the AppleEvents/AppleScript team 
 at the time we figured this stuff out [1991] and added the seemingly-useless 
 ‘oapp’ event in response to developer complaints.)
 
 Many apps have a different behavior when launched with no docs/URLs (e.g. 
 the app itself is double-clicked). For example, Apple’s iWork apps open a 
 new-document assistant. The only reliable way an app can tell whether it was 
 launched without a doc/URL is if it gets the ‘oapp’ event instead, and the 
 way that event gets sent is when LaunchServices is told to launch the app 
 but not given any other AppleEvent to launch it with. Thus there is a 
 valuable semantic difference between the two cases.
 

Jens -- this is exactly the scenario which I had expected, which it appears is 
not always the case. 

 In your example, the difference doesn't matter. If the app is sitting at the 
 new doc assistant, or has a default blank document open, it should close that 
 assistant or document and open the one requested via URL. Apps have been 
 doing this for decades.

Kyle -- understood that it can be done, and understood that apps need to be 
prepared to open (or respond) to a registered handler, even if the app is 
already running. But visually there is potential for  weirdness on launch if 
your app has to complete loading while being completely deprived of the way or 
reason it was launched, and having no knowledge of whether that info will ever 
be delivered to the app. During loading, you have to assume the app was 
launched independently by the user (not by an open event), which likely will 
cause you to load and present some UI to address where a user likely will start 
their use of the app (like the new document assistant Jens mentioned). Then if 
you receive the URL handler callback, you immediately whisk that away and 
present the opened document. That is going to be perceived as some kind of 
malfunction by the user -- I've fixed more than one of those launch flickers, 
almost always considered bugs (despite whether they were otherwise logically 
correct). 

While this may well be true that there is no sequence, this one developer's 
view is that while an app should be able to respond to any downstream open 
event while running, it makes no sense to arbitrarily deliver or delay 
information about how an app was launched to the app sometime after the launch 
loading is complete. That effectively suggests having to poll and eventually 
timeout in order to get the initial UI display right, which seems really 
unnecessary if the proper protocol is just to tell an app when loading how it 
was launched. 

Brad
___

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: Fastest way to replace characters in string

2013-08-22 Thread Keary Suska

On Aug 22, 2013, at 9:06 AM, Jens Alfke wrote:

 create the empty output mutable string with sufficient capacity (i.e. maybe 
 2x the input string length)

On an entirely different note, does the various initWithCapacity methods of 
mutable classes actually do any pre-allocation? Last I understood they really 
didn't...

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Fastest way to replace characters in string

2013-08-22 Thread Thomas Wetmore
Pre-allocation doesn't really matter as long as the re-allocations, whenever 
they occur, respect the capacity argument.

Tom Wetmore

On Aug 22, 2013, at 1:22 PM, Keary Suska cocoa-...@esoteritech.com wrote:

 On Aug 22, 2013, at 9:06 AM, Jens Alfke wrote:
 
 create the empty output mutable string with sufficient capacity (i.e. maybe 
 2x the input string length)
 
 On an entirely different note, does the various initWithCapacity methods of 
 mutable classes actually do any pre-allocation? Last I understood they really 
 didn't...
 
 Keary Suska


___

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: Fastest way to replace characters in string

2013-08-22 Thread Steve Mills
On Aug 22, 2013, at 12:31:55, Thomas Wetmore t...@verizon.net
 wrote:

 Pre-allocation doesn't really matter as long as the re-allocations, whenever 
 they occur, respect the capacity argument.

Sure they do. If you don't preallocate, but instead keep appending, and the 
pointer needs to grow with every append, it *could* reallocate with every 
append.

--
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: Fastest way to replace characters in string

2013-08-22 Thread Thomas Wetmore
Steve,

I apologize that what I wrote wasn't clear. Pre-allocation simply means to 
allocate space BEFORE you need it. And all that means is that the FIRST 
allocation doesn't occur at init time, but WAITS until you actually put 
something in the string or container. From that point of view pre-allocation is 
NEVER required. As I said, the capacity argument MUST BE RESPECTED at the point 
of the first allocation, whenever that occurs, and at all following 
re-allocations. My assumption has always been that the capacity increment of 
each subsequent allocation may grow from the initial capacity size.

Tom Wetmore

On Aug 22, 2013, at 1:43 PM, Steve Mills smi...@makemusic.com wrote:

 On Aug 22, 2013, at 12:31:55, Thomas Wetmore t...@verizon.net
 wrote:
 
 Pre-allocation doesn't really matter as long as the re-allocations, whenever 
 they occur, respect the capacity argument.
 
 Sure they do. If you don't preallocate, but instead keep appending, and the 
 pointer needs to grow with every append, it *could* reallocate with every 
 append.
 
 --
 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/ttw4%40verizon.net
 
 This email sent to t...@verizon.net


___

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: Fastest way to replace characters in string

2013-08-22 Thread Thomas Wetmore
Steve,

Sorry, again I was unclear. Here is what I am trying to say:

Pre-allocation means to allocate space before you need it, which would be at 
init time.

But there is no need to pre-allocate -- the first allocation can be postponed 
until the first item is put in the container or characters in the string.

I assume the capacity argument is used at that first allocation.

Pre-allocation and the capacity argument are wholly orthogonal concepts.

Tom Wetmore
___

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: Fastest way to replace characters in string

2013-08-22 Thread Keary Suska
On Aug 22, 2013, at 12:05 PM, Thomas Wetmore wrote:

 Steve,
 
 Sorry, again I was unclear. Here is what I am trying to say:
 
 Pre-allocation means to allocate space before you need it, which would be at 
 init time.
 
 But there is no need to pre-allocate -- the first allocation can be postponed 
 until the first item is put in the container or characters in the string.
 
 I assume the capacity argument is used at that first allocation.
 
 Pre-allocation and the capacity argument are wholly orthogonal concepts.


I googled around and found a post at StackOverflow 
(http://stackoverflow.com/questions/8636983/what-is-the-best-way-to-initialize-nsmutablestring-object)
 that links to the open-source implementation of CFString. From there you can 
see what the optimization technique is, although I didn't notice *when* it 
allocates.

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Lack of IBAction in Some Classes

2013-08-22 Thread Gordon Apple
Sorry for the delay.  Got waylaid by my own issues.  I guess that¹s the
case.  Without re-declaring the header, it just doesn¹t show up in IB.


On 8/12/13 4:05 PM, Kyle Sluder k...@ksluder.com wrote:

 On Mon, Aug 12, 2013, at 01:44 PM, Gordon Apple wrote:
  Is there some reason why some classes, such as NSTextView, don¹t declare
  IBAction in their actions?
 
 Possibly because they predate IBAction? IB used to just look for methods
 that took an id argument and returned void.
 
  I¹ve taken to re-declaring such in
  subclasses,
  which works, but results in compiler warnings about unimplemented
  methods.
  Without that, you can¹t connect, say, a menu, in IB.  You can use a
  binding,
  but if you want the ³sender² parameter, you are SOL.  Am I missing
  something?
 
 Does IB really not allow you to connect to such legacy methods?
 
 --Kyle Sluder


___

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: Issues with NSTextView Attachments

2013-08-22 Thread Gordon Apple
I¹ve successfully managed to override Paste and PerformDrag to embed images
which are resizable and with specified fractional (fraction of
height)baseline offsets.  They also archive and unarchive properly.  I¹m
using a custom TextAttachmentextCell which archives the size and the
fractional baseline offset, and returns the appropriate values to draw
properly.  Undo/redo even works.  However, it¹s still not right.  I cannot
copy/pasts or drag/drop a text segment containing the attachment without
losing the attachment.  NSTextView¹s handling of images, without my
enhancements, does this correctly.  So what am I missing?

I don¹t really understand the various ³fix² methods.  When I did my own text
editor (pre-OSX), which was uses in some Mayo Clinic multimedia CDs, I
handled all this automatically when pasting, etc.  I did put in a
fixAttachmentAttributeInRange call after insertion.  That didn¹t help.


On 8/10/13 12:31 PM, Gordon Apple g...@ed4u.com wrote:

 Using NSTextView¹s native ability to embed image attachments, we have
 successfully implemented resizing of the image by using a resizable frame with
 a drag handle, and using setSize on the NSImage.  Works great.  Only one
 problem, re-archiving the NSAttributableString loses the image size change.
 Any way to fix this?  Internally, in a CoreData auxiliary file folder, we
 archive NSAttributableString.  Would we be better off storing it as RTFD?
 
 I also see allusions to subclasses of NSTextAttachment, but I see no way to
 tell NSTextView, or its associates, to use such a subclass.
 NSTextAttachmentCell is a protocol.  But who adopts this protocol?  For an
 image, is this really a NSImageCell adopting this protocol?  Or is it the
 NSTextAttachment?  Confusion here.  Documentation on attachments is sparse.
 
 We would also like to have the ability to set the baseline when an image is
 inserted, and change it when the image is resized.  Certain NSPDFImageReps
 contain baseline info in private dictionaries, which we would like to use,
 when available. In view of the above, should we abandon NSTextView¹s
 paste/drag-in capabilities for images and override all the relevant methods to
 do our own attachment inserts using a custom NSAttachment class?
 
 Related question about NSImage.  I¹ve never understood setSize in NSImage.
 Does this just affect the cached image, or does it have any impact on the
 underlying imageRep, such as resizing and remapping a bitmap?
 
 One more:  I¹ve never found a straightforward way to make a textView re-layout
 all or a portion of the text.  The best way I¹ve found is to call
 textContainerChangedGeometry.  Works, but seems rather obtuse.
 
 Inquiring minds need to know.


___

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: Fastest way to replace characters in string

2013-08-22 Thread Marcel Weiher

On Aug 22, 2013, at 19:43 , Steve Mills smi...@makemusic.com wrote:

 On Aug 22, 2013, at 12:31:55, Thomas Wetmore t...@verizon.net
 wrote:
 
 Pre-allocation doesn't really matter as long as the re-allocations, whenever 
 they occur, respect the capacity argument.
 
 Sure they do. If you don't preallocate, but instead keep appending, and the 
 pointer needs to grow with every append, it *could* reallocate with every 
 append.

But that’s not how it’s typically implemented, you usually get some sort of 
exponential growth ( 2x or optimally something around 1.5x ), so amortized 
re-allocation cost on growth tends to be dominated by other factors.  Using the 
NSData variant of the algorithm I presented earlier and averaging over 4 runs 
each, I get a 2.5% difference.  Considering the factor 10-50 or more from the 
other optimizations, that’s pretty negligible, and was also significantly less 
than the variance between runs (so we would need a whole lot more runs to see 
whether the difference is actually real, chances are it isn’t).

Despite the fact that I am somewhat performance-obsessed, I tend to not 
pre-allocate.

Cheers,

Marcel


___

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: Issues with NSTextView Attachments

2013-08-22 Thread glenn andreas
When NSTextView puts rich content on a pasteboard (for copy/paste or 
drag/drop), it converts the text to RTF.  RTF has no concept of custom text 
attachment cells, so they get dropped.

You'll need to add your own custom data type that preserves that content (such 
using an archive)


On Aug 22, 2013, at 1:48 PM, Gordon Apple g...@ed4u.com wrote:

 I¹ve successfully managed to override Paste and PerformDrag to embed images
 which are resizable and with specified fractional (fraction of
 height)baseline offsets.  They also archive and unarchive properly.  I¹m
 using a custom TextAttachmentextCell which archives the size and the
 fractional baseline offset, and returns the appropriate values to draw
 properly.  Undo/redo even works.  However, it¹s still not right.  I cannot
 copy/pasts or drag/drop a text segment containing the attachment without
 losing the attachment.  NSTextView¹s handling of images, without my
 enhancements, does this correctly.  So what am I missing?
 
 I don¹t really understand the various ³fix² methods.  When I did my own text
 editor (pre-OSX), which was uses in some Mayo Clinic multimedia CDs, I
 handled all this automatically when pasting, etc.  I did put in a
 fixAttachmentAttributeInRange call after insertion.  That didn¹t help.
 
 
 On 8/10/13 12:31 PM, Gordon Apple g...@ed4u.com wrote:
 
 Using NSTextView¹s native ability to embed image attachments, we have
 successfully implemented resizing of the image by using a resizable frame 
 with
 a drag handle, and using setSize on the NSImage.  Works great.  Only one
 problem, re-archiving the NSAttributableString loses the image size change.
 Any way to fix this?  Internally, in a CoreData auxiliary file folder, we
 archive NSAttributableString.  Would we be better off storing it as RTFD?
 
 I also see allusions to subclasses of NSTextAttachment, but I see no way to
 tell NSTextView, or its associates, to use such a subclass.
 NSTextAttachmentCell is a protocol.  But who adopts this protocol?  For an
 image, is this really a NSImageCell adopting this protocol?  Or is it the
 NSTextAttachment?  Confusion here.  Documentation on attachments is sparse.
 
 We would also like to have the ability to set the baseline when an image is
 inserted, and change it when the image is resized.  Certain NSPDFImageReps
 contain baseline info in private dictionaries, which we would like to use,
 when available. In view of the above, should we abandon NSTextView¹s
 paste/drag-in capabilities for images and override all the relevant methods 
 to
 do our own attachment inserts using a custom NSAttachment class?
 
 Related question about NSImage.  I¹ve never understood setSize in NSImage.
 Does this just affect the cached image, or does it have any impact on the
 underlying imageRep, such as resizing and remapping a bitmap?
 
 One more:  I¹ve never found a straightforward way to make a textView 
 re-layout
 all or a portion of the text.  The best way I¹ve found is to call
 textContainerChangedGeometry.  Works, but seems rather obtuse.
 
 Inquiring minds need to know.
 
 
 ___
 
 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/gandreas%40me.com
 
 This email sent to gandr...@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

frame puzzle

2013-08-22 Thread David Rowland


  CGRect tframe = CGRectMake(12, 12, 100, 100);
  [appDelegate.buttonController.rotationControl setFrame:tframe];
  CGRect qframe = appDelegate.buttonController.rotationControl.frame;


buttonController is a UIViewController, rotationControl is a UIControl. When 
this is executed qframe is reported as (0, 0, 0, 0). Does anyone see what is 
wrong?

thanks,

David


___

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: frame puzzle

2013-08-22 Thread Jeff Kelley
If any of appDelegate, appDelegate.buttonController, or
appDelegate.buttonController.rotationControl return nil, then the value of
appDelegate.buttonController.rotationControl.frame will be a zeroed-out
struct.

Jeff Kelley


On Thu, Aug 22, 2013 at 4:05 PM, David Rowland rowla...@sbcglobal.netwrote:



   CGRect tframe = CGRectMake(12, 12, 100, 100);
   [appDelegate.buttonController.rotationControl setFrame:tframe];
   CGRect qframe = appDelegate.buttonController.rotationControl.frame;


 buttonController is a UIViewController, rotationControl is a UIControl.
 When this is executed qframe is reported as (0, 0, 0, 0). Does anyone see
 what is wrong?

 thanks,

 David


 ___

 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/slaunchaman%40gmail.com

 This email sent to slauncha...@gmail.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: frame puzzle

2013-08-22 Thread Robert Vojta

On 22. 8. 2013, at 22:05, David Rowland rowla...@sbcglobal.net wrote:

  CGRect tframe = CGRectMake(12, 12, 100, 100);
  [appDelegate.buttonController.rotationControl setFrame:tframe];
  CGRect qframe = appDelegate.buttonController.rotationControl.frame;
 
 buttonController is a UIViewController, rotationControl is a UIControl. When 
 this is executed qframe is reported as (0, 0, 0, 0). Does anyone see what is 
 wrong?

Probably your appDelegate, buttonController or rotationControl is nil … Read 
Programming with Objective - C - Working with objects [1] if this is the case. 
Members of returned struct are zeroed in this case (search for nil messaging, 
message to nil, …).

[1] 
https://developer.apple.com/library/ios/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/WorkingwithObjects/WorkingwithObjects.html#//apple_ref/doc/uid/TP40011210-CH4-SW22
___

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: Variable Number of Parameters in Method

2013-08-22 Thread Lee Ann Rucker

On Aug 21, 2013, at 11:37 PM, Dave wrote:

 Hi,
 
 It's not much good to me since I don't have a problem passing objects but 
 with passing a mixed set.
 
 Type passing, 1,2,3,5.6,@hello,nil to the arrayWithObjects and you will see 
 what I mean
 
 Cheers
 Dave

But 1,2,3 etc aren't objects. I keep looking at your concept and wondering how 
you expect to handle an integer that happens to be 0. We've got code that takes 
mixed parameters but everything - even the objects - has to be in pointers. 
It's a wrapper around NSInvocation, so eventually a standard method is going to 
get it; no type-guessing involved.
___

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: frame puzzle

2013-08-22 Thread David Rowland
Good suggestion, but such is not the case. Most strange is that when I set a 
breakpoint and use control-click to print a description of rotationControl to 
the log, it shows a valid non-zero frame although qframe is zero. I have 
checked for zombies, but none reported.





On Aug 22, 2013, at 1:10 PM, Jeff Kelley slauncha...@gmail.com wrote:

 If any of appDelegate, appDelegate.buttonController, or
 appDelegate.buttonController.rotationControl return nil, then the value of
 appDelegate.buttonController.rotationControl.frame will be a zeroed-out
 struct.
 
 Jeff Kelley
 
 
 On Thu, Aug 22, 2013 at 4:05 PM, David Rowland rowla...@sbcglobal.netwrote:
 
 
 
  CGRect tframe = CGRectMake(12, 12, 100, 100);
  [appDelegate.buttonController.rotationControl setFrame:tframe];
  CGRect qframe = appDelegate.buttonController.rotationControl.frame;
 
 
 buttonController is a UIViewController, rotationControl is a UIControl.
 When this is executed qframe is reported as (0, 0, 0, 0). Does anyone see
 what is wrong?
 
 thanks,
 
 David
 
 
 ___
 
 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/slaunchaman%40gmail.com
 
 This email sent to slauncha...@gmail.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/rowlandd%40sbcglobal.net
 
 This email sent to rowla...@sbcglobal.net


___

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: frame puzzle

2013-08-22 Thread Quincey Morris
On Aug 22, 2013, at 13:42 , David Rowland rowla...@sbcglobal.net wrote:

 Good suggestion, but such is not the case. Most strange is that when I set a 
 breakpoint and use control-click to print a description of rotationControl to 
 the log, it shows a valid non-zero frame although qframe is zero. I have 
 checked for zombies, but none reported.

One thing to keep in mind is that frame is a *derived* property in iOS. 
Further, its value is meaningless if the view's transform is anything other 
than the identity.

If you're seeing weird values for frame, your very first strategy should be 
to examine center and bounds separately. If they contain the expected 
values, then there's probably a good reason why frame is meaningless in your 
scenario, so don't use it. If they don't, you know that you need to look at 
other factors to determine what's going on.

In your scenario, though, perhaps rotationControl actually uses rotation of 
its own visual appearance to represent its own value. In that case, setting its 
frame property isn't going to work.

___

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: frame puzzle

2013-08-22 Thread David Rowland
Pain and humiliation.

I had moved things around and put rotationControl in a new place. However, I 
failed to @synthesize it, so it was lumbered with rotationControl and 
_rotationControl. Fixed that, works just as it should.

Thanks to several of you for the attention.

David


On Aug 22, 2013, at 3:19 PM, Quincey Morris 
quinceymor...@rivergatesoftware.com wrote:

 On Aug 22, 2013, at 13:42 , David Rowland rowla...@sbcglobal.net wrote:
 
 Good suggestion, but such is not the case. Most strange is that when I set a 
 breakpoint and use control-click to print a description of rotationControl 
 to the log, it shows a valid non-zero frame although qframe is zero. I have 
 checked for zombies, but none reported.
 
 One thing to keep in mind is that frame is a *derived* property in iOS. 
 Further, its value is meaningless if the view's transform is anything other 
 than the identity.
 
 If you're seeing weird values for frame, your very first strategy should be 
 to examine center and bounds separately. If they contain the expected 
 values, then there's probably a good reason why frame is meaningless in 
 your scenario, so don't use it. If they don't, you know that you need to look 
 at other factors to determine what's going on.
 
 In your scenario, though, perhaps rotationControl actually uses rotation of 
 its own visual appearance to represent its own value. In that case, setting 
 its frame property isn't going to work.
 

___

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: handleGetURLEvent getting called after applicationDidFinishLaunching

2013-08-22 Thread Jens Alfke

On Aug 22, 2013, at 9:00 AM, Kyle Sluder k...@ksluder.com wrote:

 In your example, the difference doesn't matter. If the app is sitting at the 
 new doc assistant, or has a default blank document open, it should close that 
 assistant or document and open the one requested via URL. Apps have been 
 doing this for decades.

Well, modulo some flickering.

Actually I forgot the more significant case — apps that open an untitled 
document when launched (which used to be the official thing to do per the HI 
Guidelines.) Without the ‘oapp’ event, they’d open first an untitled doc and 
then the document that had been double-clicked.

—Jens
___

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: Issues with NSTextView Attachments

2013-08-22 Thread Gordon Apple
I guess the operative word here is ³custom².  So how does NSTextView handle
attachments which are not custom, because it does?  Why not RTFD?  I thought
RTF didn¹t handle attachments.

So, it looks like I need to archive the attributed string segment as a
custom pboard type, in addition to the normal RTF, and prioritize that.  In
my (internal) storage, I generally just archive the attributed string.


On 8/22/13 2:02 PM, glenn andreas gandr...@me.com wrote:

 When NSTextView puts rich content on a pasteboard (for copy/paste or
 drag/drop), it converts the text to RTF.  RTF has no concept of custom text
 attachment cells, so they get dropped.
 
 You'll need to add your own custom data type that preserves that content (such
 using an archive)
 

___

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: Fastest way to replace characters in string

2013-08-22 Thread Jens Alfke

On Aug 22, 2013, at 11:05 AM, Thomas Wetmore t...@verizon.net wrote:

 Pre-allocation means to allocate space before you need it, which would be at 
 init time.
 But there is no need to pre-allocate -- the first allocation can be postponed 
 until the first item is put in the container or characters in the string.

This is nit-picking (and btw, that optimization doesn’t sound very useful to 
me.) 

The point is that using -initWithCapacity: is a good optimization because it 
reduces, and hopefully eliminates, re-allocation of the backing store.

—Jens
___

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: handleGetURLEvent getting called after applicationDidFinishLaunching

2013-08-22 Thread Shane Stanley
On 23/08/2013, at 9:36 AM, Jens Alfke j...@mooseyard.com wrote:

 Nope. (And not to pull rank, but I was on the AppleEvents/AppleScript team at 
 the time we figured this stuff out [1991] and added the seemingly-useless 
 ‘oapp’ event in response to developer complaints.)

snip

 Actually I forgot the more significant case — apps that open an untitled 
 document when launched (which used to be the official thing to do per the HI 
 Guidelines.) Without the ‘oapp’ event, they’d open first an untitled doc and 
 then the document that had been double-clicked.

Jens,

Are you sure you're not misremembering? That sounds more like the 'noop' event, 
aka launch command.

If so, I'd point out that it's broken (as in behaves like 'oapp', aka run) in 
the current OS, and has been for some time.

-- 
Shane Stanley sstan...@myriad-com.com.au
'AppleScriptObjC Explored' www.macosxautomation.com/applescript/apps/


___

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: handleGetURLEvent getting called after applicationDidFinishLaunching

2013-08-22 Thread Bradley O'Hearne

On Aug 22, 2013, at 5:44 PM, Shane Stanley sstan...@myriad-com.com.au wrote:

 If so, I'd point out that it's broken (as in behaves like 'oapp', aka run) 
 in the current OS, and has been for some time.

Shane, 

Just to clarify -- it is broken in that it's behavior doesn't specifically 
what instead of doing specifically what?

Thanks, 

Brad
___

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: Issues with NSTextView Attachments

2013-08-22 Thread Kyle Sluder
On Thu, Aug 22, 2013, at 04:40 PM, Gordon Apple wrote:
 I guess the operative word here is ³custom².  So how does NSTextView
 handle
 attachments which are not custom, because it does?  Why not RTFD?  I
 thought
 RTF didn¹t handle attachments.

It uses RTFD, but it might be the case that RTFD might only support file
wrappers.

Have you implemented -[NSTextViewDelegate
textView:writablePasteboardTypesForCell:atIndex:] and
-[NSTextViewDelegate textView:writeCell:atIndex:toPasteboard:type:]?

--Kyle Sluder

___

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: handleGetURLEvent getting called after applicationDidFinishLaunching

2013-08-22 Thread Shane Stanley
On 23/08/2013, at 10:53 AM, Bradley O'Hearne br...@bighillsoftware.com wrote:

 Just to clarify -- it is broken in that it's behavior doesn't specifically 
 what instead of doing specifically what?

The actual bug was logged on AppleScript behavior, so excuse the diversion -- I 
suspect you can extrapolate. Traditionally the launch command was used to 
launch an app but not make it active, thus avoiding splash screens and new 
documents that appeared with the run command, or where there was no explicit 
run/launch command. In 10.5 launching in the background was made the default 
behavior, so launch was rarely needed. However, if you saved an AppleScript 
application, and launched it from a separate script or app using the launch 
command, it would launch but not call its run handler. At some stage, possibly 
as far back as 10.7, this changed, and launch now behaves exactly the same as 
run ('oapp') in such cases. I don't think the change was the result of anything 
done to AppleScript, so I suspect it's something further upstream, in AppKit or 
launch services.

-- 
Shane Stanley sstan...@myriad-com.com.au
'AppleScriptObjC Explored' www.macosxautomation.com/applescript/apps/


___

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: handleGetURLEvent getting called after applicationDidFinishLaunching

2013-08-22 Thread Shane Stanley
On 23/08/2013, at 10:44 AM, Shane Stanley sstan...@myriad-com.com.au wrote:

 Jens,
 
 Are you sure you're not misremembering?

And he was not...

-- 
Shane Stanley sstan...@myriad-com.com.au
'AppleScriptObjC Explored' www.macosxautomation.com/applescript/apps/

___

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: handleGetURLEvent getting called after applicationDidFinishLaunching

2013-08-22 Thread Uli Kusterer
On Aug 22, 2013, at 18:29, Bradley O'Hearne br...@bighillsoftware.com wrote:
 On Aug 22, 2013, at 9:00 AM, Kyle Sluder k...@ksluder.com wrote:
 On Aug 22, 2013, at 8:00 AM, Jens Alfke j...@mooseyard.com wrote:
 On Aug 22, 2013, at 1:34 AM, Uli Kusterer witness.of.teacht...@gmx.net 
 wrote:
 
 The notion of one of these being ‘more correct’ than the other is 
 ridiculous. The second case is simply a performance optimization from the 
 classic MacOS days that was carried over to OS X.
 
 Nope. (And not to pull rank, but I was on the AppleEvents/AppleScript team 
 at the time we figured this stuff out [1991] and added the 
 seemingly-useless ‘oapp’ event in response to developer complaints.)
 
  While this may well be true that there is no sequence, this one developer's 
 view is that while an app should be able to respond to any downstream open 
 event while running, it makes no sense to arbitrarily deliver or delay 
 information about how an app was launched to the app sometime after the 
 launch loading is complete. That effectively suggests having to poll and 
 eventually timeout in order to get the initial UI display right, which seems 
 really unnecessary if the proper protocol is just to tell an app when loading 
 how it was launched. 

Sorry, I misunderstood your original post then. Of course, if you’re looking at 
the kAEOpenApplication Apple Event, the second case is ‘more correct’, but 
NSApplicationDidFinishLaunching is not equivalent to kAEOpenApplication, and 
the OP didn’t ask about it either*. NSApplicationDidFinishLaunching is a 
notification sent by the framework to indicate the event loop of an application 
has been set up. kAEOpenApplication on the other hand is an event sent by the 
system to indicate an application has been opened without documents.

 The OP’s problem is choosing the wrong trigger. If you look at the docs 
(https://developer.apple.com/library/mac/documentation/cocoa/reference/NSApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/NSApplicationDelegate/applicationDidFinishLaunching:),
 it even explicitly says:

 If you want to perform initialization before any files are opened, implement 
 the applicationWillFinishLaunching: method in your delegate, which is called 
 before application:openFile:.)

Though I still think it’s safer to NOT rely on this order, and instead perform 
the initialization in a lazy-loading accessor, so that it is guaranteed the 
first one who needs the information (and requests it using the accessor) causes 
it to be loaded, no matter what spot the code is moved to.

Cheers,
-- Uli Kusterer
“The Witnesses of TeachText are everywhere...”
http://zathras.de

*) For completeness’ sake and people searching the list archives: The 
equivalent to kAEOpenApplication in AppKit (apart from installing an Apple 
Event handler for that event directly) is probably the 
applicationOpenUntitledFile: delegate method. However, that also gets called 
for ‘rapp’ events (kAEReopenApplication, i.e. app has been requested to launch 
w/o documents while already running e.g. by Finder double-click or dock icon 
click).



___

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: handleGetURLEvent getting called after applicationDidFinishLaunching

2013-08-22 Thread Uli Kusterer
Dang, now my mind switched back into Classic mode and I used kAEOpenApplication 
instead of calling it ‘oapp’ as Jens called it. Sorry for the confusion, the 
two things are equivalent. Mine’s the constant, Jens’ is the value. Carry on.

On Aug 23, 2013, at 7:35, Uli Kusterer witness.of.teacht...@gmx.net wrote:
 On Aug 22, 2013, at 18:29, Bradley O'Hearne br...@bighillsoftware.com wrote:
 On Aug 22, 2013, at 9:00 AM, Kyle Sluder k...@ksluder.com wrote:
 On Aug 22, 2013, at 8:00 AM, Jens Alfke j...@mooseyard.com wrote:
 On Aug 22, 2013, at 1:34 AM, Uli Kusterer witness.of.teacht...@gmx.net 
 wrote:
 
 The notion of one of these being ‘more correct’ than the other is 
 ridiculous. The second case is simply a performance optimization from the 
 classic MacOS days that was carried over to OS X.
 
 Nope. (And not to pull rank, but I was on the AppleEvents/AppleScript team 
 at the time we figured this stuff out [1991] and added the 
 seemingly-useless ‘oapp’ event in response to developer complaints.)
 
 While this may well be true that there is no sequence, this one developer's 
 view is that while an app should be able to respond to any downstream open 
 event while running, it makes no sense to arbitrarily deliver or delay 
 information about how an app was launched to the app sometime after the 
 launch loading is complete. That effectively suggests having to poll and 
 eventually timeout in order to get the initial UI display right, which seems 
 really unnecessary if the proper protocol is just to tell an app when 
 loading how it was launched. 
 
 Sorry, I misunderstood your original post then. Of course, if you’re looking 
 at the kAEOpenApplication Apple Event, the second case is ‘more correct’, but 
 NSApplicationDidFinishLaunching is not equivalent to kAEOpenApplication, and 
 the OP didn’t ask about it either*. NSApplicationDidFinishLaunching is a 
 notification sent by the framework to indicate the event loop of an 
 application has been set up. kAEOpenApplication on the other hand is an event 
 sent by the system to indicate an application has been opened without 
 documents.
 
 The OP’s problem is choosing the wrong trigger. If you look at the docs 
 (https://developer.apple.com/library/mac/documentation/cocoa/reference/NSApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/NSApplicationDelegate/applicationDidFinishLaunching:),
  it even explicitly says:
 
 If you want to perform initialization before any files are opened, implement 
 the applicationWillFinishLaunching: method in your delegate, which is called 
 before application:openFile:.)
 
 Though I still think it’s safer to NOT rely on this order, and instead 
 perform the initialization in a lazy-loading accessor, so that it is 
 guaranteed the first one who needs the information (and requests it using the 
 accessor) causes it to be loaded, no matter what spot the code is moved to.
 
 Cheers,
 -- Uli Kusterer
 “The Witnesses of TeachText are everywhere...”
 http://zathras.de
 
 *) For completeness’ sake and people searching the list archives: The 
 equivalent to kAEOpenApplication in AppKit (apart from installing an Apple 
 Event handler for that event directly) is probably the 
 applicationOpenUntitledFile: delegate method. However, that also gets called 
 for ‘rapp’ events (kAEReopenApplication, i.e. app has been requested to 
 launch w/o documents while already running e.g. by Finder double-click or 
 dock icon click).
 
 
 
 ___
 
 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/witness.of.teachtext%40gmx.net
 
 This email sent to witness.of.teacht...@gmx.net


___

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