Re: OS + iOS best practice

2011-06-06 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 6/6/11 10:51 PM, Amy Gibbs wrote:
> After the announcements about iCloud, should I just wait a while and
> I'll be able to build this in 'for free' (there will be a cocoa way to
> do this)?

While the iCloud announcement was obviously public, all the
implementation details are under NDA (and of course, like other such
subjects, cannot be discussed on this list).

I presume, though, that you are an iOS program member; login to the dev
center and you can read any pertinent documentation to your heart's
content.  (There are also NDA-cleared forums on the dev site you can use.)

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3tx8wACgkQaOlrz5+0JdWkagCfYtgxpBEUO4/QlR/Rb7i8flim
XqIAn3sC0x2oerMXa2GD8kokFnJ6j8yX
=5khG
-END PGP 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: How can I be so wrong about graphics?

2011-06-06 Thread Manfred Schwind
> Hmm... it looks like it does draw the line... way off in the ether 
> somewhere...
> I think I drew in the global coord system not the local to the view

Are you sure you are _not_ calling drawRect yourself, but let the system call 
it when needed?
If a view needs to be redrawn, the system sets up the correct graphics context, 
coordinate system transformations etc. and then calls drawRect. If you call 
drawRect yourself (what you should never do!), you end up drawing into 
"somewhere".

Regards,
Mani
--
http://mani.de - friendly software

___

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: OS + iOS best practice

2011-06-06 Thread Amy Gibbs
After the announcements about iCloud, should I just wait a while and  
I'll be able to build this in 'for free' (there will be a cocoa way to  
do this)?


On 3 Jun 2011, at 9:29PM, Evadne Wu wrote:

As for the SQLite file, I am never sure if Core Data’s OS X  
implementation and iOS implementation share the same format and will  
continue to be so, and it is surely a very strong and valid idea to  
just use an intermediate format you control, I’ve been bouncing them  
across OS X & iOS with no problem…


Note that Dropbox exposes directory hashes, so that might help with  
images.  I’m not sure if referenced images would be updated at all —  
this can be a big problem if they can be updated outside the app and  
you need to handle that.


For the record, going with Dropbox might not be very safe, could be  
not scalable at all, and might have security implications as Jeffrey  
pointed out.  But it might work very well for your scenario.  If  
you’re serious about making it robust, I still recommend that you  
create a tiny and dedicated web service for this app…


-ev

On Jun 4, 2011, at 04:23, Amy Gibbs wrote:


Thanks

Sounds like dropbox would be a good fit, I'll download the ask and  
give it a go.


My current mac app stores the data in a sqllite file that I'm  
hoping to just sync with dropbox. However it does currently also  
store images in a directory and just store the paths as string  
attributes. Not sure of the best solution for those. I'm not  
expecting to always have web access on the iPad when the app is  
running.


The images would not change too often once the app is initialised  
with data. A dozen or so new ones a month, and from the iPad they  
would only need to be read.


Perhaps I could store the SQLite file and the images in a directory  
that can be stored in the dropbox directory?


Many thanks for all your help.

Sent from my iPad

On 3 Jun 2011, at 19:48, Evadne Wu  wrote:

Dropbox sync is good for a pile of files, but no more than that.   
Let’s rebound the requirements:


* there’s a single user Core Data app
* want an iPad version of the app
* the two versions will sync up

Given the requirements, and add the fact that I’m pretty sure that  
Dropbox would keep conflicted copies of any file around, so there  
is no fear for lost data, and you can probably merge anything…   
it’s probably a good fit.  If you don’t pull in any external  
resources, for example pictures on the filesystem which are only  
referenced by path strings in Core Data entities, the only thing  
that needs syncing would be the .sqlite file and things can  
probably work.  If this is not the case then a simple Web service  
would go a long way.


Dropbox carries its own stateless JSON based API, but there is a  
SDK out there (for prototyping purposes) too.


-ev

On Jun 4, 2011, at 02:16, Amy Heavey wrote:

Thanks, It's an app for just me really. I just prefer to work on  
a desktop mac when I'm in the house, and I can't carry my iMac  
with me :) I do find typing much easier on an actual keyboard.  
Maybe I should just get a keyboard for the iPad?


Many Thanks

Amy



On 3 Jun 2011, at 7:11PM, John Joyce wrote:



On Jun 3, 2011, at 1:04 PM, Amy Heavey wrote:

I hope this appropriate for this list, if not please accept my  
apologies.


I've got a fairly basic core data app that I've written for  
personal use on my iMac. I'd like to have an iPad version as it  
would be very useful to have whilst I was mobile. (It's  
basically a customer/product database).


Is there a best way to manage sharing the data between an OS  
and iOS version? I assume it will be possible as long as they  
use the same datamodel.


I was thinking maybe some kind of dropbox sync would be best as  
it wouldn't depend on a network connection, and I wouldn't need  
to use both the mac an iPad versions at the same time. I have  
absolutely no idea how to do this though. I know some apps have  
built in dropbox sync but I fear it may be beyond me as I  
haven't found a handy tutorial anywhere.


Can anyone point me in the right direction at all?

Many Thanks

Amy

If it's an app for multiple users to have the same data, you  
probably want to have a central database that client apps  
retrieve data from.

Core data isn't really a multi-cient database.


___

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/ev%40monoceroi.com

This email sent to e...@monoceroi.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

Re: How can I be so wrong about graphics?

2011-06-06 Thread David Duncan
If you are unsure, I would start with the line from 0,0 to 
bounds.size.width,bounds.size.height.

On Jun 6, 2011, at 2:51 PM, Development wrote:

> Hmm... it looks like it does draw the line... way off in the ether 
> somewhere...
> I think I drew in the global coord system not the local to the view
> 
> On Jun 6, 2011, at 2:37 PM, David Duncan wrote:
> 
>> On Jun 6, 2011, at 2:31 PM, Development wrote:
>> 
>>> I'm really loosing faith in my ability to read simple english
>>> 
>>> 
>>> According to like a million examples... If I place the follow bit of code 
>>> in a view's drawRect: method I should get a line from pointA to pointB 
>>> however I get nothing.
>>> How can subclassing UIView be this difficult? I have turned off clips to 
>>> bounds, set the stroke color to black and done basically everything I know 
>>> to do but I get an empty path
>>> 
>>> 
>>>  CGContextRef context= UIGraphicsGetCurrentContext();
>>> 
>>>  CGContextSetStrokeColorWithColor(context, self.strokeColor.CGColor);
>>>  CGContextBeginPath(context);//According to most examples this is a waste 
>>> of code
>>> 
>>>  // Draw them with a 2.0 stroke width so they are a bit more visible.
>>>  CGContextSetLineWidth(context, 2.0);
>>> 
>>>  CGContextMoveToPoint(context, pointA.x,pointA.y); //start at this point
>>> 
>>>  CGContextAddLineToPoint(context,pointB.x, pointB.y); //draw to this point
>>> 
>>>  // and now draw the Path!
>>>  CGContextStrokePath(context);
>> 
>> 
>> What is pointA & pointB? What is self.strokeColor? Assuming this is 
>> happening within -drawRect:, it should work just fine.
>> --
>> David Duncan
>> 
> 

--
David Duncan

___

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: How can I be so wrong about graphics?

2011-06-06 Thread Evadne Wu
Something along the line of [self convertPoint:aPoint fromView:nil] should do 
the trick, if you’re very sure that the points were global.  Hope it helps.

-ev

On Jun 7, 2011, at 05:51, Development wrote:

> Hmm... it looks like it does draw the line... way off in the ether 
> somewhere...
> I think I drew in the global coord system not the local to the view
> 
> On Jun 6, 2011, at 2:37 PM, David Duncan wrote:
> 
>> On Jun 6, 2011, at 2:31 PM, Development wrote:
>> 
>>> I'm really loosing faith in my ability to read simple english
>>> 
>>> 
>>> According to like a million examples... If I place the follow bit of code 
>>> in a view's drawRect: method I should get a line from pointA to pointB 
>>> however I get nothing.
>>> How can subclassing UIView be this difficult? I have turned off clips to 
>>> bounds, set the stroke color to black and done basically everything I know 
>>> to do but I get an empty path
>>> 
>>> 
>>>  CGContextRef context= UIGraphicsGetCurrentContext();
>>> 
>>>  CGContextSetStrokeColorWithColor(context, self.strokeColor.CGColor);
>>>  CGContextBeginPath(context);//According to most examples this is a waste 
>>> of code
>>> 
>>>  // Draw them with a 2.0 stroke width so they are a bit more visible.
>>>  CGContextSetLineWidth(context, 2.0);
>>> 
>>>  CGContextMoveToPoint(context, pointA.x,pointA.y); //start at this point
>>> 
>>>  CGContextAddLineToPoint(context,pointB.x, pointB.y); //draw to this point
>>> 
>>>  // and now draw the Path!
>>>  CGContextStrokePath(context);
>> 
>> 
>> What is pointA & pointB? What is self.strokeColor? Assuming this is 
>> happening within -drawRect:, it should work just fine.
>> --
>> David Duncan
>> 
> 
> ___
> 
> 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/ev%40monoceroi.com
> 
> This email sent to e...@monoceroi.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: Handling mouse events on transparent window conditionally

2011-06-06 Thread Raleigh Ledet
I'm shooting off the cuff here. But try setting up a tracking area that matches 
your "active" rectangle. When the mouse enters the tracking area, 
setIgnoreMouseEvents:NO, when the mouse exits the tracking area 
setIgnoreMouseEvents:YES.

-raleigh
 
On May 31, 2011, at 1:30 AM, Ken Thomases wrote:

> On May 31, 2011, at 1:33 AM, Deepa wrote:
> 
>> I am developing an Desktop application in which I should be able to take 
>> mouse events on transparent window. But, transparent NSWindow does not take 
>> mouse events. So, I have set  setIgnoreMouseEvents to NO which allows the 
>> transparent window to take mouse events.
>> 
>> I have the problem in the following scenario:
>> There is dynamically created rectangular shape on this window. The 
>> transparent window should not take mouse events in this region; it should be 
>> delegated to the window (of some other app) that is present behind this 
>> shape.
>> For this purpose, if the mouseDown event is inside the shape I am setting 
>> setIgnoreMouseEvents to YES. Now, if the user performs mouse events in the 
>> area outside the shape the transparent window should take the event. Since, 
>> setIgnoreMouseEvents is set to YES, window does not take mouse events.
>> 
>> There is no way to identify that mouseDown event has occurred so that I can 
>> set setIgnoreMouseEvents to NO.
>> 
>> Could someone suggest me some best method to handle mouse events on 
>> transparent window?
> 
> The Mac OS X Window Server has to decide where to route events.  It is a 
> process outside of any particular application.  Once it has picked which 
> window (and therefore application) will receive an event, that's the end of 
> the matter.  That application chooses how to respond (including, possibly, 
> doing nothing), but the event won't be delivered to any other application.
> 
> You can't dynamically choose to pass an event along to the "next" 
> application.  (You could try to approach this using CGEventTaps, but I doubt 
> you'd achieve anything satisfactory.)
> 
> The better approach is to use multiple transparent overlay windows.  If you 
> need to make a frame that accepts mouse events around a rectangular area that 
> does not, you may need four transparent windows for the frame and, if 
> necessary, one for the interior rectangle.  You can use child windows 
> (-[NSWindow addChildWindow:ordered:]) to make sure the windows move together.
> 
> 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/ledet%40apple.com
> 
> This email sent to le...@apple.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: How can I be so wrong about graphics?

2011-06-06 Thread Development
Hmm... it looks like it does draw the line... way off in the ether somewhere...
I think I drew in the global coord system not the local to the view

On Jun 6, 2011, at 2:37 PM, David Duncan wrote:

> On Jun 6, 2011, at 2:31 PM, Development wrote:
> 
>> I'm really loosing faith in my ability to read simple english
>> 
>> 
>> According to like a million examples... If I place the follow bit of code in 
>> a view's drawRect: method I should get a line from pointA to pointB however 
>> I get nothing.
>> How can subclassing UIView be this difficult? I have turned off clips to 
>> bounds, set the stroke color to black and done basically everything I know 
>> to do but I get an empty path
>> 
>> 
>>   CGContextRef context= UIGraphicsGetCurrentContext();
>> 
>>   CGContextSetStrokeColorWithColor(context, self.strokeColor.CGColor);
>>   CGContextBeginPath(context);//According to most examples this is a waste 
>> of code
>> 
>>   // Draw them with a 2.0 stroke width so they are a bit more visible.
>>   CGContextSetLineWidth(context, 2.0);
>> 
>>   CGContextMoveToPoint(context, pointA.x,pointA.y); //start at this point
>> 
>>   CGContextAddLineToPoint(context,pointB.x, pointB.y); //draw to this point
>> 
>>   // and now draw the Path!
>>   CGContextStrokePath(context);
> 
> 
> What is pointA & pointB? What is self.strokeColor? Assuming this is happening 
> within -drawRect:, it should work just fine.
> --
> David Duncan
> 

___

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: How can I be so wrong about graphics?

2011-06-06 Thread Andy Lee
How do you know you are getting an empty path? Did you put a breakpoint in the 
code and step through with the debugger?

Is it possible you forgot to assign the view class in IB?

--Andy

On Jun 6, 2011, at 2:31 PM, Development  wrote:

> I'm really loosing faith in my ability to read simple english
> 
> 
> According to like a million examples... If I place the follow bit of code in 
> a view's drawRect: method I should get a line from pointA to pointB however I 
> get nothing.
> How can subclassing UIView be this difficult? I have turned off clips to 
> bounds, set the stroke color to black and done basically everything I know to 
> do but I get an empty path
> 
> 
>CGContextRef context= UIGraphicsGetCurrentContext();
> 
>CGContextSetStrokeColorWithColor(context, self.strokeColor.CGColor);
>CGContextBeginPath(context);//According to most examples this is a waste 
> of code
> 
>// Draw them with a 2.0 stroke width so they are a bit more visible.
>CGContextSetLineWidth(context, 2.0);
> 
>CGContextMoveToPoint(context, pointA.x,pointA.y); //start at this point
> 
>CGContextAddLineToPoint(context,pointB.x, pointB.y); //draw to this point
> 
>// and now draw the Path!
>CGContextStrokePath(context);
___

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: How can I be so wrong about graphics?

2011-06-06 Thread David Duncan
On Jun 6, 2011, at 2:31 PM, Development wrote:

> I'm really loosing faith in my ability to read simple english
> 
> 
> According to like a million examples... If I place the follow bit of code in 
> a view's drawRect: method I should get a line from pointA to pointB however I 
> get nothing.
> How can subclassing UIView be this difficult? I have turned off clips to 
> bounds, set the stroke color to black and done basically everything I know to 
> do but I get an empty path
> 
> 
>CGContextRef context= UIGraphicsGetCurrentContext();
> 
>CGContextSetStrokeColorWithColor(context, self.strokeColor.CGColor);
>CGContextBeginPath(context);//According to most examples this is a waste 
> of code
> 
>// Draw them with a 2.0 stroke width so they are a bit more visible.
>CGContextSetLineWidth(context, 2.0);
> 
>CGContextMoveToPoint(context, pointA.x,pointA.y); //start at this point
> 
>CGContextAddLineToPoint(context,pointB.x, pointB.y); //draw to this point
> 
>// and now draw the Path!
>CGContextStrokePath(context);


What is pointA & pointB? What is self.strokeColor? Assuming this is happening 
within -drawRect:, it should work just fine.
--
David Duncan

___

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


How can I be so wrong about graphics?

2011-06-06 Thread Development
I'm really loosing faith in my ability to read simple english


According to like a million examples... If I place the follow bit of code in a 
view's drawRect: method I should get a line from pointA to pointB however I get 
nothing.
How can subclassing UIView be this difficult? I have turned off clips to 
bounds, set the stroke color to black and done basically everything I know to 
do but I get an empty path


CGContextRef context= UIGraphicsGetCurrentContext();

CGContextSetStrokeColorWithColor(context, self.strokeColor.CGColor);
CGContextBeginPath(context);//According to most examples this is a waste of 
code

// Draw them with a 2.0 stroke width so they are a bit more visible.
CGContextSetLineWidth(context, 2.0);

CGContextMoveToPoint(context, pointA.x,pointA.y); //start at this point

CGContextAddLineToPoint(context,pointB.x, pointB.y); //draw to this point

// and now draw the Path!
CGContextStrokePath(context);



___

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: How disable Special Characters menu item?

2011-06-06 Thread Greg Guerin

McLaughlin, Michael P wrote:

I have a Cocoa app (Xcode 3.2.6) which displays text output in a  
window.  This is pure output not meant to be edited by the user.   
Accordingly, the textfield is marked as not editable or selectable  
in IB.



Speaking as a possible user, it is often useful to be able to select  
text and copy it to the clipboard, even if the text is pure output  
and isn't editable.  For example, Terminal.app allows this for all  
the text displayed in a shell window.


  -- GG

___

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: iOS: Automatically resizing subviews

2011-06-06 Thread Development

On Jun 6, 2011, at 10:00 AM, Kyle Sluder wrote:

> On Jun 6, 2011, at 9:35 AM, Development  wrote:
> 
>> 
>> That might be the problem. I'm not doing this in IB. I'm creating the view's 
>> programatically.
>> 
>> I also noticed that no matter what I do, the subview's auto resizing mask 
>> always returns 0;
> 
> Did you make sure you didn't accidentally create multiple copies of your view?

Yes, I've verified that only one copy per view object is added. 
Meaning. The application might have several instances of the class however when 
the class is initialized it is the only copy with it's parameters

> 
>> 
>> Actually the whole thing is a screwed up mess.
>> 
>> Neither view seems to respond to the drawing code I try to use. For 
>> instance. I want the outer view to have a dashed border around it when it is 
>> selected.
> 
> Your terminology bothers me. Views don't "respond to" drawing code, they 
> perform it within -drawRect:. Are you trying to draw into the view from 
> elsewhere?

your right, not the right term I suppose.
No, I am using the view's drawInRect: method to do all drawing. and 
more or less I get nothing.

> 
> --Kyle Sluder
> (Sent from the WWDC keynote line)

___

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: How disable Special Characters menu item?

2011-06-06 Thread Nick Zitzmann

On Jun 6, 2011, at 11:17 AM, McLaughlin, Michael P. wrote:

> I have a Cocoa app (Xcode 3.2.6) which displays text output in a window.  
> This is pure output not meant to be edited by the user.  Accordingly, the 
> textfield is marked as not editable or selectable in IB.
> 
> When the window appears, all of the Edit menu items are disabled except 
> Special Characters…  This seems conceptually incorrect (in fact, it seems 
> like a bug).
> 
> Is there any way to disable this menu item on a window-specific basis?

No. That item is added by the AppKit and cannot be disabled or removed at all.

Nick Zitzmann


___

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


How disable Special Characters menu item?

2011-06-06 Thread McLaughlin, Michael P.
I have a Cocoa app (Xcode 3.2.6) which displays text output in a window.  This 
is pure output not meant to be edited by the user.  Accordingly, the textfield 
is marked as not editable or selectable in IB.

When the window appears, all of the Edit menu items are disabled except Special 
Characters…  This seems conceptually incorrect (in fact, it seems like a bug).

Is there any way to disable this menu item on a window-specific basis?

TIA.

--
Michael P. McLaughlin
___

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: iOS: Automatically resizing subviews

2011-06-06 Thread Kyle Sluder
On Jun 6, 2011, at 9:35 AM, Development  wrote:

> 
> That might be the problem. I'm not doing this in IB. I'm creating the view's 
> programatically.
> 
> I also noticed that no matter what I do, the subview's auto resizing mask 
> always returns 0;

Did you make sure you didn't accidentally create multiple copies of your view?

> 
> Actually the whole thing is a screwed up mess.
> 
> Neither view seems to respond to the drawing code I try to use. For instance. 
> I want the outer view to have a dashed border around it when it is selected.

Your terminology bothers me. Views don't "respond to" drawing code, they 
perform it within -drawRect:. Are you trying to draw into the view from 
elsewhere?

--Kyle Sluder
(Sent from the WWDC keynote line)___

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: iOS: Automatically resizing subviews

2011-06-06 Thread Development

That might be the problem. I'm not doing this in IB. I'm creating the view's 
programatically.

I also noticed that no matter what I do, the subview's auto resizing mask 
always returns 0;

Actually the whole thing is a screwed up mess.

Neither view seems to respond to the drawing code I try to use. For instance. I 
want the outer view to have a dashed border around it when it is selected.

I use 
CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetLineWidth(context, 3.0);

CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);

CGFloat dashArray[] = {3,3};

CGContextSetLineDash(context, 3, dashArray, 2);

CGContextStrokePath(context);

and have no border at all.

Basically I don't know what I am doing wrong when I initialize these subclasses 
but it is all epic fail.

The only thing that actually works is filling the inner view's rectangle with a 
solid color and rotating it.


On Jun 6, 2011, at 8:38 AM, David Duncan wrote:

> On Jun 5, 2011, at 11:51 PM, Development wrote:
> 
>> 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?
> 
> 
> The contentMode is irrelevant (it has to do with how the view's graphical 
> content – what you draw in -drawRect: – fits in the view, not its subviews).
> 
> You may want to just spend a bit of time in Interface Builder prototyping 
> this, as it can sometimes be difficult to predict what you get from setting 
> the autoresizing masks in a particular way.
> --
> David Duncan
> 

___

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: NSTerminateLater and thread

2011-06-06 Thread Leonardo
I will try that, anyway I think the OS should grant the developer to manage
the logout at his wish. For example, I return NSTerminateLater, then I
launch my task in a thread and, at then end of the task I call
replyToApplicationShouldTerminate:YES
Easy. I understand the developer could even "forget" to call
replyToApplicationShouldTerminate but there are so many other bad and worse
things he can do actually, so why don't give him the freedom to make this
mistake too? Mistery.



Regards
-- Leonardo



Da: Peter Lübke 
Data: Sat, 4 Jun 2011 04:47:48 +0200
A: Leonardo , Kyle Sluder 
Cc: Cocoa Developers 
Oggetto: Re: NSTerminateLater and thread

 
Besides from the fact I didn't care about the aborted logout, I was wrong
anyway due to bad memory :(

But you can bring up an application modal window after detaching the
secondary thread in applicationShouldTerminate, giving the user options like
cancelling, showing a progress indicator etc..
Repeatedly call runModalSession until the task is finished or the user
cancelled.
This worked fine for me in a similar situation.
I guess a logout will time out anyway if the task takes too long.

Cheers,
Peter



Am 03.06.2011 um 22:23 schrieb Leonardo:

> Thank you Kyle,
> however, I realize, it's incredible there is no way to execute a task before
> quitting the app. I easily run a task at launch but I can't run a task
> before quit. The problem is that the task could a few minutes and the app
> should remain responsive to the user, in the best Mac tradition.
> I will struggle myself some day more on this issue. Let's cross the fingers.
> 
> Regards
> -- Leonardo
> 
> 
>  
>> Da: Kyle Sluder 
>> Data: Fri, 3 Jun 2011 11:35:41 -0700
>> A: Peter Lübke 
>> Cc: Leonardo , Cocoa Developers
>> 
>> Oggetto: Re: NSTerminateLater and thread
>> 
>> 2011/6/3 Peter Lübke :
>>  
>>> Return NSTerminateCancel when applicationShouldTerminate calls
>>> ExecuteLogOutTask to be performed in a secondary thread.
>>> At the end of your ExecuteLogOutTask method, call something like
>>> [myApplicationDelegate performSelectorOnMainThread:(logOutTaskDidFinish)
>>>  withObject:nil waitUntilDone:NO].
>>> Then, in logOutTaskDidFinish, call NSApplication's -terminate: method and
>>> set a flag indicating that ExecuteLogOutTask was already executed.
>>> The next time applicationShouldTerminate is called, return NSTerminateNow if
>>> this flag is has been set so ExecuteLogOutTask is not called forever.
>>>  
>> 
>> That's not going to resume the aborted logout.
>> 
>> Leonardo, you will need to either finish your task in the time
>> allotted by NSTerminateLater, or you will need to abort logout.
>> 
>> --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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: iOS: Automatically resizing subviews

2011-06-06 Thread David Duncan
On Jun 5, 2011, at 11:51 PM, Development wrote:

> 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?


The contentMode is irrelevant (it has to do with how the view's graphical 
content – what you draw in -drawRect: – fits in the view, not its subviews).

You may want to just spend a bit of time in Interface Builder prototyping this, 
as it can sometimes be difficult to predict what you get from setting the 
autoresizing masks in a particular way.
--
David Duncan

___

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-06 Thread Thomas Davie

On 6 Jun 2011, at 16:10, Philip Mötteli wrote:

> Hi,
> 
> 
> Am 06.06.2011 um 00:12 schrieb 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.
> 
> I really appreciate how BN support is implemented in ParseKit: 
> . I like it very much, that there are no 
> numbers, but call backs for every token, using method-names (c. f. above URL 
> under "Instantiating Grammar Parsers in Objective-C").

Yep, I agree that my current implementation is not particularly nice in that 
respect.  That said, I'm not entirely keen on ParseKit's design either.  The 
alternative I'm pondering at the moment is to add a protocol defining 
-initWithSyntaxTree: and have CP do

id x = [NSStringFromClass(nonTerminalName) alloc];
if ([x conformsToProtocol:@protocol(CPParsing)])
{
return [[x initWithSyntaxTree:tree] autorelease];
}
else
{
return tree;
}

It strikes me that this has disadvantages for the user too (creating a lot of 
boiler plate classes potentially).  It seems to fit cases where you actually 
want to construct a data structure from your parse nicely, but not so well when 
you want to do a computation as a result of the parse.

I will think about it some more, but I'd appreciate contributions on how to do 
this cleanly.

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


Re: iOS: Automatically resizing subviews

2011-06-06 Thread Development
The parent view does not clip the subview actually. However the inner view is 
set to the exact same rectangle as the outer one initially. Would that make a 
difference?


On Jun 6, 2011, at 6:55 AM, Heath Borders wrote:

> Make sure your subviews are small enough to fit inside your view initially.
> I've had issues with resizing clipped subviews.
> 
> -Heath
> On Jun 6, 2011 1:52 AM, "Development"  wrote:
>> 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/heath.borders%40gmail.com
>> 
>> This email sent to heath.bord...@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/development%40fornextsoft.com
> 
> This email sent to developm...@fornextsoft.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-06 Thread Philip Mötteli
Hi,


Am 06.06.2011 um 00:12 schrieb 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.

I really appreciate how BN support is implemented in ParseKit: 
. I like it very much, that there are no 
numbers, but call backs for every token, using method-names (c. f. above URL 
under "Instantiating Grammar Parsers in Objective-C").


Thanks for your 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: postNotificationName Executes Many Times for a Single Invocation

2011-06-06 Thread Bing Li
Dear Graham,

You are right. I am trying to fix the bug.

Thanks so much!

Best regards,
Bing

On Mon, Jun 6, 2011 at 9:46 PM, Graham Cox  wrote:

>
> On 06/06/2011, at 11:40 PM, Bing Li wrote:
>
> > The log is shown as follows similarly. This log tells a single invocation
> > got three notifications. Why?
>
>
> Probably because you subscribed to the same notification three times.
>
> The notification center doesn't bother to work out that you've already
> asked for a given notification from a given target, it just adds it to its
> list of subscribers. If that contains the same object three times, it gets
> called three times.
>
> --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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: iOS: Automatically resizing subviews

2011-06-06 Thread Heath Borders
Make sure your subviews are small enough to fit inside your view initially.
I've had issues with resizing clipped subviews.

-Heath
On Jun 6, 2011 1:52 AM, "Development"  wrote:
> 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/heath.borders%40gmail.com
>
> This email sent to heath.bord...@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: postNotificationName Executes Many Times for a Single Invocation

2011-06-06 Thread Graham Cox

On 06/06/2011, at 11:40 PM, Bing Li wrote:

> The log is shown as follows similarly. This log tells a single invocation
> got three notifications. Why?


Probably because you subscribed to the same notification three times.

The notification center doesn't bother to work out that you've already asked 
for a given notification from a given target, it just adds it to its list of 
subscribers. If that contains the same object three times, it gets called three 
times.

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

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


postNotificationName Executes Many Times for a Single Invocation

2011-06-06 Thread Bing Li
Dear all,

I got a problem which confused me when using postNotificationName. The
method that invokes "postNotificationName" is as follows. The line that
includes "postNotificationName" runs multiple times even though the method
is invoked only one time. Why could it happen?

-(void)notifyMessageReceived:(NSString *)message
{
// The line is added to prove that the method is invoked.
NSLog(@"** Begin NotifyMessageReceived");

NSMutableDictionary *messageDictionary = [[[NSMutableDictionary
alloc] initWithCapacity:5] autorelease];
[messageDictionary setObject:message forKey:@"RECEIVED_MESSAGE"];

// The following line can execute many times even though the method
is invoked for only once! When will it happen?
[[NSNotificationCenter defaultCenter]
postNotificationName:@"MESSAGE_RECEIVED"
object:self userInfo:messageDictionary];

// The line ensures that the method is ended
NSLog(@"** End NotifyMessageReceived");
}

The log is shown as follows similarly. This log tells a single invocation
got three notifications. Why?

2011-06-06 21:38:48.281 Overlay[4515:3507] ** Begin
NotifyMessageReceived
2011-06-06 21:38:48.282 Overlay[4515:3507] Message Received!
2011-06-06 21:38:48.282 Overlay[4515:3507] Message Received!
2011-06-06 21:38:48.282 Overlay[4515:3507] Message Received!
2011-06-06 21:38:48.283 Overlay[4515:3507] ** End NotifyMessageReceived

Thanks so much!

Best regards,
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: Can NSNotificationCenter Memorize Old Events?

2011-06-06 Thread Bing Li
Dear Jonathan,

Thanks! I tried. Obj-C string is not the reason to the problem.

Best,
Bing

On Mon, Jun 6, 2011 at 6:53 PM, jonat...@mugginsoft.com <
jonat...@mugginsoft.com> wrote:

> HI Bing
>
> I don't know why the note center is behaving as it is but you have used C
> strings where you should have used Obj-C string literals (note the @).
> This may be the source of the weird behaviour.
>
> Regards
>
> Jonathan Mitchell
>
> Developer
> Mugginsoft LLP
> http://www.mugginsoft.com
>
>
>
>
>
>
>
> On 6 Jun 2011, at 11:38, Bing Li wrote:
>
> Dear Jonathan,
>
> Thanks so much for your reply!
>
> But I don't understand what you said. Could you explain that much?
>
> Best regards,
> Bing
>
> On Mon, Jun 6, 2011 at 6:17 PM, jonat...@mugginsoft.com <
> jonat...@mugginsoft.com> wrote:
>
>>
>> On 6 Jun 2011, at 10:51, Bing Li wrote:
>>
>> >// The lines are used to save message in a dictionary to transmit
>> > with the notification
>> >NSMutableDictionary *messageDictionary = [[[NSMutableDictionary
>> > alloc] initWithCapacity:5] autorelease];
>> >[messageDictionary setObject:message forKey:"RECEIVED_MESSAGE"];
>> Try:
>>
>> [messageDictionary setObject:message forKey:@"RECEIVED_MESSAGE"];
>>
>> >
>> >// To my surprise, the line is invoked the same times as the
>> times
>> > the client initializes a connection even though the client just sends
>> only
>> > one message after each connection is initialized
>> >[[NSNotificationCenter defaultCenter]
>> > postNotificationName:"MESSAGE_RECEIVED" object:self
>> > userInfo:messageDictionary];
>> >}
>> Try:
>>
>> [[NSNotificationCenter defaultCenter]
>> postNotificationName:@"MESSAGE_RECEIVED" object:self
>> userInfo:messageDictionary];
>>
>> Regards
>>
>> Jonathan Mitchell
>>
>> Developer
>> Mugginsoft LLP
>> http://www.mugginsoft.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: Asynchronous Notification Does NOT Work

2011-06-06 Thread Ken Thomases
Hi Bing,

On Jun 5, 2011, at 11:36 PM, Bing Li wrote:

> In my system, a server needs to handle requests from remote clients. Multiple 
> local threads are raised to listen to the specific port concurrently.

This is an unusual design.  It is more common for one thread (often the main 
thread) to listen for connection requests.  When a connection is made, then the 
work associated with that connection may be spun off into its own thread.

It is not normal for multiple threads to all listen for connections on the same 
port.

> When a request is received by one of the thread, it must notify other 
> responding threads asynchronously.

What do the other threads do with this notification?  Why must they be 
notified?  Is it just to coordinate shared access to the port?  If so, you're 
better off eliminating that shared access, as described above.

> 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.

Notifications were never going to be asynchronous in this sense.  Using 
NSNotificationQueue is not really asynchronous, it's only deferred.  When 
notifications are delivered, they are always delivered synchronously.  It's 
just that delivery can be delayed so that it doesn't occur at the moment it's 
queued; it can happen later, when control is returned to the run loop.  And 
that's in addition to the fact that notifications don't cross threads.

If you have a reference to the NSThread you wish to notify, you can use 
-performSelector:onThread:withObject:waitUntilDone: with NO for the wait 
parameter to submit a message to that thread.  However, once again, such 
performed selectors rely on the run loop.  If you're not going to run the run 
loop on your thread, the thread won't receive these messages.


That brings us to another question: how do you imagine that an asynchronous 
communication could be received by a thread which isn't specifically arranging 
to receive it?  As a practical matter, there's no useful mechanism to interrupt 
a thread which is not cooperating and cause it to run some method or function.  
The target thread must be cooperating with your attempt to communicate with it. 
 It must have made arrangements to receive your message.  For example, it must 
include a pipe, socket, Mach port, or some similar communication mechanism in 
the set of I/O inputs it's waiting for.  The easiest way to achieve this is 
using the run loop.

If your thread runs its run loop, then it's automatically cooperating with 
communication mechanisms built into the frameworks, such as 
-performSelector:onThread:withObject:waitUntilDone:.  Or, you can add your own 
run loop source to the run loop to build another mechanism.  For example, you 
could add an NSMachPort to the run loop, and other threads can send messages to 
that run loop to have them received by the target thread.  This technique is 
illustrated in Apple's documentation about run loops 
.

If you're not comfortable with run loops, you can use a pipe and select(), 
kqueue(), or poll() to achieve something similar.  The idea is to alter your 
code such that, at each place where you would otherwise perform blocking I/O on 
a single file descriptor, you instead block in select() waiting on multiple 
file descriptors.  You should then configure all of the file descriptors for 
non-blocking I/O.  When each file descriptor is ready, you read what's 
immediately available from it and do the appropriate work on the received data. 
 Then you go back to select() to wait for any of your file descriptors to have 
more data.  Once you have an architecture like this, you can create a pipe for 
inter-thread communication.  Each thread would have its own pipe.  It would add 
the read end of that pipe to the set passed to select().  When other threads 
want to communicate with that thread, they'd write to the other end of the 
pipe.  (This is the sort of hard-coded, non-generalizable, and inflexible 
mechanism that a run loop is designed to replace with a generalized and 
flexible mechanism, but you may be more familiar with it.)

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: Can NSNotificationCenter Memorize Old Events?

2011-06-06 Thread jonat...@mugginsoft.com

On 6 Jun 2011, at 10:51, Bing Li wrote:

>// The lines are used to save message in a dictionary to transmit
> with the notification
>NSMutableDictionary *messageDictionary = [[[NSMutableDictionary
> alloc] initWithCapacity:5] autorelease];
>[messageDictionary setObject:message forKey:"RECEIVED_MESSAGE"];
Try:

[messageDictionary setObject:message forKey:@"RECEIVED_MESSAGE"];

> 
>// To my surprise, the line is invoked the same times as the times
> the client initializes a connection even though the client just sends only
> one message after each connection is initialized
>[[NSNotificationCenter defaultCenter]
> postNotificationName:"MESSAGE_RECEIVED" object:self
> userInfo:messageDictionary];
>}
Try:

[[NSNotificationCenter defaultCenter]
postNotificationName:@"MESSAGE_RECEIVED" object:self
userInfo:messageDictionary];

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.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


Can NSNotificationCenter Memorize Old Events?

2011-06-06 Thread Bing Li
Dear all,

I got a weird phenomenon when using NSNotificationCenter. At the server end,
when a remote message is received, the following code is called to notify
relevant module to respond.

When a client initializes a TCP connection with the server, it just sends
only one message each time. After that, it disconnects the connection. After
each disconnection, the relevant memory must be released, including removing
the observers.

If the client connects the server for the 2nd time, two notifications are
posted even though only one message is sent from the client! For the 3rd
time, three notifications for just one message. … The server becomes normal
until it is restarted.

I felt weird about the phenomenon. It seems that the NSNotificationCenter
can memorize the previous or old events? So even though I attempt to post
just one event, the previous events are also posted with the new one? Is it
true? How to clear the previous events?

-(void)notifyMessageReceived:(NSString *)message
{
 // In the log, the string, "NotifyMessageReceived", is shown only
once if the remote client sends just one message.
NSLog(@"NotifyMessageReceived");

// The lines are used to save message in a dictionary to transmit
with the notification
NSMutableDictionary *messageDictionary = [[[NSMutableDictionary
alloc] initWithCapacity:5] autorelease];
[messageDictionary setObject:message forKey:"RECEIVED_MESSAGE"];

// To my surprise, the line is invoked the same times as the times
the client initializes a connection even though the client just sends only
one message after each connection is initialized
[[NSNotificationCenter defaultCenter]
postNotificationName:"MESSAGE_RECEIVED" object:self
userInfo:messageDictionary];
}

Thanks so much!

Best regards,
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: [ANN] CoreParse

2011-06-06 Thread Thomas Davie

On 5 Jun 2011, at 15:35, Stephane Sudre wrote:

> Hi,
> 
> your post probably misses the following stuff:
> 
> - a URL
> - the license
> - whether it's written in Obj-C 2.0 (which I personally hope it's not) or 1.0.


That'll teach me for posting this just as I was going out the door!

- URL - http://www.github.com/beelsebob/CoreParse
- The License - BSD 3 part
- Obj-C 2.0 - yes, fraid so, it's all Obj-C 2.0 and requires the non-fragile 
ABI too.  It supports both ref counting and GC modes though.

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