Re: Need some advice on multithreading

2008-11-24 Thread Peter N Lewis

At 13:38 -0500 24/11/08, Michael Ash wrote:

No, it's not a general consensus. It's something I discovered on my
own, and posted about it here. I haven't received any overall
confirmation that it's broken, but my simple test project was able to
reliably crash on perhaps half a dozen different hardware
configurations. (And fail to crash on quite a few more.)

If you like, you can go through the original thread here and come to
your own conclusions:

http://www.cocoabuilder.com/archive/message/cocoa/2008/10/30/221452

If you want to know more about it, please feel free to ask me.


I looked through this a bit further and am sadly coming to the 
conclusion that you're right, under some (quite easy to duplicate) 
circumstances, the NSInvocationOperation appears to be executed by 
two worker threads and chaos ensues.


As near as I can tell, it is safe if (and perhaps only if) 
addOperation only happens on the main thread (or perhaps only happens 
on a single thread).


As soon as addOperation happens on multiple threads, even if the 
queue is set to  setMaxConcurrentOperationCount = 1, and even if no 
queue ever executes more than a single NSInvocationOperation, then 
the problem appears.


I adjusted your test such that a new Tester object (with new 
NSOperationQueue) is created each time so only a single operation is 
ever executed for any given NSOperationQueue and it still results in 
[NSInvocationOperation start] being called twice for the same 
operation.


The only saving grace is that 
performSelectorOnMainThread:@selector(addOperation:), or only calling 
the addOperations from the main thread resolves the problem, which 
means my recent use of NSOperation in soon to be shipping code should 
be safe, but I certainly would not be recommending NSOperationQueue 
be used as it stands and would not have used if I knew what I know 
now.


Very sad.
   Peter.

--
  Keyboard Maestro 3 Now Available!
Now With Status Menu triggers!

Keyboard Maestro  Macros for your Mac
   
___

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 [EMAIL PROTECTED]


Re: Call getElementById in Cocoa

2008-11-24 Thread Pierce Freeman
Okay Adam, I think I am beginning to understand.  However, I just get two
problems trying to run that code:

1. error: 'request' undeclared (first use in this function)
2. warning: 'webView' may not respond to '+isLoading'

Thanks for your help.


Sincerely,

Pierce Freeman

-- 
Pierce Freeman
[EMAIL PROTECTED]





On 11/24/08 7:02 PM, "Adam R. Maxwell" <[EMAIL PROTECTED]> wrote:

> 
> On Nov 24, 2008, at 6:32 PM, Pierce Freeman wrote:
> 
>> Sorry for my newbie-ness, but I still don't really get what you are
>> talking
>> about.  Are you saying that I should do this:
>> 
>> [WebView setFrameLoadDelegate:didFinishLoadForFrame];
>> 
>> - (void)didFinishLoadForFrame
>> {
>>// Do stuff
>> }
> 
> No.  Here you're sending setFrameLoadDelegate: to the WebView class
> instead of an instance, and passing part of the method name as an
> argument.  It likely won't compile, and certainly won't work.
> Additionally, you're missing part of the delegate method signature.
> 
> You'd typically have something like this:
> 
> - (void)loadURL
> {
>  NSURLRequest *request = [NSURLRequest requestWithURL:_httpURL
> cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60.0];
> 
> // self is an object implementing any delegate methods you want to
> receive
>  [_webView setFrameLoadDelegate:self];
>  [[_webView mainFrame] loadRequest:request];
> }
> 
> - (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)
> error forFrame:(WebFrame *)frame;
> {
>  // do something with error
> }
> 
> - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)
> frame
> {
>  // wait until all frames are loaded
>  if (NO == [_webView isLoading])
>  // do something with frame/view
> }
> 
> where the delegate messages are delivered after each frame loads or
> fails.  This is the basic delegate pattern in Cocoa, which should be
> explained pretty thoroughly in the documentation.
> 
> See 
> http://developer.apple.com/documentation/Cocoa/Conceptual/DisplayWebContent/Ta
> sks/LocationChanges.html
>   and 
> http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/Co
> mmunicatingWithObjects/chapter_6_section_4.html.


___

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 [EMAIL PROTECTED]


Re: Multiple views in a nib file?

2008-11-24 Thread Graham Cox


On 25 Nov 2008, at 4:56 am, Jean-Nicolas Jolivet wrote:

Thanks a lot for your reply! It does help a lot to see how someone  
else implemented a similar concept!... I love the multiple  
controllers (1 per subclass) / Multiple views (again, 1 per  
subclass)  idea... I'll try to implement it for my situation as it  
seems to be the best way to go...



I should also mention that, in my graphics attributes classes, there  
is a certain amount of inheritance going on - they all inherit a  
common root class, but some build on others too, for example I have a  
basic stroke class, and a number of modified strokes that subclass it.  
The controllers follow exactly the same inheritance pattern also, so  
each controller class is only implementing the additional or different  
parts from its ancestor. The amount of work needed in the controllers  
classes is thus kept to a minimum.


In fact, because I'm using KVO most of the key functionality is in the  
controller root class and isn't duplicated for the subclasses. To make  
this work I leverage -setValue:forKeyPath: in a different way - I have  
each controller implement methods that mimics the model object's  
methods - in other words they have identical keypaths. In the  
controller's case the method sets the relevant control's value, in the  
model class it sets the property, as usual. Then, in my KVO observer  
method in the root controller class, I just do this (removing some  
context-checking code for clarity):


- (void)	observeValueForKeyPath:(NSString*) keypath ofObject:(id)  
object change:(NSDictionary*) change context:(void*) context

{
id theValue = [change objectForKey:NSKeyValueChangeNewKey];
[self setValue:theValue forKeyPath:keypath];
}


This means each controller subclass just needs to implement a method  
for each property it's observing having the same keypath, and the UI  
just works. I also override setValueForUndefinedKey: as a no-op so  
that if I forget a method the ensuing exception doesn't bring it to a  
halt.


Of course bindings takes this idea to its ultimate conclusion, but I  
like this way because there's no real hidden magic, other than  
setValue:forKeyPath:, and the amount of glue code required is really  
small. In fact, one could even eliminate the glue code by adopting a  
naming convention for control outlets also, but I currently don't  
bother. However, once you have done that you've really reinvented  
bindings.


--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 [EMAIL PROTECTED]


Re: Call getElementById in Cocoa

2008-11-24 Thread Adam R. Maxwell


On Nov 24, 2008, at 6:32 PM, Pierce Freeman wrote:

Sorry for my newbie-ness, but I still don't really get what you are  
talking

about.  Are you saying that I should do this:

[WebView setFrameLoadDelegate:didFinishLoadForFrame];

- (void)didFinishLoadForFrame
{
   // Do stuff
}


No.  Here you're sending setFrameLoadDelegate: to the WebView class  
instead of an instance, and passing part of the method name as an  
argument.  It likely won't compile, and certainly won't work.   
Additionally, you're missing part of the delegate method signature.


You'd typically have something like this:

- (void)loadURL
{
NSURLRequest *request = [NSURLRequest requestWithURL:_httpURL  
cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60.0];


	// self is an object implementing any delegate methods you want to  
receive

[_webView setFrameLoadDelegate:self];
[[_webView mainFrame] loadRequest:request];
}

- (void)webView:(WebView *)sender didFailLoadWithError:(NSError *) 
error forFrame:(WebFrame *)frame;

{
// do something with error
}

- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *) 
frame

{
// wait until all frames are loaded
if (NO == [_webView isLoading])
// do something with frame/view
}

where the delegate messages are delivered after each frame loads or  
fails.  This is the basic delegate pattern in Cocoa, which should be  
explained pretty thoroughly in the documentation.


See http://developer.apple.com/documentation/Cocoa/Conceptual/DisplayWebContent/Tasks/LocationChanges.html 
 and http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_4.html.


--
Adam

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 [EMAIL PROTECTED]

Re: MVC in Cocoa?

2008-11-24 Thread Clark Cox
On Thu, Nov 20, 2008 at 4:13 PM, Michael Hines <[EMAIL PROTECTED]> wrote:
> Hey guys,
>
> This is my first message to the mailing list, so please let me know if
> I violate any form of etiquette.  I apologize ahead of time.
>
> This is also my first Obj-C and Cocoa application.
>
> My application is basically a client for a text-protocol TCP server.
> If you are familiar with freechess.org, this is what I'm consuming.
>
> I want to have several views for the application.  For example I want
> to have a login view, console view, a game board view, a chat view,
> etc.
>
> I have experience in Ruby on Rails, so I have an intuition that
> somehow I should implement models for Commands, Chats, Games, etc.,
> but I'm having trouble imagining how exactly this should be done.
>

> Specifically, who should own the connection?

Typically, the model itself should pretty dumb (i.e. set this
attribute, get this other attribute, load from file, save to file,
etc.)
The controller (or controllers) should be responsible for the "smarts"
(i.e. when the user does this, I tell the model to set these
attributes, when the view asks to draw that, I give it these
attributes from the model, etc.). The controllers are responsible for
managing the connections.

> How should it communicate with the models?

The model should be responsible for posting appropriate notifications
as its attributes are changed (quite trivial with Key Value
Notification).
The controller and view should listen for those notifications and take
action as appropriate

> How will the controllers get the same instances of the models?

If your application only has one model, then it can be a global
singleton, otherwise, the controller can be responsible for creating
the model when needed (remember, the controller should be responsible
for most of the "smarts").

> How can I have the views update dynamically when the models change?

Look into Key Value Coding, Key Value Observation, and Key Value
Binding. If your model is set up with accessor methods that follow the
normal Cocoa paradigms, then the notification happens as needed,
virtually automatically as the setters are called.

-- 
Clark S. Cox III
[EMAIL PROTECTED]
___

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 [EMAIL PROTECTED]


Re: Call getElementById in Cocoa

2008-11-24 Thread Pierce Freeman
Sorry for my newbie-ness, but I still don't really get what you are talking
about.  Are you saying that I should do this:

[WebView setFrameLoadDelegate:didFinishLoadForFrame];

- (void)didFinishLoadForFrame
{
// Do stuff
}


Sincerely,

Pierce F.


On 11/24/08 6:02 PM, "Adam R. Maxwell" <[EMAIL PROTECTED]> wrote:

> 
> On Nov 24, 2008, at 5:53 PM, Pierce Freeman wrote:
> 
>> Thanks for your response, though I am wondering how I could make the
>> delegate method.  I know how to do it for NSWorkspace, however not for
>> WebKit.
> 
> Call -[WebView setFrameLoadDelegate:] and then implement whatever
> WebFrameLoadDelegate methods you want (such as
> webView:didFinishLoadForFrame: and
> webView:didFailLoadWithError:forFrame:) in the delegate.  Check -
> [WebView isLoading] in your delegate implementation, and when it
> returns NO, you're done and can operate on the view or handle the error.


___

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 [EMAIL PROTECTED]


Re: Call getElementById in Cocoa

2008-11-24 Thread Adam R. Maxwell


On Nov 24, 2008, at 5:53 PM, Pierce Freeman wrote:


Thanks for your response, though I am wondering how I could make the
delegate method.  I know how to do it for NSWorkspace, however not for
WebKit.


Call -[WebView setFrameLoadDelegate:] and then implement whatever  
WebFrameLoadDelegate methods you want (such as  
webView:didFinishLoadForFrame: and  
webView:didFailLoadWithError:forFrame:) in the delegate.  Check - 
[WebView isLoading] in your delegate implementation, and when it  
returns NO, you're done and can operate on the view or handle the error.


--
Adam



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 [EMAIL PROTECTED]

Re: Call getElementById in Cocoa

2008-11-24 Thread Pierce Freeman
Hi Adam:

Thanks for your response, though I am wondering how I could make the
delegate method.  I know how to do it for NSWorkspace, however not for
WebKit.


Sincerely,

Pierce F.


On 11/24/08 5:41 PM, "Adam R. Maxwell" <[EMAIL PROTECTED]> wrote:

> 
> On Nov 24, 2008, at 5:10 PM, Pierce Freeman wrote:
> 
>> Okay, sounds good.  Just making sure, would that code would work?
> 
> It looked fine to me; I use something similar for loading URLs in an
> offscreen webview.  As Jean-Daniel pointed out, you'll have to use the
> delegate methods to tell when it's loaded, or else load it
> synchronously using something like this:
> http://lists.apple.com/archives/quicklook-dev/2007/Nov/msg00047.html.


___

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 [EMAIL PROTECTED]


Re: iPhone Development Lists

2008-11-24 Thread Bruno Sanz Marino

Here you have 2 lists on the web

There are more...


http://forums.macrumors.com/forumdisplay.php?f=135

http://www.iphonedevsdk.com/forum/iphone-sdk-development/


I. Savant escribió:

I noticed that there is NOT an iPhone Dev list on this server.  Does anyone
have any recommendations for newbie iPhone development?  The only one I know
of is iPhoneDevCentral.Org, however it is quite limited at the moment?



  Have you searched this list's archives or read the details of the
iPhone developer program? When you join, you can sign in and enjoy the
(password-protected, for-members-only) forums offered there. This is
done (apparently) as a way to preserve the non-disclosure agreement
but give developers the forum they've been demanding for months.

--
I.S.
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/brunosanzmarino%40gmail.com

This email sent to [EMAIL PROTECTED]

  


___

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 [EMAIL PROTECTED]


NSAnimation subclass calling display on a view

2008-11-24 Thread David Alter
I'm creating an animation using NSAnimation. I have created a subclass of
NSAnimation that over loads setCurrentProgress. The delegate is a subclass
of NSImageView. When setCurrentProgress gets called I call my delegate
display method. My drawRect method in my subclass of NSImageView identifies
if we are animating and draws accordingly.

//Here is where I create an instance of my animation subclass. I'm using the
default settings for blocking.
myAnimationSubclass = [[MyAnimation alloc] initWithDuration:0.5
animationCurve:NSAnimationEaseInOut];
[myAnimationSubclass setDelegate:delegate];
// Run the animation synchronously.
[myAnimationSubclass startAnimation];

//This is from my subclass of NSAnimation
- (void)setCurrentProgress:(NSAnimationProgress)progress {
[super setCurrentProgress:progress];

  [[self delegate] display];
}


//This is from my subclass of NSImageView
- (void)drawRect:(NSRect)rect {
if(![myAnimationSubclass isAnimating]) {
[super drawRect:rect];
} else {
//Do my drawing stuff
}
}

My drawRect method is not being called until the animation is complete. It
was my understanding that calling display would force an immediate redrawing
of the NSView, or subclass of NSImageView in this case. This would result in
calling drawRect. However setCurrentProgress is getting called several times
but drawRect is not being called. Resulting in no animation.

I'm clearly missing something but I'm not sure what it is. If you have any
ideas please let me know.

thanks
-dave
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Call getElementById in Cocoa

2008-11-24 Thread Adam R. Maxwell


On Nov 24, 2008, at 5:10 PM, Pierce Freeman wrote:


Okay, sounds good.  Just making sure, would that code would work?


It looked fine to me; I use something similar for loading URLs in an  
offscreen webview.  As Jean-Daniel pointed out, you'll have to use the  
delegate methods to tell when it's loaded, or else load it  
synchronously using something like this: http://lists.apple.com/archives/quicklook-dev/2007/Nov/msg00047.html.


--
Adam

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 [EMAIL PROTECTED]

Re: MVC in Cocoa?

2008-11-24 Thread Michael Hines
Have you read the MVC introduction from Apple?
<
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/chapter_5_section_4.html
>

sherm--

So I read the MVC introduction and a bunch of the other design patterns
documents, this is how I see the models working:  Some kind of static
connection class that models add observers to.  When views load the
controller creates a model and maybe add it's own observer to the model to
update the view.

I have two problems then. The static connection class seems hackish. I'm not
sure if it's even possible in ObjC. Is there a better option?
Is the "observer" option the way to go?  What class documentation should I
look at for that?

-- Mike
___

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 [EMAIL PROTECTED]


Re: Call getElementById in Cocoa

2008-11-24 Thread Pierce Freeman
Okay, sounds good.  Just making sure, would that code would work?


Sincerely,

Pierce F


On 11/24/08 3:54 PM, "Jean-Daniel Dupas" <[EMAIL PROTECTED]> wrote:

> The link I provided is for another option, using Javascript call to
> retreive the value, but I think using the native DOM API is prefered.
> 
> Note that before calling mainFrameDocument, you should make sure the
> document is loaded. There is probably a WebView delegate method that
> provide this info.
> 
> 
> Le 25 nov. 08 à 00:43, Pierce Freeman a écrit :
> 
>> Does this code convey what you are saying/how to do this?
>> 
>> IBOutlet id webView;
>> 
>> NSString *urlOfObject = [NSString stringWithFormat:
>> @"http://www.somesite.com/hiddenFieldPage.php";];
>> 
>> 
>> [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL
>> URLWithString:urlOfObject]]];
>> 
>> DomDocument *domObject = [webView mainFrameDocument];
>> 
>> NSString *hiddenField = [domObject getElementById:@"hiddenField"];
>> 
>> Also, how would the link that you gave come into play in this case?
>> 
>> 
>> Sincerely,
>> 
>> Pierce F
>> 
>> 
>> 
>> On 11/24/08 8:11 AM, "Jean-Daniel Dupas" <[EMAIL PROTECTED]>
>> wrote:
>> 
>>> 
>>> Le 24 nov. 08 à 16:42, Pierce Freeman a écrit :
>>> 
 Hi everyone.
 
 I am wondering if there is some way to call the getElementById on a
 website
 through Cocoa, and then return the value of the field.  I am
 assuming it
 would somehow be through WebKit, but I am not sure how to do this
 (as well
 as if the method needs a different way to get the page's code).  The
 use
 would be the application getting the value of a hidden field, and
 then
 outputting it to the user.
 
 
 Sincerely,
 
 Pierce Freeman
>>> 
>>> You can do this either by using the Cocoa DOM API directly:
>>> 
>>> You call -mainFrameDocument on your WebView to get a DOMDocument
>>> instance, and have access to the DOM functions from here (there is no
>>> up-to-date doc of the Cocoa DOM API, you will have to check headers
>>> files directly to see what function is available, for example the
>>> DOMDocument.h file show you that there is a -[DomDocument
>>> getElementById:] method.
>>> 
>>> or you can execute js from your Cocoa code:
>>> 
>>> http://developer.apple.com/documentation/Cocoa/Conceptual/DisplayWebContent/
>>> Ta
>>> sks/JavaScriptFromObjC.html
>>> 
>>> 
>>> 
>>> 
>>> 
>> 
>> 
>> 
> 


___

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 [EMAIL PROTECTED]


Re: Need some advice on multithreading

2008-11-24 Thread Peter Duniho

Date: Mon, 24 Nov 2008 11:35:42 +0100
From: WT <[EMAIL PROTECTED]>

Hi Peter,

thanks for answering my post.


Happy to.  :)


[...]

While it may wind up making sense to put the simulation engine in a

separate thread, I would recommend _not_ trying to adjust the
simulation rate to account for the speed of the balls, precision,  
etc.

This sort of load-adjusting sounds good in theory, but it ultimately
fails because the performance characteristics of the code changes
according to the settings.



I'm afraid I'll have to disagree.


It's your program, your prerogative.  :)  Still...


My concern is not balancing the CPU
load, but getting accurate results. To use the bouncing balls example
again, if the balls move fast enough and if I don't compensate by
decreasing the time-interval through which I'm advancing the motion,
the balls WILL overlap and may do so considerably. Even if they don't
overlap in a way that's visible to the human eye, overlaps may cause
other anomalies, such as energy non-conservation. These kinds of
problems are typical of numerical integration of differential
equations and have nothing to do with optimizing the CPU use.


Sure, they do.  The only reason to not run the simulation at the  
minimum time-interval possible is to adjust CPU usage.  My advice:  
just always run the simulation at the minimum time-interval possible.


You seem to have misunderstood my statement to mean that you should  
_reduce_ the precision always.  I'm not saying that.  I'm saying that  
you should run the simulation at maximum precision always.


And while I appreciate that you feel I and others have gone off-road  
a bit with your question, the fact is, you posted the original  
message, and it doesn't make sense for you to then expect people to  
ignore aspects of the message you wrote.  You probably should have  
made the original message more concise and to the point, but given  
that you didn't, objecting to comments offered by people to parts you  
never intended for people to care about doesn't make sense.  You  
posted the message; live with the replies.  At worst, you can just  
ignore them.



[...]
Very true. Another of my concerns, though, is that having high enough
simulation refresh rates and frame update rates will cause a large
number of object allocations, which will compete with other resources
needed for the simulation to happen. It seems to me that lots of
objects in Cocoa cannot be reused once created and have to be created
again. For instance, as far as I know, there is no way to change the
period of an NSTimer that's already in existence. Since both the
simulation update rate and the frame update rate are timer-driven and
dynamically changeable by the user, I expect lots of NSTimer objects
to be created.


I'm not sure I understand the NSTimer concern.  Surely the rate for  
the timer should not change that frequently.  A user can only provide  
their commands so quickly (or at worst, you could respond to them  
only so quickly...even if the user can provide a new timer interval  
every 1 ms, surely it would be fine to update the actual timer  
interval only every 100 ms or so...the user would never know the  
difference).


It is unfortunate that NSTimer doesn't appear to have a way to change  
the auto-repeat interval after creation, but it seems to me that  
creation of NSTimer objects should not be an activity the code would  
spend much of its time doing anyway.


More important to you is probably this information from the timer  
docs (http://developer.apple.com/documentation/Cocoa/Conceptual/ 
Timers/Articles/timerConcepts.html#//apple_ref/doc/uid/2806- 
BAJFBAIH):


Because of the various input sources a typical run loop
manages, the effective resolution of the time interval
for a timer is limited to on the order of 50-100 milliseconds.

In other words, the best you can hope for is a timer firing 10 to 20  
times per second.  This is yet another argument in favor of just  
running the simulation as fast as it will go.  Doing so provides at  
least three benefits:


-- Fewer worries about missing corner-cases in the performance  
testing (mentioned in my previous message)
-- Higher resolution simulation (with NSTimer, your simulation  
thread just isn't going to get notified that frequently)
-- No need to manage _any_ NSTimer objects (so no memory  
management overhead for that at all)


If you insist on adjusting the simulation frequency, you may find  
that using the NSThread's sleepForTimeInterval: method is more  
appropriate.  I don't know for sure, but I suspect that method uses  
Unix's thread-scheduling mechanism, rather than relying on the  
NSRunLoop to manage the notification.  That's likely to produce  
higher-resolution results.


As far as memory management goes, I think more interesting is the  
question of data objects used for inter-thread communication.  One  
advantage of foregoing the advice to use immutable objects is the  
p

Fully justified text on a single line

2008-11-24 Thread Graham Cox
I need to layout some text fully justified even if it's only one line  
or even one word. The standard layout never justifies the last line,  
even when the paragraph alignment is set to NSJustifiedTextAlignment,  
and for one line, the first line is the last line...


I can't see a way to set a flag to alter this behaviour anywhere, so  
I'm guessing I'm going to have to do it myself.


Is changing the value associated with NSKernAttributeName the right  
way to actually alter the letter spacing having calculated the amount  
I need to pad it by?



tia,


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 [EMAIL PROTECTED]


Re: NSOpenPanel Preview

2008-11-24 Thread Graham Cox


On 25 Nov 2008, at 10:12 am, David Blanton wrote:


Cool. I'll look at QuickLook.


David Blanton



Also, note that if you can write your file preview as a PDF or other  
image (JPEG), and your file is packaged, you don't need to write a QL  
plug-in, you just need to add a QuickLook folder to your package and  
store the preview images in there. This is documented but it's well  
buried.


--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 [EMAIL PROTECTED]


Re: Call getElementById in Cocoa

2008-11-24 Thread Jean-Daniel Dupas
The link I provided is for another option, using Javascript call to  
retreive the value, but I think using the native DOM API is prefered.


Note that before calling mainFrameDocument, you should make sure the  
document is loaded. There is probably a WebView delegate method that  
provide this info.



Le 25 nov. 08 à 00:43, Pierce Freeman a écrit :


Does this code convey what you are saying/how to do this?

IBOutlet id webView;

NSString *urlOfObject = [NSString stringWithFormat:
@"http://www.somesite.com/hiddenFieldPage.php";];


[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL
URLWithString:urlOfObject]]];

DomDocument *domObject = [webView mainFrameDocument];

NSString *hiddenField = [domObject getElementById:@"hiddenField"];

Also, how would the link that you gave come into play in this case?


Sincerely,

Pierce F



On 11/24/08 8:11 AM, "Jean-Daniel Dupas" <[EMAIL PROTECTED]>  
wrote:




Le 24 nov. 08 à 16:42, Pierce Freeman a écrit :


Hi everyone.

I am wondering if there is some way to call the getElementById on a
website
through Cocoa, and then return the value of the field.  I am
assuming it
would somehow be through WebKit, but I am not sure how to do this
(as well
as if the method needs a different way to get the page's code).  The
use
would be the application getting the value of a hidden field, and  
then

outputting it to the user.


Sincerely,

Pierce Freeman


You can do this either by using the Cocoa DOM API directly:

You call -mainFrameDocument on your WebView to get a DOMDocument
instance, and have access to the DOM functions from here (there is no
up-to-date doc of the Cocoa DOM API, you will have to check headers
files directly to see what function is available, for example the
DOMDocument.h file show you that there is a -[DomDocument
getElementById:] method.

or you can execute js from your Cocoa code:

http://developer.apple.com/documentation/Cocoa/Conceptual/DisplayWebContent/Ta
sks/JavaScriptFromObjC.html











___

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 [EMAIL PROTECTED]


Re: CGImageDestinationSetProperties does not work for animated GIF

2008-11-24 Thread Patrick Haruksteiner


That was the way I tried it before - like the docs suggested - but it  
did not work.

On my search for a solution to this problem I came across this:

http://pojos-devlog.blogspot.com/2005/08/saving-animated-gif-using- 
coregraphics.html


I thought that this is the solution to my problem, but it only was  
half of it. By wrapping the properties in another dictionary using  
kCGImagePropertyGIFDictionary the frame related properties like the  
frame delay time for animation worked. But the properties affecting  
the whole animated gif, like the loop count did not work. I checked  
the resulting file, the frame related properties have been written,  
the image related not.


I even tested the code in the given example as it was, but it did not  
work for the loop count too.
I'm using 10.4.11 with Xcode 2.4.1 - and I'm wondering that not even  
the above mentioned example works...


Could someone test if the example works for him and produces a gif  
that has the loop property set?


--
Patrick Haruksteiner



Date: Mon, 24 Nov 2008 18:24:16 +1000
From: Rob Keniger <[EMAIL PROTECTED]>
Subject: Re: CGImageDestinationSetProperties does not work for
animated GIF
To: Cocoa-dev Mailinglist 

On 24/11/2008, at 6:24 AM, Patrick Haruksteiner wrote:


  CGImageDestinationSetProperties(imageDestination,
(CFDictionaryRef)finalGIFImageProperties);




I've never worked with this API before, but what happens if you change
the above line to this?:

CGImageDestinationSetProperties(imageDestination, (CFDictionaryRef)
gifImageProperties);

My reading of the the docs seems to suggest that you would pass the
keys directly rather than wrapping them in another dictionary using
kCGImagePropertyGIFDictionary.

--
Rob Keniger



___

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 [EMAIL PROTECTED]


Re: Call getElementById in Cocoa

2008-11-24 Thread Pierce Freeman
Does this code convey what you are saying/how to do this?

IBOutlet id webView;

NSString *urlOfObject = [NSString stringWithFormat:
@"http://www.somesite.com/hiddenFieldPage.php";];


[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL
URLWithString:urlOfObject]]];

DomDocument *domObject = [webView mainFrameDocument];

NSString *hiddenField = [domObject getElementById:@"hiddenField"];

Also, how would the link that you gave come into play in this case?


Sincerely,

Pierce F



On 11/24/08 8:11 AM, "Jean-Daniel Dupas" <[EMAIL PROTECTED]> wrote:

> 
> Le 24 nov. 08 à 16:42, Pierce Freeman a écrit :
> 
>> Hi everyone.
>> 
>> I am wondering if there is some way to call the getElementById on a
>> website
>> through Cocoa, and then return the value of the field.  I am
>> assuming it
>> would somehow be through WebKit, but I am not sure how to do this
>> (as well
>> as if the method needs a different way to get the page's code).  The
>> use
>> would be the application getting the value of a hidden field, and then
>> outputting it to the user.
>> 
>> 
>> Sincerely,
>> 
>> Pierce Freeman
> 
> You can do this either by using the Cocoa DOM API directly:
> 
> You call -mainFrameDocument on your WebView to get a DOMDocument
> instance, and have access to the DOM functions from here (there is no
> up-to-date doc of the Cocoa DOM API, you will have to check headers
> files directly to see what function is available, for example the
> DOMDocument.h file show you that there is a -[DomDocument
> getElementById:] method.
> 
> or you can execute js from your Cocoa code:
> 
> http://developer.apple.com/documentation/Cocoa/Conceptual/DisplayWebContent/Ta
> sks/JavaScriptFromObjC.html
> 
> 
> 
> 
> 


___

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 [EMAIL PROTECTED]


[Reposted] Document based resource strategy

2008-11-24 Thread Carlos Eduardo Mello
Hi, [ I'm reposting this since it apparently  didn't go through the  
first time... ]


Newbie questions here. I've been studying Hillegass's book and  
Apple's Guides and just started to prepare for implementing my own  
code. I know similar questions have been asked here recently but it I  
am still confused about it. Here it is:


I am starting to write my app's GUI in Cocoa. The data model is  
contained in a framework of standard C++ classes. The application is  
documment based. My documents will typically have only one window, so  
I don't think I need to mess with window controlers for now. Within a  
document's window, I need to load several large views (let's call  
them canvas views) upon user commands. These canvases will be  
associated with collections of items in my data model. Each canvas  
will contain several smaller views which need to be loaded/unloaded  
programmatically during program execution. Each small view is  
associated with a data item contained in a collection of items  
represented on screen by the canvas views. These small views need to  
be moved, selected and redimensioned with the mouse. (obs.: a  
suggestion, given to another poster on this list, not to use views  
for the small items, was discarded because I need to handle lots of  
complex behavior which is alredy set up for me in a view, like mouse  
clicks, double clicks, mouse drags, and other user events...)


I started with the document based template in Xcode, and now I want  
to organize my resources in nib files. Here is a list of ideas/ 
questions I have about this whole plan. Please do comment and/or help  
me figure out which way to go.


1. Create all my views (both canvas and item views) programmatically  
and use nib files only for the document window where I can set up  
buttons an other controls to be wired in IB with actions, etc.


2. Create a separate nib file for each type of view and load the  
nib's as needed when a new view is required during execution. From  
everything I've heard on this list and read in books and  
documentation, this seems like a more Cocoa-like approach (?) However  
I fail to see how I would benefit from this since the looks of my  
views will be determined at runtime, pending user actions. Their  
structure is really simple (just collored rectangles), but their  
behavior/dimensions will vary... Also if I go this route, how do I  
reach the individual nibs when it's time to load them?


3. What is the correct way for an NSDocument subclass to access it's  
associated window in order to add/remove views to the window's  
content view? I see it contains an NSWindow instance, but I could  
find no accessors. In all the examples I've tried so far, the views  
were already contained in the nib file's window.


4. My idea is to have my document controller declare an array of  
canvas controllers, in order to hanldle each canvas view and its  
contained items. My GUI needs to organize the canvas views as  
trasnslucent layers of different colors on top of each other so that  
the position of every loaded canvas's items can be compared. The app  
would then move a view to the front when it's items need to be edited.


5. One other thing I am still confused about is when, in a document  
based application, do I need to declare an instance of the NSDocument  
subclass in the nib and when not to.


Any help will be very much appreciated.

Carlos.

___

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 [EMAIL PROTECTED]


Re: NSPopupUpButton not showing checked menu items

2008-11-24 Thread Steve Christensen

On Nov 23, 2008, at 11:26 PM, Benjamin Dobson wrote:

Actually, I only wanted to select a single item in the pulldown  
case, the same as what correctly happens for me in the popup case.  
The problem has always been that, even though the button itself is  
reporting that a particular item is "selected," none of the  
underlying NSMenuItems' state is ever set to anything other than  
where it was left in IB (which is typically NSOffState). And so a  
check mark is never set next to the most-recently selected menu item.


I'm still wondering why you're using a pull down menu, not a pop up  
one.


Very simply because I have a situation where real estate is tight.  
The popup variant always displays the current selection so you need  
to allocate enough horizontal space for the button to display the  
widest menu item text. By using the pulldown button, I can just  
display an icon and "down arrow" on the button, and use more space  
only when the user changes options. I have a descriptive icon next to  
each menu item, which gets reflected directly on the button when the  
menu is closed.


Believe me, if I could do something similar with a popup (vs  
pulldown) button, I would. Much less work.


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 [EMAIL PROTECTED]


Re: NSOpenPanel Preview

2008-11-24 Thread David Blanton

Cool. I'll look at QuickLook.


David Blanton





___

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 [EMAIL PROTECTED]


Re: Using PDF for help --- with spotlight search?

2008-11-24 Thread Russ
I'm trying to get spotlight search support for my PDF help file, users expect 
it to work since the input field is there. This is legit:  Apple Final Cut Pro 
has PDF-based help.

I've been studying what Final Cut Pro does--- it has CFBundleHelpBookFolder set 
to a folder containing the PDF, and it has a HelpMenu.plist XML file there to 
describe what items to put on the help menu.

Is there anything to officially describe and sanction this? (For example, I'd 
like to have only the spotlight search box set up this way, and leave the rest 
of my menu items in place.) I can give it a play, but that can come back to 
cause trouble later. The only docs I've seen describe only the "Apple Help" 
which isn't helpful here.

Final note--- the CFBundleHelpBookFolder stuff looks
to want the help file/folder buried deep inside the app bundle's
resources. That's definitely uncool, users regularly ask tech support
where to find the help file; they expect to be able to find and look at
it themselves without running the app. 

So, I am planning to
change my app to have /Application/myApp be a plain folder containing
the help and support files plus the myApp.app  At present I have that
stuff in /Library/Application Support/myApp and it is widely
overlooked/confusing --- a customer expectation mismatch. 



  
___

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 [EMAIL PROTECTED]


Re: NSOpenPanel Preview

2008-11-24 Thread Mike Abdullah

You want to write a Quick Look generator.
http://developer.apple.com/documentation/UserExperience/Conceptual/Quicklook_Programming_Guide/Introduction/chapter_1_section_1.html#/ 
/apple_ref/doc/uid/TP40005020-CH1-DontLinkElementID_5


On 24 Nov 2008, at 22:36, David Blanton wrote:

I have a custom file format which when selected in an NSOpenPanel I  
want to show a preview.


I can only find information on showing a preview through Navigation  
Services.


Should I use Navigation Services (ugly api)?

I want to use NSOpenPanel.

David Blanton





___

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/cocoadev%40mikeabdullah.net

This email sent to [EMAIL PROTECTED]


___

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 [EMAIL PROTECTED]


Re: NSOpenPanel Preview

2008-11-24 Thread Corbin Dunn

Le Nov 24, 2008 à 2:36 PM, David Blanton a écrit :
I have a custom file format which when selected in an NSOpenPanel I  
want to show a preview.


I can only find information on showing a preview through Navigation  
Services.


Should I use Navigation Services (ugly api)?



No...


I want to use NSOpenPanel.


On Leopard, under the covers Nav Services uses NSOpenPanel. If you  
write a QuickLook plugin for your file format, then it'll work in  
Finder and the open/save panel.


corbin___

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 [EMAIL PROTECTED]


Re: Need some advice on multithreading

2008-11-24 Thread Scott Ribe
You can also drop down below Cocoa. See MPQueue, and google MP2POSIX.
Further discussion would probably be more productive on the mt-smp or
perfoptimization-dev lists. I had typed up much more info, but apparently
there's a magic key in Entourage that clears the text of a draft, closes the
window, and moves the message to the trash all at once--and I hit it by
accident...


___

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 [EMAIL PROTECTED]


NSOpenPanel Preview

2008-11-24 Thread David Blanton
I have a custom file format which when selected in an NSOpenPanel I  
want to show a preview.


I can only find information on showing a preview through Navigation  
Services.


Should I use Navigation Services (ugly api)?

I want to use NSOpenPanel.

David Blanton





___

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 [EMAIL PROTECTED]


Re: Need some advice on multithreading

2008-11-24 Thread WT
That's exactly what I had done in the first place, but the results  
weren't too good. I then wrote a much simpler app (one bouncing  
ball) to test possible solutions and, of course, started with this  
very approach. For fun, I allow the user to rotate the container  
and, sure enough, the ball hangs in mid-air while I'm rotating the  
view. And this, of course, happens regardless of how slow the steps  
are because the problem is really that the simulation, the drawing,  
and all the event handling all happen in the same thread (the main  
thread), so when I'm playing with the slider, the simulation is not  
running.


NSTimers are scheduled in particular run-loop modes.  Tracking of a  
mouse drag on a control runs in a special mode,  
NSEventTrackingRunLoopMode.  If you schedule your timer to run in  
that mode, too, it will keep running while tracking is going on.


Excellent! That solves one of my problems already. Thank you, 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 [EMAIL PROTECTED]


Re: NSPopupUpButton not showing checked menu items

2008-11-24 Thread Peter Ammon


On Nov 24, 2008, at 1:21 PM, Steve Christensen wrote:


On Nov 24, 2008, at 12:53 PM, Peter Ammon wrote:


On Nov 23, 2008, at 3:33 PM, Steve Christensen wrote:


On Nov 23, 2008, at 3:05 PM, Kyle Sluder wrote:

On Sun, Nov 23, 2008 at 6:01 PM, Steve Christensen  
<[EMAIL PROTECTED]> wrote:
The class methods also don't make a distinction between popup  
and pulldown,
so I would think that the "selection" should still be marked in  
the menu
when it's visible. I'm not trying to be argumentative, just  
wondering if I
have, in fact, made a good or bad assumption about behavior  
given how every
other menu I've seen works. I suppose I could manually set the  
individual

menu item states but that seems like work I shouldn't need to do.


I think you have made a bad assumption.  The selection bindings for
NSPopupButton consist of selectedIndex, selectedObject,  
selectedTag,

and selectedValue.  In order to support multiple selected items,
NSPopupButton would need a selectionIndexes binding.


Actually, I only wanted to select a single item in the pulldown  
case, the same as what correctly happens for me in the popup case.  
The problem has always been that, even though the button itself is  
reporting that a particular item is "selected," none of the  
underlying NSMenuItems' state is ever set to anything other than  
where it was left in IB (which is typically NSOffState). And so a  
check mark is never set next to the most-recently selected menu  
item.


Pull-down popups are used for commands, like a context menu, and  
therefore pull-down popups do not change the state of the selected  
item.  This is by design, since the commands are assumed to be  
stateless. If you want to change the state of the menu item, you  
can do so manually, but you might consider using a regular popup  
button or a different control entirely.  A pull-down popup that  
acts like a matrix of radio buttons is a departure from Apple's HIG.


Well, I was specifically using the pulldown mode because I wanted a  
control that would take up less space most of the time. In the  
closed state, it's pretty much a button with a small icon  
(reflecting the current option) and a down-arrow; clicking on the  
button reveals a larger popup with a set of options.


I ended up setting and clearing checkmarks manually, which works  
fine but was unexpected work. The NSPopUpButton class specifies both  
methods and bindings for specifying the "selected item" regardless  
of popup/pulldown control type. And since the API docs don't call  
out any differences in behavior, I ended up wasting time trying to  
figure out why my bindings weren't working "correctly."


Whether an item is selected is distinct from its state - see the  
NSPopUpButtonCell method setAltersStateOfSelectedItem:.  This setting  
is always treated as false for pull-down popups.


It sounds like the docs aren't very clear on this.  Please do file a  
bug report for clarifying the documentation.  Thanks!


-Peter


___

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 [EMAIL PROTECTED]


Re: NSPopupUpButton not showing checked menu items

2008-11-24 Thread Steve Christensen

On Nov 24, 2008, at 12:53 PM, Peter Ammon wrote:


On Nov 23, 2008, at 3:33 PM, Steve Christensen wrote:


On Nov 23, 2008, at 3:05 PM, Kyle Sluder wrote:

On Sun, Nov 23, 2008 at 6:01 PM, Steve Christensen  
<[EMAIL PROTECTED]> wrote:
The class methods also don't make a distinction between popup  
and pulldown,
so I would think that the "selection" should still be marked in  
the menu
when it's visible. I'm not trying to be argumentative, just  
wondering if I
have, in fact, made a good or bad assumption about behavior  
given how every
other menu I've seen works. I suppose I could manually set the  
individual

menu item states but that seems like work I shouldn't need to do.


I think you have made a bad assumption.  The selection bindings for
NSPopupButton consist of selectedIndex, selectedObject, selectedTag,
and selectedValue.  In order to support multiple selected items,
NSPopupButton would need a selectionIndexes binding.


Actually, I only wanted to select a single item in the pulldown  
case, the same as what correctly happens for me in the popup case.  
The problem has always been that, even though the button itself is  
reporting that a particular item is "selected," none of the  
underlying NSMenuItems' state is ever set to anything other than  
where it was left in IB (which is typically NSOffState). And so a  
check mark is never set next to the most-recently selected menu item.


Pull-down popups are used for commands, like a context menu, and  
therefore pull-down popups do not change the state of the selected  
item.  This is by design, since the commands are assumed to be  
stateless. If you want to change the state of the menu item, you  
can do so manually, but you might consider using a regular popup  
button or a different control entirely.  A pull-down popup that  
acts like a matrix of radio buttons is a departure from Apple's HIG.


Well, I was specifically using the pulldown mode because I wanted a  
control that would take up less space most of the time. In the closed  
state, it's pretty much a button with a small icon (reflecting the  
current option) and a down-arrow; clicking on the button reveals a  
larger popup with a set of options.


I ended up setting and clearing checkmarks manually, which works fine  
but was unexpected work. The NSPopUpButton class specifies both  
methods and bindings for specifying the "selected item" regardless of  
popup/pulldown control type. And since the API docs don't call out  
any differences in behavior, I ended up wasting time trying to figure  
out why my bindings weren't working "correctly."


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 [EMAIL PROTECTED]


Re: NSPopupUpButton not showing checked menu items

2008-11-24 Thread Peter Ammon


On Nov 23, 2008, at 3:33 PM, Steve Christensen wrote:


On Nov 23, 2008, at 3:05 PM, Kyle Sluder wrote:

On Sun, Nov 23, 2008 at 6:01 PM, Steve Christensen  
<[EMAIL PROTECTED]> wrote:
The class methods also don't make a distinction between popup and  
pulldown,
so I would think that the "selection" should still be marked in  
the menu
when it's visible. I'm not trying to be argumentative, just  
wondering if I
have, in fact, made a good or bad assumption about behavior given  
how every
other menu I've seen works. I suppose I could manually set the  
individual

menu item states but that seems like work I shouldn't need to do.


I think you have made a bad assumption.  The selection bindings for
NSPopupButton consist of selectedIndex, selectedObject, selectedTag,
and selectedValue.  In order to support multiple selected items,
NSPopupButton would need a selectionIndexes binding.


Actually, I only wanted to select a single item in the pulldown  
case, the same as what correctly happens for me in the popup case.  
The problem has always been that, even though the button itself is  
reporting that a particular item is "selected," none of the  
underlying NSMenuItems' state is ever set to anything other than  
where it was left in IB (which is typically NSOffState). And so a  
check mark is never set next to the most-recently selected menu item.


Hi Steve,

Pull-down popups are used for commands, like a context menu, and  
therefore pull-down popups do not change the state of the selected  
item.  This is by design, since the commands are assumed to be  
stateless.


If you want to change the state of the menu item, you can do so  
manually, but you might consider using a regular popup button or a  
different control entirely.  A pull-down popup that acts like a matrix  
of radio buttons is a departure from Apple's HIG.


-Peter

___

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 [EMAIL PROTECTED]


Re: Need some advice on multithreading

2008-11-24 Thread Ken Thomases

On Nov 24, 2008, at 1:39 PM, WT wrote:

That's exactly what I had done in the first place, but the results  
weren't too good. I then wrote a much simpler app (one bouncing  
ball) to test possible solutions and, of course, started with this  
very approach. For fun, I allow the user to rotate the container  
and, sure enough, the ball hangs in mid-air while I'm rotating the  
view. And this, of course, happens regardless of how slow the steps  
are because the problem is really that the simulation, the drawing,  
and all the event handling all happen in the same thread (the main  
thread), so when I'm playing with the slider, the simulation is not  
running.


NSTimers are scheduled in particular run-loop modes.  Tracking of a  
mouse drag on a control runs in a special mode,  
NSEventTrackingRunLoopMode.  If you schedule your timer to run in that  
mode, too, it will keep running while tracking is going on.


Cheers,
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 [EMAIL PROTECTED]


Re: Determining use of serial comma

2008-11-24 Thread Aki Inoue
I believe the serial comma is, in a strict sense, not tied to any  
particular locale even though it's commonly used in US.


Also, it's advisable not to try algorithmically formatting localized  
strings like this.
It often causes issues with other locales because it's very hard for a  
single person to predict what localizers would want to with such  
strings.
Usually you can get more flexible localizability if you give the  
entire context to localizers (let them localize the entire format  
string, for example).


Just my two cents.

Aki

On 2008/11/23, at 2:56, Andreas Eriksson wrote:


Hi,

is there a way to find out if a serial comma should be used or not
("foo, bar, and baz" or "foo, bar and baz"?) according to the users
current settings?

I've locked around in the NSLocale class but couldn't find anything.

Regards

Andreas
___

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/aki%40apple.com

This email sent to [EMAIL PROTECTED]


___

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 [EMAIL PROTECTED]


Re: CALayer containing a view

2008-11-24 Thread David Duncan

On Nov 24, 2008, at 1:54 AM, Kenneth Ballenegger wrote:


I cannot find anything in the docs regarding this.
Is it possible, and if so, how, to set a layer's content to a view?


You might try setting up a delegate that calls the view's -drawRect:  
method, but this may not work in all cases. This is probably not  
trivial, which is why Appkit provides layers itself that know how to  
handle these details.


Now if you just want to replicate view contents, then you can set the  
contents of any layer to those of another layer.


The doc for the content propriety says it should be a CGImageRef,  
and the delegate methods seem to be for drawing content like one  
would draw in a view.


The contents property is typically a CGImageRef when dealing with user- 
generated content. It can also be the contents of another layer,  
allowing for content replication across layers.


Also, can it cause any problems having a whacky hierarchy of a main  
view containing layers, one of them containing another view with  
subviews which also have layers?



You may see strange things as AppKit manages its layer hierarchy,  
especially if some of those views go offscreen or are removed from the  
window. You might want to reconsider your design.

--
David Duncan
Apple DTS Animation and Printing

___

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 [EMAIL PROTECTED]


Re: Remove HTML Tags

2008-11-24 Thread Douglas Davidson


On Nov 24, 2008, at 2:02 AM, Rob Keniger wrote:


On 24/11/2008, at 6:54 PM, Jean-Daniel Dupas wrote:

Hello, what's the best way to remove html tags and javascript from  
a NSString?
(I'm working on a web crawler and I'm needing a way to get the  
contents of a page that doesn't have a description on it.)


Thanks,
Mr. Gecko


Just a suggestion:
loading it in a WebView and retreiving the page text content.



Or you can use one of the various -initWithHTML methods of  
NSAttributedString and then just ask for the -string value.


Here's what I wrote a couple of years ago on the general topic of  
"HTML stripping", i.e., obtaining the plain-text content of a given  
piece of HTML:


NSAttributedString's HTML import feature will do this, but it's too  
heavyweight to really be thought of as "HTML stripping".  It will give  
you a full rich-text copy of the HTML--the equivalent of selecting and  
copying from Safari and pasting in TextEdit, for example--from which  
you are then going to discard all of the formatting.


If you just want to extract plain text from HTML, you can do it with  
NSXMLDocument, using the NSXMLDocumentTidyHTML option.  That will  
avoid dealing with the formatting, and so should be significantly  
faster.


Bear in mind that the notion of the plain-text content of HTML is not  
well-defined in general.  The most troublesome issue is whitespace.   
For example, in HTML the relationship between two adjacent paragraphs  
in text, or between two adjacent cells in a table, is a logical one  
that is represented in the rendered result by a certain spatial  
offset.  In a plain-text representation one might prefer to have this  
represented by certain whitespace characters, but it is not  
necessarily obvious which ones are to be chosen, and in practice any  
two different plain-text conversion mechanisms are likely to give  
different results.  Whitespace within the HTML source itself, on the  
other hand, is supposed to be of limited significance, since the HTML  
specification calls for it to be collapsed under most circumstances;  
that may or may not occur under any particular plain-text conversion  
mechanism.


Another issue is generated content, such as list markers, which does  
not actually exist within the HTML itself, but instead is generated at  
rendering time.  A simple plain-text conversion mechanism may simply  
ignore it; a more complex one may represent it in one way or another,  
but there may not necessarily be a suitable plain-text representation  
in all cases.  Because of issues of this sort, you may need to  
consider what it is that you actually want out of an HTML to plain- 
text conversion process, and examine the various options available to  
you to see how well they agree with what you want.


Douglas Davidson
___

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 [EMAIL PROTECTED]


iPhone Development Lists

2008-11-24 Thread Greg Deward

Good afternoon!

I noticed that there is NOT an iPhone Dev list on this server.  Does  
anyone have any recommendations for newbie iPhone development?  The  
only one I know of is iPhoneDevCentral.Org, however it is quite  
limited at the moment?


Thanx, in advance.

-- Greg
___

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 [EMAIL PROTECTED]


Re: iPhone Development Lists

2008-11-24 Thread I. Savant
> I noticed that there is NOT an iPhone Dev list on this server.  Does anyone
> have any recommendations for newbie iPhone development?  The only one I know
> of is iPhoneDevCentral.Org, however it is quite limited at the moment?

  Have you searched this list's archives or read the details of the
iPhone developer program? When you join, you can sign in and enjoy the
(password-protected, for-members-only) forums offered there. This is
done (apparently) as a way to preserve the non-disclosure agreement
but give developers the forum they've been demanding for months.

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data/Bindings issue

2008-11-24 Thread Benjamin Stiglitz

The popup button has:
Content bound to MyArrayController.arrangedObjects
Content Values bound to MyArrayController.arrangedObjects.name

Sometimes, and is vaguely seems to be related to changing the XIB,  
the labels of the cells in the popup are what I would expect from  
calling -description on the managed objects it's listing. The rest  
of the UI works as expected when it happens, but the cell content is  
gibberish.


And as luck would have it, I haven't been able to replicate this  
while writing this mail.


There are two usual reasons that happens:
1) The content values binding is not set up to bind to a string value  
of the content—in this case it looks like you’re OK—or,
2) the bound selection isn’t available in the bound content values and  
the pop-up falls back to something else.


-Ben___

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 [EMAIL PROTECTED]


How to debug GC related EXC_BAD_ACCESS

2008-11-24 Thread Nirias
I have a garbage collected application that runs (apparently) flawlessly
with a debug build.  But with a release build it promptly fails with an
EXC_BAD_ACESS error.  My guess is that somehow the GC is not seeing a clear
reference to some object(s) and is releasing them too soon.
Is there a recommended way to debug this?  Maybe some way to log all
releases from the GC?

TIA for any help
___

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 [EMAIL PROTECTED]


Re: Need some advice on multithreading

2008-11-24 Thread WT
>> Is that the general consensus? I've now seen a few examples and  
they all
>> seem to work fine. Then, again, extrapolating from a small sample  
is always

>> dangerous...
>
>No, it's not a general consensus. It's something I discovered on my
>own, and posted about it here. I haven't received any overall
>confirmation that it's broken, but my simple test project was able to
>reliably crash on perhaps half a dozen different hardware
>configurations. (And fail to crash on quite a few more.)
>
>If you like, you can go through the original thread here and come to
>your own conclusions:
>
>http://www.cocoabuilder.com/archive/message/cocoa/2008/10/30/221452
>
>If you want to know more about it, please feel free to ask me.

Thanks. I've just read your first post in that thread (no pun  
intended!). I'll read the other posts and will try your test shortly.  
If I have something useful to add, I'll contact you directly, or post  
to the list.


>Depending on exactly what you're after, you might look into other
>facilities provided by Cocoa. If you start a worker thread that runs
>an NSRunLoop, you can then use a method like
>-performSelector:onThread:withObject:waitUntilDone: to execute a
>method on that thread. You miss out on a lot of what NSOperation
>provides, but depending on exactly what you need that may not be a big
>problem. For what you're describing, you could perhaps run the
>simulation from an NSTimer on the secondary thread, then communicate
>the value changes to it using this method.

That sounds like a good solution and, I must admit, it's closer in  
spirit to the mental model I have from my Java experience. I'll give  
it a shot.


>Have you thought about replacing the main loop of your simulation with
>a timer on the main thread instead of multithreading it? If the
>individual timesteps in your simulation happen fast enough then this
>can be a very good solution. Basically, instead of having a loop that
>does something like "while(!done) simulationStep();", you just set up
>an NSTimer to call simulationStep() repeatedly. The downside is that
>if your individual steps are slow, the user interface will not be very
>responsive, so this is not always a good way to go. I mention it
>because it avoids multithreading and all the difficulties that brings
>along, so it can be nice, but of course it's not always the best.

That's exactly what I had done in the first place, but the results  
weren't too good. I then wrote a much simpler app (one bouncing ball)  
to test possible solutions and, of course, started with this very  
approach. For fun, I allow the user to rotate the container and, sure  
enough, the ball hangs in mid-air while I'm rotating the view. And  
this, of course, happens regardless of how slow the steps are because  
the problem is really that the simulation, the drawing, and all the  
event handling all happen in the same thread (the main thread), so  
when I'm playing with the slider, the simulation is not running.


I think I'm still going to give NSOperation and friends a try, and  
will also try your suggestion of running the simulation on a worker  
thread. If nothing else, these will help me learn some more about Cocoa.


Thanks to everyone for all the input.

Wagner
___

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 [EMAIL PROTECTED]


Re: Remove HTML Tags

2008-11-24 Thread Mr. Gecko

I am just using a php script because it's easier.
On Nov 24, 2008, at 2:54 AM, Jean-Daniel Dupas wrote:



Le 24 nov. 08 à 00:54, Mr. Gecko a écrit :

Hello, what's the best way to remove html tags and javascript from  
a NSString?
(I'm working on a web crawler and I'm needing a way to get the  
contents of a page that doesn't have a description on it.)


Thanks,
Mr. Gecko


Just a suggestion:
loading it in a WebView and retreiving the page text content.




___

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 [EMAIL PROTECTED]


Core Data/Bindings issue

2008-11-24 Thread Paul Tomlin

Hi,

Precis: I'm sometimes seeing what appears to be the result of  
[(NSManagedObject) description] in an NSPopUpButton instead of the  
expected value as set in bindings.


I've got a Core Data Document Based Application in which I'm seeing  
occasional issues with a binding.


The application uses two persistent stores, the default one for the  
document and another one which is stored in the bundle and setup in  
the document class - 
configurePersistentStoreCoordinatorForURL:ofType:error: and - 
initWithType:error:. The additional store is just a library of items  
the documents refer to (or will when that bit is written). There are  
also two data models which I believe are merged by the framework.


The document class also has a property which is lazily loaded from the  
library store, basically the root object in the store. I'm not seeing  
any issues/logs when I load this object from the managed context; it  
appears to be loading fine. This property is referred to below as  
rootObject (but it's not in the code).


On my view I have a popup button which lists entities of a to-many  
relationship of the root object.


It's backed by an NSArrayController with the following settings:

ContentSet bound to File's Owner (the document) Model Key Path  
rootObject.mySetOfStuff


The popup button has:
Content bound to MyArrayController.arrangedObjects
Content Values bound to MyArrayController.arrangedObjects.name

Sometimes, and is vaguely seems to be related to changing the XIB, the  
labels of the cells in the popup are what I would expect from calling - 
description on the managed objects it's listing. The rest of the UI  
works as expected when it happens, but the cell content is gibberish.


And as luck would have it, I haven't been able to replicate this while  
writing this mail.


Any ideas? I've not spotted anything useful in the Core Data Guide,  
though it's probably there somewhere...


___

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 [EMAIL PROTECTED]


CALayer containing a view

2008-11-24 Thread Kenneth Ballenegger

Hello,

I cannot find anything in the docs regarding this.
Is it possible, and if so, how, to set a layer's content to a view?

The doc for the content propriety says it should be a CGImageRef, and  
the delegate methods seem to be for drawing content like one would  
draw in a view.


Also, can it cause any problems having a whacky hierarchy of a main  
view containing layers, one of them containing another view with  
subviews which also have layers?


Thanks,
-Ken


---
Kenneth Ballenegger
www.seoxys.com
kenneth.ballenegger.com
[EMAIL PROTECTED]

Azure Talon Software
www.azuretalon.com
[EMAIL PROTECTED]

___

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 [EMAIL PROTECTED]


Re: NSTypesetter problem

2008-11-24 Thread Aki Inoue

NSATSTypesetter trying to create a new instance is a normal behavior.
When the typesetter detects it's being invoked to layout recursively,  
it instantiates a copy.


The real culprit here is probably at #15 -[TTypesetter  
setLineFragmentRect:forGlyphRange:usedRect:baselineOffset:]  that's  
triggering the recursive layout.


Aki

On 2008/11/23, at 22:45, chaitanya pandit wrote:

In my application i have an NSTextView with custom NSTextContainer  
and also a custom NSTypesetter, i have a problem with displaying  
HTML stuff in the textView.
I copied and pasted the entire contents of an html page ( it was news.google.com 
 to be precise), it displays it fine, but whenever i try to edit the  
text contents, my app goes into an infinite loop.


While debugging i observed a very weird thing, a new typesetter is  
getting initialized within the  
"layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments 
" method.

Any idea about what might be going wrong?
I'd appreciate any help.

Here is the trace(note the  #0):

#0  0x00077a35 in -[TTypesetter init] at TTypesetter.m:25
#1	0x907691a9 in -[NSATSTypesetter  
layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments 
:]
#2	0x00077c08 in -[TTypesetter  
layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments 
:] at TTypesetter.m:95
#3	0x90455f77 in -[NSLayoutManager(NSPrivate)  
_fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:]

#4  0x905953b6 in _NSFastFillAllLayoutHolesForGlyphRange
#5	0x9051e0ba in -[NSLayoutManager(NSPrivate)  
_firstPassGlyphRangeForBoundingRect:inTextContainer:okToFillHoles:]
#6	0x9051cff1 in -[NSLayoutManager(NSPrivate)  
_glyphRangeForBoundingRect:inTextContainer:fast:okToFillHoles:]
#7	0x9051ce27 in -[NSLayoutManager  
glyphRangeForBoundingRect:inTextContainer:]
#8	0x9051c35e in -[NSTextView  
setNeedsDisplayInRect:avoidAdditionalLayout:]

#9  0x9051be8b in -[NSTextView setNeedsDisplayInRect:]
#10 0x903be662 in -[NSView setNeedsDisplay:]
#11 0x9051cb82 in -[NSTextView textContainerOrigin]
#12	0x90521b8f in -[NSLayoutManager(NSPrivate)  
_resizeTextViewForTextContainer:]
#13	0x90406ed0 in -[NSLayoutManager(NSPrivate)  
_updateUsageForTextContainer:addingUsedRect:]
#14	0x9045be46 in -[NSLayoutManager  
setLineFragmentRect:forGlyphRange:usedRect:]
#15	0x00078688 in -[TTypesetter  
setLineFragmentRect:forGlyphRange:usedRect:baselineOffset:] at  
TTypesetter.m:325
#16	0x90420776 in -[NSATSTypesetter  
_layoutLineFragmentStartingWithGlyphAtIndex:characterIndex:atPoint:renderingContext 
:]

#17 0x904583db in -[NSATSTypesetter layoutParagraphAtPoint:]
#18	0x00077ba8 in -[TTypesetter layoutParagraphAtPoint:] at  
TTypesetter.m:86
#19	0x90400bcd in -[NSTypesetter  
_layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:maxCharacterIndex:nextGlyphIndex:nextCharacterIndex 
:]
#20	0x909ed6f6 in -[NSTypesetter  
layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments 
:]
#21	0x90769238 in -[NSATSTypesetter  
layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments 
:]
#22	0x00077c08 in -[TTypesetter  
layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments 
:] at TTypesetter.m:95
#23	0x90455f77 in -[NSLayoutManager(NSPrivate)  
_fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:]

#24 0x905953b6 in _NSFastFillAllLayoutHolesForGlyphRange
#25	0x90548225 in -[NSTextView(NSPrivate)  
_ensureLayoutCompleteToEndOfCharacterRange:]

#26 0x90547c81 in -[NSTextView(NSSharing) didChangeText]
#27 0x90543ea2 in -[NSTextView insertText:replacementRange:]
#28 0x905433d3 in -[NSTextView insertText:]
#29	0x90542efa in -[NSKeyBindingManager 
(NSKeyBindingManager_MultiClients) flushTextForClient:]

#30 0x9054144f in -[NSTSMInputContext interpretKeyEvents:]
#31 0x90540f1a in -[NSView interpretKeyEvents:]
#32 0x90540e2a in -[NSTextView keyDown:]
#33 0x904b13a5 in -[NSWindow sendEvent:]
#34 0x9047d311 in -[NSApplication sendEvent:]
#35 0x903dad0f in -[NSApplication run]
#36 0x903a7f14 in NSApplicationMain
#37 0x29b0 in main at main.m:12

___

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/aki%40apple.com

This email sent to [EMAIL PROTECTED]


___

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 [EMAIL PROTECTED]


Re: Special Characters... menu item

2008-11-24 Thread Aki Inoue

There is no sure way of preventing it to be added.

The menu item and the Character Palette accessed from it is a part of  
Mac OS X user experience.  Why disable ?


Aki

On 2008/11/22, at 14:51, [EMAIL PROTECTED] wrote:


Hi,

Is there a way to keep "Special Characters..." from being added to  
the end of the Edit menu?


thanks
Jeff


___

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/aki%40apple.com

This email sent to [EMAIL PROTECTED]


___

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 [EMAIL PROTECTED]


Re: Need some advice on multithreading

2008-11-24 Thread Michael Ash
On Mon, Nov 24, 2008 at 5:08 AM, WT <[EMAIL PROTECTED]> wrote:
>>- First, don't use NSOperationQueue unless you can stand to have your
>>app crash from time to time, or unless you can require Snow Leopard.
>>It's crashy and I have no particular hope that Apple is going to make
>>it stop being crashy at any time in the 10.5 series.
>
> Is that the general consensus? I've now seen a few examples and they all
> seem to work fine. Then, again, extrapolating from a small sample is always
> dangerous...

No, it's not a general consensus. It's something I discovered on my
own, and posted about it here. I haven't received any overall
confirmation that it's broken, but my simple test project was able to
reliably crash on perhaps half a dozen different hardware
configurations. (And fail to crash on quite a few more.)

If you like, you can go through the original thread here and come to
your own conclusions:

http://www.cocoabuilder.com/archive/message/cocoa/2008/10/30/221452

If you want to know more about it, please feel free to ask me.

Depending on exactly what you're after, you might look into other
facilities provided by Cocoa. If you start a worker thread that runs
an NSRunLoop, you can then use a method like
-performSelector:onThread:withObject:waitUntilDone: to execute a
method on that thread. You miss out on a lot of what NSOperation
provides, but depending on exactly what you need that may not be a big
problem. For what you're describing, you could perhaps run the
simulation from an NSTimer on the secondary thread, then communicate
the value changes to it using this method.

>>- When multithreading for the purposes of optimization as you're
>>doing, treat it as any other optimization. That is, measure and
>>profile your app before you do anything else to it. Trying to figure
>>out where to put the threads when you don't even know what parts of
>>your app are slow is pointless. Just as it's a bunch of wasted effort
>>to carefully hand-craft a super fast assembly language version of a
>>function that only runs one time for one millisecond, it's likewise a
>>bunch of wasted effort to carefully come up with a multithreaded
>>implementation of such a function. In your case, if the simulation
>>engine only takes up, say, 10% of your CPU time compared to display,
>>then the absolute possible best speed gain you could ever see from
>>shoving it into a background thread would be 10%, probably not worth
>>all the work and risk.
>
> Generally, I'd agree with you on what you just said, but I have to disagree
> this time because I am not using multithreading for the purpose of
> optimization. I'm using it because it's a requirement that the user should
> be able to change certain aspects of the simulation while the simulation is
> running. For instance, in the example of the bouncing balls, if the user
> were to rotate the container (the custom NSView), the balls should continue
> moving, rather than stop until the user has finished rotating the view. This
> requirement necessitates a complete separation between running the
> simulation and dealing with user events, and that spells multithreading to
> me.

I see, I misunderstood the purpose of your question.

Have you thought about replacing the main loop of your simulation with
a timer on the main thread instead of multithreading it? If the
individual timesteps in your simulation happen fast enough then this
can be a very good solution. Basically, instead of having a loop that
does something like "while(!done) simulationStep();", you just set up
an NSTimer to call simulationStep() repeatedly. The downside is that
if your individual steps are slow, the user interface will not be very
responsive, so this is not always a good way to go. I mention it
because it avoids multithreading and all the difficulties that brings
along, so it can be nice, but of course it's not always the best.

>>- When multithreading, use message passing and immutable objects as
>>much as possible. The nightmare case for multithreading is when you
>>have some gigantic object with a ton of shared state that gets used
>>from four different threads at once and has a complex hierarchy of
>>locks to ensure that none of them step on each other's toes. If you
>>can decompose your operations into individual immutable messages which
>>you fire across to other threads, you remove a lot of shared data
>>which is where a lot of the problems with multithreading come from.
>>NSOperation is actually a nice way to do this, too bad it's pretty
>>much unusable.
>
> Yes, I'm aware of the problems you mentioned. My application, however, will
> likely not suffer severely from those problems, since the data sharing in it
> fits the producer/observer pattern, as opposed to a model where several
> threads all read and write shared data. The UI produces values that must be
> passed to the simulation engine and the simulation engine produces data to
> be displayed. The simulation engine never writes back to the UI controls

Re: Call getElementById in Cocoa

2008-11-24 Thread Frédéric Testuz

Le 24 nov. 08 à 18:34, Mike Abdullah a écrit :



On 24 Nov 2008, at 17:28, Jean-Daniel Dupas wrote:



Le 24 nov. 08 à 18:03, Mike Abdullah a écrit :



On 24 Nov 2008, at 16:45, John Terranova wrote:



On Nov 24, 2008, at 8:11 AM, Jean-Daniel Dupas wrote:

You call -mainFrameDocument on your WebView to get a DOMDocument  
instance, and have access to the DOM functions from here (there  
is no up-to-date doc of the Cocoa DOM API, you will have to  
check headers files directly to see what function is available,  
for example the DOMDocument.h file show you that there is a - 
[DomDocument getElementById:] method.


Is it possible to use the DOM functions without first creating  
the WebView?


I want to download a webpage and parse its contents without ever  
displaying the page. I currently parse the html text directly,  
but it is somewhat cumbersome.  If I could just walk the DOM  
structure, then that would likely be much cleaner.


No, this is not possible. But there is no reason why you have to  
present the WebView to the user. Just stick it in an offscreen  
window and wait for it to load.


Mike.


I don't think you have to create an offscreen window at all.  
Creating the WebView and loading the URL programmatically is enough  
to access the dom tree.



That would be ideal, but I could swear I've run across WebKit  
documentation stating that a WebView must be placed within a window  
for it to operate properly.


I'm using a WebView for printing without a window and it works  
perfectly (but perhaps the PrintOperation is doing what the window is  
doing in the normal situation).


___

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 [EMAIL PROTECTED]


Re: Multiple views in a nib file?

2008-11-24 Thread Jean-Nicolas Jolivet
Thanks a lot for your reply! It does help a lot to see how someone  
else implemented a similar concept!... I love the multiple controllers  
(1 per subclass) / Multiple views (again, 1 per subclass)  idea...  
I'll try to implement it for my situation as it seems to be the best  
way to go...


I'll let you know if I hit a dead end!

Again, thank you!

J-N

On 24-Nov-08, at 5:38 AM, Graham Cox wrote:



On 24 Nov 2008, at 7:56 pm, Jean-Nicolas Jolivet wrote:

mm interesting reading!... I'm trying to see how I could implement  
this in my case...I used the "Tool" example as it seemed easier to  
explain but basically, what the abstract class represents is an  
"Operation" (just a simple operation performed on some text...)..  
example of subclass could be "Insert text Operation", "Replace Text  
Operation" etc... basically an operation has some parameters  
(textToInsert, textToSearchFor etc..) and it takes some text,  
performs a transformation on it and returns a string... the custom  
views are just used to set those operation's parameters (text to  
insert etc..)... I thought of several way of doing it but since an  
operation could have boolean, int or string parameters, I figured  
having a custom view for each operation would be the way to go...


So to sum it up, each operation has a set of parameters, controlled  
by a custom view ... but the user can add as many operations as he  
wants (so it's not really like there will be only 1 instance of  
each operation... which makes things a little more complex than if  
it were just a tool...)



This sounds similar to a couple of things in my app.

In one case, I have a search mechanism that finds objects based on  
matching a list of criteria. It's conceptually much the same as  
predicate filtering but the code predates the existence of  
predicates so it rolls its own. I have an object that represents the  
query and it's pure model - it takes an array argument and returns  
an array argument which is the subset of the input that matched the  
query. This sounds sort of similar to your operation object. Each  
separate clause of the query is modelled using another object, of  
which the query can have any number, stored in a list.


I also have a UI for editing and creating the query which again has  
a modern equivalent in the NSPredicateEditor but which I wrote  
myself prior to that being available. It works by having one sub- 
controller per 'clause' as well as an overall controller for the  
whole query. Each clause has an implicit data type (think of  
matching a string, in which case the data type is a string, or  
matching a value, in which case the data type is a number) and each  
data type has an associated set of controls in a view, so each data  
type maps to one of several different views. There are about 6 or 7  
data types, so my nib has 6 or 7 views which contain the appropriate  
controls. When the user adds a clause to the query, adding a row of  
controls to the UI, they pick a property from a menu for what to  
search on, and this finds the data type that that property is  
associated with, makes a controller for it, and installs the  
matching type of view (the view is copied from one of the predefined  
prototype views), so the UI is correct for the data type. The  
overall controller simply has outlets to all the different  
"flavours" of view and simply returns the right one, copied, given  
the data type for that row.


When I wrote this one I hadn't thought of the naming convention +  
valueForKey: idea, so it currently hard-codes the look up of the  
outlet in a switch/case statement, which is OK but could be done  
slightly more cleverly. If I added new data types I'd have to modify  
this code to match.


Given that the query object itself is pure model, it knows nothing  
about this UI stuff. The 'clause' object doesn't have or need a view  
outlet, but it does have a data type, so the controller uses that to  
look up a view. In this case, note that the same view can be  
installed many times, which is why I copy it, since the same data  
type can be associated with different properties.


In the second case, I have a style object that applies graphical  
attributes to objects. Again any number of attributes can be applied  
and the overall style object contains these in a list. Though this  
does drawing, it's model in that the attributes are graphical  
properties of objects in my data model. There are numerous kinds,  
about 16 different classes at the moment.


The UI to set the parameters for the attributes is a master/detail  
interface, the master being an NSOutlineView (the attributes can be  
arranged in hierarchies) and I switch in a view appropriate to the  
class of the selected item. This uses the naming convention +  
valueForKey: approach. Each class of attribute has its own sub- 
controller which uses KVO to observe the attribute model object.  
Each sub-controller has an outlet to all of the controls 

Re: Call getElementById in Cocoa

2008-11-24 Thread Mike Abdullah


On 24 Nov 2008, at 17:28, Jean-Daniel Dupas wrote:



Le 24 nov. 08 à 18:03, Mike Abdullah a écrit :



On 24 Nov 2008, at 16:45, John Terranova wrote:



On Nov 24, 2008, at 8:11 AM, Jean-Daniel Dupas wrote:

You call -mainFrameDocument on your WebView to get a DOMDocument  
instance, and have access to the DOM functions from here (there  
is no up-to-date doc of the Cocoa DOM API, you will have to check  
headers files directly to see what function is available, for  
example the DOMDocument.h file show you that there is a - 
[DomDocument getElementById:] method.


Is it possible to use the DOM functions without first creating the  
WebView?


I want to download a webpage and parse its contents without ever  
displaying the page. I currently parse the html text directly, but  
it is somewhat cumbersome.  If I could just walk the DOM  
structure, then that would likely be much cleaner.


No, this is not possible. But there is no reason why you have to  
present the WebView to the user. Just stick it in an offscreen  
window and wait for it to load.


Mike.


I don't think you have to create an offscreen window at all.  
Creating the WebView and loading the URL programmatically is enough  
to access the dom tree.



That would be ideal, but I could swear I've run across WebKit  
documentation stating that a WebView must be placed within a window  
for it to operate properly.___


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 [EMAIL PROTECTED]


Re: Need some advice on multithreading

2008-11-24 Thread WT
For instance, as far as I know, there is no way to change the  
period of an NSTimer that's already in existence. Since both the  
simulation update rate and the frame update rate are timer-driven  
and dynamically changeable by the user, I expect lots of NSTimer  
objects to be created.




I think you can reuse it using -[NSTimer setFireDate:] to set the  
next fire date. The doc is not very clear about it. If this is not  
the case, you can use CFRunLoopTimerSetNextFireDate  (as NSTimer and  
CFRunLoopTimer are tool free bridged), which has a better  
documentation:


"Resetting a timer’s next firing time is a relatively expensive  
operation and should not be done if it can be avoided; letting  
timers autorepeat is more efficient. In some cases, however,  
manually-adjusted, repeating timers are useful. For example, if you  
have an action that will be performed multiple times in the future,  
but at irregular time intervals, it would be very expensive to  
create, add to run loop modes, and then destroy a timer for each  
firing event. Instead, you can create a repeating timer with an  
initial firing time in the distant future (or the initial firing  
time) and a very large repeat interval—on the order of decades or  
more—and add it to all the necessary run loop modes. Then, when you  
know when the timer should fire next, you reset the firing time with  
CFRunLoopTimerSetNextFireDate, perhaps from the timer’s own callback  
function. This technique effectively produces a reusable,  
asynchronous timer."


Ha! Great, I'll try that. Thanks!

___

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 [EMAIL PROTECTED]


Re: NaN values from presentationLayer

2008-11-24 Thread David Duncan

On Nov 24, 2008, at 6:53 AM, DKJ wrote:

I have a UIView myView that I animate by changing its center  
property. During the animation, this line is called by an NSTimer  
every 0.1 seconds:


CGRect myViewFrame = [[myView.layer presentationLayer] frame];

But sometimes this gives me all NaN values in the CGRect, and things  
go off the rails.


What might be causing this? Is it some kind of "between frames"  
condition in the animation?



I'm not exactly certain what is going on here, but since the frame is  
a derived property, there could be some threading issues causing the  
fuss. Please file a bug report.


Try watching the position & bounds of the layer instead.
--
David Duncan
Apple DTS Animation and Printing

___

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 [EMAIL PROTECTED]


Re: Core Animation: How to swicth off all implicit animations?

2008-11-24 Thread David Duncan

On Nov 22, 2008, at 11:41 AM, Wolf Hauser wrote:

Question: is there a (simple) way to switch all these implicit  
behaviors off (while keeping the possibility to stack the two views  
in layers)?



Since this doesn't appear to have been answered, there is a long  
mechanism that determines what animation is done for any given  
property. This sequence of events is described in the docs for  
CALayer's -actionForKey: method.

--
David Duncan
Apple DTS Animation and Printing

___

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 [EMAIL PROTECTED]


Re: Animated subviews

2008-11-24 Thread David Duncan

On Nov 23, 2008, at 9:54 AM, DKJ wrote:

Now I'm getting a very odd result. In the code for a UIView I have  
this:


CALayer *theLayer = self.layer;
id pLayer = [theLayer presentationLayer];

The first line is fine, but for the second I get a compiler warning:

no '-presentationLayer' method found


Did you import the QuartzCore/QuartzCore.h header?


I'm looking at the CALayer docs, which has this:

- (id)presentationLayer

Return Value
A layer instance representing the current presentation layer.

Any idea what's going on? (I'm also puzzled why this method would  
return an id.)



The return value is an id so that you can assign it to the proper real  
class without type casting. For example...


CALayer *pLayer = [myLayer presentationLayer];
CATiledLayer *ptLayer = [myTiledLayer presentationLayer];

If it was statically typed as a CALayer, then the second assignment  
would require a typecase.

--
David Duncan
Apple DTS Animation and Printing

___

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 [EMAIL PROTECTED]


Re: Call getElementById in Cocoa

2008-11-24 Thread Jean-Daniel Dupas


Le 24 nov. 08 à 18:03, Mike Abdullah a écrit :



On 24 Nov 2008, at 16:45, John Terranova wrote:



On Nov 24, 2008, at 8:11 AM, Jean-Daniel Dupas wrote:

You call -mainFrameDocument on your WebView to get a DOMDocument  
instance, and have access to the DOM functions from here (there is  
no up-to-date doc of the Cocoa DOM API, you will have to check  
headers files directly to see what function is available, for  
example the DOMDocument.h file show you that there is a - 
[DomDocument getElementById:] method.


Is it possible to use the DOM functions without first creating the  
WebView?


I want to download a webpage and parse its contents without ever  
displaying the page. I currently parse the html text directly, but  
it is somewhat cumbersome.  If I could just walk the DOM structure,  
then that would likely be much cleaner.


No, this is not possible. But there is no reason why you have to  
present the WebView to the user. Just stick it in an offscreen  
window and wait for it to load.


Mike.


I don't think you have to create an offscreen window at all. Creating  
the WebView and loading the URL programmatically is enough to access  
the dom tree.



___

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 [EMAIL PROTECTED]


Re: Need some advice on multithreading

2008-11-24 Thread WT

>> [...]
>>2. continuously running the simulation engine, at a rate that can  
also

>>be changed dynamically by the user (for instance, in the bouncing
>>balls example, increasing gravity makes the balls move faster,  
thereby
>>requiring the engine to run more often in order to preserve  
accuracy
>>and to prevent anomalies such as the balls overlapping one  
another);


This isn't normally how physics simulations are done (decreasing  
step time based on number of objects).  This is especially bad  
because collision detection can go up exponentially with the number  
of objects (so more math has to be done per step as it is).


I'm not decreasing the time step based on the number of objects. In  
the example of the bouncing balls (which, by the way, is merely an  
example I used to introduce my questions - the simulations I'm doing  
are related to far more advanced physics than merely collisions), the  
number of balls is constant. As far as collision detection, the growth  
is actually not exponential but quadratic (simultaneous collisions  
between more than 2 balls can safely be ignored), and there are a  
variety of efficient data structures to handle collision detection  
(quad-trees, range-trees, cell-based data structures, and others).


>While it may wind up making sense to put the simulation engine in  
a separate thread, I would recommend _not_ trying to adjust the  
simulation rate to account for the speed of the balls, precision,  
etc. This sort of load-adjusting sounds good in theory, but it  
ultimately fails because the performance characteristics of the  
code changes according to the settings.


I'm afraid I'll have to disagree. My concern is not balancing the  
CPU load, but getting accurate results. To use the bouncing balls  
example again, if the balls move fast enough and if I don't  
compensate by decreasing the time-interval through which I'm  
advancing the motion, the balls WILL overlap and may do so  
considerably. Even if they don't overlap in a way that's visible to  
the human eye, overlaps may cause other anomalies, such as energy  
non-conservation. These kinds of problems are typical of numerical  
integration of differential equations and have nothing to do with  
optimizing the CPU use.




Actually, this sounds more like a problem in the physics simulation  
itself - no matter how small the time-step of the simulation,  
collision will cause items to overlap.  There are two approaches  
that are common - recalculate with a smaller time step until the  
items no longer overlap (basically a binary search to find the  
impact time).  The second is to use the math to figure out the exact  
moment of collision - it's not too hard to figure out when two  
spheres will intersect based on position, direction, and  
acceleration (or sphere vs plane), but doing this for an arbitrary  
shape that is also spinning (think rolling dice) becomes much harder.


That overlaps will happen is unavoidable and it's not due to the  
physics simulation itself. It's due to the nature of floating point  
calculations being of finite precision. It is possible to deal with  
these overlaps, but it's generally a good idea not to have them happen  
very often.


The way it is generally done is to basically have two loops - one  
that is always executed on a regular basis (to advance, say, a  
single frame) and then within that "update simulation 1 frame" it  
can use one of the two basic options above to have multiple (and non- 
regular) updates to advance the simulation.


Personally I'd recommend looking into how existing physics engines  
work (I'm a fan of ODE), as well getting a copy of O'Reilly's  
"Physics for Game Developers", and track down David Baraff's (of  
Pixar) "Rigid Body Simulation" paper.  Brent Dingle's "Rigid Body  
Motion, An Introduction" is a good lead in to the Baraff paper as  
well.  In general, the trick is to figure out how to do as little  
math as possible on a regular basis, even if it requires doing some  
more sophisticated math on an occasional basis.


I appreciate the suggestions, but I'd like to say that the math, the  
physics, and the simulation aren't the problem for me. I'm a physicist  
by training with experience simulating physical phenomena and, as I  
already mentioned, the bouncing balls are merely an example to  
illustrate the general nature of the questions I had, which really  
have to do with the best practices of using threads in a Cocoa  
application.


I don't mean to sound ungrateful for people's efforts to help me, and  
this isn't directed specifically to Glenn, but to everyone, but I'd  
appreciate if people provided tips related to threads in Cocoa rather  
than tips on how to simulate bouncing balls.


Thanks.
Wagner

___

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)l

Re: Call getElementById in Cocoa

2008-11-24 Thread Matt Long

You can use an NSXMLDocument:

NSString *webpageString = [[[NSString alloc] initWithContentsOfURL:@"http://www.google.com 
"] autorelease];


NSError *error = nil;
NSXMLDocument *document = [[NSXMLDocument alloc]  
initWithXMLString:webpageString
   
options:NSXMLDocumentTidyHTML
 
error:&error];


It doesn't give you the DOM methods, however, XML is easier to parse  
than trying to parse the HTML directly.


-Matt


On Nov 24, 2008, at 10:03 AM, Mike Abdullah wrote:



On 24 Nov 2008, at 16:45, John Terranova wrote:



On Nov 24, 2008, at 8:11 AM, Jean-Daniel Dupas wrote:

You call -mainFrameDocument on your WebView to get a DOMDocument  
instance, and have access to the DOM functions from here (there is  
no up-to-date doc of the Cocoa DOM API, you will have to check  
headers files directly to see what function is available, for  
example the DOMDocument.h file show you that there is a - 
[DomDocument getElementById:] method.


Is it possible to use the DOM functions without first creating the  
WebView?


I want to download a webpage and parse its contents without ever  
displaying the page. I currently parse the html text directly, but  
it is somewhat cumbersome.  If I could just walk the DOM structure,  
then that would likely be much cleaner.


No, this is not possible. But there is no reason why you have to  
present the WebView to the user. Just stick it in an offscreen  
window and wait for it to load.


Mike.


___

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 [EMAIL PROTECTED]


Re: Call getElementById in Cocoa

2008-11-24 Thread Mike Abdullah


On 24 Nov 2008, at 16:45, John Terranova wrote:



On Nov 24, 2008, at 8:11 AM, Jean-Daniel Dupas wrote:

You call -mainFrameDocument on your WebView to get a DOMDocument  
instance, and have access to the DOM functions from here (there is  
no up-to-date doc of the Cocoa DOM API, you will have to check  
headers files directly to see what function is available, for  
example the DOMDocument.h file show you that there is a - 
[DomDocument getElementById:] method.


Is it possible to use the DOM functions without first creating the  
WebView?


I want to download a webpage and parse its contents without ever  
displaying the page. I currently parse the html text directly, but  
it is somewhat cumbersome.  If I could just walk the DOM structure,  
then that would likely be much cleaner.


No, this is not possible. But there is no reason why you have to  
present the WebView to the user. Just stick it in an offscreen window  
and wait for it to load.


Mike.

___

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 [EMAIL PROTECTED]


Re: Call getElementById in Cocoa

2008-11-24 Thread John Terranova


On Nov 24, 2008, at 8:11 AM, Jean-Daniel Dupas wrote:

You call -mainFrameDocument on your WebView to get a DOMDocument  
instance, and have access to the DOM functions from here (there is  
no up-to-date doc of the Cocoa DOM API, you will have to check  
headers files directly to see what function is available, for  
example the DOMDocument.h file show you that there is a - 
[DomDocument getElementById:] method.


Is it possible to use the DOM functions without first creating the  
WebView?


I want to download a webpage and parse its contents without ever  
displaying the page. I currently parse the html text directly, but it  
is somewhat cumbersome.  If I could just walk the DOM structure, then  
that would likely be much cleaner.


Thanks.

john
___

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 [EMAIL PROTECTED]


Re: Killing a Thread

2008-11-24 Thread Joseph Kelly

Why can't your thread just return when it's finished?

On Nov 24, 2008, at 1:02 AM, Mahaboob wrote:



Hi,
I’m developing an application for sending email. This allows the  
user to

restrict,
1. Number of emails to be send simultaneously and
2. Time between emails in seconds.
So I used a thread to send the mail. I can send the mails. After  
sending
mail to all email id’s I need to kill the thread. But I failed to do  
that
and my application getting crashed after sending the mail. I think I  
should
write the code for that in - (void) connectionTerminated: method.  
But I

can’t able to Kill the thread. How can I do this ?
I’m attaching the code here.

Thanks in advance
Mahaboob



___

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/joeman%40mac.com

This email sent to [EMAIL PROTECTED]


___

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 [EMAIL PROTECTED]


Re: main thread communicating with background thread and vice-versa

2008-11-24 Thread Joseph Kelly
From what I can tell, clicking the button is not setting  
mainThreadParm = kStopped. Set a breakpoint in your action method to  
verify. Since (I assume) mainThreadParm is a member variable of your  
Controller class instance (and therefore accessible to all object  
methods of the class) it won't be optimized away (i.e. you don't need  
to declare the varaible w/ the volatile keyword).


Joe K.

On Nov 24, 2008, at 3:55 AM, John Love wrote:


Joseph ...

For now, my time consuming for-loop is empty for testing purposes.   
For now, I artificiallyincrease the time consumed by increasing the  
upper bound of the loop.


The mainThreadParm is an integer and is a parm in the existing  
Controller's interface, that is the main thread.


Actually, mainThreadParm is typed as an ErrorCode, where
typedef int   ErrorCode;

mainThreadParm starts out in the main Thread = 13.

The for-loop of the background thread (doCalculation:) looks like:

int row;

for (row=1; row <= 10; row++) {  // large upper bound

if (mainThreadParm == kStopped) break;  // kStopped = 15

}

By clicking a button in the main Thread, I change mainThreadParm =  
kStopped (= 15) and it does not communicate with the background  
Thread this change.


After the for-loop, the background Thread is done, so [self  
performSelectorOnMainThread:@selector(endBgCalculation:)  
withObject:nil waitUntilDone:NO] is called.


Within my -endBgCalculation, I do a NSLog(@"mainThreadParm = %d",  
mainThreadParm).  This call to NSLog shows a value of mainThreadParm  
= 13 which is what mainThreadParm started out as before the for- 
loop.  My change to kStopped = 15 from the main Thread is never seen  
by the background Thread.


?

John


___

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 [EMAIL PROTECTED]


Re: Killing a Thread

2008-11-24 Thread Nick Zitzmann


On Nov 24, 2008, at 2:02 AM, Mahaboob wrote:

So I used a thread to send the mail. I can send the mails. After  
sending
mail to all email id’s I need to kill the thread. But I failed to do  
that
and my application getting crashed after sending the mail. I think I  
should
write the code for that in - (void) connectionTerminated: method.  
But I

can’t able to Kill the thread. How can I do this ?



I think you're doing this wrong. Shouldn't you use NSOperationQueue  
and an NSOperation subclass to do this? Operations can be cancelled  
gracefully; you really shouldn't be killing threads.


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 [EMAIL PROTECTED]


Re: Call getElementById in Cocoa

2008-11-24 Thread Jean-Daniel Dupas


Le 24 nov. 08 à 16:42, Pierce Freeman a écrit :


Hi everyone.

I am wondering if there is some way to call the getElementById on a  
website
through Cocoa, and then return the value of the field.  I am  
assuming it
would somehow be through WebKit, but I am not sure how to do this  
(as well
as if the method needs a different way to get the page's code).  The  
use

would be the application getting the value of a hidden field, and then
outputting it to the user.


Sincerely,

Pierce Freeman


You can do this either by using the Cocoa DOM API directly:

You call -mainFrameDocument on your WebView to get a DOMDocument  
instance, and have access to the DOM functions from here (there is no  
up-to-date doc of the Cocoa DOM API, you will have to check headers  
files directly to see what function is available, for example the  
DOMDocument.h file show you that there is a -[DomDocument  
getElementById:] method.


or you can execute js from your Cocoa code:

http://developer.apple.com/documentation/Cocoa/Conceptual/DisplayWebContent/Tasks/JavaScriptFromObjC.html





___

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 [EMAIL PROTECTED]


Call getElementById in Cocoa

2008-11-24 Thread Pierce Freeman
Hi everyone.

I am wondering if there is some way to call the getElementById on a website
through Cocoa, and then return the value of the field.  I am assuming it
would somehow be through WebKit, but I am not sure how to do this (as well
as if the method needs a different way to get the page's code).  The use
would be the application getting the value of a hidden field, and then
outputting it to the user.


Sincerely,

Pierce Freeman

-- 
Pierce Freeman
[EMAIL PROTECTED]



___

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 [EMAIL PROTECTED]


Re: Need some advice on multithreading

2008-11-24 Thread glenn andreas


On Nov 24, 2008, at 4:35 AM, WT wrote:


Hi Peter,

thanks for answering my post.

>> [...]
>>2. continuously running the simulation engine, at a rate that can  
also

>>be changed dynamically by the user (for instance, in the bouncing
>>balls example, increasing gravity makes the balls move faster,  
thereby

>>requiring the engine to run more often in order to preserve accuracy
>>and to prevent anomalies such as the balls overlapping one another);


This isn't normally how physics simulations are done (decreasing step  
time based on number of objects).  This is especially bad because  
collision detection can go up exponentially with the number of objects  
(so more math has to be done per step as it is).




>
>While it may wind up making sense to put the simulation engine in a  
separate thread, I would recommend _not_ trying to adjust the  
simulation rate to account for the speed of the balls, precision,  
etc. This sort of load-adjusting sounds good in theory, but it  
ultimately fails because the performance characteristics of the code  
changes according to the settings.


I'm afraid I'll have to disagree. My concern is not balancing the  
CPU load, but getting accurate results. To use the bouncing balls  
example again, if the balls move fast enough and if I don't  
compensate by decreasing the time-interval through which I'm  
advancing the motion, the balls WILL overlap and may do so  
considerably. Even if they don't overlap in a way that's visible to  
the human eye, overlaps may cause other anomalies, such as energy  
non-conservation. These kinds of problems are typical of numerical  
integration of differential equations and have nothing to do with  
optimizing the CPU use.




Actually, this sounds more like a problem in the physics simulation  
itself - no matter how small the time-step of the simulation,  
collision will cause items to overlap.  There are two approaches that  
are common - recalculate with a smaller time step until the items no  
longer overlap (basically a binary search to find the impact time).   
The second is to use the math to figure out the exact moment of  
collision - it's not too hard to figure out when two spheres will  
intersect based on position, direction, and acceleration (or sphere vs  
plane), but doing this for an arbitrary shape that is also spinning  
(think rolling dice) becomes much harder.


The way it is generally done is to basically have two loops - one that  
is always executed on a regular basis (to advance, say, a single  
frame) and then within that "update simulation 1 frame" it can use one  
of the two basic options above to have multiple (and non-regular)  
updates to advance the simulation.


Personally I'd recommend looking into how existing physics engines  
work (I'm a fan of ODE), as well getting a copy of O'Reilly's "Physics  
for Game Developers", and track down David Baraff's (of Pixar) "Rigid  
Body Simulation" paper.  Brent Dingle's "Rigid Body Motion, An  
Introduction" is a good lead in to the Baraff paper as well.  In  
general, the trick is to figure out how to do as little math as  
possible on a regular basis, even if it requires doing some more  
sophisticated math on an occasional basis.





Glenn Andreas  [EMAIL PROTECTED]
  wicked fun!
quadrium2 | build, mutate, evolve, animate  | images, textures,  
fractals, art



___

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 [EMAIL PROTECTED]


Re: Need some advice on multithreading

2008-11-24 Thread Adam R. Maxwell


On Nov 24, 2008, at 2:27 AM, Jens Miltner wrote:



Am 24.11.2008 um 11:08 schrieb WT:


>And to answer one question you asked inline, NSNotificationCenter
>delivers all notifications synchronously and immediately on the  
thread

>on which they were sent. It is really just a way of indirectly
>invoking methods, it doesn't know or care about threads at all.

Ok, now, that's something I didn't know and which is very useful to  
know. Thanks!


There's also NSNotificationQueue, which you could use to distribute  
notifications to another thread.


Only if you write your own, since NSNotificationQueue is not thread  
safe [1] and does not pass notifications to another thread.   
NSDistributedNotificationCenter always posts notifications on the main  
thread, but it's not intended for interthread messaging.


Apple has a document describing how to pass notifications between  
threads [2], but I've had a doc bug open against it for most of this  
year (rdar://problem/5772256) since it may be unsafe.


--
Adam


[1] 
http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/chapter_950_section_2.html

[2] 
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/Notifications/Articles/Threading.html



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 [EMAIL PROTECTED]

NaN values from presentationLayer

2008-11-24 Thread DKJ
I have a UIView myView that I animate by changing its center property.  
During the animation, this line is called by an NSTimer every 0.1  
seconds:


CGRect myViewFrame = [[myView.layer presentationLayer] frame];

But sometimes this gives me all NaN values in the CGRect, and things  
go off the rails.


What might be causing this? Is it some kind of "between frames"  
condition in the animation?


dkj
___

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 [EMAIL PROTECTED]


Re: NSTableView Problems

2008-11-24 Thread Barry Fawthrop
To All
Thank You

My main problem was I did not set Identifiers in the IB for the
tableColumns  So I could not reference each column

Having set that and using an NSMutableDictionary
helped to get what I was needing.

Thank you for your input it sure helped me grasp the concepts

Barry


Barry Fawthrop wrote:
> Thank You
>  my datasource methods are as follows:
> 
> -(int) numberOfRowsInTableView:(NsTableView *)table {
>return [schedule count];
> }
> 
> -(id)talbeview: (NSTableView *)table objectValueForTableColumn:
> (NSTableColumn *)col: row:(int)row {
>return [schedule objectAtIndex: row];
> }
> 
> Can/Should I perhaps add a second controller, this time an Array
> Controller (the current one is NSObject based),
> And use just the Array Controller for the NSTableView ?
> 
> Would this met your suggestion on a object class?
> 
> Thanks again
> Barry
> 
> Graham Cox wrote:
>> On 24 Nov 2008, at 10:43 am, Graham Cox wrote:
>>
 [schedule addObject: [NSArray arrayWithObjects: @"TIME", filename,
 length, nil]];
>>
>> A further comment.
>>
>> While managing your data this way is OK, and may fit your application
>> well, I personally wouldn't do it this way.
>>
>> Instead, define an object class that has a filename, length and time
>> values as properties. Then your list becomes trivially easy to manage as
>> each related piece of data is always held together. In other words a
>> general-purpose array is not a good substitute for a custom object that
>> links the various bits of data together meaningfully.
>>
>> You'll also find that driving a table view is much easier - the code
>> snippet I posted always works when you do it this way, provided your
>> write your property accessors correctly.
>>
>>
>> hth,
>>
>>
>> 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/barry%40isscp.com
> 
> This email sent to [EMAIL PROTECTED]

___

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 [EMAIL PROTECTED]


RE: using C++ STL in Empty Project

2008-11-24 Thread Luca Ciciriello

In this case make you sure to use .mm as extension for your module and, as 
Jean-Daniel Dupas has said, try to link against libstdc++ lib Luca.
_
See the most popular videos on the web 
http://clk.atdmt.com/GBL/go/115454061/direct/01/___

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 [EMAIL PROTECTED]


RE: Crash when "loading" window second time

2008-11-24 Thread Ulai Beekam

Hi again,Actually the previous poster idea about unchecking the "release" 
checkbox in Interface builder works.I wonder then, why don't I have to uncheck 
this box when using a controller object that inherits from 
NSWindowController?Also, Hillegass didn't mention this checkbox before in the 
book. Does this mean I'm using the wrong approach?Thanks,U> From: [EMAIL 
PROTECTED]> CC: cocoa-dev@lists.apple.com> Date: Sun, 23 Nov 2008 14:27:11 
-0800> Subject: Re: Crash when "loading" window second time> To: [EMAIL 
PROTECTED]> > Hey Ulai -> > Do you have a backtrace for the crash?> > If you 
think the problem has to do with the aboutWindow outlet being  > referenced 
after the window has been dealloced, you could nil out the  > aboutWindow 
outlet in response to a windowDidCloseClose: delegate  > method.> > Jon Hess> > 
On Nov 21, 2008, at 3:19 PM, Ulai Beekam wrote:>  Hi,I'm trying to do the 
exercise on p. 195 in Hillegass (3rd  >> Edition).I have put this line in the 
AboutController.h header:   >> IBOutlet NSWindow *aboutWindow;And I have put 
these lines in  >> AboutController.m file:- 
(IBAction)showAboutPanel:(id)sender>> {>>  if (aboutWindow == nil)>>  {>>
NSLog(@"loading about.nib");>>[NSBundle loadNibNamed:@"About" 
owner:self];>>  }  [aboutWindow makeKeyAndOrderFront:self];>> }Now, the 
about window appears great the first time I go to the menu  >> and hit "About 
App". But if I close the about window, and hit the  >> "About App" menu item 
again, my program crashes! Any ideas why? I  >> actually believe the crash is 
caused by the aboutWindow outlet being  >> destroyed when the window closes. 
How can I prevent this crash? >> Thanks,U.>> 
_>> News, 
entertainment and everything you care about at Live.com. Get  >> it now!>> 
http://www.live.com/getstarted.aspx___
 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/jhess%40apple.com This 
email sent to [EMAIL PROTECTED]> 
_
Connect to the next generation of MSN Messenger 
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline___

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 [EMAIL PROTECTED]


Re: using C++ STL in Empty Project

2008-11-24 Thread Jean-Daniel Dupas


Le 24 nov. 08 à 13:27, BirdSong a écrit :



Hi all,I want to use c++ STL in a empty project, but there are some  
linking errors... Does anyone know how to fix it?Are there any pre- 
steps to setup the environment (such as set include path, or include  
some framework, etc).Thanks in advance.Best Wishes!


I see only one requirement: including libstdc++ to the project (and to  
the target). You can create a new C++ project (instead of an empty  
one) and compare it with your empty project.




___

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 [EMAIL PROTECTED]


RE: using C++ STL in Empty Project

2008-11-24 Thread Luca Ciciriello

Could you please give to me more info? Which compiler are you using? What kind 
of project are you attempting to build (Obj-C,/Obj-C++/C/C++)? 
 
Luca.> From: [EMAIL PROTECTED]> To: cocoa-dev@lists.apple.com> Date: Mon, 24 
Nov 2008 12:27:22 +> Subject: using C++ STL in Empty Project> > > Hi all,I 
want to use c++ STL in a empty project, but there are some linking errors... 
Does anyone know how to fix it?Are there any pre-steps to setup the environment 
(such as set include path, or include some framework, etc).Thanks in 
advance.Best Wishes!> Shuo SongSchool of Software Engineering,Tongji 
UniversityMP:+86 136-4161-7161 > 
_> 
超炫人气榜给您所有偶像的最新资讯和排名,快来支持自己的偶像!> 
http://cnweb.search.live.com/xrank/results.aspx?q=%e5%91%a8%e6%9d%b0%e4%bc%a6&FORM=MSNH>
 ___> > 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/luca_ciciriello%40hotmail.com> 
> This email sent to [EMAIL PROTECTED]
_
Win £1000 John Lewis shopping sprees with BigSnapSearch.com
http://clk.atdmt.com/UKM/go/117442309/direct/01/___

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 [EMAIL PROTECTED]

using C++ STL in Empty Project

2008-11-24 Thread BirdSong

Hi all,I want to use c++ STL in a empty project, but there are some linking 
errors... Does anyone know how to fix it?Are there any pre-steps to setup the 
environment (such as set include path, or include some framework, etc).Thanks 
in advance.Best Wishes!
Shuo SongSchool of Software Engineering,Tongji UniversityMP:+86 136-4161-7161 
_
超炫人气榜给您所有偶像的最新资讯和排名,快来支持自己的偶像!
http://cnweb.search.live.com/xrank/results.aspx?q=%e5%91%a8%e6%9d%b0%e4%bc%a6&FORM=MSNH
___

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 [EMAIL PROTECTED]


Re: Need some advice on multithreading

2008-11-24 Thread Jean-Daniel Dupas


Le 24 nov. 08 à 11:35, WT a écrit :

>>[...]
>>Is this the right idea? Does anyone have a better suggestion? Are
>>there any pitfalls that I'm not seeing? One concern I have is that
>>there might be some weird interactions between running the  
simulation
>>and drawing the results due to the fact that the simulation engine  
is
>>running on a timer and the drawing engine is running on another  
timer,

>>and their periods might not be commensurate.
>
>As long as the refresh rate of your simulation is high enough and  
the frame rate is high enough, you should not notice any anomalies  
due to the differences between the two. You are right that there  
will be theoretical unevenness in the rendering, but with everything  
happening fast enough, a human isn't going to notice.


Very true. Another of my concerns, though, is that having high  
enough simulation refresh rates and frame update rates will cause a  
large number of object allocations, which will compete with other  
resources needed for the simulation to happen. It seems to me that  
lots of objects in Cocoa cannot be reused once created and have to  
be created again.
For instance, as far as I know, there is no way to change the period  
of an NSTimer that's already in existence. Since both the simulation  
update rate and the frame update rate are timer-driven and  
dynamically changeable by the user, I expect lots of NSTimer objects  
to be created.




I think you can reuse it using -[NSTimer setFireDate:] to set the next  
fire date. The doc is not very clear about it. If this is not the  
case, you can use CFRunLoopTimerSetNextFireDate  (as NSTimer and  
CFRunLoopTimer are tool free bridged), which has a better documentation:


"Resetting a timer’s next firing time is a relatively expensive  
operation and should not be done if it can be avoided; letting timers  
autorepeat is more efficient. In some cases, however, manually- 
adjusted, repeating timers are useful. For example, if you have an  
action that will be performed multiple times in the future, but at  
irregular time intervals, it would be very expensive to create, add to  
run loop modes, and then destroy a timer for each firing event.  
Instead, you can create a repeating timer with an initial firing time  
in the distant future (or the initial firing time) and a very large  
repeat interval—on the order of decades or more—and add it to all the  
necessary run loop modes. Then, when you know when the timer should  
fire next, you reset the firing time with  
CFRunLoopTimerSetNextFireDate, perhaps from the timer’s own callback  
function. This technique effectively produces a reusable, asynchronous  
timer."



>[...]
>Mike starts with the constraint "when multithreading for the  
purposes of optimization", and taken at face value I don't see  
anything wrong with the paragraph per se. But...

>
>There's "optimization", and then there's "optimization". :) I have  
the impression from your original message that this isn't so much  
about improving throughput as it is about keeping the user-interface  
from being dependent on the simulation rate, thus improving the user  
experience.

>[...]

Precisely!

>Also, not directly related to Mike's comment, but I'll point out  
that multithreading can be a _design_ optimization as well. That is,  
while it will necessarily introduce some complexities into the  
implementation, it can also greatly simplify other aspects, by  
allowing the various work in the program to be partitioned more  
completely. So, there are often benefits to implementing  
multithreaded code, even if performance will not be improved one bit.


Very true, and it's certainly the case in my application.



___

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 [EMAIL PROTECTED]


Re: Multiple views in a nib file?

2008-11-24 Thread Graham Cox


On 24 Nov 2008, at 7:56 pm, Jean-Nicolas Jolivet wrote:

mm interesting reading!... I'm trying to see how I could implement  
this in my case...I used the "Tool" example as it seemed easier to  
explain but basically, what the abstract class represents is an  
"Operation" (just a simple operation performed on some text...)..  
example of subclass could be "Insert text Operation", "Replace Text  
Operation" etc... basically an operation has some parameters  
(textToInsert, textToSearchFor etc..) and it takes some text,  
performs a transformation on it and returns a string... the custom  
views are just used to set those operation's parameters (text to  
insert etc..)... I thought of several way of doing it but since an  
operation could have boolean, int or string parameters, I figured  
having a custom view for each operation would be the way to go...


So to sum it up, each operation has a set of parameters, controlled  
by a custom view ... but the user can add as many operations as he  
wants (so it's not really like there will be only 1 instance of each  
operation... which makes things a little more complex than if it  
were just a tool...)



This sounds similar to a couple of things in my app.

In one case, I have a search mechanism that finds objects based on  
matching a list of criteria. It's conceptually much the same as  
predicate filtering but the code predates the existence of predicates  
so it rolls its own. I have an object that represents the query and  
it's pure model - it takes an array argument and returns an array  
argument which is the subset of the input that matched the query. This  
sounds sort of similar to your operation object. Each separate clause  
of the query is modelled using another object, of which the query can  
have any number, stored in a list.


I also have a UI for editing and creating the query which again has a  
modern equivalent in the NSPredicateEditor but which I wrote myself  
prior to that being available. It works by having one sub-controller  
per 'clause' as well as an overall controller for the whole query.  
Each clause has an implicit data type (think of matching a string, in  
which case the data type is a string, or matching a value, in which  
case the data type is a number) and each data type has an associated  
set of controls in a view, so each data type maps to one of several  
different views. There are about 6 or 7 data types, so my nib has 6 or  
7 views which contain the appropriate controls. When the user adds a  
clause to the query, adding a row of controls to the UI, they pick a  
property from a menu for what to search on, and this finds the data  
type that that property is associated with, makes a controller for it,  
and installs the matching type of view (the view is copied from one of  
the predefined prototype views), so the UI is correct for the data  
type. The overall controller simply has outlets to all the different  
"flavours" of view and simply returns the right one, copied, given the  
data type for that row.


When I wrote this one I hadn't thought of the naming convention +  
valueForKey: idea, so it currently hard-codes the look up of the  
outlet in a switch/case statement, which is OK but could be done  
slightly more cleverly. If I added new data types I'd have to modify  
this code to match.


Given that the query object itself is pure model, it knows nothing  
about this UI stuff. The 'clause' object doesn't have or need a view  
outlet, but it does have a data type, so the controller uses that to  
look up a view. In this case, note that the same view can be installed  
many times, which is why I copy it, since the same data type can be  
associated with different properties.


In the second case, I have a style object that applies graphical  
attributes to objects. Again any number of attributes can be applied  
and the overall style object contains these in a list. Though this  
does drawing, it's model in that the attributes are graphical  
properties of objects in my data model. There are numerous kinds,  
about 16 different classes at the moment.


The UI to set the parameters for the attributes is a master/detail  
interface, the master being an NSOutlineView (the attributes can be  
arranged in hierarchies) and I switch in a view appropriate to the  
class of the selected item. This uses the naming convention +  
valueForKey: approach. Each class of attribute has its own sub- 
controller which uses KVO to observe the attribute model object. Each  
sub-controller has an outlet to all of the controls appropriate to the  
class it's controlling, as well as an outlet to the custom view that  
contains them all (this is used to insert the view in its entirety  
into the hosting view in the window). In this case the mapping is from  
the class of the attribute to a specific controller so my outlet  
naming convention is derived from the class name of the original  
attribute object. All I do is when the m

Re: Need some advice on multithreading

2008-11-24 Thread WT

Hi Peter,

thanks for answering my post.

>> [...]
>>2. continuously running the simulation engine, at a rate that can  
also

>>be changed dynamically by the user (for instance, in the bouncing
>>balls example, increasing gravity makes the balls move faster,  
thereby

>>requiring the engine to run more often in order to preserve accuracy
>>and to prevent anomalies such as the balls overlapping one another);
>
>While it may wind up making sense to put the simulation engine in a  
separate thread, I would recommend _not_ trying to adjust the  
simulation rate to account for the speed of the balls, precision, etc.  
This sort of load-adjusting sounds good in theory, but it ultimately  
fails because the performance characteristics of the code changes  
according to the settings.


I'm afraid I'll have to disagree. My concern is not balancing the CPU  
load, but getting accurate results. To use the bouncing balls example  
again, if the balls move fast enough and if I don't compensate by  
decreasing the time-interval through which I'm advancing the motion,  
the balls WILL overlap and may do so considerably. Even if they don't  
overlap in a way that's visible to the human eye, overlaps may cause  
other anomalies, such as energy non-conservation. These kinds of  
problems are typical of numerical integration of differential  
equations and have nothing to do with optimizing the CPU use.


>[...]
>On the other hand, there are some significant risks to trying to  
implement something like this, not the least of which is the risk of  
getting it wrong. :)


How well I know... :)

>>[...]
>>Is this the right idea? Does anyone have a better suggestion? Are
>>there any pitfalls that I'm not seeing? One concern I have is that
>>there might be some weird interactions between running the simulation
>>and drawing the results due to the fact that the simulation engine is
>>running on a timer and the drawing engine is running on another  
timer,

>>and their periods might not be commensurate.
>
>As long as the refresh rate of your simulation is high enough and  
the frame rate is high enough, you should not notice any anomalies due  
to the differences between the two. You are right that there will be  
theoretical unevenness in the rendering, but with everything happening  
fast enough, a human isn't going to notice.


Very true. Another of my concerns, though, is that having high enough  
simulation refresh rates and frame update rates will cause a large  
number of object allocations, which will compete with other resources  
needed for the simulation to happen. It seems to me that lots of  
objects in Cocoa cannot be reused once created and have to be created  
again. For instance, as far as I know, there is no way to change the  
period of an NSTimer that's already in existence. Since both the  
simulation update rate and the frame update rate are timer-driven and  
dynamically changeable by the user, I expect lots of NSTimer objects  
to be created.


>[...]
>Mike starts with the constraint "when multithreading for the  
purposes of optimization", and taken at face value I don't see  
anything wrong with the paragraph per se. But...

>
>There's "optimization", and then there's "optimization". :) I have  
the impression from your original message that this isn't so much  
about improving throughput as it is about keeping the user-interface  
from being dependent on the simulation rate, thus improving the user  
experience.

>[...]

Precisely!

>Also, not directly related to Mike's comment, but I'll point out  
that multithreading can be a _design_ optimization as well. That is,  
while it will necessarily introduce some complexities into the  
implementation, it can also greatly simplify other aspects, by  
allowing the various work in the program to be partitioned more  
completely. So, there are often benefits to implementing multithreaded  
code, even if performance will not be improved one bit.


Very true, and it's certainly the case in my application.
___

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 [EMAIL PROTECTED]


Re: Need some advice on multithreading

2008-11-24 Thread Jens Miltner


Am 24.11.2008 um 11:08 schrieb WT:


>And to answer one question you asked inline, NSNotificationCenter
>delivers all notifications synchronously and immediately on the  
thread

>on which they were sent. It is really just a way of indirectly
>invoking methods, it doesn't know or care about threads at all.

Ok, now, that's something I didn't know and which is very useful to  
know. Thanks!


There's also NSNotificationQueue, which you could use to distribute  
notifications to another thread.




___

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 [EMAIL PROTECTED]


Re: NSTableView Problems

2008-11-24 Thread Alexander Spohr

Am 24.11.2008 um 01:21 schrieb Barry Fawthrop:


Thank You
my datasource methods are as follows:

-(int) numberOfRowsInTableView:(NsTableView *)table {
 return [schedule count];
}

-(id)talbeview: (NSTableView *)table objectValueForTableColumn:
(NSTableColumn *)col: row:(int)row {
 return [schedule objectAtIndex: row];
}



try something like
return [[schedule objectAtIndex:row] objectAtIndex:[[table  
tableColumns] indexOfColumn:col]];

instead.

atze
___

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 [EMAIL PROTECTED]


Re: Need some advice on multithreading

2008-11-24 Thread WT

Hi Mike,

thank you for taking the time to answer my post.

>> Elsewhere, I also found these two Late Night Cocoa podcasts
>>
>> Concurrent Programming
>> 
http://www.mac-developer-network.com/podcasts/latenightcocoa/episode25/index.html
>>
>> Lockless Thread-Safe Data Structures
>> 
http://www.mac-developer-network.com/podcasts/latenightcocoa/episode32/index.html
>>
>> but I haven't had a chance to go through them yet, so I thought  
I'd pick

>> people's brains until I do.
>
>Well I suggest you go through those first. You'll find it much more
>fruitful to get direct advice from people after you're already
>familiar with the basics.

I have now gone through both podcasts and, frankly, the first one  
didn't provide me with much that I didn't already know. As it happens,  
I have quite a bit of experience programming multithreaded apps in  
Java so I knew all the basics already. What I needed (and still do) is  
some more Cocoa-specific guidance, something like the best-practices  
of thread programming in Cocoa.


>Although I suggest you skip the last one. It's absolutely not "the
>basics" in any way, shape, or form. It's extremely advanced techniques
>that I recommend that you stay away from forever. (By which I mean
>that you should stay away from it until you've advanced to the point
>that you're no longer taking my silly advice on what to stay away
>from.)

I rather enjoyed the second one. If and when I need to optimize the  
performance of the simulation engine itself, I might consider using  
some of the techniques discussed in that podcast.


>- First, don't use NSOperationQueue unless you can stand to have your
>app crash from time to time, or unless you can require Snow Leopard.
>It's crashy and I have no particular hope that Apple is going to make
>it stop being crashy at any time in the 10.5 series.

Is that the general consensus? I've now seen a few examples and they  
all seem to work fine. Then, again, extrapolating from a small sample  
is always dangerous...


>- When multithreading for the purposes of optimization as you're
>doing, treat it as any other optimization. That is, measure and
>profile your app before you do anything else to it. Trying to figure
>out where to put the threads when you don't even know what parts of
>your app are slow is pointless. Just as it's a bunch of wasted effort
>to carefully hand-craft a super fast assembly language version of a
>function that only runs one time for one millisecond, it's likewise a
>bunch of wasted effort to carefully come up with a multithreaded
>implementation of such a function. In your case, if the simulation
>engine only takes up, say, 10% of your CPU time compared to display,
>then the absolute possible best speed gain you could ever see from
>shoving it into a background thread would be 10%, probably not worth
>all the work and risk.

Generally, I'd agree with you on what you just said, but I have to  
disagree this time because I am not using multithreading for the  
purpose of optimization. I'm using it because it's a requirement that  
the user should be able to change certain aspects of the simulation  
while the simulation is running. For instance, in the example of the  
bouncing balls, if the user were to rotate the container (the custom  
NSView), the balls should continue moving, rather than stop until the  
user has finished rotating the view. This requirement necessitates a  
complete separation between running the simulation and dealing with  
user events, and that spells multithreading to me.


>- When multithreading, use message passing and immutable objects as
>much as possible. The nightmare case for multithreading is when you
>have some gigantic object with a ton of shared state that gets used
>from four different threads at once and has a complex hierarchy of
>locks to ensure that none of them step on each other's toes. If you
>can decompose your operations into individual immutable messages which
>you fire across to other threads, you remove a lot of shared data
>which is where a lot of the problems with multithreading come from.
>NSOperation is actually a nice way to do this, too bad it's pretty
>much unusable.

Yes, I'm aware of the problems you mentioned. My application, however,  
will likely not suffer severely from those problems, since the data  
sharing in it fits the producer/observer pattern, as opposed to a  
model where several threads all read and write shared data. The UI  
produces values that must be passed to the simulation engine and the  
simulation engine produces data to be displayed. The simulation engine  
never writes back to the UI controls and the drawing engine never  
writes back to the simulation engine. The flow of data is always  
unidirectional. This model (producer/observer) is the ideal case to  
apply messaging but there is still the issue of when the new data is  
inserted into the current thread. Message-passing and immutable  
objects do not necessarily solve the issue of dat

Re: Remove HTML Tags

2008-11-24 Thread Rob Keniger


On 24/11/2008, at 6:54 PM, Jean-Daniel Dupas wrote:

Hello, what's the best way to remove html tags and javascript from  
a NSString?
(I'm working on a web crawler and I'm needing a way to get the  
contents of a page that doesn't have a description on it.)


Thanks,
Mr. Gecko


Just a suggestion:
loading it in a WebView and retreiving the page text content.



Or you can use one of the various -initWithHTML methods of  
NSAttributedString and then just ask for the -string value.


--
Rob Keniger



___

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 [EMAIL PROTECTED]


Re: NSXMLElement -stringValue and whitepsace

2008-11-24 Thread Klaus Backert


Am 24.11.2008 um 02:41 schrieb Keith Blount:

Thanks for trying... It's a shame... I have an OPML importer (no  
export) working based on old code I had found based on  
CFXMLTreeRef, but I was hoping to write an importer/exporter based  
on NSXMLDocument, and this is the one sticking point - everything  
else has been trivial with the NSXMLDocument class. Is this just an  
oddity with the OPML specs, that they allow such whitespace in an  
attributes when XML in general doesn't? Or is it just a limitation  
of NSXMLNode attributes? And does this mean that there is just no  
way of doing it using NSXMLDocument and that I'll have to look for  
a different solution altogether?


It's known in the "XML scene", that there is an eval tendency to use  
attributes too much where nodes were more appropriate. This is a  
failure made by designers of XML data structures, not by the  
designers of XML. Your case may be one of those.


If it's possible anyhow, someone should redesign the structure of the  
XML data your application uses. But it may be – as it is so often –  
that you have to handle this as fixed.


Klaus

___

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 [EMAIL PROTECTED]


Killing a Thread

2008-11-24 Thread Mahaboob

Hi,
I¹m developing an application for sending email. This allows the user to
restrict,
1. Number of emails to be send simultaneously and
2. Time between emails in seconds.
So I used a thread to send the mail. I can send the mails. After sending
mail to all email id¹s I need to kill the thread. But I failed to do that
and my application getting crashed after sending the mail. I think I should
write the code for that in - (void) connectionTerminated: method. But I
can¹t able to Kill the thread. How can I do this ?
I¹m attaching the code here.

Thanks in advance
Mahaboob





Send.rtf
Description: Binary data
___

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 [EMAIL PROTECTED]

Re: GetApplicationTextEncoding & "carbon free"

2008-11-24 Thread spsaxena
Thanks all for your reply. I would like to go with your suggestion of
removing it.
S!

On Fri, Nov 21, 2008 at 8:57 PM, Michael Ash <[EMAIL PROTECTED]> wrote:

> On Fri, Nov 21, 2008 at 4:42 AM, spsaxena <[EMAIL PROTECTED]> wrote:
> > Hi all,
> > I am working on making my application carbon free. I could not find any
> > replacement for the API "GetApplicationTextEncoding" probably because
> this
> > API has not been marked as deprecated yet. Because of this API I need to
> > link with the carbon framework which I don't want. Can you please suggest
> > any non-carbon API as a replacement for this API.
>
> May I suggest simply removing it and *not* replacing it?
>
> Language-specific text encodings are evil. Sometimes you have to deal
> with them, of course. But if you do, then you should already know what
> encoding you're dealing with and shouldn't need an API to give you an
> "application" encoding. For places where you are able to choose the
> encoding, UTF-8 is the only reasonable ASCII-compatible encoding to
> use.
>
> Mike
> ___
>
> 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/mail2spsaxena%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
___

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 [EMAIL PROTECTED]


Re: Multiple views in a nib file?

2008-11-24 Thread Jean-Nicolas Jolivet
mm interesting reading!... I'm trying to see how I could implement  
this in my case...I used the "Tool" example as it seemed easier to  
explain but basically, what the abstract class represents is an  
"Operation" (just a simple operation performed on some text...)..  
example of subclass could be "Insert text Operation", "Replace Text  
Operation" etc... basically an operation has some parameters  
(textToInsert, textToSearchFor etc..) and it takes some text, performs  
a transformation on it and returns a string... the custom views are  
just used to set those operation's parameters (text to insert  
etc..)... I thought of several way of doing it but since an operation  
could have boolean, int or string parameters, I figured having a  
custom view for each operation would be the way to go...


So to sum it up, each operation has a set of parameters, controlled by  
a custom view ... but the user can add as many operations as he wants  
(so it's not really like there will be only 1 instance of each  
operation... which makes things a little more complex than if it were  
just a tool...)


Basically this is the idea... anyway it's almost 4am I'll have to re- 
read your post tomorrow morning and see how I can make this work for  
my situation! :) in any case, thanks for the ideas!


On 24-Nov-08, at 3:32 AM, Graham Cox wrote:



On 24 Nov 2008, at 6:17 pm, Jean-Nicolas Jolivet wrote:

What I'm trying to do is a bit weird but, it seems to be the only  
way I can think of implementing such a concept, anyway I'll do my  
best to explain... so I have an abstract class (let's call it  
Tools)... basically it just defines some methods/properties that  
the subclass should implement (as I said... an abstract class)...


Each subclass of Tools must have a different custom view assigned  
to it (i.e.  the "Pencil" class, which is a Tool subclass, has a  
custom view, the "Paintbrush" class has a custom view etc...), so I  
added a "NSView *view" properties to my base "Tool" class.


The problem is, I'm not sure how I can store those custom views and  
associate them with their respective subclasses once they are  
instantiated. I'm able to do it if each views are in separate nib  
files, that way I just add a "nibName" property to my Tool class,  
so that every subclass of it has a distinct nib name, I load that  
nib and load the only view in it...


however, this doesn't really seems like the ideal way of doing  
this... wouldn't it be more  practical to save all those views in  
only one nib file? But the problem is, if I do it that way I don't  
know how to access a specific view from that nib file... I thought  
about trying to access it via the "Interface Builder Identity" name  
property but apparently this isn't accessible programatically...


Obviously, if I store all my custom views in the same nib file, and  
each subclass of Tool has to be associated with one of those custom  
views, I can't really set a File Owner to that nib file and define  
an outlet to be associated with any of the view since the "File  
Owner" could basically be any of Tool's subclasses


Should I just store each custom view in their respective nib  
files??? Or perhaps I'm just looking at this the wrong way?


Any help would be appreciated...



Is the idea that as one selects a tool, a pane is switched to show  
the tool's options?


If so, and all the views are in the same window, then I'd put all  
the views in the same nib (one window = one nib). Then you can  
simply have outlets to each view and install the one you want given  
the selected tool. Easier still is to use a tabless tab view and  
switch the current tab.


I'd also resist somewhat the idea of each tool having a "view"  
outlet. While that seems an obvious way to link a tool with its  
options, it's breaking MVC a little bit, though it depends on your  
app's concept of a tool of course. I'd have a tool controller that  
receives the tool selection and installs the relevant options view.  
One way I've done this in the app I'm currently working on is to use  
a simple naming convention for the outlets to the views which is  
related to the name of the tool. Then I can simply look up the  
relevant view by taking the tool's name, building the outlet name  
from it, then using valueForKey: on the controller to return the  
outlet which gets processed further (by installing the view into the  
window in my case). It's very extensible and means that the tool  
controller doesn't need to know about all the different tool  
classes, only that the generic tool has a name, and that the outlets  
follow a simple naming scheme.


I can't see any benefit to having each view in separate nibs if this  
indeed what you're trying to do - it's an extra level of complexity  
that isn't worth the trouble.


hth,

Graham




Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.com

___

Cocoa-dev mailing list (Cocoa-de

Re: Remove HTML Tags

2008-11-24 Thread Jean-Daniel Dupas


Le 24 nov. 08 à 00:54, Mr. Gecko a écrit :

Hello, what's the best way to remove html tags and javascript from a  
NSString?
(I'm working on a web crawler and I'm needing a way to get the  
contents of a page that doesn't have a description on it.)


Thanks,
Mr. Gecko


Just a suggestion:
loading it in a WebView and retreiving the page text content.


___

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 [EMAIL PROTECTED]


Re: Need some advice on multithreading

2008-11-24 Thread Peter Duniho
Mike already gave a bunch of good advice, so I'll just try to  
usefully expand on that (but I also have one "sort-of" disagreement  
I'll mention :) )...



Date: Mon, 24 Nov 2008 01:06:17 +0100
From: WT <[EMAIL PROTECTED]>

 [...]
2. continuously running the simulation engine, at a rate that can also
be changed dynamically by the user (for instance, in the bouncing
balls example, increasing gravity makes the balls move faster, thereby
requiring the engine to run more often in order to preserve accuracy
and to prevent anomalies such as the balls overlapping one another);


While it may wind up making sense to put the simulation engine in a  
separate thread, I would recommend _not_ trying to adjust the  
simulation rate to account for the speed of the balls, precision,  
etc.  This sort of load-adjusting sounds good in theory, but it  
ultimately fails because the performance characteristics of the code  
changes according to the settings.


In particular, in this scenario the best you can hope for is to  
consume less CPU than the simulation would need at its most precise,  
when the balls are moving more slowly.  But your code will still need  
to perform adequately at the highest ball speed, and you'll  
necessarily still have to limit just how fast the updates can go (if  
by no other means than that the simulation thread winds up running  
full throttle without any delay).  If the program can't provide a  
good user experience in that situation, then you need to set the  
limits lower to where it can, and once you've done that, you gain  
very little by reducing the performance load when lower precision is  
feasible.


On the other hand, there are some significant risks to trying to  
implement something like this, not the least of which is the risk of  
getting it wrong.  :)  The other risk is that some high-load scenario  
may miss testing (testers make mistakes too :) ), and it will go  
undetected because of that.  If you are running the simulation at its  
highest possible precision all the time, then you are more likely to  
detect performance issues.



[...]
Is this the right idea? Does anyone have a better suggestion? Are
there any pitfalls that I'm not seeing? One concern I have is that
there might be some weird interactions between running the simulation
and drawing the results due to the fact that the simulation engine is
running on a timer and the drawing engine is running on another timer,
and their periods might not be commensurate.


As long as the refresh rate of your simulation is high enough and the  
frame rate is high enough, you should not notice any anomalies due to  
the differences between the two.  You are right that there will be  
theoretical unevenness in the rendering, but with everything  
happening fast enough, a human isn't going to notice.


I recommend you pay particular attention to Mike's thoughts on  
synchronization and data passing, re: immutable objects and messaging  
(a form of immutable objects, assuming he means what I think he  
means).  The less that data actually needs to be synchronized between  
threads, the better.


The one disagreement I have with his comments is here (and it's not  
so much a disagreement as it is a redirection):



Date: Sun, 23 Nov 2008 20:31:01 -0500
From: "Michael Ash" <[EMAIL PROTECTED]>

[...]
- When multithreading for the purposes of optimization as you're
doing, treat it as any other optimization. That is, measure and
profile your app before you do anything else to it. Trying to figure
out where to put the threads when you don't even know what parts of
your app are slow is pointless. Just as it's a bunch of wasted effort
to carefully hand-craft a super fast assembly language version of a
function that only runs one time for one millisecond, it's likewise a
bunch of wasted effort to carefully come up with a multithreaded
implementation of such a function. In your case, if the simulation
engine only takes up, say, 10% of your CPU time compared to display,
then the absolute possible best speed gain you could ever see from
shoving it into a background thread would be 10%, probably not worth
all the work and risk.


Mike starts with the constraint "when multithreading for the purposes  
of optimization", and taken at face value I don't see anything wrong  
with the paragraph per se.  But...


There's "optimization", and then there's "optimization".  :)  I have  
the impression from your original message that this isn't so much  
about improving throughput as it is about keeping the user-interface  
from being dependent on the simulation rate, thus improving the user  
experience.  In programs where the simulation and/or screen rendering  
is very slow, but user-input is handled only between frames, the user  
experience can be very frustrating, as compared to a program that is  
always ready to respond to the user via a separate thread (OS quantum  
is usually something like 50ms, which is generally plenty responsive  
for UI)

Re: Multiple views in a nib file?

2008-11-24 Thread Graham Cox


On 24 Nov 2008, at 6:17 pm, Jean-Nicolas Jolivet wrote:

What I'm trying to do is a bit weird but, it seems to be the only  
way I can think of implementing such a concept, anyway I'll do my  
best to explain... so I have an abstract class (let's call it  
Tools)... basically it just defines some methods/properties that the  
subclass should implement (as I said... an abstract class)...


Each subclass of Tools must have a different custom view assigned to  
it (i.e.  the "Pencil" class, which is a Tool subclass, has a custom  
view, the "Paintbrush" class has a custom view etc...), so I added a  
"NSView *view" properties to my base "Tool" class.


The problem is, I'm not sure how I can store those custom views and  
associate them with their respective subclasses once they are  
instantiated. I'm able to do it if each views are in separate nib  
files, that way I just add a "nibName" property to my Tool class, so  
that every subclass of it has a distinct nib name, I load that nib  
and load the only view in it...


however, this doesn't really seems like the ideal way of doing  
this... wouldn't it be more  practical to save all those views in  
only one nib file? But the problem is, if I do it that way I don't  
know how to access a specific view from that nib file... I thought  
about trying to access it via the "Interface Builder Identity" name  
property but apparently this isn't accessible programatically...


Obviously, if I store all my custom views in the same nib file, and  
each subclass of Tool has to be associated with one of those custom  
views, I can't really set a File Owner to that nib file and define  
an outlet to be associated with any of the view since the "File  
Owner" could basically be any of Tool's subclasses


Should I just store each custom view in their respective nib  
files??? Or perhaps I'm just looking at this the wrong way?


Any help would be appreciated...



Is the idea that as one selects a tool, a pane is switched to show the  
tool's options?


If so, and all the views are in the same window, then I'd put all the  
views in the same nib (one window = one nib). Then you can simply have  
outlets to each view and install the one you want given the selected  
tool. Easier still is to use a tabless tab view and switch the current  
tab.


I'd also resist somewhat the idea of each tool having a "view" outlet.  
While that seems an obvious way to link a tool with its options, it's  
breaking MVC a little bit, though it depends on your app's concept of  
a tool of course. I'd have a tool controller that receives the tool  
selection and installs the relevant options view. One way I've done  
this in the app I'm currently working on is to use a simple naming  
convention for the outlets to the views which is related to the name  
of the tool. Then I can simply look up the relevant view by taking the  
tool's name, building the outlet name from it, then using valueForKey:  
on the controller to return the outlet which gets processed further  
(by installing the view into the window in my case). It's very  
extensible and means that the tool controller doesn't need to know  
about all the different tool classes, only that the generic tool has a  
name, and that the outlets follow a simple naming scheme.


I can't see any benefit to having each view in separate nibs if this  
indeed what you're trying to do - it's an extra level of complexity  
that isn't worth the trouble.


hth,

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 [EMAIL PROTECTED]


Re: CGImageDestinationSetProperties does not work for animated GIF

2008-11-24 Thread Rob Keniger


On 24/11/2008, at 6:24 AM, Patrick Haruksteiner wrote:

  CGImageDestinationSetProperties(imageDestination,  
(CFDictionaryRef)finalGIFImageProperties);



I've never worked with this API before, but what happens if you change  
the above line to this?:


CGImageDestinationSetProperties(imageDestination, (CFDictionaryRef)  
gifImageProperties);


My reading of the the docs seems to suggest that you would pass the  
keys directly rather than wrapping them in another dictionary using  
kCGImagePropertyGIFDictionary.


--
Rob Keniger



___

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 [EMAIL PROTECTED]