Re: terminates app when main window closes

2010-06-18 Thread Kyle Sluder
On Thu, Jun 17, 2010 at 11:41 PM, Angelo Chen
 wrote:
> I have a non document based application, I quit the app by sending terminate 
> to NSApplication(file owner). if I close the main window, application will 
> not be closed, what I'd like is, when user close the main window, application 
> also terminates, possible? Thanks,

Non-document-based apps typically don't do this.

That said, look at -applicationShouldTerminateAfterLastWindowClosed:
in the NSApplicationDelegate protocol.

--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: terminates app when main window closes

2010-06-18 Thread John Joyce

On Jun 18, 2010, at 2:02 AM, Kyle Sluder wrote:

> On Thu, Jun 17, 2010 at 11:41 PM, Angelo Chen
>  wrote:
>> I have a non document based application, I quit the app by sending terminate 
>> to NSApplication(file owner). if I close the main window, application will 
>> not be closed, what I'd like is, when user close the main window, 
>> application also terminates, possible? Thanks,
> 
> Non-document-based apps typically don't do this.
> 
> That said, look at -applicationShouldTerminateAfterLastWindowClosed:
> in the NSApplicationDelegate protocol.
> 
> --Kyle Sluder
From the HIG:

In most cases, applications that are not document-based should quit when the 
main window is closed. For Example, System Preferences quits if the user closes 
the window. If an application continues to perform some function when the main 
window is closed, however, it may be appropriate to leave it running when the 
main window is closed. For example, iTunes continues to play when the user 
closes the main window.

Closing Windows



___

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


Base class/subclass model in objective c

2010-06-18 Thread Jonny Taylor
I am still getting to grips with objective C, coming from a C++ background, and 
I'm stuck on a particular aspect of the base class/subclass model that I hope 
somebody can help me with.

I need an object representing a video camera plugged into the mac, a camera 
which may be one of several models with their own API. I think the tidiest way 
of implementing this in C++ would be to have a base class that handles the 
logic for actions such as "acquire video", but calls pure virtual functions for 
actions such as "allocate memory for a frame buffer" whose details will vary 
depending on camera model and associated API.

I believe an equivalent approach in objective C would use a protocol to 
represent generic actions and provide a generic interface on top of the 
camera-specific APIs, plus a base class containing generic code and subclasses 
containing camera-specific code. The base class will NOT conform to the 
protocol because it does not implement all the methods in the protocol (i.e. 
those that require direct knowledge of a specific camera API), whereas the 
subclasses DO conform to the protocol - and because I have told it this the 
compiler will do a good job of warning me if there are some methods not 
implemented in either the base class or a given subclass.

The problem comes when the base class tries to call a method such as "allocate 
memory for a frame buffer" that is not implemented in the base class, but only 
in subclasses (and the protocol). Because the base class does not conform to 
the protocol, if the base class calls such a method I (quite rightly) get 
warnings saying it may not respond to the method... although I do in fact know 
that a naked base class will never be instantiated and so in practice the 
method will always exist.

I can see two ways of working around this - either implement placeholder 
methods in the base class (that raise an exception or something) in order to 
make the base class conform to the protocol (knowing that in practice they 
should always be overridden by a subclass), or have the subclass pass its 
"self" pointer to the base class in the form of an id that the base 
class uses when it needs to call such methods. Both of these leave me feeling 
pretty dirty, though.

It may be that I am missing the "right" way of dealing with my problem because 
I am still thinking from a C++ point of view. Can anybody suggest how I should 
be dealing with this scenario? Hopefully what I am trying to achieve makes 
sense.

Thanks for any suggestions
Jonny___

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: terminates app when main window closes

2010-06-18 Thread Jean-Daniel Dupas

On Jun 18, 2010, at 2:02 AM, Kyle Sluder wrote:

> On Thu, Jun 17, 2010 at 11:41 PM, Angelo Chen
>  wrote:
>> I have a non document based application, I quit the app by sending terminate 
>> to NSApplication(file owner). if I close the main window, application will 
>> not be closed, what I'd like is, when user close the main window, 
>> application also terminates, possible? Thanks,
> 
> Non-document-based apps typically don't do this.
> 
> That said, look at -applicationShouldTerminateAfterLastWindowClosed:
> in the NSApplicationDelegate protocol.
> 
> --Kyle Sluder

Non document based applications typically do this:

Try Disk Utilities, DigitalColor Meter, Network Utility, System Preferences, 
Image Capture, Photo Booth…

-- Jean-Daniel




___

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

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

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

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


Re: Base class/subclass model in objective c

2010-06-18 Thread Jean-Daniel Dupas

Le 18 juin 2010 à 12:44, Jonny Taylor a écrit :

> I am still getting to grips with objective C, coming from a C++ background, 
> and I'm stuck on a particular aspect of the base class/subclass model that I 
> hope somebody can help me with.
> 
> I need an object representing a video camera plugged into the mac, a camera 
> which may be one of several models with their own API. I think the tidiest 
> way of implementing this in C++ would be to have a base class that handles 
> the logic for actions such as "acquire video", but calls pure virtual 
> functions for actions such as "allocate memory for a frame buffer" whose 
> details will vary depending on camera model and associated API.
> 
> I believe an equivalent approach in objective C would use a protocol to 
> represent generic actions and provide a generic interface on top of the 
> camera-specific APIs, plus a base class containing generic code and 
> subclasses containing camera-specific code. The base class will NOT conform 
> to the protocol because it does not implement all the methods in the protocol 
> (i.e. those that require direct knowledge of a specific camera API), whereas 
> the subclasses DO conform to the protocol - and because I have told it this 
> the compiler will do a good job of warning me if there are some methods not 
> implemented in either the base class or a given subclass.
> 
> The problem comes when the base class tries to call a method such as 
> "allocate memory for a frame buffer" that is not implemented in the base 
> class, but only in subclasses (and the protocol). Because the base class does 
> not conform to the protocol, if the base class calls such a method I (quite 
> rightly) get warnings saying it may not respond to the method... although I 
> do in fact know that a naked base class will never be instantiated and so in 
> practice the method will always exist.
> 
> I can see two ways of working around this - either implement placeholder 
> methods in the base class (that raise an exception or something) in order to 
> make the base class conform to the protocol (knowing that in practice they 
> should always be overridden by a subclass), or have the subclass pass its 
> "self" pointer to the base class in the form of an id that the 
> base class uses when it needs to call such methods. Both of these leave me 
> feeling pretty dirty, though.
> 

Adding stub methods that raise an exception seam a good way to solve the 
problem (that what all class cluster abstract class do in Cocoa Framework).


-- Jean-Daniel




___

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

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

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

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


Re: terminates app when main window closes

2010-06-18 Thread Kyle Sluder
On Jun 18, 2010, at 3:51 AM, Jean-Daniel Dupas  wrote:

> 
> On Jun 18, 2010, at 2:02 AM, Kyle Sluder wrote:
> 
>> On Thu, Jun 17, 2010 at 11:41 PM, Angelo Chen
>>  wrote:
>>> I have a non document based application, I quit the app by sending 
>>> terminate to NSApplication(file owner). if I close the main window, 
>>> application will not be closed, what I'd like is, when user close the main 
>>> window, application also terminates, possible? Thanks,
>> 
>> Non-document-based apps typically don't do this.
>> 
>> That said, look at -applicationShouldTerminateAfterLastWindowClosed:
>> in the NSApplicationDelegate protocol.
>> 
>> --Kyle Sluder
> 
> Non document based applications typically do this:
> 
> Try Disk Utilities, DigitalColor Meter, Network Utility, System Preferences, 
> Image Capture, Photo Booth…

Vs. Keychain Access, Workfroup Manager, Server Admin, iTunes… unless perhaps my 
definition of "document-based" (each window represents a thing to be 
saved/loaded) is too literal.

--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: terminates app when main window closes

2010-06-18 Thread Angelo Chen

Thanks, applicationShouldTerminateAfterLastWindowClosed works.
Now I'd like to prompt user if he really wants to quit, if not, return NO, that 
seems working as well.
--- 2010年6月18日 星期五,Kyle Sluder  寫道﹕

寄件人: Kyle Sluder 
主題: Re: terminates app when main window closes
收件人: "Angelo Chen" 
副本(CC): cocoa-dev@lists.apple.com
日期: 2010年6月18日,星期五,下午3:02

On Thu, Jun 17, 2010 at 11:41 PM, Angelo Chen
 wrote:
> I have a non document based application, I quit the app by sending terminate 
> to NSApplication(file owner). if I close the main window, application will 
> not be closed, what I'd like is, when user close the main window, application 
> also terminates, possible? Thanks,

Non-document-based apps typically don't do this.

That said, look at -applicationShouldTerminateAfterLastWindowClosed:
in the NSApplicationDelegate protocol.

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


autorelease: how does this work!? (if at all)

2010-06-18 Thread Jonny Taylor
I've just been looking back at some code that has been working fine for me for 
a while, and as far as I can see it shouldn't actually work! I'd be interested 
for peoples' comments. The code is as follows:

dispatch_async(queue1,
^{
NSImage *theImage = [frame GetNSImage];
NSData *tiffRep = [theImage TIFFRepresentation];
dispatch_async(queue2,
^{
[tiffRep writeToFile:[NSString stringWithFormat:@"%...@%d.tif", 
[[frame Camera] ExportFilePrefix], 
[frame FrameNumber]]
atomically:YES];
});
[theImage release];
});

Work running on serial queue "queue1" calculates a TIFF representation for an 
image, and then schedules work on serial queue "queue2" to write that data to 
disk. What I can't work out is why tiffrep isn't autoreleased as soon as the 
outer block completes. Is the compiler/runtime being clever enough to retain it 
because it is going to be needed in the inner block (if so: very clever!)? If 
not, am I just getting lucky here with exactly when/how grand central does its 
autorelease cleanup? Or maybe the TIFF representation and/or my frame data is 
still being retained elsewhere for a while (possible, depending on how the 
thread timings work out...).

I'm pretty new to Cocoa so I'm keen to understand this properly - I'd be 
interested to hear peoples thoughts on this: is what I am doing ok, or do I 
need to add some explicit retain/releasing of tiffRep?

Cheers
Jonny___

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: Base class/subclass model in objective c

2010-06-18 Thread Jonny Taylor
Thanks for your reply Jean-Daniel.

>> I can see two ways of working around this - either implement placeholder 
>> methods in the base class (that raise an exception or something) in order to 
>> make the base class conform to the protocol (knowing that in practice they 
>> should always be overridden by a subclass), or have the subclass pass its 
>> "self" pointer to the base class in the form of an id that the 
>> base class uses when it needs to call such methods. Both of these leave me 
>> feeling pretty dirty, though.
> Adding stub methods that raise an exception seam a good way to solve the 
> problem (that what all class cluster abstract class do in Cocoa Framework).

The reason I wasn't wild on this is that it stops me getting compile-time 
warnings saying that the protocol is not fully implemented (since the base 
class fully implements it). There will be run-time errors when the 
non-overridden base class stub is hit. Maybe that's the best of the available 
choices, though. I just hoped there would be a "proper" way around this. I'm 
sure the language designers are far smarter than me and had good reasons for 
what they did, but I do miss abstract base classes!

Cheers
Jonny___

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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Jeff Kelley
Blocks do retain objects that are passed in, so that's probably what's 
happening. Also, keep in mind that autoreleased objects aren't freed 
immediately; it happens when the run loop completes. You should always act as 
if it does happen immediately, but it isn't always true.

Jeff Kelley

On Jun 18, 2010, at 11:00 AM, Jonny Taylor wrote:

> I've just been looking back at some code that has been working fine for me 
> for a while, and as far as I can see it shouldn't actually work! I'd be 
> interested for peoples' comments. The code is as follows:
> 
> dispatch_async(queue1,
> ^{
>   NSImage *theImage = [frame GetNSImage];
>   NSData *tiffRep = [theImage TIFFRepresentation];
>   dispatch_async(queue2,
>   ^{
>   [tiffRep writeToFile:[NSString stringWithFormat:@"%...@%d.tif", 
>   [[frame Camera] ExportFilePrefix], 
> [frame FrameNumber]]
>   atomically:YES];
>   });
>   [theImage release];
> });
> 
> Work running on serial queue "queue1" calculates a TIFF representation for an 
> image, and then schedules work on serial queue "queue2" to write that data to 
> disk. What I can't work out is why tiffrep isn't autoreleased as soon as the 
> outer block completes. Is the compiler/runtime being clever enough to retain 
> it because it is going to be needed in the inner block (if so: very clever!)? 
> If not, am I just getting lucky here with exactly when/how grand central does 
> its autorelease cleanup? Or maybe the TIFF representation and/or my frame 
> data is still being retained elsewhere for a while (possible, depending on 
> how the thread timings work out...).
> 
> I'm pretty new to Cocoa so I'm keen to understand this properly - I'd be 
> interested to hear peoples thoughts on this: is what I am doing ok, or do I 
> need to add some explicit retain/releasing of tiffRep?
> 
> Cheers
> Jonny
___

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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Julien Jalon
"Is the compiler/runtime being clever enough to retain it because it is
going to be needed in the inner block (if so: very clever!)?"

Yes, it is very clever.

When creating the block, the ObjC compiler also specifies the Object stored
into the block metadata. When the block is copied (which is done as soon as
you call dispatch_async), the copied block retains these objects.

Note that it only works for blocks and ObjectiveC objects with some
(logical) special cases (ivars, __block).

See:
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Blocks/Articles/bxVariables.html

-- 
Julien

On Fri, Jun 18, 2010 at 5:00 PM, Jonny Taylor wrote:

> I've just been looking back at some code that has been working fine for me
> for a while, and as far as I can see it shouldn't actually work! I'd be
> interested for peoples' comments. The code is as follows:
>
> dispatch_async(queue1,
> ^{
>NSImage *theImage = [frame GetNSImage];
>NSData *tiffRep = [theImage TIFFRepresentation];
>dispatch_async(queue2,
>^{
>[tiffRep writeToFile:[NSString stringWithFormat:@
> "%...@%d.tif",
>[[frame Camera] ExportFilePrefix],
> [frame FrameNumber]]
>atomically:YES];
>});
>[theImage release];
> });
>
> Work running on serial queue "queue1" calculates a TIFF representation for
> an image, and then schedules work on serial queue "queue2" to write that
> data to disk. What I can't work out is why tiffrep isn't autoreleased as
> soon as the outer block completes. Is the compiler/runtime being clever
> enough to retain it because it is going to be needed in the inner block (if
> so: very clever!)? If not, am I just getting lucky here with exactly
> when/how grand central does its autorelease cleanup? Or maybe the TIFF
> representation and/or my frame data is still being retained elsewhere for a
> while (possible, depending on how the thread timings work out...).
>
> I'm pretty new to Cocoa so I'm keen to understand this properly - I'd be
> interested to hear peoples thoughts on this: is what I am doing ok, or do I
> need to add some explicit retain/releasing of tiffRep?
>
> Cheers
> Jonny___
>
> 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/jjalon%40gmail.com
>
> This email sent to jja...@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: Base class/subclass model in objective c

2010-06-18 Thread Jean-Daniel Dupas

Le 18 juin 2010 à 17:05, Jonny Taylor a écrit :

> Thanks for your reply Jean-Daniel.
> 
>>> I can see two ways of working around this - either implement placeholder 
>>> methods in the base class (that raise an exception or something) in order 
>>> to make the base class conform to the protocol (knowing that in practice 
>>> they should always be overridden by a subclass), or have the subclass pass 
>>> its "self" pointer to the base class in the form of an id that 
>>> the base class uses when it needs to call such methods. Both of these leave 
>>> me feeling pretty dirty, though.
>> Adding stub methods that raise an exception seam a good way to solve the 
>> problem (that what all class cluster abstract class do in Cocoa Framework).
> 
> The reason I wasn't wild on this is that it stops me getting compile-time 
> warnings saying that the protocol is not fully implemented (since the base 
> class fully implements it). There will be run-time errors when the 
> non-overridden base class stub is hit. Maybe that's the best of the available 
> choices, though. I just hoped there would be a "proper" way around this. I'm 
> sure the language designers are far smarter than me and had good reasons for 
> what they did, but I do miss abstract base classes!

Yes you will get error at runtime instead at compile time. That the main 
difference between a strongly typed, static language (c++), and a language that 
support dynamic typing and binding.
That's the proper Obj-C way, In Obj-C there is a lots of implicit contracts 
that could not be enforced by the compiler due to the dynamic nature of the 
language.

For example, it's perfectly legal in obj-c to declare a method without 
implementation as the implementation can be loaded at runtime or dynamically 
generated. 

Note that an other way to get ride of the compiler warnings is to create a 
extension interface (without implementation):

in MyBaseClass.h:

@interface MyBaseClass : NSObject {
}
@end

@interface MyBaseClass (MyProtocol) 

@end

in MyBaseClass.m

@implementation MyBaseClass

// implements only a subset of the protocol

@end

But here again you will get runtime errors and no warning if a subclass does 
not override the missing methods (or call super implementation).


-- Jean-Daniel




___

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

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

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

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


Re: autorelease: how does this work!? (if at all)

2010-06-18 Thread Mike Abdullah

On 18 Jun 2010, at 16:00, Jonny Taylor wrote:

> I've just been looking back at some code that has been working fine for me 
> for a while, and as far as I can see it shouldn't actually work! I'd be 
> interested for peoples' comments. The code is as follows:
> 
> dispatch_async(queue1,
> ^{
>   NSImage *theImage = [frame GetNSImage];
>   NSData *tiffRep = [theImage TIFFRepresentation];
>   dispatch_async(queue2,
>   ^{
>   [tiffRep writeToFile:[NSString stringWithFormat:@"%...@%d.tif", 
>   [[frame Camera] ExportFilePrefix], 
> [frame FrameNumber]]
>   atomically:YES];
>   });
>   [theImage release];
> });
> 
> Work running on serial queue "queue1" calculates a TIFF representation for an 
> image, and then schedules work on serial queue "queue2" to write that data to 
> disk. What I can't work out is why tiffrep isn't autoreleased as soon as the 
> outer block completes. Is the compiler/runtime being clever enough to retain 
> it because it is going to be needed in the inner block (if so: very clever!)? 
> If not, am I just getting lucky here with exactly when/how grand central does 
> its autorelease cleanup? Or maybe the TIFF representation and/or my frame 
> data is still being retained elsewhere for a while (possible, depending on 
> how the thread timings work out...).
> 
> I'm pretty new to Cocoa so I'm keen to understand this properly - I'd be 
> interested to hear peoples thoughts on this: is what I am doing ok, or do I 
> need to add some explicit retain/releasing of tiffRep?

Aside from your actual question, I urge you to go back and read the Cocoa 
fundamentals. Your method names are totally wrong, and the memory management 
guide covers all the details of -autorelease.

___

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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Jens Alfke

On Jun 18, 2010, at 9:20 AM, Mike Abdullah wrote:

> Aside from your actual question, I urge you to go back and read the Cocoa 
> fundamentals. Your method names are totally wrong,

I only saw one error: the method name “GetNSImage” should probably be “image” 
(method names should be lowercase unless they begin with a common acronym like 
“URL” or “TIFF”, and the prefix “get” is not used.)

> and the memory management guide covers all the details of -autorelease.

Has it been extended to discuss objects referenced inside blocks? That’s a 
pretty tricky detail.

—Jens___

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

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

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

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


(no subject)

2010-06-18 Thread Brad Peterson
http://kvlbehqiqu.modestmuch.ru


  
___

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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Julien Jalon
[theImage release] is really suspicious.

On Friday, June 18, 2010, Jens Alfke  wrote:
>
> On Jun 18, 2010, at 9:20 AM, Mike Abdullah wrote:
>
>> Aside from your actual question, I urge you to go back and read the Cocoa 
>> fundamentals. Your method names are totally wrong,
>
> I only saw one error: the method name “GetNSImage” should probably be “image” 
> (method names should be lowercase unless they begin with a common acronym 
> like “URL” or “TIFF”, and the prefix “get” is not used.)
>
>> and the memory management guide covers all the details of -autorelease.
>
> Has it been extended to discuss objects referenced inside blocks? That’s a 
> pretty tricky detail.
>
> —Jens___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/jjalon%40gmail.com
>
> This email sent to jja...@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


Alert Moderators

2010-06-18 Thread Rick Langschultz

Moderators: please look into this SPAM account.

Sent from my iPhone

On Jun 18, 2010, at 12:58 PM, Brad Peterson  wrote:


http://kvlbehqiqu.modestmuch.ru



___

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/ricklangschultz%40me.com

This email sent to ricklangschu...@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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Tony Romano
First, the objects are retained by dispatch_async as others have mentioned.  
Second, I'm not sure why you used 2 queues for the tasks in your code, seems 
overly complex.  Async queues are serialized, which means that you can continue 
to add to the queue and the jobs will be done in order which they were added. 
The next job will not start until the previous one in the queue is completed.   

-Tony

On Jun 18, 2010, at 8:36 AM, Julien Jalon wrote:

> "Is the compiler/runtime being clever enough to retain it because it is
> going to be needed in the inner block (if so: very clever!)?"
> 
> Yes, it is very clever.
> 
> When creating the block, the ObjC compiler also specifies the Object stored
> into the block metadata. When the block is copied (which is done as soon as
> you call dispatch_async), the copied block retains these objects.
> 
> Note that it only works for blocks and ObjectiveC objects with some
> (logical) special cases (ivars, __block).
> 
> See:
> http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Blocks/Articles/bxVariables.html
> 
> -- 
> Julien
> 
> On Fri, Jun 18, 2010 at 5:00 PM, Jonny Taylor wrote:
> 
>> I've just been looking back at some code that has been working fine for me
>> for a while, and as far as I can see it shouldn't actually work! I'd be
>> interested for peoples' comments. The code is as follows:
>> 
>> dispatch_async(queue1,
>> ^{
>>   NSImage *theImage = [frame GetNSImage];
>>   NSData *tiffRep = [theImage TIFFRepresentation];
>>   dispatch_async(queue2,
>>   ^{
>>   [tiffRep writeToFile:[NSString stringWithFormat:@
>> "%...@%d.tif",
>>   [[frame Camera] ExportFilePrefix],
>> [frame FrameNumber]]
>>   atomically:YES];
>>   });
>>   [theImage release];
>> });
>> 
>> Work running on serial queue "queue1" calculates a TIFF representation for
>> an image, and then schedules work on serial queue "queue2" to write that
>> data to disk. What I can't work out is why tiffrep isn't autoreleased as
>> soon as the outer block completes. Is the compiler/runtime being clever
>> enough to retain it because it is going to be needed in the inner block (if
>> so: very clever!)? If not, am I just getting lucky here with exactly
>> when/how grand central does its autorelease cleanup? Or maybe the TIFF
>> representation and/or my frame data is still being retained elsewhere for a
>> while (possible, depending on how the thread timings work out...).
>> 
>> I'm pretty new to Cocoa so I'm keen to understand this properly - I'd be
>> interested to hear peoples thoughts on this: is what I am doing ok, or do I
>> need to add some explicit retain/releasing of tiffRep?
>> 
>> Cheers
>> Jonny___
>> 
>> 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/jjalon%40gmail.com
>> 
>> This email sent to jja...@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/tonyrom%40hotmail.com
> 
> This email sent to tony...@hotmail.com
> 

-Tony

___

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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Jonny Taylor
> [theImage release] is really suspicious.
Suspicious in what way? Are you saying I am using the wrong sort of 
implementation for my [frame GetNSImage], and I shouldn't be returning 
something that requires an explicit release? Because I can certainly confirm 
that in its current state it leaks memory unless I include the release - the 
function is returning an internally cached NSImage with its reference count 
incremented by one.

To be fair the release is in an illogical place - it should immediately follow 
the call to [theImage TIFFRepresentation], but with the code as currently 
written, the release is definitely 
necessary...___

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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Jonny Taylor
> First, the objects are retained by dispatch_async as others have mentioned.  
> Second, I'm not sure why you used 2 queues for the tasks in your code, seems 
> overly complex.  Async queues are serialized, which means that you can 
> continue to add to the queue and the jobs will be done in order which they 
> were added. The next job will not start until the previous one in the queue 
> is completed.   
Possibly overly complex, but notice that the nested block is running on *a 
different queue* to the block that spawns it. My intention is that the "write" 
queue (running the nested block) can have a write outstanding at all times, 
maximizing the rate at which data can be written to disk. To be fair the outer 
block does not strictly require a dedicated queue - it could probably run 
equally well on the global concurrent queue - but I don't think that's what 
you're commenting on is it?___

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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Scott Anguish

On Jun 18, 2010, at 1:02 PM, Jens Alfke wrote:

>> and the memory management guide covers all the details of -autorelease.
> 
> Has it been extended to discuss objects referenced inside blocks? That’s a 
> pretty tricky detail.

The current version of that document doesn’t appear to have been.

The Blocks Programming Topics Book has a small amount of Memory management 
discussed in it, and I’m not sure if it covers what you’re looking for

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Blocks/Articles/bxVariables.html#//apple_ref/doc/uid/TP40007502-CH6-SW1

and even if it does, a link may be worthwhile between the two.

Either way, a Radar has been 
filed.___

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 running CocoaDVDPlayer sample

2010-06-18 Thread Laurent Daudelin
On Jun 17, 2010, at 19:17, Nick Zitzmann wrote:

> 
> On Jun 17, 2010, at 4:52 PM, Laurent Daudelin wrote:
> 
>> I'm just starting to explore DVD playback and downloaded the 
>> "CocoaDVDPlayer" sample. Did a build and started it in the debugger. As soon 
>> as it calls "DVDInitialize()", the application stops with "Program exited 
>> with status value:45.kill" in the debugger. Anybody has any clue? I can't 
>> find any error 45 and it's certainly not a DVD Framework possible errors 
>> because they are all in the -70001 to -70029 range.
> 
> The function probably detected using ptrace() that you were running it in a 
> debugger and killed itself. This happens with a lot of Apple frameworks that 
> deal with DRM, even though the DRM used on DVDs was cracked a long time ago.
> 
> Nick Zitzmann
> 
> 

Thanks Nick (and others who replied privately). I think I now have an idea to 
get around this.

Further on this sample, still using the DVD Playback framework, I see that you 
provide a window ID to the framework and the video will play there. Does anyone 
know if it would be remotely possible to capture the video stream sent to the 
window to stream it somewhere else? No, I'm not trying to use the DVD Playback 
framework to circumvent DRM, just wondering if it would be possible to capture 
the video stream.

Thanks!

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.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


Way to select a file in NSOpenPanel

2010-06-18 Thread Sanyam Jain
Hi,



I need a way to select a file programmatically in browser list of
NSOpenPanel based on some user action, while the panel is running.

Similar to Navigation services NavCustomControl() with
NavCustomControlMessage:kNavCtlSetSelection.



- Sanyam
___

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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Bill Bumgarner

On Jun 18, 2010, at 12:09 PM, Tony Romano wrote:

> First, the objects are retained by dispatch_async as others have mentioned.  
> Second, I'm not sure why you used 2 queues for the tasks in your code, seems 
> overly complex.  Async queues are serialized, which means that you can 
> continue to add to the queue and the jobs will be done in order which they 
> were added. The next job will not start until the previous one in the queue 
> is completed.   

To be precise, it is the Blocks runtime that takes care of memory management, 
triggered by dispatch_async()s copying of the block passed to it.

As for their being two queues, that pattern is actually pretty common.  A best 
practice is to subdivide your application into subsystems and then have one (or 
more, depending on concurrency used) queue per subsystem.The queues both 
allow the application to do work across many cores simultaneously while also 
providing a natural lock-less exclusion primitive per subsystem.

The trick is to keep the object graphs being acted upon within the subsystems 
relatively isolated from each other (with the points of contention being 
carefully considered).

b.bum

___

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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Laurent Daudelin
On Jun 18, 2010, at 15:15, Jonny Taylor wrote:

>> [theImage release] is really suspicious.
> Suspicious in what way? Are you saying I am using the wrong sort of 
> implementation for my [frame GetNSImage], and I shouldn't be returning 
> something that requires an explicit release? Because I can certainly confirm 
> that in its current state it leaks memory unless I include the release - the 
> function is returning an internally cached NSImage with its reference count 
> incremented by one.
> 
> To be fair the release is in an illogical place - it should immediately 
> follow the call to [theImage TIFFRepresentation], but with the code as 
> currently written, the release is definitely 
> necessary...___

Usually, you don't release objects you don't own. In the block you showed, 
there really is no indication that you own theImage (there is no alloc/init, 
copy or retain) so you shouldn't release it, unless I'm missing something with 
blocks.

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Tony Romano
I did notice the inner block was running on a second q, that's what my comment 
is about.  I guess the first block what's really in questioned, how big is the 
images??  If it will block, then put it in the same block as the write.  I'm 
assuming you want he image transformed prior to the write.

-Tony

On Jun 18, 2010, at 12:20 PM, Jonny Taylor wrote:

>> First, the objects are retained by dispatch_async as others have mentioned.  
>> Second, I'm not sure why you used 2 queues for the tasks in your code, seems 
>> overly complex.  Async queues are serialized, which means that you can 
>> continue to add to the queue and the jobs will be done in order which they 
>> were added. The next job will not start until the previous one in the queue 
>> is completed.   
> Possibly overly complex, but notice that the nested block is running on *a 
> different queue* to the block that spawns it. My intention is that the 
> "write" queue (running the nested block) can have a write outstanding at all 
> times, maximizing the rate at which data can be written to disk. To be fair 
> the outer block does not strictly require a dedicated queue - it could 
> probably run equally well on the global concurrent queue - but I don't think 
> that's what you're commenting on is it?

-Tony

___

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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Tony Romano
Because you make 2 queues, doesn't mean internally they will operate on 
separate cores/threads.  GCD may coalesce these based on system resources.  I 
agree with the best practice you outlined; however, the example in this email 
thread has 2 queues within the same subsystem.  So there must be some "trick" I 
am not groc'ing within the snippet of code.  Anyhow, I think the OP got the 
answer to his original question.

-Tony

On Jun 18, 2010, at 12:34 PM, Bill Bumgarner wrote:

> 
> On Jun 18, 2010, at 12:09 PM, Tony Romano wrote:
> 
>> First, the objects are retained by dispatch_async as others have mentioned.  
>> Second, I'm not sure why you used 2 queues for the tasks in your code, seems 
>> overly complex.  Async queues are serialized, which means that you can 
>> continue to add to the queue and the jobs will be done in order which they 
>> were added. The next job will not start until the previous one in the queue 
>> is completed.   
> 
> To be precise, it is the Blocks runtime that takes care of memory management, 
> triggered by dispatch_async()s copying of the block passed to it.
> 
> As for their being two queues, that pattern is actually pretty common.  A 
> best practice is to subdivide your application into subsystems and then have 
> one (or more, depending on concurrency used) queue per subsystem.The 
> queues both allow the application to do work across many cores simultaneously 
> while also providing a natural lock-less exclusion primitive per subsystem.
> 
> The trick is to keep the object graphs being acted upon within the subsystems 
> relatively isolated from each other (with the points of contention being 
> carefully considered).
> 
> b.bum
> 
> 

-Tony

___

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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Greg Guerin

Jens Alfke wrote:

I only saw one error: the method name “GetNSImage” should probably  
be “image” (method names should be lowercase unless they begin with  
a common acronym like “URL” or “TIFF”, and the prefix “get” is not  
used.)



Also See These Methods Three:

 [[frame Camera] ExportFilePrefix], [frame FrameNumber]]

Which May Be Fine In Sharpened C,
Are Ne'er Condoned In Objective-C.

  -- GG

___

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

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

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

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


Re: Problem running CocoaDVDPlayer sample

2010-06-18 Thread Jens Alfke

On Jun 17, 2010, at 4:37 PM, Laurent Daudelin wrote:

> Does anyone know if it would be remotely possible to capture the video stream 
> sent to the window to stream it somewhere else?

No; this would be near the top of the list of things the MPAA really does not 
want people to be able to do with DVDs.

> No, I'm not trying to use the DVD Playback framework to circumvent DRM, just 
> wondering if it would be possible to capture the video stream.

I understand, but the framework is designed to block any attempt to do things 
like this (probably because it’s a condition of being able to license the DVD 
DRM.)

—Jens___

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

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

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

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


Re: Way to select a file in NSOpenPanel

2010-06-18 Thread Corbin Dunn
There is no API to do this, sorry. Please log feature requests asking to do it. 

corbin
On Jun 17, 2010, at 11:32 PM, Sanyam Jain wrote:

> Hi,
> 
> 
> 
> I need a way to select a file programmatically in browser list of
> NSOpenPanel based on some user action, while the panel is running.
> 
> Similar to Navigation services NavCustomControl() with
> NavCustomControlMessage:kNavCtlSetSelection.

___

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: Odd Behaviour with CALayer

2010-06-18 Thread Ajay Sabhaney
Well, the problem seems to have been fixed.

I tried replacing every instance of MRWorkspaceItemLayer with a regular CALayer 
instance, and it seemed to work fine, meaning my problem was actually in the 
MRWorkspaceItemLayer subclass.  Seemed everytime I would unselect then select 
an item, the MRWorkspaceItemLayer would be destroyed, and then the message 
"expecting model layer not copy: MRWorkspaceItemLayer" would come up in the 
console.  So I overrided -initWithLayer: and -hitTest: , and now it seems to be 
fine.

Thanks for your comments

-AJ

On 2010-06-17, at 7:35 PM, Kyle Sluder wrote:

> On Thu, Jun 17, 2010 at 5:09 PM, Ajay Sabhaney  
> wrote:
>> -The initializer initWithLayer: of my subclass of CALayer, 
>> MRWorkspaceItemLayer is being invoked, even though I never explicitly invoke 
>> this
> 
> The documentation for -[CALayer initWithLayer:] describes how this
> method is used to create the layers for the presentation tree.
> 
>> 
>> -For when I handle the mouse down event, I tried changing my code from:
>> 
>> CALayer *layer = [_rootLayer hitTest: where];
>> 
>> to
>> 
>> CALayer *presLayer = [_rootLayer presentationLayer];
>> CALayer *layer = [presLayer hitTest: where];
>> 
>> but now [[_rootLayer sublayers] indexOfObject:layer] is returning 
>> NSNotFound,but I'm still looking in to this part...
> 
> Of course, if _rootLayer is a model layer, it can't contain a
> presentation layer as a sublayer.
> 
> Have you tried breaking on NSLog or perhaps write, to get a backtrace
> for the specific line this message is coming from?
> 
> --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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Clark S. Cox III
That depends on how you define "subsystem". I see nothing wrong with the way 
the op is structuring this (i.e. doing the transformation on one serial queue, 
and doing the writing on another queue. This allows many if the transformations 
to complete without ever waiting on the disk, yet still serializes the disk 
access in a nice, orderly fashion.

If this were all on a single serial queue, you'd end up with the queue blocked 
while writing to disk, when the CPUs are otherwise idle and could have already 
started doing useful work on the next image(s).

As Bill said, this is a very common GCD idiom. 

Sent from my iPhone

On Jun 18, 2010, at 12:44, Tony Romano  wrote:

> Because you make 2 queues, doesn't mean internally they will operate on 
> separate cores/threads.  GCD may coalesce these based on system resources.  I 
> agree with the best practice you outlined; however, the example in this email 
> thread has 2 queues within the same subsystem.  So there must be some "trick" 
> I am not groc'ing within the snippet of code.  Anyhow, I think the OP got the 
> answer to his original question.
> 
> -Tony
> 
> On Jun 18, 2010, at 12:34 PM, Bill Bumgarner wrote:
> 
>> 
>> On Jun 18, 2010, at 12:09 PM, Tony Romano wrote:
>> 
>>> First, the objects are retained by dispatch_async as others have mentioned. 
>>>  Second, I'm not sure why you used 2 queues for the tasks in your code, 
>>> seems overly complex.  Async queues are serialized, which means that you 
>>> can continue to add to the queue and the jobs will be done in order which 
>>> they were added. The next job will not start until the previous one in the 
>>> queue is completed.   
>> 
>> To be precise, it is the Blocks runtime that takes care of memory 
>> management, triggered by dispatch_async()s copying of the block passed to it.
>> 
>> As for their being two queues, that pattern is actually pretty common.  A 
>> best practice is to subdivide your application into subsystems and then have 
>> one (or more, depending on concurrency used) queue per subsystem.The 
>> queues both allow the application to do work across many cores 
>> simultaneously while also providing a natural lock-less exclusion primitive 
>> per subsystem.
>> 
>> The trick is to keep the object graphs being acted upon within the 
>> subsystems relatively isolated from each other (with the points of 
>> contention being carefully considered).
>> 
>> b.bum
>> 
>> 
> 
> -Tony
> 
> ___
> 
> 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/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@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


NSTreeController and insertObject:atArrangedObjectIndexPath:

2010-06-18 Thread Tony Romano
Scenario:  Adding a new node to a NSOutlineView backed by a NSTreeController.

1. Create a new internal object add add it to the data store(file system).  
This will be my representedObject in the treecontroller
2. Compute the path and call insertObject:atArrangedObjectIndexPath:

the treecontroller does 2 things during the call to insertObject:

1. It calls my getter, children, and asks me for all the children under the 
parent node I have added the new node to.  I give it the list INCLUDING the 
newly created node since it is now in the store.
2. Then it calls the setter, setChildren,  and gives me the newChildren list.  
Which now has an additional copy of the new node, one from the getter call and 
one from the insertAt call. I know this for a fact because I purposely added 
some data to the newly created node for the insert to distinguish them.

From the UI, the outlineview is correct, but my internal child list has the 
extra node.  It's not displayed because the treecontroller optimizes when to 
ask me for a childlist.  I have a work around which I don't like to basically 
lock out the getter method and just return the current child list(i.e the 
previous child list which doesn't have the new node added from the file 
system).  Anyone experience this before and have a recommendation?

TIA,
-Tony

___

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


What's wrong with this approach ?

2010-06-18 Thread Jean-François Brouillet
Hi.

I pulled my hair way too long for this issue and finally
decided to solve the problem of the UINavigationBar's
topItem's titleView *not* being centred when either of
the other two sides had an UIBarButtonItem by ...
subclassing UINavigationBar!

All my attempts at manipulating the titleView's frame from
any place other than "layoutSubviews" have all utterly failed.

So, I just changed the UINavigationBar class reference to
UINavigationBarCenteredTitleView in IB and created:

//  UINavigationBarCenteredTitleView.h

#import 

// Hack to have the titleView centered even when there is a left 
// or right UIBarButton
@interface UINavigationBarCenteredTitleView : UINavigationBar {

}

@end

//  UINavigationBarCenteredTitleView.m

#import "UINavigationBarCenteredTitleView.h"

@implementation UINavigationBarCenteredTitleView

- (id) initWithFrame: (CGRect) frame {
if ((self = [super initWithFrame:frame])) {
// nothing special to do: we just override to fix
// the layout
}
return self;
}

- (void) layoutSubviews {
[super layoutSubviews] ;

if (self.topItem) {
UIView * centeredView = self.topItem.titleView ;

CGRect selfFrame = self.frame ;
CGRect viewFrame = centeredView.frame ; 

viewFrame.origin.x = (selfFrame.size.width - viewFrame.size.width) / 
2.0f ;

centeredView.frame = viewFrame ;
}
}

- (void)dealloc {
[super dealloc];
}

@end

And it works!

But ... what's wrong with this? How would I solve this problem in
a more idiomatic way?

It seems odd that I am forced to subclass just to get a
supposedly centered view ... centred, no?

Many thanks
--
JFB

___

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: NSTreeController and insertObject:atArrangedObjectIndexPath:

2010-06-18 Thread Tony Romano
I solved this my not adding the file to the store until after the insert is 
completed in the controller.  The side effect is if the file system operation 
fails, I have to back out the node inserted into the tree which seems 
counterintuitive(i.e. I should only add the node if the model successfully has 
the data). It still calls both the getter and the setter within this one call.  
This has to be is a bug and I will file it.  It should only call the setter.

-Tony

On Jun 18, 2010, at 3:53 PM, Tony Romano wrote:

> Scenario:  Adding a new node to a NSOutlineView backed by a NSTreeController.
> 
> 1. Create a new internal object add add it to the data store(file system).  
> This will be my representedObject in the treecontroller
> 2. Compute the path and call insertObject:atArrangedObjectIndexPath:
> 
> the treecontroller does 2 things during the call to insertObject:
> 
> 1. It calls my getter, children, and asks me for all the children under the 
> parent node I have added the new node to.  I give it the list INCLUDING the 
> newly created node since it is now in the store.
> 2. Then it calls the setter, setChildren,  and gives me the newChildren list. 
>  Which now has an additional copy of the new node, one from the getter call 
> and one from the insertAt call. I know this for a fact because I purposely 
> added some data to the newly created node for the insert to distinguish them.
> 
> From the UI, the outlineview is correct, but my internal child list has the 
> extra node.  It's not displayed because the treecontroller optimizes when to 
> ask me for a childlist.  I have a work around which I don't like to basically 
> lock out the getter method and just return the current child list(i.e the 
> previous child list which doesn't have the new node added from the file 
> system).  Anyone experience this before and have a recommendation?
> 
> TIA,
> -Tony
> 
> ___
> 
> 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/tonyrom%40hotmail.com
> 
> This email sent to tony...@hotmail.com
> 

-Tony

___

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


Getting time zone abbreviations

2010-06-18 Thread Rick Mann
iPhone

Hi. I need to display the time zone in which a particular time is displayed. 
The time zone is created from its full POSIX name (i.e. "Asia/Oral"), but when 
I ask the NSTimeZone for its abbreviation, I often get abbreviations in the 
form of "GMT+05:00" instead of "RST" (or whatever is appropriate for that time 
zone).

Time Zone abbreviations are not unique across the world; that's okay. What I 
want is for a user local to Asia/Oral to see the 2-4 letter abbreviation 
displayed and understand what he's seeing.

There is an abbreviation dictionary in iPhone OS, but it goes the wrong way. It 
uses the abbreviations as keys, and the POSIX names as values. But POSIX names 
are unique, while abbreviations are not, so this is a very US-centric 
dictionary.

Is there any way to get short abbreviations for a TimeZone? I need it short due 
to limited space. I need a common abbreviation due to users not knowing POSIX 
timezone names.

Thanks!

-- 
Rick___

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


autorelease: how does this work!? (if at all)

2010-06-18 Thread Julien Jalon
Suspicious because it clearly does not follow ObjC coding style for
memory management.

If you have to call release here, it's likely because GetNSImage is
incorrect by returning an object that needs to be released.

If your code happens not to use C++ (or in very localized places), you
should run Build & Analyze (in Build menu) and see the static analyzer
pointing to where your code might clearly be wrong wrt coding style
and memory management.

-- 
Julien

On Friday, June 18, 2010, Jonny Taylor  wrote:
> [theImage release] is really suspicious.
> Suspicious in what way? Are you saying I am using the wrong sort of 
> implementation for my [frame GetNSImage], and I shouldn't be returning 
> something that requires an explicit release? Because I can certainly confirm 
> that in its current state it leaks memory unless I include the release - the 
> function is returning an internally cached NSImage with its reference count 
> incremented by one.
> To be fair the release is in an illogical place - it should immediately 
> follow the call to [theImage TIFFRepresentation], but with the code as 
> currently written, the release is definitely necessary...
___

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


iPhone Dev Center down?

2010-06-18 Thread Rick Mann
I'm unable to log in. Anyone else?

-- 
Rick

___

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 Dev Center down?

2010-06-18 Thread Ryan C. Payne
I'm able to get logged in.

Ryan

On Jun 18, 2010, at 10:10 PM, Rick Mann wrote:

> I'm unable to log in. Anyone else?
> 
> -- 
> Rick
> 
> ___
> 
> 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/rpayne-oss%40bullittsystems.com
> 
> This email sent to rpayne-...@bullittsystems.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: iPhone Dev Center down?

2010-06-18 Thread Rick Mann
Thanks. As soon as I click the "Log In" button on the iPhone Dev Center home 
page, I get "An Internal Server Error Has Occurred" on an otherwise blank page. 
Mac OS Dev Center shows me as logged in.

--
Rick

On Jun 18, 2010, at 19:13:15, Ryan C. Payne wrote:

> I'm able to get logged in.
> 
> Ryan
> 
> On Jun 18, 2010, at 10:10 PM, Rick Mann wrote:
> 
>> I'm unable to log in. Anyone else?
>> 
>> -- 
>> Rick
>> 
>> ___
>> 
>> 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/rpayne-oss%40bullittsystems.com
>> 
>> This email sent to rpayne-...@bullittsystems.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: iPhone Dev Center down?

2010-06-18 Thread Brad Garton
Is there something weird going on?  My problem is with "iTunes Connect" -- I 
sign in and get to the main page, but whenever I click on anything like "Manage 
Your Applications" or "Contracts Tax and Banking Information" (or even "Contact 
Us"!), it takes me to a page where I dutifully re-enter my iPhone Developer ID 
and password, and then it cycles me back to the original "iTunes Connect" main 
page. I thought it something I was doing incorrectly (and perhaps it is...)

brad


On Jun 18, 2010, at 10:15 PM, Rick Mann wrote:

> Thanks. As soon as I click the "Log In" button on the iPhone Dev Center home 
> page, I get "An Internal Server Error Has Occurred" on an otherwise blank 
> page. Mac OS Dev Center shows me as logged in.
> 
> --
> Rick
> 
> On Jun 18, 2010, at 19:13:15, Ryan C. Payne wrote:
> 
>> I'm able to get logged in.
>> 
>> Ryan
>> 
>> On Jun 18, 2010, at 10:10 PM, Rick Mann wrote:
>> 
>>> I'm unable to log in. Anyone else?
>>> 
>>> -- 
>>> Rick
>>> 
>>> ___
>>> 
>>> 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/rpayne-oss%40bullittsystems.com
>>> 
>>> This email sent to rpayne-...@bullittsystems.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/garton%40columbia.edu
> 
> This email sent to gar...@columbia.edu
> 

___

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 Dev Center down?

2010-06-18 Thread Ryan C. Payne
Brad,

I am experiencing the same thing you are reporting with iTunes Connect...

Ryan

On Jun 18, 2010, at 10:28 PM, Brad Garton wrote:

> Is there something weird going on?  My problem is with "iTunes Connect" -- I 
> sign in and get to the main page, but whenever I click on anything like 
> "Manage Your Applications" or "Contracts Tax and Banking Information" (or 
> even "Contact Us"!), it takes me to a page where I dutifully re-enter my 
> iPhone Developer ID and password, and then it cycles me back to the original 
> "iTunes Connect" main page. I thought it something I was doing incorrectly 
> (and perhaps it is...)
> 
> brad
> 
> 
> On Jun 18, 2010, at 10:15 PM, Rick Mann wrote:
> 
>> Thanks. As soon as I click the "Log In" button on the iPhone Dev Center home 
>> page, I get "An Internal Server Error Has Occurred" on an otherwise blank 
>> page. Mac OS Dev Center shows me as logged in.
>> 
>> --
>> Rick
>> 
>> On Jun 18, 2010, at 19:13:15, Ryan C. Payne wrote:
>> 
>>> I'm able to get logged in.
>>> 
>>> Ryan
>>> 
>>> On Jun 18, 2010, at 10:10 PM, Rick Mann wrote:
>>> 
 I'm unable to log in. Anyone else?
 
 -- 
 Rick
 
 ___
 
 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/rpayne-oss%40bullittsystems.com
 
 This email sent to rpayne-...@bullittsystems.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/garton%40columbia.edu
>> 
>> This email sent to gar...@columbia.edu
>> 
> 
> ___
> 
> 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/rpayne-oss%40bullittsystems.com
> 
> This email sent to rpayne-...@bullittsystems.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: iPhone Dev Center down?

2010-06-18 Thread Scott Anguish
Guys, 

Not appropriate for this list. Technical discussions only please.

If the devforums are up, use those. Otherwise assume that it’s being actively 
corrected.

Scott
Moderator




On Jun 18, 2010, at 10:31 PM, Ryan C. Payne wrote:

> Brad,
> 
> I am experiencing the same thing you are reporting with iTunes Connect...
> 
> Ryan
> 
> On Jun 18, 2010, at 10:28 PM, Brad Garton wrote:
> 
>> Is there something weird going on?  My problem is with "iTunes Connect" -- I 
>> sign in and get to the main page, but whenever I click on anything like 
>> "Manage Your Applications" or "Contracts Tax and Banking Information" (or 
>> even "Contact Us"!), it takes me to a page where I dutifully re-enter my 
>> iPhone Developer ID and password, and then it cycles me back to the original 
>> "iTunes Connect" main page. I thought it something I was doing incorrectly 
>> (and perhaps it is...)
>> 
>> brad
>> 
>> 
>> On Jun 18, 2010, at 10:15 PM, Rick Mann wrote:
>> 
>>> Thanks. As soon as I click the "Log In" button on the iPhone Dev Center 
>>> home page, I get "An Internal Server Error Has Occurred" on an otherwise 
>>> blank page. Mac OS Dev Center shows me as logged in.
>>> 
>>> --
>>> Rick
>>> 
>>> On Jun 18, 2010, at 19:13:15, Ryan C. Payne wrote:
>>> 
 I'm able to get logged in.
 
 Ryan
 
 On Jun 18, 2010, at 10:10 PM, Rick Mann wrote:
 
> I'm unable to log in. Anyone else?
> 
> -- 
> Rick
> 
> ___
> 
> 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/rpayne-oss%40bullittsystems.com
> 
> This email sent to rpayne-...@bullittsystems.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/garton%40columbia.edu
>>> 
>>> This email sent to gar...@columbia.edu
>>> 
>> 
>> ___
>> 
>> 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/rpayne-oss%40bullittsystems.com
>> 
>> This email sent to rpayne-...@bullittsystems.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/scott%40cocoadoc.com
> 
> This email sent to sc...@cocoadoc.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: Getting time zone abbreviations

2010-06-18 Thread David Rowland

On Jun 18, 2010, at 6:38 PM, Rick Mann wrote:

> iPhone
> 
> Hi. I need to display the time zone in which a particular time is displayed. 
> The time zone is created from its full POSIX name (i.e. "Asia/Oral"), but 
> when I ask the NSTimeZone for its abbreviation, I often get abbreviations in 
> the form of "GMT+05:00" instead of "RST" (or whatever is appropriate for that 
> time zone).
> 
> Time Zone abbreviations are not unique across the world; that's okay. What I 
> want is for a user local to Asia/Oral to see the 2-4 letter abbreviation 
> displayed and understand what he's seeing.
> 
> There is an abbreviation dictionary in iPhone OS, but it goes the wrong way. 
> It uses the abbreviations as keys, and the POSIX names as values. But POSIX 
> names are unique, while abbreviations are not, so this is a very US-centric 
> dictionary.
> 
> Is there any way to get short abbreviations for a TimeZone? I need it short 
> due to limited space. I need a common abbreviation due to users not knowing 
> POSIX timezone names.

this works for me:

NSTimeZone* theZone;
NSString* zoneAbbreviation;

theZone = [NSTimeZone timeZoneWithName:tzName];
zoneAbbreviation = [theZone abbreviation];

___

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: Getting time zone abbreviations

2010-06-18 Thread Rick Mann
On Jun 18, 2010, at 21:15:58, David Rowland wrote:

> 
> On Jun 18, 2010, at 6:38 PM, Rick Mann wrote:
> 
>> iPhone
>> 
>> Hi. I need to display the time zone in which a particular time is displayed. 
>> The time zone is created from its full POSIX name (i.e. "Asia/Oral"), but 
>> when I ask the NSTimeZone for its abbreviation, I often get abbreviations in 
>> the form of "GMT+05:00" instead of "RST" (or whatever is appropriate for 
>> that time zone).
>> 
>> Time Zone abbreviations are not unique across the world; that's okay. What I 
>> want is for a user local to Asia/Oral to see the 2-4 letter abbreviation 
>> displayed and understand what he's seeing.
>> 
>> There is an abbreviation dictionary in iPhone OS, but it goes the wrong way. 
>> It uses the abbreviations as keys, and the POSIX names as values. But POSIX 
>> names are unique, while abbreviations are not, so this is a very US-centric 
>> dictionary.
>> 
>> Is there any way to get short abbreviations for a TimeZone? I need it short 
>> due to limited space. I need a common abbreviation due to users not knowing 
>> POSIX timezone names.
> 
> this works for me:
> 
> NSTimeZone* theZone;
> NSString* zoneAbbreviation;
> 
> theZone = [NSTimeZone timeZoneWithName:tzName];
> zoneAbbreviation = [theZone abbreviation];
> 

I've discovered that this seems to be a change between iOS 3.1/3.2 and 4.0.

That is, the code works, but does not return the correct values.

-- 
Rick

___

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: Getting time zone abbreviations

2010-06-18 Thread David Rowland

On Jun 18, 2010, at 9:19 PM, Rick Mann wrote:

> On Jun 18, 2010, at 21:15:58, David Rowland wrote:
> 
>> 
>> On Jun 18, 2010, at 6:38 PM, Rick Mann wrote:
>> 
>>> iPhone
>>> 
>>> Hi. I need to display the time zone in which a particular time is 
>>> displayed. The time zone is created from its full POSIX name (i.e. 
>>> "Asia/Oral"), but when I ask the NSTimeZone for its abbreviation, I often 
>>> get abbreviations in the form of "GMT+05:00" instead of "RST" (or whatever 
>>> is appropriate for that time zone).
>>> 
>>> Time Zone abbreviations are not unique across the world; that's okay. What 
>>> I want is for a user local to Asia/Oral to see the 2-4 letter abbreviation 
>>> displayed and understand what he's seeing.
>>> 
>>> There is an abbreviation dictionary in iPhone OS, but it goes the wrong 
>>> way. It uses the abbreviations as keys, and the POSIX names as values. But 
>>> POSIX names are unique, while abbreviations are not, so this is a very 
>>> US-centric dictionary.
>>> 
>>> Is there any way to get short abbreviations for a TimeZone? I need it short 
>>> due to limited space. I need a common abbreviation due to users not knowing 
>>> POSIX timezone names.
>> 
>> this works for me:
>> 
>> NSTimeZone* theZone;
>> NSString* zoneAbbreviation;
>> 
>> theZone = [NSTimeZone timeZoneWithName:tzName];
>> zoneAbbreviation = [theZone abbreviation];
>> 
> 
> I've discovered that this seems to be a change between iOS 3.1/3.2 and 4.0.
> 
> That is, the code works, but does not return the correct values.

If it doesn't return the correct values then it doesn't work. I have not used 
4.0 yet, so this goes high on my watch list.

___

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: Getting time zone abbreviations

2010-06-18 Thread Rick Mann

On Jun 18, 2010, at 21:21:32, David Rowland wrote:

> 
> On Jun 18, 2010, at 9:19 PM, Rick Mann wrote:
> 
>> On Jun 18, 2010, at 21:15:58, David Rowland wrote:
>> 
>>> 
>>> On Jun 18, 2010, at 6:38 PM, Rick Mann wrote:
 Is there any way to get short abbreviations for a TimeZone? I need it 
 short due to limited space. I need a common abbreviation due to users not 
 knowing POSIX timezone names.
>>> 
>>> this works for me:
>>> 
>>> NSTimeZone* theZone;
>>> NSString* zoneAbbreviation;
>>> 
>>> theZone = [NSTimeZone timeZoneWithName:tzName];
>>> zoneAbbreviation = [theZone abbreviation];
>>> 
>> 
>> I've discovered that this seems to be a change between iOS 3.1/3.2 and 4.0.
>> 
>> That is, the code works, but does not return the correct values.
> 
> If it doesn't return the correct values then it doesn't work. I have not used 
> 4.0 yet, so this goes high on my watch list.

Well, the values are correct in that some time zones return correct 
abbreviations like PDT, and other time zones return "GMT±HH:MM", depending on 
the time zone.

Interestingly,

NSTimeZone* tz = [NSTimeZone timeZoneWithName: @"UTC"];
NSString* abv = tz.abbreviation;

returns "GMT+00:00". Not very nice.

-- 
Rick


___

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: Getting time zone abbreviations

2010-06-18 Thread Stephen J. Butler
On Fri, Jun 18, 2010 at 11:25 PM, Rick Mann  wrote:
> NSTimeZone* tz = [NSTimeZone timeZoneWithName: @"UTC"];
> NSString* abv = tz.abbreviation;
>
> returns "GMT+00:00". Not very nice.

I was trying your example (Asia/Oral) on 10.6.4 but couldn't get the
response you want. Just GMT+05:00. I thought that -[NSTimeZone
localizedName:locale:] looked promising, but I couldn't get a
combination that gave anything other than GMT+05:00. I tried:

- currentLocale
- initWithLocaleIdentifier:@"kk"
- initWithLocaleIdentifier:@"kk_KZ"

Nada.
___

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: Getting time zone abbreviations

2010-06-18 Thread David Rowland
 On Jun 18, 2010, at 6:38 PM, Rick Mann wrote:
> Is there any way to get short abbreviations for a TimeZone? I need it 
> short due to limited space. I need a common abbreviation due to users not 
> knowing POSIX timezone names.
 
 this works for me:
 
 NSTimeZone* theZone;
 NSString* zoneAbbreviation;
 
 theZone = [NSTimeZone timeZoneWithName:tzName];
 zoneAbbreviation = [theZone abbreviation];
 
>>> 
>>> I've discovered that this seems to be a change between iOS 3.1/3.2 and 4.0.
>>> 
>>> That is, the code works, but does not return the correct values.
>> 
>> If it doesn't return the correct values then it doesn't work. I have not 
>> used 4.0 yet, so this goes high on my watch list.
> 
> Well, the values are correct in that some time zones return correct 
> abbreviations like PDT, and other time zones return "GMT±HH:MM", depending on 
> the time zone.
> 
> Interestingly,
> 
> NSTimeZone* tz = [NSTimeZone timeZoneWithName: @"UTC"];
> NSString* abv = tz.abbreviation;
> 
> returns "GMT+00:00". Not very nice.

A step backwards. I would report it as a bug, but I don't yet use 4.0. I 
suggest you report it.


___

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: Getting time zone abbreviations

2010-06-18 Thread Rick Mann

On Jun 18, 2010, at 21:34:30, David Rowland wrote:

> On Jun 18, 2010, at 6:38 PM, Rick Mann wrote:
>> Is there any way to get short abbreviations for a TimeZone? I need it 
>> short due to limited space. I need a common abbreviation due to users 
>> not knowing POSIX timezone names.
> 
> this works for me:
> 
> NSTimeZone* theZone;
> NSString* zoneAbbreviation;
> 
> theZone = [NSTimeZone timeZoneWithName:tzName];
> zoneAbbreviation = [theZone abbreviation];
> 
 
 I've discovered that this seems to be a change between iOS 3.1/3.2 and 4.0.
 
 That is, the code works, but does not return the correct values.
>>> 
>>> If it doesn't return the correct values then it doesn't work. I have not 
>>> used 4.0 yet, so this goes high on my watch list.
>> 
>> Well, the values are correct in that some time zones return correct 
>> abbreviations like PDT, and other time zones return "GMT±HH:MM", depending 
>> on the time zone.
>> 
>> Interestingly,
>> 
>> NSTimeZone* tz = [NSTimeZone timeZoneWithName: @"UTC"];
>> NSString* abv = tz.abbreviation;
>> 
>> returns "GMT+00:00". Not very nice.
> 
> A step backwards. I would report it as a bug, but I don't yet use 4.0. I 
> suggest you report it.

Already did.___

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