iOS: Automatically resizing subviews

2011-06-05 Thread Development
I thought I understood how auto resizing worked but I don't


According to the docs if I want to automatically resize all the subviews of a 
view I need to set the View up with

[self setAutoresizesSubviews:YES];
self.contentMode =UIViewContentModeScaleToFill;

No?

I tried this but when I resize the view it's subview remains centered and the 
same size.

Inside of all the subviews I have done the following: 
[self setAutoresizingMask:UIViewAutoresizingFlexibleWidth | 
UIViewAutoresizingFlexibleHeight];

Is there a step I'm missing?

The problem is that the main view's subview rotates. And the whole thing 
obviously can be resized.
If I manually resize the rotated subview I'm doing it wrong because it looses 
it's shape completely
I was hoping I could use autoresizing to solve this issue but I can't get it 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: [ANN] CoreParse

2011-06-05 Thread Angus Hardie

On 5 Jun 2011, at 18:22, Jens Alfke wrote:

> 
> On Jun 5, 2011, at 6:21 AM, Thomas Davie wrote:
> 
>> I've just completed firming up the API and documentation for CoreParse.  
>> CoreParse provides a powerful tokenisation and parsing engine, which uses 
>> shift-reduce parsing (unlike ParseKit) to support a wide range of context 
>> free grammars.
>> 
>> Parsers can be built quickly and easily using BNF like syntax.
> 
> Cool! What advantages does this have over using a more-established tool like 
> ANTLR? (“An Objective-C API” is an obvious answer, I suppose, but it doesn’t 
> look that difficult to call into ANTLR-generated C++ code from Obj-C.)
> 




As a minor point, the current 3.x release of ANTLR has a (somewhat 
experimental) objective C API, but doesn't have a C++ API, you have to use the 
C API instead.

I think ANTLR 2.7.x has the C++ API, but I've never used it.

The ANTLR Objective C API appears to be making good progress and I'm hoping to 
switch from the C to Obj C APIs when ANTLR 4.0 is released.

I'm also looking forward to giving CoreParse a try too. It looks great.

Angus


___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Asynchronous Notification Does NOT Work

2011-06-05 Thread Bing Li
Dear Ken and Jens,

I appreciate so much for your detailed explanations!

In my system, a server needs to handle requests from remote clients.
Multiple local threads are raised to listen to the specific port
concurrently. When a request is received by one of the thread, it must
notify other responding threads asynchronously. The reason to notify
asynchronously is to avoid possible blocking by the responding threads. But
I think it is not necessary to use asynchronous notification if the
responding threads are non-blocking. This is the high-level framework in my
system.

Best regards,
Bing


On Mon, Jun 6, 2011 at 4:50 AM, Ken Thomases  wrote:

> On Jun 5, 2011, at 2:45 PM, Bing Li wrote:
>
> > In this case, notification might occur among two threads and both of them
> > are not the main thread.
>
> This can't work.  Notifications do not cross threads.  They are delivered
> on the same thread in which they're posted or queued.
>
> What are you trying to achieve, from a high-level point of view.  Don't
> describe the mechanism you think you want to use (e.g. asynchronous
> notification).  Describe the high-level problem you're trying to solve, the
> goal you're trying to achieve.
>
> One starting point might be: why do you feel it's important for your
> notifications to be asynchronous?  What problem would arise if your
> notifications were delivered synchronously?
>
> Frankly, there are relatively few cases where asynchronous notifications
> are the correct solution to a problem.  Developers sometimes think they're
> appropriate when they aren't, because of preconceptions which aren't
> appropriate for Cocoa.  The same can be said about threading, too.  In most
> cases, Cocoa's asynchronous APIs, such as those for file and network I/O,
> can achieve the appropriate results, all on the main thread.  The asynchrony
> would be provided by the framework, not by you explicitly introducing it.
>
> As for run loops, they really aren't that complicated.  You won't get a
> tutorial on using them _in isolation_ because that makes no sense.  Run
> loops are a generalization of any kind of wait-on-a-set-of-inputs API you
> may be familiar with (e.g. WaitForMultipleObjects).  A run loop source
> encapsulates both "the thing to wait on" and the callback function or method
> to be invoked when that thing has arrived.  Same with a timer; it
> encapsulates both when to fire and the callback function or method to call
> when it fires.
>
> This frees the code which runs the run loop from having to know either what
> inputs to wait on (because those inputs have already been added to the run
> loop) or how to handle those inputs.  That allows for both the frameworks
> and your application code to add inputs to a run loop and know that, when
> the run loop is run, their inputs will be processed.  The framework can run
> the run loop without having to be specially coded with explicit knowledge of
> what inputs your application might have added.  Obviously, this is necessary
> to make the frameworks generalized for all sorts of applications.
>  Similarly, your application can run the run loop without having to be
> specially coded with knowledge of what inputs the frameworks may have added.
>  This allows for the frameworks' implementation details to remain hidden
> within the frameworks; those implementation details can even change with new
> releases without your application needing to be changed.
>
> The one hitch is that, of course, if nobody runs the run loop, then none of
> its inputs are processed or handled.  In the main thread, the framework will
> run the run loop for you, if you let it -- if you allow flow of control to
> return to the framework after it has called your code.  In other threads,
> you have to arrange to run the run loop yourself.  That basically just means
> invoking one of the -run... methods on [NSRunLoop currentRunLoop], possibly
> repeatedly until some condition specific to your application has been met.
>
> 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: [ANN] CoreParse

2011-06-05 Thread Kyle Sluder
How 'bout a link? ;-)

--Kyle Sluder
(Sent from the bar at BJ's Brewhouse, in Apple HQ's parking lot)

On Jun 5, 2011, at 6:21 AM, Thomas Davie  wrote:

> Hi guys,
> 
> I guess this will get rather overshadowed by some other guy's announcements 
> in the near future, but I thought I'd throw this out there.
> 
> I've just completed firming up the API and documentation for CoreParse.  
> CoreParse provides a powerful tokenisation and parsing engine, which uses 
> shift-reduce parsing (unlike ParseKit) to support a wide range of context 
> free grammars.
> 
> Parsers can be built quickly and easily using BNF like syntax.
> 
> I'd really appreciate anyone's questions, comments and feature requests for 
> future versions.
> 
> Thanks
> 
> Tom Davie
> 
> ___
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/kyle.sluder%40gmail.com
> 
> This email sent to kyle.slu...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: [ANN] CoreParse

2011-06-05 Thread Thomas Wetmore

On Jun 5, 2011, at 6:12 PM, Thomas Davie wrote:
> On 5 Jun 2011, at 18:22, Jens Alfke wrote:
>> On Jun 5, 2011, at 6:21 AM, Thomas Davie wrote:
>> 
>>> I've just completed firming up the API and documentation for CoreParse.  
>>> CoreParse provides a powerful tokenisation and parsing engine, which uses 
>>> shift-reduce parsing (unlike ParseKit) to support a wide range of context 
>>> free grammars.
>>> 
>>> Parsers can be built quickly and easily using BNF like syntax.
>> 
>> Cool! What advantages does this have over using a more-established tool like 
>> ANTLR? (“An Objective-C API” is an obvious answer, I suppose, but it doesn’t 
>> look that difficult to call into ANTLR-generated C++ code from Obj-C.)
> 
> I've not investigated ANTLR, but you're right, my primary goal was a nice, 
> clean, cocoa-like API in pure Obj-C only API.  The only comparable API that I 
> know of is ParseKit which uses recursive decent, and hence doesn't support a 
> lot of grammars.  By comparison there, I support SLR, LR(1) and LALR(1), so 
> there's rather more coverage.
> 
> I'd really appreciate you taking a look and reporting back if you find any 
> interesting things that ANTLR or other tools does better.

And just a reminder that Yacc/Bison is supported by Xcode with builtin build 
rules and build settings. Yacc/Bison is the original LALR(1) parser generator 
written by Steve Johnson of Bell Labs in the middle 1970's. Apple has cleverly 
set things up so that by using a .ym file instead of a .y file, all semantic 
actions can be written in Objective-C. Other settings are available to allow 
multiple Yacc-generated parsers per executable. It's an ancient tool, but it 
works well.

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: [ANN] CoreParse

2011-06-05 Thread Thomas Davie

On 5 Jun 2011, at 18:22, Jens Alfke wrote:

> 
> On Jun 5, 2011, at 6:21 AM, Thomas Davie wrote:
> 
>> I've just completed firming up the API and documentation for CoreParse.  
>> CoreParse provides a powerful tokenisation and parsing engine, which uses 
>> shift-reduce parsing (unlike ParseKit) to support a wide range of context 
>> free grammars.
>> 
>> Parsers can be built quickly and easily using BNF like syntax.
> 
> Cool! What advantages does this have over using a more-established tool like 
> ANTLR? (“An Objective-C API” is an obvious answer, I suppose, but it doesn’t 
> look that difficult to call into ANTLR-generated C++ code from Obj-C.)

I've not investigated ANTLR, but you're right, my primary goal was a nice, 
clean, cocoa-like API in pure Obj-C only API.  The only comparable API that I 
know of is ParseKit which uses recursive decent, and hence doesn't support a 
lot of grammars.  By comparison there, I support SLR, LR(1) and LALR(1), so 
there's rather more coverage.

I'd really appreciate you taking a look and reporting back if you find any 
interesting things that ANTLR or other tools does better.

Thanks

Bob

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Asynchronous Notification Does NOT Work

2011-06-05 Thread Steve Sisak

At 3:45 AM +0800 6/6/11, Bing Li wrote:

In this case, notification might occur among two threads and both of them
are not the main thread. I think I can use synchronous notification and
threading together to replace asynchronous notification. How to you think
about that?


I suspect the problem is that your RunLoop is not being run, but WAYRTTD?

If you're trying to get messages processed on a specific 
thread/RunLoop and you're starting fresh, I'd highly recommend 
reading TN2109, which describes a really clean way to do it:




(Works on iOS or Mac OS X)

Then steal QRunLoopOperation out of the LinkedImageFetcher sample -- 
read the comments to see how hard this is to do right.


HTH,

-Steve
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Asynchronous Notification Does NOT Work

2011-06-05 Thread Ken Thomases
On Jun 5, 2011, at 2:45 PM, Bing Li wrote:

> In this case, notification might occur among two threads and both of them
> are not the main thread.

This can't work.  Notifications do not cross threads.  They are delivered on 
the same thread in which they're posted or queued.

What are you trying to achieve, from a high-level point of view.  Don't 
describe the mechanism you think you want to use (e.g. asynchronous 
notification).  Describe the high-level problem you're trying to solve, the 
goal you're trying to achieve.

One starting point might be: why do you feel it's important for your 
notifications to be asynchronous?  What problem would arise if your 
notifications were delivered synchronously?

Frankly, there are relatively few cases where asynchronous notifications are 
the correct solution to a problem.  Developers sometimes think they're 
appropriate when they aren't, because of preconceptions which aren't 
appropriate for Cocoa.  The same can be said about threading, too.  In most 
cases, Cocoa's asynchronous APIs, such as those for file and network I/O, can 
achieve the appropriate results, all on the main thread.  The asynchrony would 
be provided by the framework, not by you explicitly introducing it.

As for run loops, they really aren't that complicated.  You won't get a 
tutorial on using them _in isolation_ because that makes no sense.  Run loops 
are a generalization of any kind of wait-on-a-set-of-inputs API you may be 
familiar with (e.g. WaitForMultipleObjects).  A run loop source encapsulates 
both "the thing to wait on" and the callback function or method to be invoked 
when that thing has arrived.  Same with a timer; it encapsulates both when to 
fire and the callback function or method to call when it fires.

This frees the code which runs the run loop from having to know either what 
inputs to wait on (because those inputs have already been added to the run 
loop) or how to handle those inputs.  That allows for both the frameworks and 
your application code to add inputs to a run loop and know that, when the run 
loop is run, their inputs will be processed.  The framework can run the run 
loop without having to be specially coded with explicit knowledge of what 
inputs your application might have added.  Obviously, this is necessary to make 
the frameworks generalized for all sorts of applications.  Similarly, your 
application can run the run loop without having to be specially coded with 
knowledge of what inputs the frameworks may have added.  This allows for the 
frameworks' implementation details to remain hidden within the frameworks; 
those implementation details can even change with new releases without your 
application needing to be changed.

The one hitch is that, of course, if nobody runs the run loop, then none of its 
inputs are processed or handled.  In the main thread, the framework will run 
the run loop for you, if you let it -- if you allow flow of control to return 
to the framework after it has called your code.  In other threads, you have to 
arrange to run the run loop yourself.  That basically just means invoking one 
of the -run... methods on [NSRunLoop currentRunLoop], possibly repeatedly until 
some condition specific to your application has been met.

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Asynchronous Notification Does NOT Work

2011-06-05 Thread Bing Li
Dear Jens,

Thanks so much for your reply!

But I have not got a tutorial that I can follow to program RunLoop. So I
decide to use threading and signal/wait to control threads. Is it fine?

In this case, notification might occur among two threads and both of them
are not the main thread. I think I can use synchronous notification and
threading together to replace asynchronous notification. How to you think
about that?

Best regards,
Bing

On Mon, Jun 6, 2011 at 3:34 AM, Jens Alfke  wrote:

>
> On Jun 5, 2011, at 11:59 AM, Bing Li wrote:
>
> > One issue is that the notification job is done in a thread I created
> explicitly. It is the potential reason? I will test it.
>
> Oh, that would do it. The notifications are going to be queued on that
> thread’s runloop then. Did you create a runloop for it, and did you want the
> notifications to be delivered on that thread, instead of the main thread?
>
> If you just want a background thread to post an action to the main thread,
> it’s pretty easy to use -performSelectorOnMainThread:.
>
> —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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Howto eliminate the delay for the first call of -(NSMenu*)menuForEvent: (NSTableView class)?

2011-06-05 Thread Ken Thomases
On Jun 5, 2011, at 2:11 PM, Nick wrote:

> Thanks for the response.

You're welcome.

> Yes, submenu Services, in contrary to other submenus, takes some time to pop 
> up. 
> I take it, my application has nothing to do with that?

Probably correct.  Still, if I were you, I'd try my best to figure out what's 
causing it, just to be absolutely sure.  Check in Console.app to see if other 
messages are written to the console log or the "All Messages" search.  Follow 
Jens' suggestion to identify what other process might be the culprit.

> On other machines it will work just fine without this delay?

Also probably correct.

> Do "Services" pop up without delays on your machine?

Yes.

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Asynchronous Notification Does NOT Work

2011-06-05 Thread Jens Alfke

On Jun 5, 2011, at 11:59 AM, Bing Li wrote:

> One issue is that the notification job is done in a thread I created 
> explicitly. It is the potential reason? I will test it.

Oh, that would do it. The notifications are going to be queued on that thread’s 
runloop then. Did you create a runloop for it, and did you want the 
notifications to be delivered on that thread, instead of the main thread?

If you just want a background thread to post an action to the main thread, it’s 
pretty easy to use -performSelectorOnMainThread:.

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Howto eliminate the delay for the first call of -(NSMenu*)menuForEvent: (NSTableView class)?

2011-06-05 Thread Nick
Ken,
Thanks for the response.
Yes, submenu Services, in contrary to other submenus, takes some time to pop
up.
I take it, my application has nothing to do with that? On other machines it
will work just fine without this delay?
Do "Services" pop up without delays on your machine?
Thanks

2011/6/5 Ken Thomases 

> On Jun 5, 2011, at 7:28 AM, Nick wrote:
>
> > Everything works fine, except that when the user clicks first time on the
> > TableView after application has loaded, i get this
> > "__CFServiceControllerBeginPBSLoadForLocalizations
> > timed out while talking to psb" message in the console output, and a few
> > seconds delay before the menu appears. All subsequent clicks on the view
> > make the context menu appear normally, without any delays or messages in
> the
> > console.
> >
> > Why does this happen?
>
> You probably have a misbehaving service (or application which provides a
> service) installed.  Or something is corrupted in your system configuration.
>
> pbs is the pasteboard server.  It coordinates the pasteboard and, in that
> capacity, services.
>
> You would probably see the same delay if you go to your application menu
> and open the Services submenu.
>
> 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Asynchronous Notification Does NOT Work

2011-06-05 Thread Bing Li
Dear Ken,

According to your reply, I think the threads I created explicitly caused the
problem? So asynchronous notification cannot be used in this case?

Thanks so much!

Best,
Bing

On Mon, Jun 6, 2011 at 2:34 AM, Ken Thomases  wrote:

> On Jun 5, 2011, at 11:20 AM, Bing Li wrote:
>
> > My system is a Cocoa Application. I know RunLoop is created automatically
> in
> > such a project. So asynchronous notification should work.
>
> A Cocoa application does automatically run the run loop of the main thread,
> if you allow it.  So, I have a couple of questions:
>
> 1) Are you queuing these notifications on the main thread?
>
> 2) Are you allowing the flow of execution to return back to the framework,
> thus allowing it to run the run loop?
>
> Another point: it was recently discussed on this list that the NSPostASAP
> posting style has a very specific meaning.  Notifications queued with that
> style are delivered immediately after a run loop source or timer has been
> serviced.  If no run loop sources or timers are being serviced for a while,
> then they may be delayed indefinitely.  NSNotificationQueue predates
> NSOperationQueue and GCD.  Back then, just about the only way to run code on
> the main thread was while servicing a run loop source or timer, so an
> NSPostASAP notification would in fact be delivered immediately after you let
> execution return to the framework.  However, now it's possible to run an
> operation or a block on the main thread, and I don't think those count as
> run loop sources or timers.
>
> 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Asynchronous Notification Does NOT Work

2011-06-05 Thread Bing Li
Dear Jens,

I just checked carefully. The instance of NSNotificationQueue keeps alive
when posting.

One issue is that the notification job is done in a thread I created
explicitly. It is the potential reason? I will test it.

Thanks,
Bing

On Mon, Jun 6, 2011 at 1:13 AM, Jens Alfke  wrote:

>
> On Jun 5, 2011, at 9:20 AM, Bing Li wrote:
>
> >// This line does not work.
> > //  [[[NSNotificationQueue alloc]
> > initWithNotificationCenter:[NSNotificationCenter defaultCenter]]
> > enqueueNotification:[NSNotification
> > notificationWithName:@"CONNECTION_DISCONNECTED"
> > object:self userInfo:connectionDisconnectedDictionary]
> > postingStyle:NSPostWhenIdle];
>
> Weird; that should work. It’s been a few years since I used delayed
> notifications like this, but they worked fine for me in a Cocoa app.
>
> The only thing I can imagine is that maybe in your real code the
> NSNotificationQueue instance is getting dealloced before it can post its
> notifications. Are you sure you’re managing its refcount so it stays alive?
>
> —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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Asynchronous Notification Does NOT Work

2011-06-05 Thread Ken Thomases
On Jun 5, 2011, at 11:20 AM, Bing Li wrote:

> My system is a Cocoa Application. I know RunLoop is created automatically in
> such a project. So asynchronous notification should work.

A Cocoa application does automatically run the run loop of the main thread, if 
you allow it.  So, I have a couple of questions:

1) Are you queuing these notifications on the main thread?

2) Are you allowing the flow of execution to return back to the framework, thus 
allowing it to run the run loop?

Another point: it was recently discussed on this list that the NSPostASAP 
posting style has a very specific meaning.  Notifications queued with that 
style are delivered immediately after a run loop source or timer has been 
serviced.  If no run loop sources or timers are being serviced for a while, 
then they may be delayed indefinitely.  NSNotificationQueue predates 
NSOperationQueue and GCD.  Back then, just about the only way to run code on 
the main thread was while servicing a run loop source or timer, so an 
NSPostASAP notification would in fact be delivered immediately after you let 
execution return to the framework.  However, now it's possible to run an 
operation or a block on the main thread, and I don't think those count as run 
loop sources or timers.

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: [ANN] CoreParse

2011-06-05 Thread Jens Alfke

On Jun 5, 2011, at 6:21 AM, Thomas Davie wrote:

> I've just completed firming up the API and documentation for CoreParse.  
> CoreParse provides a powerful tokenisation and parsing engine, which uses 
> shift-reduce parsing (unlike ParseKit) to support a wide range of context 
> free grammars.
> 
> Parsers can be built quickly and easily using BNF like syntax.

Cool! What advantages does this have over using a more-established tool like 
ANTLR? (“An Objective-C API” is an obvious answer, I suppose, but it doesn’t 
look that difficult to call into ANTLR-generated C++ code from Obj-C.)

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Howto eliminate the delay for the first call of -(NSMenu*)menuForEvent: (NSTableView class)?

2011-06-05 Thread Jens Alfke

On Jun 5, 2011, at 7:40 AM, Ken Thomases wrote:

> You probably have a misbehaving service (or application which provides a 
> service) installed.  Or something is corrupted in your system configuration.
> 
> pbs is the pasteboard server.  It coordinates the pasteboard and, in that 
> capacity, services.

I had something like this happen system-wide a year or so ago, where 
occasionally an app would lock up for ~30 seconds when I right-clicked. I 
eventually tracked it down to Dropbox; for some reason its context-menu plugin 
code was misbehaving. (That’s since been fixed in Dropbox, so I don’t mean to 
cast blame at them in this case.)

If this state lasts long enough for you to do something, poke around and see if 
any other apps are locked up at the time. If so, try to sample them with 
Activity Monitor or the ‘sample’ tool.

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Asynchronous Notification Does NOT Work

2011-06-05 Thread Jens Alfke

On Jun 5, 2011, at 9:20 AM, Bing Li wrote:

>// This line does not work.
> //  [[[NSNotificationQueue alloc]
> initWithNotificationCenter:[NSNotificationCenter defaultCenter]]
> enqueueNotification:[NSNotification
> notificationWithName:@"CONNECTION_DISCONNECTED"
> object:self userInfo:connectionDisconnectedDictionary]
> postingStyle:NSPostWhenIdle];

Weird; that should work. It’s been a few years since I used delayed 
notifications like this, but they worked fine for me in a Cocoa app.

The only thing I can imagine is that maybe in your real code the 
NSNotificationQueue instance is getting dealloced before it can post its 
notifications. Are you sure you’re managing its refcount so it stays alive?

—Jens



smime.p7s
Description: S/MIME cryptographic signature
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Asynchronous Notification Does NOT Work

2011-06-05 Thread Bing Li
Dear all,

I just learned the technique of asynchronous notification. This is the first
time for me to use it in my system. However, I got a weird problem. Only
synchronous notification works well. If replacing the synchronous
notification lines of code with asynchronous ones, it does not work.

My system is a Cocoa Application. I know RunLoop is created automatically in
such a project. So asynchronous notification should work. The primary code
is as follows.

..

// The following two lines are the parameters to be transmitted with
the notification.
NSMutableDictionary *connectionDisconnectedDictionary =
[[[NSMutableDictionary alloc] initWithCapacity:5] autorelease];
[connectionDisconnectedDictionary setObject:serviceKey forKey:@
"SERVICE_KEY"];

// This line does not work.
//  [[[NSNotificationQueue alloc]
initWithNotificationCenter:[NSNotificationCenter defaultCenter]]
enqueueNotification:[NSNotification
notificationWithName:@"CONNECTION_DISCONNECTED"
object:self userInfo:connectionDisconnectedDictionary]
postingStyle:NSPostWhenIdle];

// This line works well.
//  [[[NSNotificationQueue alloc]
initWithNotificationCenter:[NSNotificationCenter defaultCenter]]
enqueueNotification:[NSNotification
notificationWithName:@"CONNECTION_DISCONNECTED" object:self
userInfo:connectionDisconnectedDictionary] postingStyle:NSPostNow];

 // It does not work.
//   [[[NSNotificationQueue alloc]
initWithNotificationCenter:[NSNotificationCenter defaultCenter]]
enqueueNotification:[NSNotification
notificationWithName:@"CONNECTION_DISCONNECTED" object:self
userInfo:connectionDisconnectedDictionary] postingStyle:NSPostASAP];

// It works
[[NSNotificationCenter defaultCenter]
postNotificationName:@"CONNECTION_DISCONNECTED" object:self
userInfo:connectionDisconnectedDictionary];

..

The registration and events code is the same. So I felt confused.

Could you please give me a hand? What reasons might cause the above problem?

Best,
Bing
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Good and updated book for iPhone development

2011-06-05 Thread Wilker
Thanks guys,

I bought the: Beginning iPhone 4 Development: Exploring the iOS SDK Kindle
Version

It seems cool, but I will sure I will look for others later :)

Thanks for you suggestions.
---
Wilker Lúcio
http://about.me/wilkerlucio/bio
Kajabi Consultant
+55 81 82556600



On Sat, Jun 4, 2011 at 3:36 AM, Geoffrey GOUTALLIER wrote:

> There is an upcoming book from Aaron Hillegass @ Big Nerd Ranch :
>
> iOS Programming: The Big Nerd Ranch Guide <
> http://www.amazon.com/iOS-Programming-Ranch-Guide-Guides/dp/0321773772/ref=sr_1_1?ie=UTF8&qid=1306951634&sr=8-1>
>
> Haven't read it yet, as it is not yet released, but I think that it will be
> a great book, as the Cocoa Programming book, still from Aaron, is a must
> have.
> ++
>
> Geoffrey
>
> On 4 juin 2011, at 07:42, Rikza Azriyan wrote:
>
> > Beginning iphone 4 prograaming by jeff lamarche i tought
> >
> >
> > Rikza Azriyan
> > Student of Sriwijaya University
> > Palembang, Indonesia
> >
> > Sent from my iPhone 4
> > Provided by Telkomsel.
> >
> > On Jun 4, 2011, at 11:46 AM, David Rowland 
> wrote:
> >
> >> I like "Programming iOS4" by Matt Neuburg (O'Reilly)
> >>
> >> David
> >>
> >>
> >> On Jun 2, 2011, at 1:37 AM, Wilker wrote:
> >>
> >>> Hi Guys,
> >>>
> >>> I have some general experience on programming (8 years) but I'm just
> >>> starting on Cocoa / Objective-C world now.
> >>> Currently I'm reading the: Cocoa Programming by Pragmatic
> >>> Programmers
> >>> This book is a
> nice
> >>> intro and cover the basics nice, but after I finish it I wanna get some
> book
> >>> for iPhone specific stuff, if possible some updated book for XCode 4
> and iOS
> >>> 4.
> >>>
> >>> What you guys can recommend to me?
> >>>
> >>> Thanks
> >>> ---
> >>> Wilker Lúcio
> >>> http://about.me/wilkerlucio/bio
> >>> Kajabi Consultant
> >>> +55 81 82556600
> >>> ___
> >>>
> >>> 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:
> >>>
> http://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:
> >>
> http://lists.apple.com/mailman/options/cocoa-dev/rikzaxtrmsprt%40yahoo.com
> >>
> >> This email sent to rikzaxtrms...@yahoo.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:
> > http://lists.apple.com/mailman/options/cocoa-dev/coding%40farfadet.net
> >
> > This email sent to cod...@farfadet.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Howto eliminate the delay for the first call of -(NSMenu*)menuForEvent: (NSTableView class)?

2011-06-05 Thread Ken Thomases
On Jun 5, 2011, at 7:28 AM, Nick wrote:

> Everything works fine, except that when the user clicks first time on the
> TableView after application has loaded, i get this
> "__CFServiceControllerBeginPBSLoadForLocalizations
> timed out while talking to psb" message in the console output, and a few
> seconds delay before the menu appears. All subsequent clicks on the view
> make the context menu appear normally, without any delays or messages in the
> console.
> 
> Why does this happen?

You probably have a misbehaving service (or application which provides a 
service) installed.  Or something is corrupted in your system configuration.

pbs is the pasteboard server.  It coordinates the pasteboard and, in that 
capacity, services.

You would probably see the same delay if you go to your application menu and 
open the Services submenu.

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


[ANN] CoreParse

2011-06-05 Thread Thomas Davie
Hi guys,

I guess this will get rather overshadowed by some other guy's announcements in 
the near future, but I thought I'd throw this out there.

I've just completed firming up the API and documentation for CoreParse.  
CoreParse provides a powerful tokenisation and parsing engine, which uses 
shift-reduce parsing (unlike ParseKit) to support a wide range of context free 
grammars.

Parsers can be built quickly and easily using BNF like syntax.

I'd really appreciate anyone's questions, comments and feature requests for 
future versions.

Thanks

Tom Davie

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Howto eliminate the delay for the first call of -(NSMenu*)menuForEvent: (NSTableView class)?

2011-06-05 Thread Nick
Hello!

I am trying to add a context menu to the NSTableView. For this purpose, I
have subclassed NSTableView, and implemented this method:


-(NSMenu*)menuForEvent:(NSEvent*)evt

{

NSPoint point = [self convertPoint:[evt locationInWindow]

  fromView:NULL];

int column = [self columnAtPoint:point];

int row = [self rowAtPoint:point];

if ( column >= 0 && row >= 0) {

if([self selectedRow] != row)

[self selectRow:row byExtendingSelection:NO];

return [[NSApp delegate] popupMenu];

} else

return nil;

}


In Interface Builder I am instantiating my NSMenu and binding it with the
outlet in the  class, which also has this NSMenu as a
property.


Everything works fine, except that when the user clicks first time on the
TableView after application has loaded, i get this
"__CFServiceControllerBeginPBSLoadForLocalizations
timed out while talking to psb" message in the console output, and a few
seconds delay before the menu appears. All subsequent clicks on the view
make the context menu appear normally, without any delays or messages in the
console.

Why does this happen?

Have I forgotten something?

Thanks for the response!

Nick
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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