Re: observeValueForKeyPath returns null in the change directory???

2009-08-15 Thread Sandro Noel

thanks guy's


Sandro Noël
sandro.n...@mac.com
Mac OS X : Swear by your computer, not at it.

P
-Pensez vert! avant d’imprimer ce courriel.
-Go Green! please consider the environment before printing this email.




On 15-Aug-09, at 7:05 PM, Kyle Sluder wrote:

Unfortunately, NSController's implementation of -bind:… ignores your  
options and does not fill in the change information. It's incredibly  
frustrating.


File a Radar, they'll add it to the pile…

--Kyle Sluder


___

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

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

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

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


Re: NSProgressIndicator not animating when part of NSAnimation

2009-08-15 Thread Thomas Bauer

Hi!

Thanks for your response.
I am not quite sure if I understand you correctly but here is what I  
tried:


- Calling the whole code (starting the NSAnimation and the  
ProgressIndicator animation) using a performSelectorOnMainThread does  
not fix it.

- Calling the whole code using performSelector delayed does not fix it.
- Calling the NSProgressIndicator startanimation alone on the main  
thread does not fix it either.


However your response triggered an idea and this works:

[myViewNSAnimation startAnimation];
[myindicator performSelector:@selector(startAnimation:) withObject:nil  
afterDelay:1.1];


Does the trick, but only if the delay is greater than the duration of  
the NSAnimation.
In short, if I call the selector (even on the main thread) during the  
NSAnimation is running, it does not work.
That would make some sense - but why the same thing works without  
those tricks in awakefromnib does not make sense to me...
Because I would think that running it in awakefromnib and running it  
using performSelectorOnMainThread should be somewhat identical?


While it is great that I have a workaround ... I would appreciate any  
explaination on why it behaves that way.

Technically this does not make sense to me.

Cheers
Thomas



On 16/08/2009, at 1:11 PM, Kyle Sluder wrote:

On Aug 15, 2009, at 6:04 PM, Thomas Bauer   
wrote:



Further to my below question I found out that the problem is  
related to what is triggering the code that starts the animation:
If the code that starts the NSAnimation and the NSProgressIndicator  
animation is called in an IBAction called by a button on a  
different window,

the NSProgressIndicator animation does not start.


Try scheduling a delayed perform in a normal runloop mode. The  
button is probably implementing its own runloop (one of the two ways  
controls perform mouse tracking). You need to break out of this  
runloop mode, and peformSelector:onMainThread: will do it.


--Kyle Sluder




___

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

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

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

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


Re: NSProgressIndicator not animating when part of NSAnimation

2009-08-15 Thread Kyle Sluder

On Aug 15, 2009, at 6:04 PM, Thomas Bauer  wrote:


Further to my below question I found out that the problem is related  
to what is triggering the code that starts the animation:
If the code that starts the NSAnimation and the NSProgressIndicator  
animation is called in an IBAction called by a button on a different  
window,

the NSProgressIndicator animation does not start.


Try scheduling a delayed perform in a normal runloop mode. The button  
is probably implementing its own runloop (one of the two ways controls  
perform mouse tracking). You need to break out of this runloop mode,  
and peformSelector:onMainThread: will do it.


--Kyle Sluder



___

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

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

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

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


Re: NSProgressIndicator not animating when part of NSAnimation

2009-08-15 Thread Thomas Bauer

Dear List!

Further to my below question I found out that the problem is related  
to what is triggering the code that starts the animation:
If the code that starts the NSAnimation and the NSProgressIndicator  
animation is called in an IBAction called by a button on a different  
window,

the NSProgressIndicator animation does not start.

However - if i execute the same code in awakefromnib, everything is ok.
I furthermore found out the in a case where the animation of the  
progressindicator does not start

it is sometimes sufficient to move the mouse over it.

I would already be happy if I could workaround that problem by adding  
a call to my code that simulates what a keystroke or such.
I have tried a NSApp updateWindows... redrawing of views etc. Nothing  
helps.


Cheers
Thomas

On 15/08/2009, at 10:15 PM, Thomas Bauer wrote:


Dear List!

I am using an indetermined NSProgressIndicator as a subview of a  
NSView.

The frame of the NSView is animated using a NSAnimation.

Basically before (or after - i have tried both) [mynsanimation  
startAnimation] I do a [myprogressindicator startAnimation:self];

However, the progressindicator does not animate.

Even if the progressindicator is switched to a determined  
progressindicator later in the code,
although the change is visible, the barberpoleanimation inside the  
blue part is not moving.


However - when I click on the Window or perform a random keystroke,  
the animation starts.

Both is consistently happening in Leopard and Tiger.

If comment out the [mynsanimation startAnimation] and instead  
perform a non animated move of my view [myview setframe:newlocation],

the animation of the progress indicator works as expected.

The progressindicator is set to use its own thread for animation.
I have tried all different NSAnimation blocking modes to no effect.

I would appreciate any hint on how I could make the  
progressindication animate even if it is part of a view that is  
NSAnimated.

I would also very much like to know what the underlying reason is.

Thanks and kind regards
Thomas





___

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/tb%40freeridecoding.com

This email sent to t...@freeridecoding.com


___

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

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

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

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


Re: signals question

2009-08-15 Thread Kyle Sluder



--Kyle Sluder

On Aug 15, 2009, at 8:08 AM, Rolando Abarca  wrote:


The thing is that somehow, I'm not locking the ruby VM to do not allow
it to be interrupted during it's execution, because apparently it is
being interrupted and that's causing some really nasty (random)
crashes. Is it possible to do it? I mean, to lock a portion of code to
not be interrupted by signals during it's execution.


I don't understand how signals come into this.



Someone told me to not run the VM from within a signal handler, but
how would I be able to do that?...


Simple. You don't. It's a lot harder to do something than to not do  
it. Unless you aren't talking about POSIX signal handlers.


--Kyle Sluder
___

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

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

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

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


signals question

2009-08-15 Thread Rolando Abarca
Hi All,

I've been hunting a bug for almost a week now, and I think I got it
narrowed enough now: I'm embedding a ruby interpreter in an app, and
calling ruby code from within my app asynchronously. The app is only
one thread, but it responds to events generated by the OS (click,
timers, etc.) and some of these events trigger a ruby function.
The thing is that somehow, I'm not locking the ruby VM to do not allow
it to be interrupted during it's execution, because apparently it is
being interrupted and that's causing some really nasty (random)
crashes. Is it possible to do it? I mean, to lock a portion of code to
not be interrupted by signals during it's execution.

Someone told me to not run the VM from within a signal handler, but
how would I be able to do that?...

thanks a lot!
-- 
Rolando Abarca
http://rolando.cl
___

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

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

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

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


NSProgressIndicator not animating when part of NSAnimation

2009-08-15 Thread Thomas Bauer

Dear List!

I am using an indetermined NSProgressIndicator as a subview of a NSView.
The frame of the NSView is animated using a NSAnimation.

Basically before (or after - i have tried both) [mynsanimation  
startAnimation] I do a [myprogressindicator startAnimation:self];

However, the progressindicator does not animate.

Even if the progressindicator is switched to a determined  
progressindicator later in the code,
although the change is visible, the barberpoleanimation inside the  
blue part is not moving.


However - when I click on the Window or perform a random keystroke,  
the animation starts.

Both is consistently happening in Leopard and Tiger.

If comment out the [mynsanimation startAnimation] and instead perform  
a non animated move of my view [myview setframe:newlocation],

the animation of the progress indicator works as expected.

The progressindicator is set to use its own thread for animation.
I have tried all different NSAnimation blocking modes to no effect.

I would appreciate any hint on how I could make the progressindication  
animate even if it is part of a view that is NSAnimated.

I would also very much like to know what the underlying reason is.

Thanks and kind regards
Thomas





___

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

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

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

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


Re: observeValueForKeyPath returns null in the change directory???

2009-08-15 Thread Kyle Sluder
Unfortunately, NSController's implementation of -bind:… ignores your  
options and does not fill in the change information. It's incredibly  
frustrating.


File a Radar, they'll add it to the pile…

--Kyle Sluder___

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

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

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

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


Re: observeValueForKeyPath returns null in the change directory???

2009-08-15 Thread Jean-Daniel Dupas

Le 15 août 2009 à 21:18, Sandro Noel a écrit :


Greetings.

I would like to watch to prefeences change in my application.
so i add these observers as so:

settings = [NSUserDefaultsController sharedUserDefaultsController];
[settings addObserver:self
forKeyPath:@"values.filesPath"
options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld)
context:NULL];

My observers are registered in applicationDidFinishLaunching.

I do successfully receive the notification for my key path.
but the change directory only returns null values for the old and  
the new values, I do not know what i'm doing wrong.




if i fetch the new value directly from the UserDefaultsController  
the path did change and I can use it from there.

but I would need the old value to remove the old path from my monitor.


[...]


Any clues would be great !!!
thank you !




Don't know why it behaves like this, but you can probably work around  
this by using the NSKeyValueObservingOptionPrior option.
By setting this option, you will receive a notification before the new  
value is set, and you can retrieve the old value.
In your observer, you can detect if the notification is the prior one  
by querying the NSKeyValueChangeNotificationIsPriorKey key in the  
change dictionary.


___

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

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

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

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


Re: iPhone: detect if docked?

2009-08-15 Thread Jack Carbaugh
ah but wouldn't this be a FAIL if say, the user was using a battery  
extender for a quick recharge ?



On Aug 15, 2009, at 3:40 AM, David Duncan wrote:


On Aug 14, 2009, at 4:29 AM, Sean Kline wrote:


Is another option to use the External Accessory framework?



I don't think so. A simple charger may not appear as any kind of  
accessory at all (consider the wall-outlet charger) so EA wouldn't  
track it. If you want to know if the device is on external power  
(which in this particular case would likely be a false positive on  
one of those external battery packs) then you want to know if the  
battery status is "charging".

--
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/intrntmn%40aol.com

This email sent to intrn...@aol.com


___

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

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

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

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


Is it possible to detour a drag and drop operation?

2009-08-15 Thread Iceberg-Dev

Problem:


Let's say I have 2 windows:

+---++---+
+---++---+
|   ||   |
|  +-+  ||   |
|  |  A  |  ||   |
|  +-+  ||   |
|   ||   |
+---++---+

When I drag item A from the window on the left to the window on the  
right, I want to do this:


When the drop is validated in the right window (type of item  
accepted), I would like to either display a window above the right  
window or change the right window content to give the user a list of  
more detailed possible drop locations.


Something like this:

+---++---+
+---+++--+
|   |||  |
|  +-+  |||  |
|  |  A  |  ||  Left  |   Right  |
|  +-+  |||  |
|   |||  |
+---+++--+

There's something like this in Final Cut Pro (http://www.geniusdv.com/ 
news_and_tutorials/assets_c/2009/04/superimpose3- 
thumb-394x397-2264.gif).


Question:
-

How could this be achieved in Cocoa?


I have tried with a window but the target of the drop does not get  
changed.



___

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

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

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

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


Re: Timer in drawing loop performance problems

2009-08-15 Thread Shayne Wissler
Evidently I wasn't clear. It's using ~15% of the CPU while not drawing
anything at all, but just from the timer going off and calling
setNeedsDisplay. I don't actually redisplay unless something changed.

Thanks for the tip on CVDisplayLink, I missed that.


Shayne Wissler

On Sat, Aug 15, 2009 at 2:14 AM, Jean-Daniel
Dupas wrote:
> And if you enabled vsync (which is by default), your code will never draw
> faster than the refresh rate (usually 60 Hz). That's probably why you never
> use more than 15 % of the CPU.
>
> Le 15 août 2009 à 06:05, Roland King a écrit :
>
>> 1) again I think you'll get better answers on the OpenGL list than the
>> cocoa dev list - the guys on that list eat and breathe openGL and I've had
>> some fantastic help there.
>>
>> 2) Are you targetting OSX 10.3 for your code? That tech tip says use an
>> NSTimer only for 10.3 compatibility and CVDisplayLink for anything from 10.4
>> onwards. If you do have to use a timer have you read the caveat about
>> enabling vertical synchronization (however one does that) or "the
>> application will burn a lot of CPU time just firing off the timer, even
>> though the drawing loop hasn't even completed its last run."?
>>
>>
>> On Aug 15, 2009, at 11:21 AM, Shayne Wissler wrote:
>>
>>> Hello,
>>>
>>> Following the advice at
>>> http://developer.apple.com/qa/qa2004/qa1385.html, I attempted using a
>>> timer running at 1000Hz. However, on my iMac, this causes about a ~15%
>>> CPU hit. When I run Shark, it says it's spending a good deal of time
>>> in objc_msgSend, presumably in the call "[self setNeedsDisplay:YES]".
>>>
>>> Is all this normal/expected?
>>>
>>>
>>> Shayne Wissler
>>> ___
>>>
>>> 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/rols%40rols.org
>>>
>>> This email sent to r...@rols.org
>>
>> ___
>>
>> 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/devlists%40shadowlab.org
>>
>> This email sent to devli...@shadowlab.org
>>
>
>
___

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

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

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

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


observeValueForKeyPath returns null in the change directory???

2009-08-15 Thread Sandro Noel

Greetings.

I would like to watch to prefeences change in my application.
so i add these observers as so:

settings = [NSUserDefaultsController sharedUserDefaultsController];
[settings addObserver:self
forKeyPath:@"values.filesPath"
options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld)
context:NULL];

My observers are registered in applicationDidFinishLaunching.

I do successfully receive the notification for my key path.
but the change directory only returns null values for the old and the  
new values, I do not know what i'm doing wrong.




if i fetch the new value directly from the UserDefaultsController the  
path did change and I can use it from there.

but I would need the old value to remove the old path from my monitor.

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


[keyPath retain];
[change retain];

if ([keyPath isEqual:@"values.filesPath"]) {
NSString *old = [change objectForKey:NSKeyValueChangeOldKey];
NSString *new = [change objectForKey:NSKeyValueChangeNewKey];

// both are NSNull
[fileMonitor removePath:old];
[fileMonitor addPath:new];

// this works fine
[fileMonitor addPath:[[settings values] 
valueForKey:@"filesPath"]];
}

[change release];
[keyPath release];  
}

Any clues would be great !!!
thank you !

Sandro Noël
sandro.n...@mac.com
Mac OS X : Swear by your computer, not at it.

P
-Pensez vert! avant d’imprimer ce courriel.
-Go Green! please consider the environment before printing this email.




___

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

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

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

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


Re: initWithCoder but I do not have nib file

2009-08-15 Thread Agha Khan

Thank for reply.

First of all I should had written
self.helpButton = [UIButton buttonWithType:UIButtonTypeCustom];
Not UIButtonTypeRoundedRect

CustomButton*myButton = [CustomButton buttonWithType:  
UIButtonTypeCustom];



That does not work either, even my base class is UIButton for  
CustomButton.
This is a new bug and it should had init through CustomButton, but it  
didn't. This code just returns me  UIButton*.
After that there is no point because It has not gone through my code  
and unable apply  any custom attributes.


Work around  and it works.
call [self Attach:myButton];

- (void) Attach:(UIButton*) btn
{
[btn.titleLabel setNumberOfLines:0];
[btn.titleLabel setLineBreakMode:UILineBreakModeWordWrap];

btn.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15];
if (!normalImage)
{
UIImage *image = [UIImage 
imageNamed:@"customButtonImageDefault.png"];
		normalImage =[image stretchableImageWithLeftCapWidth:12 topCapHeight: 
12];

}

if (!pressedImage)
{
UIImage *image = [UIImage 
imageNamed:@"customButtonImageDown.png"];
		pressedImage = [image stretchableImageWithLeftCapWidth:12  
topCapHeight:12];

}

[btn setBackgroundImage:normalImage  forState:UIControlStateNormal];
	[btn setBackgroundImage:pressedImage  
forState:UIControlStateHighlighted];


	[btn setTitleColor:[UIColor blackColor]   
forState:UIControlStateNormal];
	[btn setTitleColor:[UIColor blackColor]  
forState:UIControlStateHighlighted];


	btn.contentHorizontalAlignment =  
UIControlContentHorizontalAlignmentCenter;

btn.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

}






On Aug 15, 2009, at 8:08 AM, Luke the Hiesterman wrote:

For some reason I don't have this original email in my inbox, but to  
the author:


As you've observed, initWithCoder: is called when your object is  
instantiated from a nib. Since you don't have a nib, and you're  
instantiating the object in code, you should not use initWithCoder:.  
Instead you should use the designated initializer of the given  
class. The blog entry doesn't include the full interface of the  
class, so I don't know exactly what the designated initializer is,  
but given that it's a UIButton subclass, and UIButtons are  
instantiated from a class method, I would expect that it needs to be  
instantiated from a class method also, like this:


CustomButton*myButton = [CustomButton  
buttonWithType:UIButtonTypeRoundedRect];


Luke



On Aug 15, 2009, at 5:07 AM, Agha Khan wrote:


Hi:
I was looking a blog about customButton


http://supergravelynbros.com/?p=871


The author explained that initializing with
- (id)initWithCoder:(NSCoder *)coder

I implemented something like this
self.helpButton = [CustomButton  
initWithCoder:UIButtonTypeRoundedRect];

which complies OK, but get exception at this point.

I know the reason I do not have a nib file, but I believe I don't  
need it.


According to author
The initWithCoder: method is what will be called when the game  
reads the button in from the nib files.


But I do not have any nib file in my project. What can we do in  
such 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/agha.khan%40me.com

This email sent to agha.k...@me.com


___

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

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

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

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


Re: Aqua animations drawing from separate thread

2009-08-15 Thread Frederik Slijkerman
The problem is that of course, you don't know that in general, so it's a 
potentially difficult-to-find bug that could happen anywhere in your 
code. For example, I now have a button that's just above a view with 
complex drawing, so the border of the button overlaps with that view and 
causes it to redraw.


I definitely agree with Dave Keck that it seems like a gross oversight 
on Apple's part to handle Aqua animations from a secondary thread -- 
that should have been done with a timer from the main thread. There's 
nothing in the drawRect documentation that would suggest this, I found 
it out using the debugger. (And yes, it does cause a crash in my code.)


I briefly tried calling the drawing code via [NSObject 
performSelectorOnMainThread] but that of course causes an immediate 
deadlock. Looks like the only solution is to do all complex drawing to 
an off-screen bitmap if drawRect is called from the main thread, and 
just draw that bitmap if drawRect is called from another thread. But 
this is slower and consumes more memory.


Best regards,
Frederik Slijkerman


BravoBug Software wrote:
> If you don't need to do secondary-thread drawing in your view, you
> don't have to. You can check which thread is sending the -drawRect
> method. Allow the subviews such as the aqua button to draw themselves,
> and skip over any thread-unsafe custom -drawRect stuff in your
> superview.
>
> The only thing you would need to redraw in your superview is the tiny
> rect surrounding the pulsing blue aqua button. I can't really imagine
> what kind of complex thread-unsafe stuff would be going on in the tiny
> spaces around the rounded-corner edges of the button. Seems like that
> would typically be transparent, a background color/pattern, or
> something similar. You should be able to supply that minimal amount of
> drawing in a thread-safe fashion without too much difficulty.
>
> On Fri, Aug 14, 2009 at 8:45 AM, Frederik
> Slijkerman wrote:
>> Hi,
>>
>> Another question... I've noticed that Aqua animations, for example the
>> pulsing default button, are implemented via a separate thread, which 
redraws
>> the button repeatedly. This also causes the view (for example a 
custom view
>> that I wrote myself) that contains the button to receive a drawRect 
message,

>> of course.
>>
>> The problem is that this drawRect message is sent from the separate 
thread,

>> which means that drawing in all my custom views needs to be thread-safe.
>> This is a huge pain.
>>
>> Is there any way around this? Are you all always writing thread-safe
>> drawRect handlers? It seems like a huge responsibility to make sure this
>> will always work correctly...
>>
>> Thanks in advance!
>>
>> Best regards,
>> Frederik Slijkerman


___

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

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

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

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


Re: Disabled controls don't update their visual appearance

2009-08-15 Thread Christopher Campbell Jensen
No, it's a just a regular application. It's functionality is very  
similar to MetaX (an mp4 tagging tool), in that it has a file viewer  
where you can have a bunch of files open, when you select one it  
updates all the fields in the rest of the UI to reflect the  
information contained and selected previously for that file. This  
context switch has caused me a lot of headaches, and I am sure I have  
gone about it all wrong, but it works now, all except the updating of  
those fields.
Your question concerning if I was using an nsdocument based app made  
me question if perhaps that would have been a better idea, but it  
seems that each window in an nsdocument based core data app keeps it's  
own database, while I would want all of them to share one database + I  
really want just one window, and the selection of a new file in the  
"file viewer"/nstableview to update the context. I am certain there is  
a perfect design pattern that I should have used, instead of my ramble  
of code.


The "model" is kept in both the core data repository, and then the  
current selected stuff is kept in an object that contains both the  
file path and the meta data related to that file.


If anyone dares/wishes to look at the code, it is available here:
http://www.mediafire.com/file/arjmmgdzwyz/MP4BatchTagger.tgz

I warn you though, this is the first app from a nice objective-c/cocoa  
programmer, and it is not as neat as I wish it could have been. I have  
had a few uphill battles, and it will be evident in the code.
Oh, and not everything is implemented, and there is some debug stuff  
still in there. If you do a search, then click the cancel button, some  
mock entries will be added to the core data db to play around with.


Chris

On 15 Aug 2009, at 06:45, Uli Kusterer wrote:


On Aug 11, 2009, at 5:45 PM, Christopher Campbell Jensen wrote:
To check when/if any of them were nil, I set a breakpoint and  
stepped through the code pausing it each time  
"refreshButtonsEnabledState" was called and it made me realise that  
the buttons fail to update their state the first time the method  
gets called and movieFile is nil. When I, at the end of the movie,  
again click on the second tab item, "refreshButtonsEnabledState"  
gets called and at this point movieFile is still nil. How come it  
works the second time around, and not the first?


Is this an NSDocument-based app? You may want to re-read the  
relevant chapter in Hillegass' book: You generally get the "load  
document" message before the NIB has been loaded at startup (though  
you may also get it afterwards, e.g. when the user chooses the  
"revert" menu item). Your code should only load its model into  
ivars, and try to update the GUI (if it is there) in *both* the load  
method (for the case where it's a revert) and the  
windowControllerDidLoadNib method (for the regular "open" case.


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







___

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

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

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

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


Re: initWithCoder but I do not have nib file

2009-08-15 Thread Chase Meadors
You're completely correct, that was an error on my part. I don't know  
exactly why I wrote it that way... morning?


On Aug 15, 2009, at 9:55 AM, Luke the Hiesterman wrote:

What? No, that is not the idea. When an object is unarchived from a  
nib it is instantiated as part of the unarchiving process, and  
you're supposed to perform initialization in initWithCoder:, not  
allocation (that's why in Cocoa we separate the concepts of  
allocation and initialization). The code you have below completely  
negates the effect of having an object in a nib by creating a new  
object and returning that. Instead of returning a new button object,  
you should be performing initialization on the one you already have.


Luke

On Aug 15, 2009, at 7:42 AM, Chase Meadors wrote:


The idea is to do something like this in a custom class:

- (id)initWithCoder:(NSCoder *)coder {

if (self = [super initWithCoder:coder]) {

return [NSButton buttonWithType:UIButtonTypeRoundedRect];

}

}




___

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

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

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

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


Re: initWithCoder but I do not have nib file

2009-08-15 Thread Luke the Hiesterman
For some reason I don't have this original email in my inbox, but to  
the author:


As you've observed, initWithCoder: is called when your object is  
instantiated from a nib. Since you don't have a nib, and you're  
instantiating the object in code, you should not use initWithCoder:.  
Instead you should use the designated initializer of the given class.  
The blog entry doesn't include the full interface of the class, so I  
don't know exactly what the designated initializer is, but given that  
it's a UIButton subclass, and UIButtons are instantiated from a class  
method, I would expect that it needs to be instantiated from a class  
method also, like this:


CustomButton*myButton = [CustomButton  
buttonWithType:UIButtonTypeRoundedRect];


Luke



On Aug 15, 2009, at 5:07 AM, Agha Khan wrote:


Hi:
I was looking a blog about customButton


http://supergravelynbros.com/?p=871


The author explained that initializing with
- (id)initWithCoder:(NSCoder *)coder

I implemented something like this
self.helpButton = [CustomButton  
initWithCoder:UIButtonTypeRoundedRect];

which complies OK, but get exception at this point.

I know the reason I do not have a nib file, but I believe I don't  
need it.


According to author
The initWithCoder: method is what will be called when the game  
reads the button in from the nib files.


But I do not have any nib file in my project. What can we do in  
such 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 arch...@mail-archive.com


Re: initWithCoder but I do not have nib file

2009-08-15 Thread Luke the Hiesterman
What? No, that is not the idea. When an object is unarchived from a  
nib it is instantiated as part of the unarchiving process, and you're  
supposed to perform initialization in initWithCoder:, not allocation  
(that's why in Cocoa we separate the concepts of allocation and  
initialization). The code you have below completely negates the effect  
of having an object in a nib by creating a new object and returning  
that. Instead of returning a new button object, you should be  
performing initialization on the one you already have.


Luke

On Aug 15, 2009, at 7:42 AM, Chase Meadors wrote:


The idea is to do something like this in a custom class:

- (id)initWithCoder:(NSCoder *)coder {

if (self = [super initWithCoder:coder]) {

return [NSButton buttonWithType:UIButtonTypeRoundedRect];

}

}


___

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

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

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

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


Re: initWithCoder but I do not have nib file

2009-08-15 Thread Chase Meadors
Looks like you don't quite understand -init/initWithCoder methods. Why  
are you passing UIButtonTypeRoundedRect as the (NSCoder *)coder  
argument?


-initWithCoder only exists to be called when an object is created in a  
nib.


From the documentation on the NSCoding protocol (which includes  
initWithCoder),


"The NSCoding protocol declares the two methods that a class must  
implement so that instances of that class can be encoded and decoded.  
This capability provides the basis for archiving (where objects and  
other structures are stored on disk) and distribution (where objects  
are copied to different address spaces)."


encoding and decoding are what happens when objects are created in a  
nib. So basically, the argument to initWithCoder is something that  
interface builder uses to unarchive an object in a nib. You simply  
have to implement it and call whatever regular init method you want.


The idea is to do something like this in a custom class:

- (id)initWithCoder:(NSCoder *)coder {

if (self = [super initWithCoder:coder]) {

return [NSButton buttonWithType:UIButtonTypeRoundedRect];

}

}

From the documentation on the NSCoding protocol (which includes  
initWithCoder),


"The NSCoding protocol declares the two methods that a class must  
implement so that instances of that class can be encoded and decoded.  
This capability provides the basis for archiving (where objects and  
other structures are stored on disk) and distribution (where objects  
are copied to different address spaces)."


encoding and decoding are what happens when objects are created in a  
nib. So basically, the argument to initWithCoder is something that  
interface builder uses to unarchive an object in a nib. You simply  
have to implement it and call your regular init method.


If you're not using a nib, simply create a new button with  
[CustomButton buttonWithType:UIButtonTypeRoundedRect]; You probably  
need to override -buttonWithType to add custom behavior to your class.


Did that make sense?



On Aug 15, 2009, at 5:07 AM, Agha Khan wrote:


Hi:
I was looking a blog about customButton


http://supergravelynbros.com/?p=871


The author explained that initializing with
- (id)initWithCoder:(NSCoder *)coder

I implemented something like this
self.helpButton = [CustomButton  
initWithCoder:UIButtonTypeRoundedRect];

which complies OK, but get exception at this point.

I know the reason I do not have a nib file, but I believe I don't  
need it.


According to author
The initWithCoder: method is what will be called when the game reads  
the button in from the nib files.


But I do not have any nib file in my project. What can we do in such  
situation?


Best regards
-Agha
___

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/c.ed.mead%40gmail.com

This email sent to c.ed.m...@gmail.com


___

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

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

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

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


Re: CTLineCreateWithAttributedString ignoring font size

2009-08-15 Thread Alastair Houghton

On 15 Aug 2009, at 10:28, Charles Srstka wrote:

Now I'm just trying to figure out why it's ignoring the  
NSBackgroundColorAttributeName attribute.


Well I think the problem is that NSBackgroundColorAttributeName is a  
higher level thing.  In the Cocoa text system, the NSLayoutManager is  
responsible for drawing it, and that's done with separate methods, in  
the same way as rendering the selection highlight.


While I haven't used Core Text myself, I imagine it's architected in a  
similar manner, so CTDrawLine() is very unlikely to render anything  
other than the glyphs.  CTFrame *may* be able to render the  
background, so if you need that functionality and don't want to draw  
it yourself you could try creating a CTFramesetter rather than a  
CTLine and using that to generate a CTFrame that you then draw.   
Otherwise I think you'll just have to draw the background manually.


For the time being, I've got a workaround in just drawing the  
background color with NSRectFill, but this feels like a kludge, and  
that I really should be doing something differently to draw the  
background the "right" way.


I guess my only comment there is that it might be more consistent to  
use CGContextFillRect().  Not that it really matters either way :-)


Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


Re: Aqua animations drawing from separate thread

2009-08-15 Thread BravoBug Software
If you don't need to do secondary-thread drawing in your view, you
don't have to. You can check which thread is sending the -drawRect
method. Allow the subviews such as the aqua button to draw themselves,
and skip over any thread-unsafe custom -drawRect stuff in your
superview.

The only thing you would need to redraw in your superview is the tiny
rect surrounding the pulsing blue aqua button. I can't really imagine
what kind of complex thread-unsafe stuff would be going on in the tiny
spaces around the rounded-corner edges of the button. Seems like that
would typically be transparent, a background color/pattern, or
something similar. You should be able to supply that minimal amount of
drawing in a thread-safe fashion without too much difficulty.

On Fri, Aug 14, 2009 at 8:45 AM, Frederik
Slijkerman wrote:
> Hi,
>
> Another question... I've noticed that Aqua animations, for example the
> pulsing default button, are implemented via a separate thread, which redraws
> the button repeatedly. This also causes the view (for example a custom view
> that I wrote myself) that contains the button to receive a drawRect message,
> of course.
>
> The problem is that this drawRect message is sent from the separate thread,
> which means that drawing in all my custom views needs to be thread-safe.
> This is a huge pain.
>
> Is there any way around this? Are you all always writing thread-safe
> drawRect handlers? It seems like a huge responsibility to make sure this
> will always work correctly...
>
> Thanks in advance!
>
> Best regards,
> Frederik Slijkerman
> ___
>
> 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/bravobug%40gmail.com
>
> This email sent to bravo...@gmail.com
>
___

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

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

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

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


initWithCoder but I do not have nib file

2009-08-15 Thread Agha Khan

Hi:
I was looking a blog about customButton


http://supergravelynbros.com/?p=871


The author explained that initializing with
- (id)initWithCoder:(NSCoder *)coder

I implemented something like this
self.helpButton = [CustomButton initWithCoder:UIButtonTypeRoundedRect];
which complies OK, but get exception at this point.

I know the reason I do not have a nib file, but I believe I don't need  
it.


According to author
The initWithCoder: method is what will be called when the game reads  
the button in from the nib files.


But I do not have any nib file in my project. What can we do in such  
situation?


Best regards
-Agha
___

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

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

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

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


Re: CTLineCreateWithAttributedString ignoring font size

2009-08-15 Thread Charles Srstka

On Aug 15, 2009, at 3:40 AM, Alastair Houghton wrote:

Have you tried setting the text matrix to e.g. the identity?  From  
my own experience drawing text with Quartz, the text matrix is often  
not set to what you might want (which perhaps isn't surprising as it  
*isn't* part of the graphics state, so it will be set to whatever it  
was last set to for that context).


Sometime like

 CGContextSetTextMatrix (context, CGAffineTransformIdentity);

should do it.

Kind regards,


That works, thanks.

Now I'm just trying to figure out why it's ignoring the  
NSBackgroundColorAttributeName attribute. For the time being, I've got  
a workaround in just drawing the background color with NSRectFill, but  
this feels like a kludge, and that I really should be doing something  
differently to draw the background the "right" way.


Charles
___

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

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

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

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


Re: Multi-User DB That Talks to Core Data?

2009-08-15 Thread qutic development

Brad,

would do it with a web framework like RubyOnRails [1]. This framework  
has really a great open source community! For the database you can use  
mysql [2] or postgresql [3] or even sqlite [4]. The iPhone part could  
be realized with a project like ObjectiveResource [5] talking to the  
REST API [6] of your web application.


And the best: on you Leopard Mac you have RubyOnRails (not the latest  
release but update is easy) and MySQL already installed ;-)


Best regards
Stefan

[1] http://rubyonrails.org
[2] http://www.mysql.com
[3] http://www.postgresql.org
[4] http://sqlite.org
[4] http://iphoneonrails.com
[5] http://www.xml.com/lpt/a/1653

On 14.08.2009, at 17:57, Brad Gibbs wrote:


I'm trying to meet the following requirements:

1.  Back-end multi-user database to manage products, contacts,  
projects, inventory, etc.
2.  Ability to access and edit that DB over the Internet and the  
iPhone
3.  Ability to import/export some data in the main database to/from  
a single-user Core Data app



Filemaker seems like the easiest route to achieving 1 & 2, but I'm  
not sure how well it interacts with Core Data.  I don't have any  
experience with SQL databases, but I have seen mention of BaseTen,  
although only people recommending it -- I haven't seen posts from  
anyone claiming to use it.  I've also looked into Ruby on Rails and  
RubyCocoa, but I'm not sure how well the importing / exporting would  
work.


I'd appreciate any suggestions for the most reliable and most direct  
route for interactions between single-user Core Data-based apps and  
a multi-user back-end.



Thanks.

Brad
___

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

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

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

This email sent to mailingli...@qutic.com


___

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

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

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

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


Re: Problem with Float type variable

2009-08-15 Thread Alastair Houghton

On 15 Aug 2009, at 08:01, Adil Saleem wrote:

But why would it round 863.6 ? I mean there is only 1 digit after  
the decimal. It should not have the range problem with a value this  
small.


Decimal numbers are not necessarily exactly representable in binary.   
The C library makes it look like some of them are in many cases by  
careful rounding in its output routines, but of course it cannot  
always hide the fact that some numbers are necessarily inexact.


A very good document was published in ACM Computing Surveys back in  
1991, entitled "What Every Computer Scientist Should Know About  
Floating-Point Arithmetic".  Sun Microsystems reprinted it in 1994,  
and you can get a PDF of that version here:


  

It's very aptly titled and well worth reading.

Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


Re: CTLineCreateWithAttributedString ignoring font size

2009-08-15 Thread Alastair Houghton

On 14 Aug 2009, at 23:44, Charles Srstka wrote:

However, instead of 10 point Courier, the string ends up being drawn  
at 144 point. Also, the characters are all smashed together - the X- 
position of each letter appears to be in the place where it would be  
if it *were* a smaller font size, causing them all to overlap with  
each other.


Have you tried setting the text matrix to e.g. the identity?  From my  
own experience drawing text with Quartz, the text matrix is often not  
set to what you might want (which perhaps isn't surprising as it  
*isn't* part of the graphics state, so it will be set to whatever it  
was last set to for that context).


Sometime like

  CGContextSetTextMatrix (context, CGAffineTransformIdentity);

should do it.

Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


Re: Timer in drawing loop performance problems

2009-08-15 Thread Jean-Daniel Dupas
And if you enabled vsync (which is by default), your code will never  
draw faster than the refresh rate (usually 60 Hz). That's probably why  
you never use more than 15 % of the CPU.


Le 15 août 2009 à 06:05, Roland King a écrit :

1) again I think you'll get better answers on the OpenGL list than  
the cocoa dev list - the guys on that list eat and breathe openGL  
and I've had some fantastic help there.


2) Are you targetting OSX 10.3 for your code? That tech tip says use  
an NSTimer only for 10.3 compatibility and CVDisplayLink for  
anything from 10.4 onwards. If you do have to use a timer have you  
read the caveat about enabling vertical synchronization (however one  
does that) or "the application will burn a lot of CPU time just  
firing off the timer, even though the drawing loop hasn't even  
completed its last run."?



On Aug 15, 2009, at 11:21 AM, Shayne Wissler wrote:


Hello,

Following the advice at
http://developer.apple.com/qa/qa2004/qa1385.html, I attempted using a
timer running at 1000Hz. However, on my iMac, this causes about a  
~15%

CPU hit. When I run Shark, it says it's spending a good deal of time
in objc_msgSend, presumably in the call "[self setNeedsDisplay:YES]".

Is all this normal/expected?


Shayne Wissler
___

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/rols%40rols.org

This email sent to r...@rols.org


___

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/devlists%40shadowlab.org

This email sent to devli...@shadowlab.org



___

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

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

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

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


Re: iPhone: detect if docked?

2009-08-15 Thread David Duncan

On Aug 14, 2009, at 4:29 AM, Sean Kline wrote:


Is another option to use the External Accessory framework?



I don't think so. A simple charger may not appear as any kind of  
accessory at all (consider the wall-outlet charger) so EA wouldn't  
track it. If you want to know if the device is on external power  
(which in this particular case would likely be a false positive on one  
of those external battery packs) then you want to know if the battery  
status is "charging".

--
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 arch...@mail-archive.com


Re: Title bar highlighting behavior

2009-08-15 Thread bryscomat

Works perfectly. Thanks.

On Aug 14, 2009, at 7:39 PM, Graham Cox wrote:



On 15/08/2009, at 9:40 AM, bryscomat wrote:

In a window of my app, I have an NSView acting as a toolbar. It is  
colored with a gradient so that it looks like a textured toolbar  
and blends in nicely with the title bar. However, it does not fade  
out when window loses key. I have implemented the delegate method  
windowDidResignKey: and am attempting to modify it that way. Does  
anybody have pointers on how to go about this?


In that method, just call -setNeedsDisplay:YES on your view.

In the view's -drawRect: method, detect whether the view's window is  
currently key, and draw the appropriate background.


To detect whether key, use:

if([self window] == [NSApp keyWindow])
{
...

}


--Graham




___

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

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

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

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


Re: Problem with Float type variable

2009-08-15 Thread Graham Cox


On 15/08/2009, at 5:01 PM, Adil Saleem wrote:

But why would it round 863.6 ? I mean there is only 1 digit after  
the decimal. It should not have the range problem with a value this  
small.



It's got nothing to do with how it is written in decimal - it only  
matters what its binary representation is, and that is always 32 bits  
(or 64 if double precision or on a 64-bit machine).


Start here, particularly the section starting "Accuracy Problems":

http://en.wikipedia.org/wiki/Floating_point

Note, there is a class called NSDecimalNumber which can help with this  
sort of problem, if you can't live with the vagueness of float.


--Graham
___

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

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

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

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


Re: Problem with Float type variable

2009-08-15 Thread Adil Saleem

But why would it round 863.6 ? I mean there is only 1 digit after the decimal. 
It should not have the range problem with a value this small. 
 
 
 

--- On Fri, 8/14/09, Graham Cox  wrote:


From: Graham Cox 
Subject: Re: Problem with Float type variable
To: "Adil Saleem" 
Cc: cocoa-dev@lists.apple.com
Date: Friday, August 14, 2009, 11:53 PM



On 15/08/2009, at 4:46 PM, Adil Saleem wrote:

> On calling this, the variable aFloat in setMyvar method gets value 
> 863.599976. I also tried giving it 6.60 but still didn't work correctly. 
> I don't understand why is it changing the value. Why doesn't it get 863.6 ?


This is a classic misunderstanding of floats. Look up "floating point 
precision". Basically, a float is 32 bits - it can only represent 2^32 
different values, not the infinity of numbers that exist. So quite often 
certain values are rounded off, truncated or represent by something "close". If 
you need exact values, use integers.

--Graham






___

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

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

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

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