Re: Async NSURLConnection - Crashes - Call Stacks

2010-04-19 Thread Jeff Johnson
Hi Jerry.

I don't know about the FTP crash, but I believe that the other two crashes are 
due to a 10.6.3 regression. I've filed  "10.6.3 
Regression? Reproducible NSURLConnection crash with 301 redirects".

For more information and a sample Xcode project demonstrating the crash, see 
this ClickToFlash ticket:

https://rentzsch.lighthouseapp.com/projects/24342/tickets/615-crash-at-httpwwwpingreehousegovlegisappropriations

-Jeff


On Apr 19, 2010, at 11:33 PM, Jerry Krinock wrote:

> I can find in the list archives for 2005-2007 quite a few mentions of crashes 
> when using asynchronous NSURLConnection, and in 2005 I myself reported 
> Problem ID 4347324.  The crashes seemed to stop without a definitive 
> resolution, possibly with Mac OS 10.5, but have reappeared in my apps 
> recently.  A crash is likeliest when the app is rapidly creating, reading the 
> first packet, cancelling, and releasing NSURLConnections at a rate of 20 per 
> second, has 10-20 such connections open simultaneously, and may be more 
> likely on multi-processor/multi-core Mac Pro systems with high-speed network 
> access.
> 
> So on Wednesday I've scheduled time at an ADC lab to beat on this.  Below, 
> I've pasted in call stacks for the three crash reports I've collected; one 
> from my testing and two from users.  The first two are somewhat similar, 
> involving +[NSURLConnection(NSURLConnectionReallyInternal) 
> _resourceLoadLoop:] on a secondary thread.  I suppose this is a callback when 
> data arrives.  But the third one is quite different, and is on the main 
> thread.
> 
> I'd appreciate any suggestions of what to look for, or any better explanation 
> of what's going on in those call stacks.  I know memory management is a 
> possible issue, although I've been there many times, I'm looking again.
> 
> Thank you,
> 
> Jerry Krinock
> 
> *** Jerry's Crash ***
> Thread 7 crashed:
> #00x92b37120 in CFReadStreamCopyError
> #10x913af407 in FTPProtocol::ftpReadStreamEvent
> #20x92afedd3 in _signalEventSync
> #30x92aff7be in _cfstream_solo_signalEventSync
> #40x92afea88 in _CFStreamSignalEvent
> #50x92aff707 in CFReadStreamSignalEvent
> #60x9136ffcd in _DataStreamCallBack
> #70x92afedd3 in _signalEventSync
> #80x92afed58 in _cfstream_shared_signalEventSync
> #90x92a7515b in __CFRunLoopDoSources0
> #10   0x92a72c1f in __CFRunLoopRun
> #11   0x92a720f4 in CFRunLoopRunSpecific
> #12   0x92a71f21 in CFRunLoopRunInMode
> #13   0x93dc6434 in +[NSURLConnection(NSURLConnectionReallyInternal) 
> _resourceLoadLoop:]
> #14   0x93d8d8dc in -[NSThread main]
> #15   0x93d8d88c in __NSThread__main__
> #16   0x914c2a19 in _pthread_start
> #17   0x914c289e in thread_start
> 
> 
> *** Jon's Crash ***
> Thread 3 Crashed:
> 0   com.apple.CoreFoundation  0x91a2926e CFHash + 174
> 1   com.apple.CoreFoundation  0x91a2906c ___CFBasicHashFindBucket1 + 
> 444
> 2   com.apple.CoreFoundation  0x91a3125c CFBasicHashFindBucket + 252
> 3   com.apple.CoreFoundation  0x91a31123 CFDictionaryGetValue + 131
> 4   com.apple.CoreFoundation  0x91b17a95 _CFStreamDetachSource + 405
> 5   com.apple.CoreFoundation  0x91a4edeb _CFStreamClose + 75
> 6   com.apple.CFNetwork   0x97fec8e1 
> HTTPProtocol::destroyReadStream() + 173
> 7   com.apple.CFNetwork   0x97fec7b1 
> HTTPProtocol::cleanupStreams() + 93
> 8   com.apple.CFNetwork   0x97feb221 
> HTTPProtocol::httpReadStreamEvent(unsigned long) + 365
> 9   com.apple.CoreFoundation  0x91adfdd3 _signalEventSync + 99
> 10  com.apple.CoreFoundation  0x91adfd58 
> _cfstream_shared_signalEventSync + 664
> 11  com.apple.CoreFoundation  0x91a5615b __CFRunLoopDoSources0 + 1563
> 12  com.apple.CoreFoundation  0x91a53c1f __CFRunLoopRun + 1071
> 13  com.apple.CoreFoundation  0x91a530f4 CFRunLoopRunSpecific + 452
> 14  com.apple.CoreFoundation  0x91a52f21 CFRunLoopRunInMode + 97
> 15  com.apple.Foundation  0x9689d434 
> +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 329
> 16  com.apple.Foundation  0x968648dc -[NSThread main] + 45
> 17  com.apple.Foundation  0x9686488c __NSThread__main__ + 1499
> 18  libSystem.B.dylib 0x90567a19 _pthread_start + 345
> 19  libSystem.B.dylib 0x9056789e thread_start + 34
> 
> *** Tony's Crash ***
> Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
> 0   com.apple.CoreFoundation  0x99138d04 CFRelease + 196
> 1   com.apple.CFNetwork   0x905e58ec 
> HTTPProtocol::destroyReadStream() + 184
> 2   com.apple.CFNetwork   0x905e57b1 
> HTTPProtocol::cleanupStreams() + 93
> 3   com.apple.CFNetwork   0x905e5acb 
> HTTPProtocol::~HTTPProtocol() + 155
> 4   com.apple.CoreFoundation  0x99138ea1 _CFRelease + 353
> 5   com.apple.CFNetwork   0x905e554c 
> URLConnectionLoader::reallyCleanUpProtocol(

Async NSURLConnection - Crashes - Call Stacks

2010-04-19 Thread Jerry Krinock
I can find in the list archives for 2005-2007 quite a few mentions of crashes 
when using asynchronous NSURLConnection, and in 2005 I myself reported Problem 
ID 4347324.  The crashes seemed to stop without a definitive resolution, 
possibly with Mac OS 10.5, but have reappeared in my apps recently.  A crash is 
likeliest when the app is rapidly creating, reading the first packet, 
cancelling, and releasing NSURLConnections at a rate of 20 per second, has 
10-20 such connections open simultaneously, and may be more likely on 
multi-processor/multi-core Mac Pro systems with high-speed network access.

So on Wednesday I've scheduled time at an ADC lab to beat on this.  Below, I've 
pasted in call stacks for the three crash reports I've collected; one from my 
testing and two from users.  The first two are somewhat similar, involving 
+[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] on a 
secondary thread.  I suppose this is a callback when data arrives.  But the 
third one is quite different, and is on the main thread.

I'd appreciate any suggestions of what to look for, or any better explanation 
of what's going on in those call stacks.  I know memory management is a 
possible issue, although I've been there many times, I'm looking again.

Thank you,

Jerry Krinock

*** Jerry's Crash ***
Thread 7 crashed:
#0  0x92b37120 in CFReadStreamCopyError
#1  0x913af407 in FTPProtocol::ftpReadStreamEvent
#2  0x92afedd3 in _signalEventSync
#3  0x92aff7be in _cfstream_solo_signalEventSync
#4  0x92afea88 in _CFStreamSignalEvent
#5  0x92aff707 in CFReadStreamSignalEvent
#6  0x9136ffcd in _DataStreamCallBack
#7  0x92afedd3 in _signalEventSync
#8  0x92afed58 in _cfstream_shared_signalEventSync
#9  0x92a7515b in __CFRunLoopDoSources0
#10 0x92a72c1f in __CFRunLoopRun
#11 0x92a720f4 in CFRunLoopRunSpecific
#12 0x92a71f21 in CFRunLoopRunInMode
#13 0x93dc6434 in +[NSURLConnection(NSURLConnectionReallyInternal) 
_resourceLoadLoop:]
#14 0x93d8d8dc in -[NSThread main]
#15 0x93d8d88c in __NSThread__main__
#16 0x914c2a19 in _pthread_start
#17 0x914c289e in thread_start


*** Jon's Crash ***
Thread 3 Crashed:
0   com.apple.CoreFoundation  0x91a2926e CFHash + 174
1   com.apple.CoreFoundation  0x91a2906c ___CFBasicHashFindBucket1 + 444
2   com.apple.CoreFoundation  0x91a3125c CFBasicHashFindBucket + 252
3   com.apple.CoreFoundation  0x91a31123 CFDictionaryGetValue + 131
4   com.apple.CoreFoundation  0x91b17a95 _CFStreamDetachSource + 405
5   com.apple.CoreFoundation  0x91a4edeb _CFStreamClose + 75
6   com.apple.CFNetwork   0x97fec8e1 
HTTPProtocol::destroyReadStream() + 173
7   com.apple.CFNetwork   0x97fec7b1 HTTPProtocol::cleanupStreams() 
+ 93
8   com.apple.CFNetwork   0x97feb221 
HTTPProtocol::httpReadStreamEvent(unsigned long) + 365
9   com.apple.CoreFoundation  0x91adfdd3 _signalEventSync + 99
10  com.apple.CoreFoundation  0x91adfd58 
_cfstream_shared_signalEventSync + 664
11  com.apple.CoreFoundation  0x91a5615b __CFRunLoopDoSources0 + 1563
12  com.apple.CoreFoundation  0x91a53c1f __CFRunLoopRun + 1071
13  com.apple.CoreFoundation  0x91a530f4 CFRunLoopRunSpecific + 452
14  com.apple.CoreFoundation  0x91a52f21 CFRunLoopRunInMode + 97
15  com.apple.Foundation  0x9689d434 
+[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 329
16  com.apple.Foundation  0x968648dc -[NSThread main] + 45
17  com.apple.Foundation  0x9686488c __NSThread__main__ + 1499
18  libSystem.B.dylib 0x90567a19 _pthread_start + 345
19  libSystem.B.dylib 0x9056789e thread_start + 34

*** Tony's Crash ***
Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   com.apple.CoreFoundation0x99138d04 CFRelease + 196
1   com.apple.CFNetwork 0x905e58ec 
HTTPProtocol::destroyReadStream() + 184
2   com.apple.CFNetwork 0x905e57b1 
HTTPProtocol::cleanupStreams() + 93
3   com.apple.CFNetwork 0x905e5acb 
HTTPProtocol::~HTTPProtocol() + 155
4   com.apple.CoreFoundation0x99138ea1 _CFRelease + 353
5   com.apple.CFNetwork 0x905e554c 
URLConnectionLoader::reallyCleanUpProtocol(unsigned char) + 240
6   com.apple.CFNetwork 0x90640249 
URLConnectionLoader::cleanupProtocolFromClientThread() + 25
7   com.apple.CFNetwork 0x905bb2c8 
URLConnectionClient::getRequestForTransmission(_CFURLResponse*, _CFURLRequest 
const*, __CFError**) + 574
8   com.apple.CFNetwork 0x905bacaf 
URLConnectionClient::_clientWillSendRequest(_CFURLRequest const*, 
_CFURLResponse*, URLConnectionClient::ClientConnectionEventQueue*) + 223
9   com.apple.CFNetwork 0x9063f54a 
URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConn

An iTunes-like music playing view?

2010-04-19 Thread Chase Meadors
Hi All, I just wanted to hit up the list with this one before sitting  
down and coding.


Has anyone made or know of a Cocoa music player view, with movable  
slider & All, text, somewhat similar in functionality to the iTunes  
view at the top of the window? QTMovieView is a bit too bland for my  
tastes. Before digging into some CoreAnimation, I wanted to check here.


Thanks for any replies! -Chase.
___

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

Please do not post admin requests or moderator comments to the list.
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: where is the basic NSString literal escape documentation?

2010-04-19 Thread Aki Inoue
\u and \U formats (or universal character names ) are part of C99 
standard.

Aki

On Apr 19, 2010, at 6:11 PM, Matt Neuburg wrote:

> 
> On Apr 19, 2010, at 6:02 PM, Kyle Sluder wrote:
> 
>> On Mon, Apr 19, 2010 at 5:44 PM, Matt Neuburg  wrote:
>>> Supposing you were a complete C / Objective-C beginner. How would you find
>>> out what escape sequences are permitted in an NSString literal (that is,
>>> with @"...")? For example, K&R doesn't know about \u (backslash-u
>>> followed by four hex digits), but of course that is now legal (though it was
>>> not always). What documentation would tell the user about this? Thx - m.
>> 
>> I use the printf(3) manpage.
> 
> That's good on format-strings and stuff you can do with %, but that isn't 
> what I'm asking about. I'm asking about straightforward NSString literals, 
> such as @"this\nsort\tof\u2022thing". You can learn about the \n and \t from 
> K&R, but how would you learn about 
> \u2022?___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/aki%40apple.com
> 
> This email sent to a...@apple.com

___

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

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

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

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


Re: where is the basic NSString literal escape documentation?

2010-04-19 Thread Matt Neuburg

On Apr 19, 2010, at 6:02 PM, Kyle Sluder wrote:

> On Mon, Apr 19, 2010 at 5:44 PM, Matt Neuburg  wrote:
>> Supposing you were a complete C / Objective-C beginner. How would you find
>> out what escape sequences are permitted in an NSString literal (that is,
>> with @"...")? For example, K&R doesn't know about \u (backslash-u
>> followed by four hex digits), but of course that is now legal (though it was
>> not always). What documentation would tell the user about this? Thx - m.
> 
> I use the printf(3) manpage.

That's good on format-strings and stuff you can do with %, but that isn't what 
I'm asking about. I'm asking about straightforward NSString literals, such as 
@"this\nsort\tof\u2022thing". You can learn about the \n and \t from K&R, but 
how would you learn about \u2022?___

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

Please do not post admin requests or moderator comments to the list.
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: where is the basic NSString literal escape documentation?

2010-04-19 Thread Kyle Sluder
On Mon, Apr 19, 2010 at 5:44 PM, Matt Neuburg  wrote:
> Supposing you were a complete C / Objective-C beginner. How would you find
> out what escape sequences are permitted in an NSString literal (that is,
> with @"...")? For example, K&R doesn't know about \u (backslash-u
> followed by four hex digits), but of course that is now legal (though it was
> not always). What documentation would tell the user about this? Thx - m.

I use the printf(3) manpage.

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


where is the basic NSString literal escape documentation?

2010-04-19 Thread Matt Neuburg
Supposing you were a complete C / Objective-C beginner. How would you find
out what escape sequences are permitted in an NSString literal (that is,
with @"...")? For example, K&R doesn't know about \u (backslash-u
followed by four hex digits), but of course that is now legal (though it was
not always). What documentation would tell the user about this? Thx - m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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

Please do not post admin requests or moderator comments to the list.
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: using coregraphics with vector art from illustrator

2010-04-19 Thread Ken Ferry
On Mon, Apr 19, 2010 at 4:31 PM, Jens Alfke  wrote:

>
> On Apr 19, 2010, at 3:54 PM, Philip Mobley wrote:
>
>  Would that make a opaque white box around the shape?  What about
>> transparency... would that be retained or would it be flattened?
>>
>
> No, there's no frame. It gets drawn as a PDF, so it uses whatever
> compositing is specified in the source.
>
> Lots of apps store icons in the form of PDF files, because they're
> resolution-independent. It's encouraged by Apple.


NSImage is likely easier to use for this than CG, because it can deal with
PDF and bitmap art with the same API.   It maintains a bitmap cache of the
last way the PDF was rendered (unless shut off), which is likely to be
appropriate for your use.  Though, feel free to use CGPDFDocument instead if
you like.

NSImage will also directly read illustrator .ai files.

-Ken
___

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

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

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

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


Re: using coregraphics with vector art from illustrator

2010-04-19 Thread Jens Alfke


On Apr 19, 2010, at 3:54 PM, Philip Mobley wrote:

Would that make a opaque white box around the shape?  What about  
transparency... would that be retained or would it be flattened?


No, there's no frame. It gets drawn as a PDF, so it uses whatever  
compositing is specified in the source.


Lots of apps store icons in the form of PDF files, because they're  
resolution-independent. It's encouraged by Apple.


—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: using coregraphics with vector art from illustrator

2010-04-19 Thread Philip Mobley
On Apr 19, 2010, at 2:49 PM, Jens Alfke wrote:

>> Is there perhaps a way to create vector art paths in illustrator, and import 
>> the data into xcode and use those paths in CG and stroke/fill them there?
> 
> Save the path as a PDF file, and then load and draw it as an image.

Would that make a opaque white box around the shape?  What about 
transparency... would that be retained or would it be flattened?

___

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

Please do not post admin requests or moderator comments to the list.
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: using coregraphics with vector art from illustrator

2010-04-19 Thread Jens Alfke


On Apr 19, 2010, at 1:59 PM, Patrick J. Collins wrote:

Is there perhaps a way to create vector art paths in illustrator,  
and import
the data into xcode and use those paths in CG and stroke/fill them  
there?


Save the path as a PDF file, and then load and draw it as an image.

—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: using coregraphics with vector art from illustrator

2010-04-19 Thread Nick Zitzmann

On Apr 19, 2010, at 2:59 PM, Patrick J. Collins wrote:

> I have an app that I am using CoreGraphics to draw music notation symbols, and
> I want to keep things perfectly scalable (for zooming), and am just wondering
> what the best way to go about this is...

Either do your drawing using Bezier paths, or use a vector-based font for the 
symbols. Just stay away from scalar graphics, such as compositing bitmap images 
or old-school fonts, and you should be fine wrt zooming or changing the DPI.

Nick Zitzmann


___

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

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

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

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


using coregraphics with vector art from illustrator

2010-04-19 Thread Patrick J. Collins
Hi everyone,

I have an app that I am using CoreGraphics to draw music notation symbols, and
I want to keep things perfectly scalable (for zooming), and am just wondering
what the best way to go about this is...

Is there perhaps a way to create vector art paths in illustrator, and import
the data into xcode and use those paths in CG and stroke/fill them there?

Is that possible?

Patrick J. Collins
http://collinatorstudios.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: Text file

2010-04-19 Thread Henrietta Read
That's a good idea, thank you! :)




On Sun, Apr 18, 2010 at 12:41 PM, Jens Alfke  wrote:

>
> On Apr 18, 2010, at 12:40 AM, Henrietta Read wrote:
>
> > exactly the point germane, but in perusing NSString.h one is given to
> understand this method might not be as 'smart' as one could wish:
>
> I wouldn’t think it would fail with MacRoman, though. Did you check the
> output NSError? Also, try inspecting the file with a hex editor … maybe
> there are some invisible null bytes or control characters.
>
> What I usually do in cases like this, when trying to decode arbitrary data
> to strings, is to fall back to assuming NSWindowsCP1252StringEncoding. This
> is (a) a very common encoding [the default on most Windows systems], (b)
> fairly standard (it’s a superset of ISO-Latin-1), and (c) always works since
> it encodes all 256 bytes values.
>
> —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: Questions about 2D drawing in Cocoa

2010-04-19 Thread Rob Ross

Books:

This is pretty definitive:

http://www.amazon.com/Programming-Quartz-Graphics-Kaufmann-Computer/dp/0123694736/ref=sr_1_1?ie=UTF8&s=books&qid=1231668829&sr=1-1

This is much shorter, but a good quick start:

http://www.amazon.com/Quartz-2D-Graphics-Mac-Developers/dp/0321336631/ref=sr_1_2?ie=UTF8&s=books&qid=1231668876&sr=1-2


On Apr 19, 2010, at 1:21 PM, Philip Mobley wrote:

I am fairly new to Cocoa, and so I have 2 questions I would  
appreciate some feedback.  For a beginner, Cocoa suffers from the  
"too much info" problem and its often difficult to find the answers  
to seemly simple questions.  I have had better luck learning from  
books, and have purchased the following books:


"Cocoa Recipes for Mac OS X: Second Edition (Vermont Recipes)" by  
Bill Cheeseman

"Cocoa and Obj-C: Up and Running" by Scott Stevenson
"The iPhone Developer's Cookbook: Second Edition" by Erica Sadun

While these books are great for general Cocoa needs, I want to dive  
deeper into 2D drawing with Cocoa.


1.  Are there any books that you would recommend that deal  
specifically with designing custom views and drawing using  
CoreGraphics?  (I prefer CG drawing because more available options  
and easier to share code between desktop and iPhone apps).


2.  Secondly, for several of my desktop apps I am working on I need  
to use a custom designed Tab interface.  This interface is just to  
control the tabs and the view does NOT contain the mechanism to  
switch between tabbed views (will use borderless NSTabView for  
that).  I want to have a containing class which holds the tab button  
cells, while the containing class only manages the position of the  
tab button cells, and encapsulates messages when each button is  
pushed.  Are there any code examples like this that you know of?


___

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

Please do not post admin requests or moderator comments to the list.
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


Questions about 2D drawing in Cocoa

2010-04-19 Thread Philip Mobley
I am fairly new to Cocoa, and so I have 2 questions I would appreciate some 
feedback.  For a beginner, Cocoa suffers from the "too much info" problem and 
its often difficult to find the answers to seemly simple questions.  I have had 
better luck learning from books, and have purchased the following books:

"Cocoa Recipes for Mac OS X: Second Edition (Vermont Recipes)" by Bill Cheeseman
"Cocoa and Obj-C: Up and Running" by Scott Stevenson 
"The iPhone Developer's Cookbook: Second Edition" by Erica Sadun

While these books are great for general Cocoa needs, I want to dive deeper into 
2D drawing with Cocoa.

1.  Are there any books that you would recommend that deal specifically with 
designing custom views and drawing using CoreGraphics?  (I prefer CG drawing 
because more available options and easier to share code between desktop and 
iPhone apps).

2.  Secondly, for several of my desktop apps I am working on I need to use a 
custom designed Tab interface.  This interface is just to control the tabs and 
the view does NOT contain the mechanism to switch between tabbed views (will 
use borderless NSTabView for that).  I want to have a containing class which 
holds the tab button cells, while the containing class only manages the 
position of the tab button cells, and encapsulates messages when each button is 
pushed.  Are there any code examples like this that you know of?

___

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

Please do not post admin requests or moderator comments to the list.
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


NSXMLDocument objectByApplyingXSLT with XSL Include

2010-04-19 Thread Kristof Van Landschoot
Hi all,

I'm having some trouble with XSL-processing when there are stylesheets that
include other stylesheets relatively.

(the XML-files may be irrelevant but are included for completeness - code is
at the bottom).

Given the XML-file:




  
 Edward   
  Jenner   
  
  
 Gertrude 
  Elion
  



and the XSL-file:


http://www.w3.org/1999/XSL/Transform";
xmlns:xi="http://www.w3.org/2001/XInclude";
 version="1.0">
  
 Sorting example
 
   
 
 
  
  


referencing this stylesheet in included.xsl:


http://www.w3.org/1999/XSL/Transform";
 xmlns:xi="http://www.w3.org/2001/XInclude";
version="1.0">
  

Irrelevant
  


how can I make it that the following code fragment:

NSError *lError = nil;


 NSXMLDocument *lDocument = [ [ NSXMLDocument alloc ] initWithContentsOfURL:

[ NSURL URLWithString:
@"file:///pathto/data.xml" ]

options: 0

error: &lError ];

 NSXMLDocument *lResult = [ lDocument objectByApplyingXSLTAtURL: [ NSURL
URLWithString: @"file:///pathto/style.xsl" ]

arguments: nil

error: nil ];

does not give me the error:

*I/O warning : failed to load external entity "included.xsl"*

*compilation error: element include*

*xsl:include : unable to load included.xsl*
*
*
I have been trying all sorts of options. Also loading XML documents
with NSXMLDocumentXInclude
beforehand does not seem to help.

Is there any way to make the XSL processing so that a stylesheet can include
another stylesheet in its local path?

Thanks for your help,
Kristof
___

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

Please do not post admin requests or moderator comments to the list.
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: Baffling Button Behavior

2010-04-19 Thread Keary Suska
On Apr 19, 2010, at 10:02 AM, k...@highrolls.net wrote:

> Per Fritz suggestion / request:
> 
> (gdb) po sender
>  <<= Save Button
> (gdb) call (id) [sender superview]
> $3 = (id) 0x1183540
> (gdb) po $3
> 
> (gdb) call (int) [sender autoresizingMask]
> $4 = 36 <<= NSViewMaxXMargin = 4 & NSViewMaxYMargin = 32
> (gdb) c
> Continuing.
> (gdb) po sender
>  <<= Save As Button
> (gdb) call (id) [sender superview]
> $5 = (id) 0x1183540
> (gdb) po $5
> 
> (gdb) call (int) [sender autoresizingMask]
> $6 = 36 <<= NSViewMaxXMargin = 4 & NSViewMaxYMargin = 32
> 
> 
> Full window before containing view resized:
> 
> http://highrolls.net/Before.png
> 
> And after:
> 
> http://highrolls.net/After.png

I believe it is doing exactly what you ask it too, but it appears that it is 
incorrect because *other* views are resizing in odd ways. Both buttons are 
anchored on the left, yes? Which means that the view will maintain that 
distance, which looks to me that it is. However, the "flag" image view has 
resized larger, while the table view became shorter. This change is making it 
seems as if the "Save As" button is keeping its right margin, when in fact it 
is purely accidental.

But then in fact it is the *left* button that isn't behaving properly. But this 
may be because autoresizing becomes undefined any time sibling view overlap, 
and you may be running into this issue.

Of course, I am assuming that all of the views int the right pane of the split 
view have the same superview.

It may be useful to first solve why the image view and the scroll view above it 
aren't resizing in an expected way.

> On Apr 18, 2010, at 2:24 PM, Fritz Anderson wrote:
> 
>> On 17 Apr 2010, at 4:32 PM, k...@highrolls.net wrote:
>> 
>>> I have two buttons in a view, side by side.  Their autoresizingMask are 
>>> both NSViewMaxXMargin + NSViewMaxYMargin
>>> 
>>> When their containing view is resized only the left button behaves 
>>> properly.  The right button stays fixed.
>>> 
>>> Why?
>>> 
>>> Before resize:http://highrolls.net/Before Resize.png
>>> 
>>> After resize:http://highrolls.net/After Resize.png
>> 
>> I wish you had provided the real URLs (e.g. 
>> ).
>> 
>> I also wish your screen shots showed the enclosing window, so I could tell 
>> what resizing was done. Group: There are two buttons visible, "Save" on the 
>> left, and "Save As…" on the right. In the "before" picture, they appear 
>> side-by-side, with a normal amount of space between them. In the "after" 
>> picture, which I _assume_ comes after the window was resized to be narrower, 
>> "Save" (left) is the same x-distance from the left margin (visually 
>> stationary); "Save As…" (right) has moved to the left so it is under, and 
>> half-covered by, "Save."
>> 
>> The most obvious explanation is that the resizing mask for "Save As…" 
>> contains NSViewMinXMargin (flexible on left) and not NSViewMaxXMargin 
>> (flexible on right), despite your intention.
>> 
>> Things to try:
>> 
>> I would like to see your code in which you set the autoresizing masks, for 
>> both buttons. Or if it was done in Interface Builder, please double-check 
>> the resizing settings.
>> 
>> Verify that the two buttons are embedded in the same view.
>> 
>> In the debugger, set a breakpoint in some code where you have access to 
>> pointers to the two buttons, after their resizing masks have been set. If 
>> you really are using setAutoResizingMask:, breaking right after the second 
>> call would do. Then use the Debugger Console for these two commands:
>> 
>> p/d (int) [saveButton autoresizingMask]
>> p/d (int) [saveAsButton autoresizingMask]
>> 
>> My bet is the two numbers are different.
>> 
>>  — F
>> 
>> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.com
> 


Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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

Please do not post admin requests or moderator comments to the list.
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: Introspecting the current method

2010-04-19 Thread Jean-Daniel Dupas

Le 19 avr. 2010 à 20:54, Greg Parker a écrit :

> On Apr 18, 2010, at 7:01 PM, Ken Thomases wrote:
>> On Apr 18, 2010, at 7:14 PM, Dave DeLong wrote:
>>> If I'm inside a method, is there a way to know at runtime whether that 
>>> method is a class or an instance method?
>> 
>> Keep in mind that class methods are just instance methods, where the 
>> instance is the class object.  (The class object being an instance of its 
>> metaclass.)
>> 
>> So, in a deep sense, there's no distinction between a class method and an 
>> instance method.  There's only the receiver object and the message/selector.
> 
> Absolutely correct. But in practice, you can distinguish between class and 
> instance methods everywhere except the root class.
> 
> The methods for a non-class instance are:
> * your class's instance methods
> * any superclass instance methods
> * NSObject's instance methods
> 
> The methods for a class instance are:
> * the class's class methods
> * any superclass class methods
> * NSObject's class methods
> * NSObject's instance methods
> 
> That last line is the weird one. It's caused by the twist at the top of the 
> instance/class/metaclass diagram that makes all class objects into instances 
> of their root class (usually NSObject). 
> http://sealiesoftware.com/blog/archive/2009/04/14/objc_explain_Classes_and_metaclasses.html
> 
> Comparing the two lists, you can see that the only overlap is NSObject's 
> instance methods. Everywhere else, you'll find that class methods are called 
> on class objects only, and instance methods are called on non-class objects 
> only. So "is self a class" will distinguish instance methods from class 
> methods, as long as you aren't writing instance methods on NSObject.
> 
> Note that `[self class] == self` is the wrong check. Some classes lie about 
> [self class]. One specific case is KVO. On some OS versions, KVO creates 
> subclasses of observed classes at runtime. The subclasses override accessor 
> methods to add willChange/didChange notifications. The KVO-generated 
> subclasses override [self class] to return the non-KVO superclass instead of 
> the KVO-generated subclass.

If the test was [self class] == MyClass.class, it would be wrong, but this is 
not what he does, and AFAIK, [self class] returns self only for class objects.

> You can use `object_getClass(self) == self` instead. object_getClass() never 
> lies.

It will never be true as this test is equivalent to self->isa == self, and isa 
is never self.


-- 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: Introspecting the current method

2010-04-19 Thread Greg Parker
On Apr 18, 2010, at 7:01 PM, Ken Thomases wrote:
> On Apr 18, 2010, at 7:14 PM, Dave DeLong wrote:
>> If I'm inside a method, is there a way to know at runtime whether that 
>> method is a class or an instance method?
> 
> Keep in mind that class methods are just instance methods, where the instance 
> is the class object.  (The class object being an instance of its metaclass.)
> 
> So, in a deep sense, there's no distinction between a class method and an 
> instance method.  There's only the receiver object and the message/selector.

Absolutely correct. But in practice, you can distinguish between class and 
instance methods everywhere except the root class.

The methods for a non-class instance are:
* your class's instance methods
* any superclass instance methods
* NSObject's instance methods

The methods for a class instance are:
* the class's class methods
* any superclass class methods
* NSObject's class methods
* NSObject's instance methods

That last line is the weird one. It's caused by the twist at the top of the 
instance/class/metaclass diagram that makes all class objects into instances of 
their root class (usually NSObject). 
http://sealiesoftware.com/blog/archive/2009/04/14/objc_explain_Classes_and_metaclasses.html

Comparing the two lists, you can see that the only overlap is NSObject's 
instance methods. Everywhere else, you'll find that class methods are called on 
class objects only, and instance methods are called on non-class objects only. 
So "is self a class" will distinguish instance methods from class methods, as 
long as you aren't writing instance methods on NSObject.

Note that `[self class] == self` is the wrong check. Some classes lie about 
[self class]. One specific case is KVO. On some OS versions, KVO creates 
subclasses of observed classes at runtime. The subclasses override accessor 
methods to add willChange/didChange notifications. The KVO-generated subclasses 
override [self class] to return the non-KVO superclass instead of the 
KVO-generated subclass.

You can use `object_getClass(self) == self` instead. object_getClass() never 
lies.

-- 
Greg Parker gpar...@apple.com Runtime Wrangler


___

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

Please do not post admin requests or moderator comments to the list.
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: Introspecting the current method

2010-04-19 Thread Greg Parker
On Apr 19, 2010, at 7:09 AM, Michael Ash wrote:
> On Mon, Apr 19, 2010 at 3:27 AM, Jean-Daniel Dupas
>  wrote:
>> 
>> Le 19 avr. 2010 à 04:21, Michael Ash a écrit :
>>> On Sun, Apr 18, 2010 at 10:15 PM, Dave DeLong  wrote:
 Yes, code should obviously be written with this knowledge in mind.  The 
 use case I have for it is for macros.  I like to use a debugging macro 
 like the following to ensure that methods are getting called (without 
 having to break execution to stop at a breakpoint):
 
 #define LogMethod NSLog(@"-[%@ %...@]", NSStringFromClass([self class]), 
 NSStringFromSelector(_cmd))
 
 This, of course, is only accurate for instance methods (since I'm logging 
 a "-").  I was just wondering if there was a way I could use some sort of 
 introspection to appropriately place a + or a -.
 
 I like the ([self class] == self) method, simply because it's shorter, but 
 the [[self class] instancesRespondToSelector:_cmd] is also a great 
 solution.
>>> 
>>> The magic __func__ identifier produces a C string which I believe, in
>>> an ObjC method, has exactly the format you're looking for.
>>> 
>>> Mike
>> 
>> It is fine for most cases, but __func__ is defined at compile time, and so, 
>> does not log the real type of the instance (if this is a subclass).
> 
> For me, if you're using this in a logging function, this is a feature,
> not a bug. If I'm logging a message like "X is Y, should be Z" then I
> want to know what code triggered that, and logging the actual object
> type is much less useful for that. If you're interested in the actual
> type as well, then I'd say just log that too, like:
> 
> NSLog(@"%s:%d %@: %@", __func__, __LINE__, self, yourMessageGoesHere);

Alternatively, if you if you already know what you want to log and just can't 
decide between '-' and '+', then use __func__[0] for that.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler


___

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

Please do not post admin requests or moderator comments to the list.
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: Baffling Button Behavior

2010-04-19 Thread koko

Per Fritz suggestion / request:

(gdb) po sender
 <<= Save Button
(gdb) call (id) [sender superview]
$3 = (id) 0x1183540
(gdb) po $3

(gdb) call (int) [sender autoresizingMask]
$4 = 36 <<= NSViewMaxXMargin = 4 & NSViewMaxYMargin = 32
(gdb) c
Continuing.
(gdb) po sender
 <<= Save As Button
(gdb) call (id) [sender superview]
$5 = (id) 0x1183540
(gdb) po $5

(gdb) call (int) [sender autoresizingMask]
$6 = 36 <<= NSViewMaxXMargin = 4 & NSViewMaxYMargin = 32


Full window before containing view resized:

http://highrolls.net/Before.png

And after:

http://highrolls.net/After.png



Thanks for taking a look ... I hope I am not being to dense !

koko




On Apr 18, 2010, at 2:24 PM, Fritz Anderson wrote:


On 17 Apr 2010, at 4:32 PM, k...@highrolls.net wrote:

I have two buttons in a view, side by side.  Their autoresizingMask  
are both NSViewMaxXMargin + NSViewMaxYMargin


When their containing view is resized only the left button behaves  
properly.  The right button stays fixed.


Why?

Before resize:http://highrolls.net/Before Resize.png

After resize:http://highrolls.net/After Resize.png


I wish you had provided the real URLs (e.g. ).


I also wish your screen shots showed the enclosing window, so I  
could tell what resizing was done. Group: There are two buttons  
visible, "Save" on the left, and "Save As…" on the right. In the  
"before" picture, they appear side-by-side, with a normal amount of  
space between them. In the "after" picture, which I _assume_ comes  
after the window was resized to be narrower, "Save" (left) is the  
same x-distance from the left margin (visually stationary); "Save  
As…" (right) has moved to the left so it is under, and half-covered  
by, "Save."


The most obvious explanation is that the resizing mask for "Save  
As…" contains NSViewMinXMargin (flexible on left) and not  
NSViewMaxXMargin (flexible on right), despite your intention.


Things to try:

I would like to see your code in which you set the autoresizing  
masks, for both buttons. Or if it was done in Interface Builder,  
please double-check the resizing settings.


Verify that the two buttons are embedded in the same view.

In the debugger, set a breakpoint in some code where you have access  
to pointers to the two buttons, after their resizing masks have been  
set. If you really are using setAutoResizingMask:, breaking right  
after the second call would do. Then use the Debugger Console for  
these two commands:


p/d (int) [saveButton autoresizingMask]
p/d (int) [saveAsButton autoresizingMask]

My bet is the two numbers are different.

— F




___

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

Please do not post admin requests or moderator comments to the list.
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


CalendarStore Question

2010-04-19 Thread Mazen M. Abdel-Rahman
Hi All,

I am having difficulty with modifying recurring events in iCal using the 
Calendar Store framework.

I can take a single event (non recurring) event and make it repeating - 
including specifying an end date or number of repeats.  To do  that I use the 
following line:

[[CalCalendarStore defaultCalendarStore] saveEvent:calEvent 
span:CalSpanAllEvents error:&calError]


However - when I do that the first occurrence of the event has property 
isDetached = YES.

If  instead modify the event (make a non-repeating event repeating)  directly 
through iCal - the property isDetached = NO.

I also tried it with span = CalSpanThisEvent and span = CalSpanFutureEvents - 
and with those options I also get isDetached = YES when I make a non-repeating 
event repeating.  

Anyone have any idea what I might be doing wrong?

Thanks,
Mazen Abdel-Rahman






___

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

Please do not post admin requests or moderator comments to the list.
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 Programming For OS X Coders"?

2010-04-19 Thread Michael A. Crawford
Sorry for chiming in late, Jens.  Been busy.

I like "Cocoa Touch for iPhone OS 3" by  Jiva Devoe and The iPhone Developer's 
Cookbook by Erica Sadun.  Both focus specifically on UIKit elements with very 
little overlap to the desktop.  Exceptions are CoreData and 
NSURLConnect/NSURLRequest.  Still there are enough differences with CoreData 
and memory management that the overlap is warranted.

Both of these are excellent references and short tutorials for how to use 
views, controllers, navigation, touch-event processing, and UI* controls in 
iPhone OS.  No need to read through front to back, simply turn to the specific 
topic you are interested in implementing and you get pretty much what you need 
in just a page or two.

Of course you can save some cash by simply reading Apple's excellent on-line 
docs for UIKit and Cocoa-Touch.

-Michael

On Apr 7, 2010, at 12:49 AM, Kyle Sluder wrote:

> On Tue, Apr 6, 2010 at 9:42 PM, Philip Mobley  wrote:
>> iPhone 3.2 SDK just added UIBezierPath, but the 3.2 OS will only run on iPad 
>> right now.  Who knows if the iPhone will ever run 3.2 OS or if they will 
>> just wait until 4.0.
> 
> I imagine we'll find out on Thursday.
> 
> --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/michaelacrawford%40me.com
> 
> This email sent to michaelacrawf...@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: Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here...

2010-04-19 Thread James Bucanek
Kevin Wojniak  wrote (Sunday, April 
18, 2010 1:29 AM -0700):




If that doesn't work, you could try looping through the mounted volumes and
check each one for a matching URL with FSCopyURLForVolume().


I might try that too, just to see if the URL returned by 
FSCopyURLForVolume() is similar to the one in the mount 
notification. Thanks.


--
James Bucanek

___

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

Please do not post admin requests or moderator comments to the list.
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: Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here...

2010-04-19 Thread James Bucanek
Ken Thomases  wrote (Saturday, April 
17, 2010 5:29 PM -0500):



On Apr 17, 2010, at 6:46 PM, James Bucanek wrote:


For backwards compatibility, the notification still includes an NSDevicePath
value, but that value is wrong for AFP volumes. For

example, in 10.5 mounting the network volume "Dinah" would fire a notification
containing NSDevicePath="/Volumes/Dinah". In 10.6, mounting the same volume
posts a notification containing:


NSWorkspaceVolumeURLKey = 
NSURL(afp://james%20buca...@march%20hare._afpovertcp._tcp.local/Dinah)
NSDevicePath = "/Dinah"


Does seem like a bug.


It does, doesn't it?


Perhaps you can use -[NSWorkspace mountedLocalVolumePaths]?  You'd keep a copy
of the old value and recheck it on each mount/unmount notification.


As a friend of mine says: Great minds think alike ... or there's 
only one way out of the woods.


This is what I resorted to doing, essentially. I already had 
code to do this (for situations where NSWorkspace isn't 
available), but it's cumbersome, inefficient, and just 
ridiculous to receive a volume mount event and not be able to 
get a filesystem path to the mounted volume that was just mounted.



By the way, are you mounting this volume programmatically using
FSMountServerVolumeSync/Async?  If so, then you get a volume reference number
back, and you can use FSGetVolumeInfo to get its root directory as an FSRef,
and from there a path or URL.


Alas, no. My application is a backup program. It watches for 
events that can trigger certain actions. One of those events is 
the appearance of a volume containing a source or a destination. 
This allows you, for example, to schedule a backup of your USB 
thumb drive when you plug it it.



In fact, it may be possible to use FSMountServerVolumeSync with the afp: URL
you're getting from NSWorkspace.  You'd effectively be asking to remount the
volume that was just mounted.  Hopefully, the OS will immediately return
success without doing any actual new mounting, and that would be a way to get
the volume reference number.  On the other hand, it's just as likely to return
some sort of "volume already mounted" error.


Interesting workaround. I'll give that a try.

--
James Bucanek

___

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

Please do not post admin requests or moderator comments to the list.
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: Converting an afp:NSURL to a filesystem path - or - Ya can't get there from here...

2010-04-19 Thread James Bucanek
Kyle Sluder  wrote (Saturday, April 17, 2010 4:55 
PM -0700):

> On Sat, Apr 17, 2010 at 4:46 PM, James Bucanek  
> wrote:
> > The path "/Dinah" is (obviously) invalid.
> 
> Actually, it's annoyingly not invalid. Finder > Go To URL > "/Dinah"
> will actually work. It really stinks if you mount a volume named
> something like "Users"... >:(

I would not have thought to do that. :)

Nevertheless, what I'm really interested in is whether

[[NSFileManager defaultManager] attributesOfFileSystemForPath:@"/Dinah" 
error:NULL]

works, which it doesn't; it returns nil. And there's no equivalent URL-based 
API that I can find.

> Please add to the pile of bugs on this issue.

Will do.

-- 
James Bucanek

___

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

Please do not post admin requests or moderator comments to the list.
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: Introspecting the current method

2010-04-19 Thread Roy Lovejoy
Take a look at __PRETTY_FUNCTION__ - it includes the C++ class or the Obj-C 
class depending..

___

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

Please do not post admin requests or moderator comments to the list.
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: Introspecting the current method

2010-04-19 Thread Michael Ash
On Mon, Apr 19, 2010 at 3:27 AM, Jean-Daniel Dupas
 wrote:
>
> Le 19 avr. 2010 à 04:21, Michael Ash a écrit :
>
>> On Sun, Apr 18, 2010 at 10:15 PM, Dave DeLong  wrote:
>>> Yes, code should obviously be written with this knowledge in mind.  The use 
>>> case I have for it is for macros.  I like to use a debugging macro like the 
>>> following to ensure that methods are getting called (without having to 
>>> break execution to stop at a breakpoint):
>>>
>>> #define LogMethod NSLog(@"-[%@ %...@]", NSStringFromClass([self class]), 
>>> NSStringFromSelector(_cmd))
>>>
>>> This, of course, is only accurate for instance methods (since I'm logging a 
>>> "-").  I was just wondering if there was a way I could use some sort of 
>>> introspection to appropriately place a + or a -.
>>>
>>> I like the ([self class] == self) method, simply because it's shorter, but 
>>> the [[self class] instancesRespondToSelector:_cmd] is also a great solution.
>>
>> The magic __func__ identifier produces a C string which I believe, in
>> an ObjC method, has exactly the format you're looking for.
>>
>> Mike
>
> It is fine for most cases, but __func__ is defined at compile time, and so, 
> does not log the real type of the instance (if this is a subclass).

For me, if you're using this in a logging function, this is a feature,
not a bug. If I'm logging a message like "X is Y, should be Z" then I
want to know what code triggered that, and logging the actual object
type is much less useful for that. If you're interested in the actual
type as well, then I'd say just log that too, like:

NSLog(@"%s:%d %@: %@", __func__, __LINE__, self, yourMessageGoesHere);

Mike
___

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

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

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

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


Re: blocks and autorelease weirdness

2010-04-19 Thread Ken Ferry
On Mon, Apr 19, 2010 at 3:09 AM, Henk Kampman
wrote:

>
> On 19 apr 2010, at 11:41, Jean-Daniel Dupas wrote:
>
> >
> >
> > Le 19 avr. 2010 à 11:35, Henk Kampman a écrit :
> >
> >> Have a look at the following code
> >>
> >> -(void) test
> >> {
> >>  testString = NULL;
> >>
> >>  dispatch_async(dispatch_get_global_queue(0, 0), ^{
> >>  dispatch_async(dispatch_get_main_queue(), ^{
> >>
> >>  NSString* aString = [[NSMutableString alloc] init];
> >>  NSLog(@"retainCount: %d",[aString retainCount]);
> >>
> >>  testString = [aString retain];
> >>
> >>  [aString release];
> >>
> >>  dispatch_async(dispatch_get_main_queue(), ^{
> >>  NSLog(@"retainCount: %d",[testString
> retainCount]);
> >>  });
> >>  });
> >>  });
> >> }
> >>
> >> As expected the output is:
> >>
> >> retainCount: 1
> >> retainCount: 1
> >>
> >> However when I change [aString release] to [aString autorelease] the
> output shows:
> >>
> >> retainCount: 1
> >> retainCount: 2
> >>
> >> Why?
> >>
> >> BTW I first noticed this behavior when my application started leaking
> the QTMovie objects I was creating in a block.
> >>
> >> -
> >
> > Because you should never expect something from retainCount.
> > See archives for details.
>
> Are you sure? I'm not using GC and everything executes within the main
> thread.
>
> In this case the retainCount clearly reflects what I'm seeing in my code!
>
> But lets assume you're correct, it still doesn't explain the memory leak
> when I use autorelease instead of release.
>

Yes, you found something real.

When you use dispatch_async to the global concurrent queue, you are not
executing on the main thread.  Normally in such a situation you need to
create an autorelease pool if you're going to use Cocoa.

It turns out that dispatch creates an autorelease pool of last resort, but
it's not cleared very often, and relying on it is not encouraged.  Dispatch
doesn't want to take the overhead of creating and destroying autorelease
pools every time when some low level systems are not using Objective-C.  If
you work at the NSOperation level, this is handled.

You can clean the memory up more quickly by wrapping your code in an
autorelease pool.

dispatch_async(dispatch_get_global_queue(0, 0), ^{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

// your code

[pool drain];
});


-Ken
Cocoa Frameworks


>
> - Henk
>
> >
> > -- 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/kenferry%40gmail.com
>
> This email sent to kenfe...@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: blocks and autorelease weirdness

2010-04-19 Thread Julien Jalon
And of course, I need some rest:

On Mon, Apr 19, 2010 at 12:38 PM, Julien Jalon  wrote:

> I have to add that *you can't assume* using dispatch_async on main queue
> within an NSApp will automatically drain the autorelease pool.
>
> AppKit drains the autorelease pool upon NSEvents dispatch.
>
>
> On Mon, Apr 19, 2010 at 12:36 PM, Julien Jalon  wrote:
>
>> I don't see anything wrong with the output being 1/2:
>>
>> -(void) test
>> {
>>testString = NULL;
>>
>>dispatch_async(dispatch_get_global_queue(0, 0), ^{
>>dispatch_async(dispatch_get_main_queue(), ^{
>>
>>NSString* aString = [[NSMutableString alloc] init];
>> * // retain count is 1*
>>
>>NSLog(@"retainCount: %d",[aString retainCount]);
>>
>>testString = [aString retain]; *// retain count is
>> 2*
>>
>>[aString *auto*release]; *// retain count is still
>> 2 - object will be released sometimes in the future*
>>
>>
>>dispatch_async(dispatch_get_main_queue(), ^{
>>NSLog(@"retainCount: %d",[testString
>> retainCount]);* // you can't assume the future release has already been
>> called*
>>});
>>});
>>});
>> }
>>
>> On Mon, Apr 19, 2010 at 11:35 AM, Henk Kampman <
>> henk.kamp...@secondmove.com> wrote:
>>
>>> Have a look at the following code
>>>
>>> -(void) test
>>> {
>>>testString = NULL;
>>>
>>>dispatch_async(dispatch_get_global_queue(0, 0), ^{
>>>dispatch_async(dispatch_get_main_queue(), ^{
>>>
>>>NSString* aString = [[NSMutableString alloc]
>>> init];
>>>NSLog(@"retainCount: %d",[aString retainCount]);
>>>
>>>testString = [aString retain];
>>>
>>>[aString release];
>>>
>>>dispatch_async(dispatch_get_main_queue(), ^{
>>>NSLog(@"retainCount: %d",[testString
>>> retainCount]);
>>>});
>>>});
>>>});
>>> }
>>>
>>> As expected the output is:
>>>
>>> retainCount: 1
>>> retainCount: 1
>>>
>>> However when I change [aString release] to [aString autorelease] the
>>> output shows:
>>>
>>> retainCount: 1
>>> retainCount: 2
>>>
>>> Why?
>>>
>>> BTW I first noticed this behavior when my application started leaking the
>>> QTMovie objects I was creating in a block.
>>>
>>> -
>>>
>>> Henk___
>>>
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>>
>>> Please do not post admin requests or moderator comments to the list.
>>> 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: blocks and autorelease weirdness

2010-04-19 Thread Julien Jalon
I have to add that using dispatch_async on main queue within an NSApp will
automatically drain the autorelease pool.

AppKit drains the autorelease pool upon NSEvents dispatch.

On Mon, Apr 19, 2010 at 12:36 PM, Julien Jalon  wrote:

> I don't see anything wrong with the output being 1/2:
>
> -(void) test
> {
>testString = NULL;
>
>dispatch_async(dispatch_get_global_queue(0, 0), ^{
>dispatch_async(dispatch_get_main_queue(), ^{
>
>NSString* aString = [[NSMutableString alloc] init];
> * // retain count is 1*
>
>NSLog(@"retainCount: %d",[aString retainCount]);
>
>testString = [aString retain]; *// retain count is
> 2*
>
>[aString *auto*release]; *// retain count is still
> 2 - object will be released sometimes in the future*
>
>
>dispatch_async(dispatch_get_main_queue(), ^{
>NSLog(@"retainCount: %d",[testString
> retainCount]);* // you can't assume the future release has already been
> called*
>});
>});
>});
> }
>
> On Mon, Apr 19, 2010 at 11:35 AM, Henk Kampman <
> henk.kamp...@secondmove.com> wrote:
>
>> Have a look at the following code
>>
>> -(void) test
>> {
>>testString = NULL;
>>
>>dispatch_async(dispatch_get_global_queue(0, 0), ^{
>>dispatch_async(dispatch_get_main_queue(), ^{
>>
>>NSString* aString = [[NSMutableString alloc] init];
>>NSLog(@"retainCount: %d",[aString retainCount]);
>>
>>testString = [aString retain];
>>
>>[aString release];
>>
>>dispatch_async(dispatch_get_main_queue(), ^{
>>NSLog(@"retainCount: %d",[testString
>> retainCount]);
>>});
>>});
>>});
>> }
>>
>> As expected the output is:
>>
>> retainCount: 1
>> retainCount: 1
>>
>> However when I change [aString release] to [aString autorelease] the
>> output shows:
>>
>> retainCount: 1
>> retainCount: 2
>>
>> Why?
>>
>> BTW I first noticed this behavior when my application started leaking the
>> QTMovie objects I was creating in a block.
>>
>> -
>>
>> Henk___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> 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: blocks and autorelease weirdness

2010-04-19 Thread Julien Jalon
I don't see anything wrong with the output being 1/2:

-(void) test
{
   testString = NULL;

   dispatch_async(dispatch_get_global_queue(0, 0), ^{
   dispatch_async(dispatch_get_main_queue(), ^{

   NSString* aString = [[NSMutableString alloc] init];* //
retain count is 1*
   NSLog(@"retainCount: %d",[aString retainCount]);

   testString = [aString retain]; *// retain count is 2*

   [aString *auto*release]; *// retain count is still 2
- object will be released sometimes in the future*

   dispatch_async(dispatch_get_main_queue(), ^{
   NSLog(@"retainCount: %d",[testString
retainCount]);* // you can't assume the future release has already been
called*
   });
   });
   });
}

On Mon, Apr 19, 2010 at 11:35 AM, Henk Kampman
wrote:

> Have a look at the following code
>
> -(void) test
> {
>testString = NULL;
>
>dispatch_async(dispatch_get_global_queue(0, 0), ^{
>dispatch_async(dispatch_get_main_queue(), ^{
>
>NSString* aString = [[NSMutableString alloc] init];
>NSLog(@"retainCount: %d",[aString retainCount]);
>
>testString = [aString retain];
>
>[aString release];
>
>dispatch_async(dispatch_get_main_queue(), ^{
>NSLog(@"retainCount: %d",[testString
> retainCount]);
>});
>});
>});
> }
>
> As expected the output is:
>
> retainCount: 1
> retainCount: 1
>
> However when I change [aString release] to [aString autorelease] the output
> shows:
>
> retainCount: 1
> retainCount: 2
>
> Why?
>
> BTW I first noticed this behavior when my application started leaking the
> QTMovie objects I was creating in a block.
>
> -
>
> Henk___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> 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: blocks and autorelease weirdness

2010-04-19 Thread Henk Kampman

On 19 apr 2010, at 11:41, Jean-Daniel Dupas wrote:

> 
> 
> Le 19 avr. 2010 à 11:35, Henk Kampman a écrit :
> 
>> Have a look at the following code
>> 
>> -(void) test
>> {
>>  testString = NULL;
>>  
>>  dispatch_async(dispatch_get_global_queue(0, 0), ^{
>>  dispatch_async(dispatch_get_main_queue(), ^{
>>  
>>  NSString* aString = [[NSMutableString alloc] init];
>>  NSLog(@"retainCount: %d",[aString retainCount]);
>>  
>>  testString = [aString retain];
>>  
>>  [aString release];
>>  
>>  dispatch_async(dispatch_get_main_queue(), ^{
>>  NSLog(@"retainCount: %d",[testString 
>> retainCount]);
>>  });
>>  });
>>  });
>> }
>> 
>> As expected the output is:
>> 
>> retainCount: 1
>> retainCount: 1
>> 
>> However when I change [aString release] to [aString autorelease] the output 
>> shows:
>> 
>> retainCount: 1
>> retainCount: 2
>> 
>> Why?
>> 
>> BTW I first noticed this behavior when my application started leaking the 
>> QTMovie objects I was creating in a block.
>> 
>> -
> 
> Because you should never expect something from retainCount.
> See archives for details.

Are you sure? I'm not using GC and everything executes within the main thread.

In this case the retainCount clearly reflects what I'm seeing in my code!

But lets assume you're correct, it still doesn't explain the memory leak when I 
use autorelease instead of release.


- Henk

> 
> -- 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: blocks and autorelease weirdness

2010-04-19 Thread Jean-Daniel Dupas


Le 19 avr. 2010 à 11:35, Henk Kampman a écrit :

> Have a look at the following code
> 
> -(void) test
> {
>   testString = NULL;
>   
>   dispatch_async(dispatch_get_global_queue(0, 0), ^{
>   dispatch_async(dispatch_get_main_queue(), ^{
>   
>   NSString* aString = [[NSMutableString alloc] init];
>   NSLog(@"retainCount: %d",[aString retainCount]);
>   
>   testString = [aString retain];
>   
>   [aString release];
>   
>   dispatch_async(dispatch_get_main_queue(), ^{
>   NSLog(@"retainCount: %d",[testString 
> retainCount]);
>   });
>   });
>   });
> }
> 
> As expected the output is:
> 
> retainCount: 1
> retainCount: 1
> 
> However when I change [aString release] to [aString autorelease] the output 
> shows:
> 
> retainCount: 1
> retainCount: 2
> 
> Why?
> 
> BTW I first noticed this behavior when my application started leaking the 
> QTMovie objects I was creating in a block.
> 
> -

Because you should never expect something from retainCount.
See archives for details.

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


blocks and autorelease weirdness

2010-04-19 Thread Henk Kampman
Have a look at the following code

-(void) test
{
testString = NULL;

dispatch_async(dispatch_get_global_queue(0, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{

NSString* aString = [[NSMutableString alloc] init];
NSLog(@"retainCount: %d",[aString retainCount]);

testString = [aString retain];

[aString release];

dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"retainCount: %d",[testString 
retainCount]);
});
});
});
}

As expected the output is:

retainCount: 1
retainCount: 1

However when I change [aString release] to [aString autorelease] the output 
shows:

retainCount: 1
retainCount: 2

Why?

BTW I first noticed this behavior when my application started leaking the 
QTMovie objects I was creating in a block.

-

Henk___

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

Please do not post admin requests or moderator comments to the list.
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: Introspecting the current method

2010-04-19 Thread Jack Nutting
On Mon, Apr 19, 2010 at 9:27 AM, Jean-Daniel Dupas
 wrote:
> It is fine for most cases, but __func__ is defined at compile time, and so, 
> does not log the real type of the instance (if this is a subclass).
>

Hmmm, that's too bad.  Seems to be the case for __FUNCTION__ and
__PRETTY_FUNCTION__ as well;  All of them produce the appropriate + or
-, but they also all show the name of the class where the method is
defined, even if called on a subclass.

-- 
// jack
// http://nuthole.com
// http://learncocoa.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: Introspecting the current method

2010-04-19 Thread Jean-Daniel Dupas

Le 19 avr. 2010 à 04:21, Michael Ash a écrit :

> On Sun, Apr 18, 2010 at 10:15 PM, Dave DeLong  wrote:
>> Yes, code should obviously be written with this knowledge in mind.  The use 
>> case I have for it is for macros.  I like to use a debugging macro like the 
>> following to ensure that methods are getting called (without having to break 
>> execution to stop at a breakpoint):
>> 
>> #define LogMethod NSLog(@"-[%@ %...@]", NSStringFromClass([self class]), 
>> NSStringFromSelector(_cmd))
>> 
>> This, of course, is only accurate for instance methods (since I'm logging a 
>> "-").  I was just wondering if there was a way I could use some sort of 
>> introspection to appropriately place a + or a -.
>> 
>> I like the ([self class] == self) method, simply because it's shorter, but 
>> the [[self class] instancesRespondToSelector:_cmd] is also a great solution.
> 
> The magic __func__ identifier produces a C string which I believe, in
> an ObjC method, has exactly the format you're looking for.
> 
> Mike

It is fine for most cases, but __func__ is defined at compile time, and so, 
does not log the real type of the instance (if this is a subclass). 


-- 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: Carbon is C++?

2010-04-19 Thread Ken Ferry
On Mon, Mar 1, 2010 at 4:03 AM, Greg Parker  wrote:

> On Feb 28, 2010, at 7:24 PM, Erik Buck wrote:
> > I disagree.  I have written very low latency device drivers in
> Objective-C.  Why do you think Objective-C has too much "latency" for audio?
>  When properly used, Objective-C programs are no more likely to be preempted
> than any other kind of program.  Message dispatch generally has constant
> time and is only 2.5 times the cost of a C function call.  There aren't many
> function calls or messages sent in audio processing anyway.  Signal
> processing routines tend to be long loops.  Objective-C _IS_ C which means
> it is likely usable in any situation where C is usable.
>
> Message dispatch is generally fast. For many real-time-ish purposes that's
> good enough. But occasionally message dispatch (1) takes much longer, and
> (2) acquires locks. For some real-time-ish purposes, this sort of surprise
> is fatal when it occurs. Since there's no way for the program to control
> when dispatch is fast and when it is slow, clients with sufficiently tight
> "no surprises" requirements should avoid it altogether. If your requirements
> are demanding enough that you can't call malloc(), then you probably can't
> call objc_msgSend() either.
>
> It's the locks that kill. With care, a real-time-ish thread can pretty much
> solve problems of page faults and scheduling and the like. But the moment
> you take a lock, you're at the mercy of some other thread that may not be so
> careful.
>
> Audio clients tend to be the most paranoid about this on Mac OS X. They're
> the closest to truly-real-time requirements that I see, with good reason: if
> your audio playback skips, ever, you probably just lost a customer.
>

Just for those who haven't already noticed this interesting detail, audio is
more constrained than video.  If your movie skips a frame?  You probably
cannot tell.  If your audio drops?  Urgh!

-Ken


>
>
> --
> Greg Parker gpar...@apple.com Runtime Wrangler
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com
>
> This email sent to kenfe...@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: Warning with an initializer method of AMWorkflow

2010-04-19 Thread Mark Munz
I haven't run into this in such a long time that I completely forgot
this could still occur. While I do wish it wasn't necessary to do the
cast, it does solve the problem.

So this works as expected:

AMWorkflow* workflow = [ (AMWorkflow*)[AMWorkflow alloc]
initWithContentsOfURL:fileURL error:&createError];

Thanks for the memory jog.

Mark

On Sun, Apr 18, 2010 at 1:01 PM, Ken Thomases  wrote:
> On Apr 18, 2010, at 2:56 PM, Mark Munz wrote:
>
>> If I try to create an AMWorkflow using the initContentsWithURL:error:
>> method, I get a warning.
>
>> warning: incompatible Objective-C types 'struct NSError **', expected
>> 'struct NSDictionary **' when passing argument 2 of
>> 'initWithContentsOfURL:error:' from distinct Objective-C type
>>
>> The 2nd parameter is documented as NSError** as documented in AMWorkflow.h
>>
>> - (id)initWithContentsOfURL:(NSURL *)fileURL error:(NSError **)outError;
>>
>> This appears to happen with either the 10.5 SDK or 10.6 SDK.
>> I've logged this bug ID# 7877547
>>
>> I'd like to know how safe it is to ignore the warning or typecast to
>> remove the warning?
>
> This is the same issue as in this recent thread 
> .  There is 
> a typecast involved in the solution, but probably not the one you're 
> considering.
>
> Cheers,
> Ken
>
>



-- 
Mark Munz
unmarked software
http://www.unmarked.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