Re: Using the security framework

2009-01-25 Thread Kyle Sluder
On Sat, Jan 24, 2009 at 9:29 PM, Michael Ash  wrote:
> I'm afraid I don't understand this advice. Could you explain what sort
> of vulnerability would exist in a custom install tool that would not
> exist when using Installer.app to install a custom package?

It's vulnerable to a timing flaw.  In order to securely install a
helper tool, the installation process must run as root.  In order to
securely install an installer that runs as root, the installer
installer must run as root.  In order to...

Installer.app solves this problem because it's preconfigured to be
secure.  You can invoke it to do the privileged installation for you
without opening yourself up to the possibility that in between copying
the file and its later invocation that its contents have been changed.

--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: Coverflow like background drawing?

2009-01-25 Thread Kyle Sluder
On Sat, Jan 24, 2009 at 7:10 PM, Alex Kac  wrote:
> UIKit/AppKit are not thread-safe meaning we should never do drawing on a
> background thread. Yet, if we have say 5 views and for performance reasons
> we want the main view to draw first and then the other 4 to draw in the
> background like how CoverFlow will draw its icons/images seemingly in the
> background, how does one do that?

1) Are you sure you want to use separate views for each item in your
CoverFlow-esque interface?  You could use layers or cells.

2) Perform all your loading and rendering into an offscreen image and
then use performSelectorOnMainThread: to schedule the drawing for the
next runloop iteration.  You get all the benefits of multithreading
the I/O bound portion of your code.  Yes, you still have to do the
pixel-pushing on the main thread but that's an artifact of the
architecture.

--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: Not Resolving Aliases

2009-01-25 Thread Gerriet M. Denkmann


On 25 Jan 2009, at 09:31, Michael Ash  wrote:



On Sat, Jan 24, 2009 at 9:54 AM, Gerriet M. Denkmann
 wrote:


When I do:

[ sharedWorkspace openFile: @"/path/to/symlink"  withApplication:  
@"SomeApp"

]

then "SomeApp" does NOT get "/path/to/symlink" but the content of the
symlink.
Same for Aliases.

Is there a way to open a path without resolving aliases?


I haven't tried it, but I would bet that if you use LaunchServices
directly then it will do what you say instead of trying to do what you
mean.


I tried LSOpenURLsWithRole but it resolves symbolic links. And returns  
fnfErr = File not found for broken symlinks.


Anything else I could try?

Kind regards,

Gerriet.

___

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

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

2009-01-25 Thread Gerriet M. Denkmann


On 25 Jan 2009, at 09:31, Rob Keniger  wrote:


On 24/01/2009, at 11:46 PM, Gerriet M. Denkmann wrote:


I have a text file, called Text.
I did in Terminal:
ln -s Text SymlinkToText

When I try to open SymlinkToText in TextEdit "SymlinkToText" is
shown in the Open Panel, but when I select it, the "Open"-button is
disabled.

Is this a bug or a feature (in 10.5.6) ?
I believe this did work in Tiger, but have no machine to test this.


Call [yourOpenPanel setResolvesAliases:YES] to make an open panel
resolve aliases/symlinks.


Is there any way in an document based Cocoa app to tell the  
NSDocumentController what options to use when it gets sent the  
openDocument: message?

Like ResolvesAliases = YES or CanChooseDirectories = YES.

Kind regards,

Gerriet.

___

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

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

2009-01-25 Thread Gerriet M. Denkmann


On 25 Jan 2009, at 09:31, Rob Keniger  wrote:


On 24/01/2009, at 11:40 PM, Gerriet M. Denkmann wrote:


I want my NSOpenPanel to show all files - same as the Finder does,
if one adds AppleShowAllFiles = YES to: ~/Library/Preferences/
com.apple.finder.plist.

Is there a way to accomplish this?

Kind regards,

Gerriet.


Yes, just set AppleShowAllFiles to YES in your app's defaults.


I just added this to my app delegate:
+ (void)initialize
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
	NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:  
@"YES" forKey: @"AppleShowAllFiles"];

[defaults registerDefaults:appDefaults];
}

and now everything works as expected.
Thanks very much for this suggestion!

By the way, this is documented in "Mac OS X Leopard Developer Release  
Notes

Cocoa Application Framework":
"NSSavePanel and NSOpenPanel can once again show hidden files by  
setting a user default. For instance you can use 'defaults write -g  
AppleShowAllFiles 1' to display hidden files in the panels."


Kind regards,

Gerriet.

___

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

Please do not post admin requests or moderator comments to the list.
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: Forcing allocation of a subclass

2009-01-25 Thread João Varela

Olá António

I think your method must be corrected like this:


On 2009/01/25, at 07:28, cocoa-dev-requ...@lists.apple.com wrote:


@implementation PDFDocument (PDFDocument_Alloc)

+ (id)replacementAllocWithZone:(NSZone *)zone
{
if ([self class] == [PDFDocument class]) {
return [ANPDFDocument replacementAllocWithZone:zone];
} else {
return [super allocWithZone:zone];
}
}



Note that you have to invoke the class method of self in order to  
compare it properly. Otherwise you are comparing a pointer to a class  
and the class name, which is the same as comparing apples with  
oranges. For further information read the introspection chapter in the  
Cocoa Fundamentals Guide:


http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_7.html

HTH

Joao Varela

___

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

Please do not post admin requests or moderator comments to the list.
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: Forcing allocation of a subclass

2009-01-25 Thread Jean-Daniel Dupas


Le 25 janv. 09 à 14:50, João Varela a écrit :


Olá António

I think your method must be corrected like this:


On 2009/01/25, at 07:28, cocoa-dev-requ...@lists.apple.com wrote:


@implementation PDFDocument (PDFDocument_Alloc)

+ (id)replacementAllocWithZone:(NSZone *)zone
{
if ([self class] == [PDFDocument class]) {
return [ANPDFDocument replacementAllocWithZone:zone];
} else {
return [super allocWithZone:zone];
}
}



Note that you have to invoke the class method of self in order to  
compare it properly. Otherwise you are comparing a pointer to a  
class and the class name, which is the same as comparing apples with  
oranges. For further information read the introspection chapter in  
the Cocoa Fundamentals Guide:




'self' is a Class object as it's a class method, and +[NSObject Class]  
also return a Class (and not a class name).


I don't understand the issues and saw nothing about it in the link you  
provide.



http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_7.html


___

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

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

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

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


Re: Forcing allocation of a subclass

2009-01-25 Thread Jean-Daniel Dupas


Le 25 janv. 09 à 14:50, João Varela a écrit :


Olá António

I think your method must be corrected like this:


On 2009/01/25, at 07:28, cocoa-dev-requ...@lists.apple.com wrote:


@implementation PDFDocument (PDFDocument_Alloc)

+ (id)replacementAllocWithZone:(NSZone *)zone
{
if ([self class] == [PDFDocument class]) {
return [ANPDFDocument replacementAllocWithZone:zone];
} else {
return [super allocWithZone:zone];
}
}



Note that you have to invoke the class method of self in order to  
compare it properly. Otherwise you are comparing a pointer to a  
class and the class name, which is the same as comparing apples with  
oranges. For further information read the introspection chapter in  
the Cocoa Fundamentals Guide:


http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_7.html


Have a look at the +[NSObject initialize] reference for example:

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html#/ 
/apple_ref/occ/clm/NSObject/initialize


@implementation MyClass
+ (void)initialize
{
if ( self == [MyClass class] ) {
/* put initialization code here */
}
}___

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

Please do not post admin requests or moderator comments to the list.
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: Forcing allocation of a subclass

2009-01-25 Thread João Varela

Hi Jean-Daniel

Yes, when I re-read what I wrote I know it can cause confusion. Of  
course 'self' is a pointer to a class instance, not to a class, but I  
didn't know that 'self' was itself a method. Can you point me to the  
documentation where that is written? Of course "+ [NSObject class]"  
returns a class, not a class name (my bad). I said what I said based  
on listing 2-7 of the page I mentioned, but I now realize there is a  
slight difference with what Antonio has posted.


So you mean that

if ( self == [aReceiver class] )

is the same as

if ( [self class] == [aReceiver class] ) ?

If it is, sorry for the noise, but I would find it weird that a  
pointer to a class instance also had the same end result as invoking  
the NSObject method 'class'. Is it?


JV




On 2009/01/25, at 14:07, Jean-Daniel Dupas wrote:



Le 25 janv. 09 à 14:50, João Varela a écrit :


Olá António

I think your method must be corrected like this:


On 2009/01/25, at 07:28, cocoa-dev-requ...@lists.apple.com wrote:


@implementation PDFDocument (PDFDocument_Alloc)

+ (id)replacementAllocWithZone:(NSZone *)zone
{
if ([self class] == [PDFDocument class]) {
return [ANPDFDocument replacementAllocWithZone:zone];
} else {
return [super allocWithZone:zone];
}
}



Note that you have to invoke the class method of self in order to  
compare it properly. Otherwise you are comparing a pointer to a  
class and the class name, which is the same as comparing apples  
with oranges. For further information read the introspection  
chapter in the Cocoa Fundamentals Guide:




'self' is a Class object as it's a class method, and +[NSObject  
Class] also return a Class (and not a class name).


I don't understand the issues and saw nothing about it in the link  
you provide.



http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_7.html






___

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

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

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

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


Re: addSubview bottleneck

2009-01-25 Thread Michael Ash
On Sat, Jan 24, 2009 at 5:29 PM, Twisted Theory
 wrote:
> Hi,
>
> I am constructing an application that draws rooted trees (graphs with a
> distinguished 'first' node) by creating an NSView subclass for each node and
> adding them as subviews of the graph view.
>
> There is a big problem when the number of nodes in the tree is large: adding
> the subviews takes a very long time.  For example, one of my trees has
> around 60,000 nodes.  It takes about 1.5 seconds to create all of the
> objects, and about 200 seconds to add them as subviews.
>
> Can anyone suggest a way to speed the process up?  Multithreading didn't
> really improve matters.

As always, profile the code first, see what's slow, and then you can
see what area you need to target to make it faster.

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: Using the security framework

2009-01-25 Thread Michael Ash
On Sun, Jan 25, 2009 at 12:54 AM, Chris Hanson  wrote:
> On Jan 24, 2009, at 6:29 PM, Michael Ash wrote:
>
>> On Sat, Jan 24, 2009 at 6:08 PM, Chris Hanson  wrote:
>>>
>>> Among other things, to be truly secure you must use a secure installation
>>> mechanism.  Do not write your own install tool — it can't be made secure
>>> without itself being installed via a secure installation mechanism.
>>> Instead, use Installer.app for your installations since it's included
>>> with
>>> the operating system and not modifiable with normal user privileges.
>>
>> I'm afraid I don't understand this advice. Could you explain what sort
>> of vulnerability would exist in a custom install tool that would not
>> exist when using Installer.app to install a custom package?
>
> Because Installer.app is installed by the operating system you can - if
> you've taken appropriate security measures to begin with - be reasonably
> certain that it hasn't been tampered with.
>
> When writing your own install tool, you have a bootstrapping problem:  You
> will eventually need to have the user authorize some untrusted code to run
> as root - code that could have been modified behind the user's back.
>
> An installer package could also have been writable by the user, but modern
> packages can be signed so their integrity can be checked.

So could a custom installer. It seems to me that the problem of
protecting a custom installer and the problem of protecting a custom
package being used with the system installer are equivalent. Is there
a way that a custom binary can be tampered with that a custom .pkg is
immune to?

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: Forcing allocation of a subclass

2009-01-25 Thread Jean-Daniel Dupas


Le 25 janv. 09 à 15:31, João Varela a écrit :


Hi Jean-Daniel

Yes, when I re-read what I wrote I know it can cause confusion. Of  
course 'self' is a pointer to a class instance, not to a class, but  
I didn't know that 'self' was itself a method.



No, self is not a method, it's a parameter.

Obj-C methods have two hidden parameters (at least with the Apple  
runtime) : id self, SEL _cmd.

In a class method, they are equivalent to : Class self, SEL _cmd.

Can you point me to the documentation where that is written? Of  
course "+ [NSObject class]" returns a class, not a class name (my  
bad). I said what I said based on listing 2-7 of the page I  
mentioned, but I now realize there is a slight difference with what  
Antonio has posted.


So you mean that

if ( self == [aReceiver class] )

is the same as

if ( [self class] == [aReceiver class] ) ?



Yes it is.


Just a simple snippet to try to help you to understand.

We are ok to say that in a method, self represents the receiver.

Now have a look at this call:

[PDFDocument allocWithZone:nil]

You are ok to say that it is equivalents to:

[[PDFDocument class] allocWithZone:nil]

With the second form, you clearly see here that the receiver is  
[PDFDocument class]. And as self is the receiver,  (self ==  
[PDFDocument class]) is perfectly valid to test class equality.



___

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

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

2009-01-25 Thread Michael Ash
On Sun, Jan 25, 2009 at 3:19 AM, Kyle Sluder  wrote:
> On Sat, Jan 24, 2009 at 9:29 PM, Michael Ash  wrote:
>> I'm afraid I don't understand this advice. Could you explain what sort
>> of vulnerability would exist in a custom install tool that would not
>> exist when using Installer.app to install a custom package?
>
> It's vulnerable to a timing flaw.  In order to securely install a
> helper tool, the installation process must run as root.  In order to
> securely install an installer that runs as root, the installer
> installer must run as root.  In order to...
>
> Installer.app solves this problem because it's preconfigured to be
> secure.  You can invoke it to do the privileged installation for you
> without opening yourself up to the possibility that in between copying
> the file and its later invocation that its contents have been changed.

Instead of opening yourself up to the possibility that the contents of
the installer binary have been changed, you open yourself up to the
possibility that the contents of the installer .pkg have been changed.
Doesn't seem any better to me.

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: Forcing allocation of a subclass

2009-01-25 Thread Michael Ash
On Sun, Jan 25, 2009 at 9:31 AM, João Varela  wrote:
> Hi Jean-Daniel
>
> Yes, when I re-read what I wrote I know it can cause confusion. Of course
> 'self' is a pointer to a class instance, not to a class, but I didn't know
> that 'self' was itself a method. Can you point me to the documentation where
> that is written? Of course "+ [NSObject class]" returns a class, not a class
> name (my bad). I said what I said based on listing 2-7 of the page I
> mentioned, but I now realize there is a slight difference with what Antonio
> has posted.
>
> So you mean that
>
> if ( self == [aReceiver class] )
>
> is the same as
>
> if ( [self class] == [aReceiver class] ) ?
>
> If it is, sorry for the noise, but I would find it weird that a pointer to a
> class instance also had the same end result as invoking the NSObject method
> 'class'. Is it?

They are the same *if you are in a class method*.

If the above is in an instance method then no, they are not the same.
The first one will, in fact, never be true.

But if you're in a class method, then 'self' is the class. [self
class] == self in a class method, unless someone has overridden
+class.

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: Knowing when a NSArrayController is ready

2009-01-25 Thread jonat...@mugginsoft.com


On 24 Jan 2009, at 18:41, Matt Neuburg wrote:


On or about 1/24/09 10:17 AM, thus spake "jonat...@mugginsoft.com"
:


I am also having horrible performance problems.
A data set of 1500 items with a total on disk size of 1.8MB is taking
more than 30 secs to load.
Maybe NSArrayController -fetchWithRequest will improve things.


I would ask you the same question I just asked someone else on the  
list: are
you using the XML persistent storage format? Because, if so, you  
must expect
some delay, since even before you fetch any objects the entire XML  
file must

be loaded into memory and parsed.

I use XML because I want human readability for my data, so startup  
speed is
a sacrifice I am prepared to make. My data consists of about 5000  
items, but
they are very simple; dealing with complex objects would take  
considerably
longer, one assumes. In order to cave-man-instrument the startup  
procedure

via NSLog, I do NOT prepare content or even bind my array controller's
managed object content in the nib; instead, I do it all manually in
awakeFromNib. Here are some NSLog timings:

2009-01-24 10:37:09.157 [788] awakening from nib
2009-01-24 10:37:09.269 [788] binding to MOC
2009-01-24 10:37:09.359 [788] creating whole shebang
2009-01-24 10:37:09.360 [788] adding persistent store
2009-01-24 10:37:13.877 [788] calling fetch
2009-01-24 10:37:14.192 [788] done calling fetch

Notice the big delay between "adding persistent store" and "calling  
fetch";
that consists a single line of code (calling  
addPersistentStoreWithType:).
So the delay there is nothing but the XML file being loaded and  
parsed. m.


Hi Matt

I decided to follow your example so I set prepareContent = NO and  
called -fetchWithRequest:merge:error: from my controller.
I also switched between the XML and SQLite store types to see the  
effect.

I also made use of -setUsesLazyFetching.
Timings are Cro-magnon.

The results for a default fetch on a data set of 1500 very simple  
objects are:


XML - usesLazyFetching = NO  38.00 sec load
XML - usesLazyFetching = YES  4.78 sec load

SQLite - usesLazyFetching = NO  35.25 sec load
SQLite - usesLazyFetching = NO  2.07 sec load

So I started with a fetch time of 38s and reduced it to 2 secs without  
making any changes to my model code.


I also checked the -arrangedObjects observation on the  
NSArrayController in this configuration.

I only get one notification generated before the fetch returns.
There is a subsequent notification but that results from sorting the  
content.


Jonathan Mitchell

Central Conscious Unit
http://www.mugginsoft.com




___

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

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

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

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


Re: Knowing when a NSArrayController is ready

2009-01-25 Thread Matt Neuburg
On or about 1/25/09 8:08 AM, thus spake "jonat...@mugginsoft.com"
:

> I also made use of -setUsesLazyFetching.

Not an option for me, alas, as my app must run on Tiger. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, http://tinyurl.com/2ouo3b
Take Control of Customizing Leopard, http://tinyurl.com/2t9629
TidBITS, Mac news and reviews since 1990, http://www.tidbits.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


How to know that DOMHTMLElement is loaded?

2009-01-25 Thread Vitaly Ovchinnikov
Hello all,

I use WebView to print reports and have to change its contents on the
fly via DOMHTMLElement's -setInnerHTML method (I have accessory
control that allows to select what to print). HTML strings that I use
may have images, WebView loads them in background and I need to wait
until they are loaded before start printing.

WebView allows to register some delegates and posts some
notifications, but none of them seems to work for changes via DOM.
Does somebody know the correct way to make sure that WebView loaded
all what it needs?

Thank you.
___

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

Please do not post admin requests or moderator comments to the list.
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: NSRunloop performSelector needs CFRunLoopWakeUp ?

2009-01-25 Thread David Hoerl
Thanks to those who have posted on this, and suggested workarounds. 
However, in a simple non-threaded app, this call should work, no? And 
perhaps the 0 time timer would also suffer the same fate.


The project has a checkbox so the user can enable the CFWakeup.

To convince myself this was not caused by some other part of my code, 
I created a bare bones project with a NSApp delegate, that uses two 
methods to post the performSelector and the other to responds to it.


The project is on my idisk, and is called RunLoopWoes.zip:

http://idisk.mac.com/dhoerl-Public

Also, I did post a bug on the problem along with the sample project: 
.


If someone has the time to independently verify that in fact this 
issue occurs on another system (and its not due to some defect in my 
system) that would be just great (and please let me know!).


David


PS: well, I re-read the Threading Programming Guide, and I saw 
"performSelectorOnMainThread", so tried it in my demo project. Bingo, 
it works as expected:


 [self performSelectorOnMainThread:@selector(getNextTask) 
withObject:nil waitUntilDone:NO];


Also, this worked too:

 [self performSelector:@selector(getNextFrame) withObject:nil afterDelay:0.0];

Both of these methods essentially queue the selector so it will be 
sent during the next run loop cycle, and NOT cause it to be executed 
immediately. It would appear that both are thread safe too.

___

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

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


Class introspection [was Re: Forcing allocation of a subclass]

2009-01-25 Thread João Varela



So you mean that

if ( self == [aReceiver class] )

is the same as

if ( [self class] == [aReceiver class] ) ?



Yes it is.


Just a simple snippet to try to help you to understand.

We are ok to say that in a method, self represents the receiver.

Now have a look at this call:

[PDFDocument allocWithZone:nil]

You are ok to say that it is equivalents to:

[[PDFDocument class] allocWithZone:nil]

With the second form, you clearly see here that the receiver is  
[PDFDocument class]. And as self is the receiver,  (self ==  
[PDFDocument class]) is perfectly valid to test class equality.




Hmm...

I think this example does not cover my doubt expressed above. I  
actually now think that both examples I wrote above are wrong or at  
least semantically wrong.


The thing is: 'self' is a pointer to class instance and of course an  
actual parameter for the Obj-C runtime routines.


The example you gave is that you are talking about class methods that  
do not and should not be used with pointers to class instances but to  
receivers that are class names (in your example 'PDFDocument') or  
class objects returned by, using your example, [PDFDocument class]. As  
far as I know class objects and class instances are two different  
things.


I think the following comparison is semantically wrong:

if ( self == [MyClass class] )

This statement is comparing a pointer to an object instance (self) to  
a MyClass object (returned by the invocation of +[NSObject class]  
method) and these are two different animals altogether, unless the Obj- 
C runtime deals with this and does the right thing.


My fix is actually semantically wrong too:

if ( [self class] == [myClass class] )

because I am using a receiver (self) that should be a class name (but  
it is a pointer to a class instance) in a class method, whose receiver  
must be a class name or a class object.


Actually the fix should have been:

if ( [self isKindOfClass:[myClass class]] )

because in this case -isKindOfClass is an instance method whose  
receiver is a class instance, not a class object.


If my reasoning is not correct then the Obj-C runtime is rather messy,  
which I think that is not the case.


JV





___

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

Please do not post admin requests or moderator comments to the list.
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: Class introspection [was Re: Forcing allocation of a subclass]

2009-01-25 Thread mmalc Crawford


On Jan 25, 2009, at 10:02 AM, João Varela wrote:


I think the following comparison is semantically wrong:
if ( self == [MyClass class] )




mmalc

___

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

Please do not post admin requests or moderator comments to the list.
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: Class introspection [was Re: Forcing allocation of a subclass]

2009-01-25 Thread João Varela


On 2009/01/25, at 18:02, João Varela wrote:




So you mean that

if ( self == [aReceiver class] )

is the same as

if ( [self class] == [aReceiver class] ) ?



Yes it is.


Just a simple snippet to try to help you to understand.

We are ok to say that in a method, self represents the receiver.

Now have a look at this call:

[PDFDocument allocWithZone:nil]

You are ok to say that it is equivalents to:

[[PDFDocument class] allocWithZone:nil]

With the second form, you clearly see here that the receiver is  
[PDFDocument class]. And as self is the receiver,  (self ==  
[PDFDocument class]) is perfectly valid to test class equality.




Hmm...

I think this example does not cover my doubt expressed above. I  
actually now think that both examples I wrote above are wrong or at  
least semantically wrong.


The thing is: 'self' is a pointer to class instance and of course an  
actual parameter for the Obj-C runtime routines.


The example you gave is that you are talking about class methods  
that do not and should not be used with pointers to class instances  
but to receivers that are class names (in your example  
'PDFDocument') or class objects returned by, using your example,  
[PDFDocument class]. As far as I know class objects and class  
instances are two different things.


I think the following comparison is semantically wrong:

if ( self == [MyClass class] )

This statement is comparing a pointer to an object instance (self)  
to a MyClass object (returned by the invocation of +[NSObject class]  
method) and these are two different animals altogether, unless the  
Obj-C runtime deals with this and does the right thing.


My fix is actually semantically wrong too:

if ( [self class] == [myClass class] )

because I am using a receiver (self) that should be a class name  
(but it is a pointer to a class instance) in a class method, whose  
receiver must be a class name or a class object.


Actually the fix should have been:

if ( [self isKindOfClass:[myClass class]] )

because in this case -isKindOfClass is an instance method whose  
receiver is a class instance, not a class object.


If my reasoning is not correct then the Obj-C runtime is rather  
messy, which I think that is not the case.


JV



OK, to answer myself I just checked and the 'class' method can also be  
an instance method of NSObject objects. That explains everything. So



if ( [self class] == [myClass class] )


is as correct as


if ( [self isKindOfClass:[myClass class]] )


because in the first example we are calling -class: in [self class]  
and on the right we are calling +class: in [MyClass class]. This  
actually surprises me. Even though the +class: method is a NSObject  
class method and -class: is part of the NSObject protocol. How is that  
possible there is no collision between these two methods. Isn't that a  
case of overloading???


JV




___

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

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


Dates of the Chinese New Year

2009-01-25 Thread Kevin Ross

Hello everyone,

I see that in the docs that the Chinese calendar is not supported on  
10.4-5.  Does anyone know if one of the other calendars  
(NSBuddhistCalendar or NSJapaneseCalendar maybe?) would be able to  
find the beginning of the Chinese New Year?


Any insights would be much appreciated!



Kevin
___

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

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

2009-01-25 Thread Ashley Perrien
Is there a way to get the color of a pixel or area of an NSView during  
the drawRect method? I'll be tiling the view with a grid of random  
colors but each tile is based on the colors around it. I'd prefer to  
call something along the lines of:


NSColor *aColor = [myView colorAtPoint: somePoint];

Rather than creating and filling a potentially quite large array of  
colors.


-Ashley
___

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

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


CFHTTP +authentication

2009-01-25 Thread John Michael Zorko


Hello, all ...

I guess this is more of a Core Foundation question, but it still  
seemed more apropos to this list than Carbon-dev.  Please let me know  
if i'm wrong :-)


I'm trying to handle URLs in this format:

http://:@this.url.com/content

... with the  and  filled in of course.  I found that  
NSURLConnection handled these for me, but for reasons beyond the scope  
of this question, NSURLConnection isn't a good choice for what i'm  
trying to do, so i'm using CFNetwork stuff.  I've a question, though:


1. How do I get the HTTP return code?  I use  
CFHTTPMessageCreateRequest() to create the GET request, and  
CFReadStreamCreateForHTTPRequest() to create a CFReadStream for said  
request.  How do I get the response of the request?


Regards,

John

Falling You - exploring the beauty of voice and sound
http://www.fallingyou.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 pixel color from NSView

2009-01-25 Thread Volker in Lists

Hi,

one possibility, even so I doubt it is the most elegant, is to create  
a BitmapRepresentation of the view and get the color from this image.  
More elegant would be, if you would be able to use the information  
from the "tiling method", for example by storing the random colors in  
an array of kind.


Maybe some details on how you create the tiles would be helpful?

Cheers, Volker

Am 25.01.2009 um 20:06 schrieb Ashley Perrien:

Is there a way to get the color of a pixel or area of an NSView  
during the drawRect method? I'll be tiling the view with a grid of  
random colors but each tile is based on the colors around it. I'd  
prefer to call something along the lines of:


NSColor *aColor = [myView colorAtPoint: somePoint];

Rather than creating and filling a potentially quite large array of  
colors.


-Ashley

___

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

Please do not post admin requests or moderator comments to the list.
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: Class introspection [was Re: Forcing allocation of a subclass]

2009-01-25 Thread Jean-Daniel Dupas


Le 25 janv. 09 à 19:54, João Varela a écrit :



On 2009/01/25, at 18:02, João Varela wrote:




So you mean that

if ( self == [aReceiver class] )

is the same as

if ( [self class] == [aReceiver class] ) ?



Yes it is.


Just a simple snippet to try to help you to understand.

We are ok to say that in a method, self represents the receiver.

Now have a look at this call:

[PDFDocument allocWithZone:nil]

You are ok to say that it is equivalents to:

[[PDFDocument class] allocWithZone:nil]

With the second form, you clearly see here that the receiver is  
[PDFDocument class]. And as self is the receiver,  (self ==  
[PDFDocument class]) is perfectly valid to test class equality.




Hmm...

I think this example does not cover my doubt expressed above. I  
actually now think that both examples I wrote above are wrong or at  
least semantically wrong.


The thing is: 'self' is a pointer to class instance and of course  
an actual parameter for the Obj-C runtime routines.


The example you gave is that you are talking about class methods  
that do not and should not be used with pointers to class instances  
but to receivers that are class names (in your example  
'PDFDocument') or class objects returned by, using your example,  
[PDFDocument class]. As far as I know class objects and class  
instances are two different things.


I think the following comparison is semantically wrong:

if ( self == [MyClass class] )

This statement is comparing a pointer to an object instance (self)  
to a MyClass object (returned by the invocation of +[NSObject  
class] method) and these are two different animals altogether,  
unless the Obj-C runtime deals with this and does the right thing.


My fix is actually semantically wrong too:

if ( [self class] == [myClass class] )

because I am using a receiver (self) that should be a class name  
(but it is a pointer to a class instance) in a class method, whose  
receiver must be a class name or a class object.


Actually the fix should have been:

if ( [self isKindOfClass:[myClass class]] )

because in this case -isKindOfClass is an instance method whose  
receiver is a class instance, not a class object.


If my reasoning is not correct then the Obj-C runtime is rather  
messy, which I think that is not the case.


JV



OK, to answer myself I just checked and the 'class' method can also  
be an instance method of NSObject objects. That explains everything.  
So



if ( [self class] == [myClass class] )


is as correct as


if ( [self isKindOfClass:[myClass class]] )




No, isKindOfClass check for the superclass.  It returns true if self  
class is myClass or a subclass of myClass.

You should use isMemberOfClass: to got something equivalent.

because in the first example we are calling -class: in [self class]  
and on the right we are calling +class: in [MyClass class]. This  
actually surprises me. Even though the +class: method is a NSObject  
class method and -class: is part of the NSObject protocol. How is  
that possible there is no collision between these two methods. Isn't  
that a case of overloading???


It's perfectly legal to have class methods and instance methods with  
the same name.


But there is more:

Methods of the Root Class
All objects, classes and instances alike, need an interface to the  
runtime system. Both class objects and instances should be able to  
introspect about their abilities and to report their place in the  
inheritance hierarchy. It’s the province of the NSObject class to  
provide this interface.


So that NSObject's methods don’t have to be implemented twice—once to  
provide a runtime interface for instances and again to duplicate that  
interface for class objects—class objects are given special  
dispensation to perform instance methods defined in the root class.  
When a class object receives a message that it can’t respond to with a  
class method, the runtime system determines whether there’s a root  
instance method that can respond. The only instance methods that a  
class object can perform are those defined in the root class, and only  
if there’s no class method that can do the job.


For more on this peculiar ability of class objects to perform root  
instance methods, see the NSObject class specification in the  
Foundation framework reference






___

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

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

2009-01-25 Thread John Joyce


On Jan 24, 2009, at 8:31 PM, cocoa-dev-requ...@lists.apple.com wrote:

Not sure what you mean by "capable of running tiger". If you have a  
machine

capable of running Leopard, it should be able to run tiger.


Not true. In general, any Mac requires the latest OS available at the
time it was released. So machines released after the release of
Leopard usually require Leopard.



Not in general. No Mac is supported to run any version of the Mac OS  
earlier than the version it officially shipped with.
If your Mac officially shipped with 10.5.4 it is unsupported to run  
10.5.3 or earlier. Period.
If you do not know, and you may not, call AppleCare, provide the  
serial number of the Mac, they can tell you precisely which version it  
originally shipped with and that will be the earliest version you can  
reliably run on that computer.
Although in some cases you may successfully boot and run some earlier  
version, it is unsupported, meaning it would not be a good test   
environment.


Any Mac that runs Tiger well, will be more than adequate for most  
Tiger development. (exceptions would be targeting higher or lower end  
hardware)

___

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

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

2009-01-25 Thread Alex Kac
Could you use asyncsocket? Its a Cocoa class built using CFNetworking  
and sockets and makes working with NSURL type stuff very very easy.


asyncSocket = [[AsyncSocket alloc] initWithDelegate:self];
[asyncSocket connectToHost:[url host] onPort:80 error:nil];

	CFHTTPMessageRef httpRequest =  
CFHTTPMessageCreateRequest(kCFAllocatorDefault, (CFStringRef)@"POST",  
(CFURLRef)url, kCFHTTPVersion1_1);
	CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("User-Agent"),  
(CFStringRef)@"MyUserAgent");
	CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Content-Type"),  
(CFStringRef)headerfield);
	CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Content- 
Length"), (CFStringRef)[NSString stringWithFormat:@"%d", [data length]  
+ fileSize + [finalData length]]);
	CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Accept"),  
(CFStringRef)@"text/plain, text/html, text/*");
	CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Connection"),  
(CFStringRef)@"close");
	CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Host"),  
(CFStringRef)[url host]);


	NSData *serialData = [(NSData  
*)CFHTTPMessageCopySerializedMessage(httpRequest) autorelease];

CFRelease(httpRequest);

//send the headers
[asyncSocket writeData:serialData withTimeout:-1 tag:1];

Just an example.

On Jan 25, 2009, at 1:21 PM, John Michael Zorko wrote:



Hello, all ...

I guess this is more of a Core Foundation question, but it still  
seemed more apropos to this list than Carbon-dev.  Please let me  
know if i'm wrong :-)


I'm trying to handle URLs in this format:

http://:@this.url.com/content

... with the  and  filled in of course.  I found  
that NSURLConnection handled these for me, but for reasons beyond  
the scope of this question, NSURLConnection isn't a good choice for  
what i'm trying to do, so i'm using CFNetwork stuff.  I've a  
question, though:


1. How do I get the HTTP return code?  I use  
CFHTTPMessageCreateRequest() to create the GET request, and  
CFReadStreamCreateForHTTPRequest() to create a CFReadStream for said  
request.  How do I get the response of the request?


Regards,

John

Falling You - exploring the beauty of voice and sound
http://www.fallingyou.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/alex%40webis.net

This email sent to a...@webis.net


Alex Kac - President and Founder
Web Information Solutions, Inc.




___

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

Please do not post admin requests or moderator comments to the list.
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: Dates of the Chinese New Year

2009-01-25 Thread Nick Zitzmann


On Jan 25, 2009, at 11:55 AM, Kevin Ross wrote:

I see that in the docs that the Chinese calendar is not supported on  
10.4-5.  Does anyone know if one of the other calendars  
(NSBuddhistCalendar or NSJapaneseCalendar maybe?) would be able to  
find the beginning of the Chinese New Year?



They won't. The Buddhist and Japanese calendars are pure solar  
calendars, and are identical to the Gregorian calendar, except that  
the epoch is different. The Gregorian calendar, for example, sets year  
1 to the year in which Jesus was believed to be born in, whereas the  
Buddhist calendar sets year 1 to the Buddha's birth year, and the  
Japanese calendar sets year 1 in any given era to the year in which  
the then-emperor was crowned (which would be January 7, 1989 for the  
current emperor). But other than that, everything else is the same.


The Chinese calendar is a lunisolar calendar in which months begin and  
end based on the moon's appearance over Beijing, with leap time to  
make up for the ~12 day difference between lunar and solar years.  
There is some stuff in the ICU library that will help you figure out  
the position of the moon, which is also important in the Hebrew and  
Islamic calendars, but from there, it's up to you. There are some  
books on calendrical calculations that you might want to read...


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


Re: Class introspection [was Re: Forcing allocation of a subclass]

2009-01-25 Thread João Varela




No, isKindOfClass check for the superclass.  It returns true if self  
class is myClass or a subclass of myClass.

You should use isMemberOfClass: to got something equivalent.


Yes, you are right. Thanks for pointing it out.



because in the first example we are calling -class: in [self class]  
and on the right we are calling +class: in [MyClass class]. This  
actually surprises me. Even though the +class: method is a NSObject  
class method and -class: is part of the NSObject protocol. How is  
that possible there is no collision between these two methods.  
Isn't that a case of overloading???


It's perfectly legal to have class methods and instance methods with  
the same name.


But there is more:

Methods of the Root Class
All objects, classes and instances alike, need an interface to the  
runtime system. Both class objects and instances should be able to  
introspect about their abilities and to report their place in the  
inheritance hierarchy. It’s the province of the NSObject class to  
provide this interface.


So that NSObject's methods don’t have to be implemented twice—once  
to provide a runtime interface for instances and again to duplicate  
that interface for class objects—class objects are given special  
dispensation to perform instance methods defined in the root class.  
When a class object receives a message that it can’t respond to with  
a class method, the runtime system determines whether there’s a root  
instance method that can respond. The only instance methods that a  
class object can perform are those defined in the root class, and  
only if there’s no class method that can do the job.


For more on this peculiar ability of class objects to perform root  
instance methods, see the NSObject class specification in the  
Foundation framework reference





I think read it once but that was long ago and didn't pay attention to  
is as much. Learning about Obj-C and Cocoa every day.


Thanks for answering.

JV___

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

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

2009-01-25 Thread Peter Blazejewicz

hi John,

On Jan 25, 2009, at 8:21 PM, John Michael Zorko wrote:

Hello, all ...

I guess this is more of a Core Foundation question, but it still  
seemed more apropos to this list than Carbon-dev.  Please let me  
know if i'm wrong :-)


there is better group then Carbon-dev:
http://lists.apple.com/mailman/listinfo/macnetworkprog/

1. How do I get the HTTP return code?  I use  
CFHTTPMessageCreateRequest() to create the GET request, and  
CFReadStreamCreateForHTTPRequest() to create a CFReadStream for said  
request.  How do I get the response of the request?


Details depends if your read stream is blocking or asynchronous. In  
general getting status code is two steps:

#1 create response message reference from read stream
#2 get status code from response instance:
see section "Checking response":
file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Networking/Conceptual/CFNetwork/CFHTTPTasks/chapter_5_section_6.html 
#//apple_ref/doc/uid/TP3230-61101


regards,
Peter

___

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

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

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

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


NSArray KVC proxy

2009-01-25 Thread Quincey Morris
Consider a class with an array property '' implemented KVC- 
compliantly by the following methods:


- (NSUInteger) countOfXxxx;
- (id) objectInXxxxAtIndex: (NSUInteger) index;

(Assume there's no NSArray instance variable backing this property.)  
So, users of the class can call [valueForKey:@""] to get a proxy  
object that returns the objects in the "array".


Now, the question is: How do I implement a getter? The intention is  
that it's just a convenience method for getting a proxy:


@property (readonly) (NSArray*) ;

- (NSArray*)  {
return [self valueForKey: @""];
}

but that is a *really* bad idea, because valueForKey: will *first* try  
calling the '' method -- the one it was called from.


As I missing something simple here? It seems like there needs to be an  
'arrayValueForKey:' method (parallel to mutableArrayValueForKey:),  
which checks whether the class implements the indexed accessors before  
calling the getter, instead of after.



___

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

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


Displaying an NSSet in a Single Table Cell?

2009-01-25 Thread Brad Gibbs
I have a Core Data app for cataloging objects.  Each object has a to- 
many relationship for Type that describes the type of the object.  An  
object can have multiple types (hence, the to-many relationship...) --  
usually 2-4 types per object.


Objects are displayed in a table, one per row.  I made the table rows  
tall enough to display three lines of text.  I'd like to display one  
type per line for each object so that the user can click on one of the  
types and sort the table according to the type selected.  Essentially,  
I guess I want to put three cells in a single cell, or a matrix in a  
cell, both to display the data and to get the selection and act upon it.


There must be a way to do this, but I haven't been able to find it.


Thanks.

Brad
___

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

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

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

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


Re: NSArray KVC proxy

2009-01-25 Thread Jeff Johnson

On Jan 25, 2009, at 2:54 PM, Quincey Morris wrote:

Consider a class with an array property '' implemented KVC- 
compliantly by the following methods:


- (NSUInteger) countOfXxxx;
- (id) objectInXxxxAtIndex: (NSUInteger) index;

(Assume there's no NSArray instance variable backing this property.)  
So, users of the class can call [valueForKey:@""] to get a proxy  
object that returns the objects in the "array".


Now, the question is: How do I implement a getter? The intention is  
that it's just a convenience method for getting a proxy:


@property (readonly) (NSArray*) ;

- (NSArray*)  {
return [self valueForKey: @""];
}

but that is a *really* bad idea, because valueForKey: will *first*  
try calling the '' method -- the one it was called from.


As I missing something simple here? It seems like there needs to be  
an 'arrayValueForKey:' method (parallel to  
mutableArrayValueForKey:), which checks whether the class implements  
the indexed accessors before calling the getter, instead of after.


If you want to implement the getter , then you don't need to  
implement countOfXxxx and objectInXxxxAtIndex:. Since your backing  
store is not an array, the implementation of the getter should create  
and return an array. In the docs for KVC compliance, it says that you  
should implement the getter OR implement the indexed accessors.


http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/Compliant.html

The question of whether it's preferable to implement the getter or the  
indexed accessors really depends on how the property is used in your  
app.


-Jeff

___

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

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

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

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


Scrolling Title in IKImageBrowserView?

2009-01-25 Thread Brad Gibbs
Is it possible to set the title of an image in an IKImageBrowserView  
to scroll when the item is selected?


Thanks.
___

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

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

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

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


Core Data performance [Re: Knowing when a NSArrayController is ready]

2009-01-25 Thread Ben Trumbull

On 24 Jan 2009, at 18:41, Matt Neuburg wrote:


On or about 1/24/09 10:17 AM, thus spake "jonat...@mugginsoft.com"
:


I am also having horrible performance problems.
A data set of 1500 items with a total on disk size of 1.8MB is  
taking

more than 30 secs to load.
Maybe NSArrayController -fetchWithRequest will improve things.


I would ask you the same question I just asked someone else on the
list: are
you using the XML persistent storage format? Because, if so, you
must expect
some delay, since even before you fetch any objects the entire XML
file must
be loaded into memory and parsed.

I use XML because I want human readability for my data, so startup
speed is
a sacrifice I am prepared to make. My data consists of about 5000
items, but
they are very simple; dealing with complex objects would take
considerably
longer, one assumes. In order to cave-man-instrument the startup
procedure
via NSLog, I do NOT prepare content or even bind my array  
controller's

managed object content in the nib; instead, I do it all manually in
awakeFromNib. Here are some NSLog timings:

2009-01-24 10:37:09.157 [788] awakening from nib
2009-01-24 10:37:09.269 [788] binding to MOC
2009-01-24 10:37:09.359 [788] creating whole shebang
2009-01-24 10:37:09.360 [788] adding persistent store
2009-01-24 10:37:13.877 [788] calling fetch
2009-01-24 10:37:14.192 [788] done calling fetch

Notice the big delay between "adding persistent store" and "calling
fetch";
that consists a single line of code (calling
addPersistentStoreWithType:).
So the delay there is nothing but the XML file being loaded and
parsed. m.


Hi Matt

I decided to follow your example so I set prepareContent = NO and
called -fetchWithRequest:merge:error: from my controller.
I also switched between the XML and SQLite store types to see the
effect.
I also made use of -setUsesLazyFetching.
Timings are Cro-magnon.

The results for a default fetch on a data set of 1500 very simple
objects are:

XML - usesLazyFetching = NO  38.00 sec load
XML - usesLazyFetching = YES  4.78 sec load

SQLite - usesLazyFetching = NO  35.25 sec load
SQLite - usesLazyFetching = NO  2.07 sec load



These numbers are astronomically wrong.  On a modern intel machine,  
those numbers are off by between three and four orders of magnitude.   
A 500Mhz ppc G4 with 256MB RAM can fetch 10,000 rows over 20x faster  
than that.



Timings are Cro-magnon.


Why ?  Put Shark in Time Sample (All Threads State).  You'll get close  
to wall clock time with a sampling accuracy of microseconds.


Or just use the user default -com.apple.CoreData.SQLDebug 1 and we'll  
log all the SQL, plus annotations for timings of fetching.  It even  
comes in color -com.apple.CoreData.SyntaxColoredLogging 1


What does Instruments say ?  Select the Core Data template in the new  
document window.  That will configure all the most interesting Core  
Data instruments together.


Typically, with the SQLite store the most common error is failing to  
use prefetching when appropriate and faulting in lots of relationships.


The XML store takes a long time to parse and add to the coordinator,  
but doesn't have that problem because it caches everything in memory.   
So the fact you've managed to make the two perform about the same  
implies something else is going on.


What are you doing in -awakeFromFetch for example ?  What kind of  
machine were these numbers taken on, and did you do so after a fresh  
restart with no other apps running ?


Do you get the same performance without putting the objects in the  
array controller ?  Just set up the stack and do the fetch and toss  
the results.  Misconfigured array controllers can sometimes generate  
notification storms if you add observers that make changes while  
receiving notifications from the controller that something is changing.


The com.apple.CoreData.SQLDebug user default above is handy for that  
as what should be one or two fetches with a half page of log will  
instead by a fire-hose of logging that makes you want to quit Terminal.


- Ben

___

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

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

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

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


Re: Getting pixel color from NSView

2009-01-25 Thread Andrew Farmer

On 25 Jan 09, at 11:06, Ashley Perrien wrote:
Is there a way to get the color of a pixel or area of an NSView  
during the drawRect method? I'll be tiling the view with a grid of  
random colors but each tile is based on the colors around it...



While there are some methods you can use to determine the current  
color of a point on screen, there is no guarantee that they will be  
meaningful in the middle of a drawRect call.


... rather than creating and filling a potentially quite large array  
of colors.



This array is probably going to be a lot smaller than you're imagining  
it to be, especially if you use C arrays of color values for storage  
(rather than NSArray[NSArray[NSColor]]).

___

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

Please do not post admin requests or moderator comments to the list.
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: Dates of the Chinese New Year

2009-01-25 Thread Kevin Ross


On Jan 25, 2009, at 12:12 PM, Nick Zitzmann wrote:



On Jan 25, 2009, at 11:55 AM, Kevin Ross wrote:

I see that in the docs that the Chinese calendar is not supported  
on 10.4-5.  Does anyone know if one of the other calendars  
(NSBuddhistCalendar or NSJapaneseCalendar maybe?) would be able to  
find the beginning of the Chinese New Year?



They won't. The Buddhist and Japanese calendars are pure solar  
calendars, and are identical to the Gregorian calendar, except that  
the epoch is different. The Gregorian calendar, for example, sets  
year 1 to the year in which Jesus was believed to be born in,  
whereas the Buddhist calendar sets year 1 to the Buddha's birth  
year, and the Japanese calendar sets year 1 in any given era to the  
year in which the then-emperor was crowned (which would be January  
7, 1989 for the current emperor). But other than that, everything  
else is the same.


The Chinese calendar is a lunisolar calendar in which months begin  
and end based on the moon's appearance over Beijing, with leap time  
to make up for the ~12 day difference between lunar and solar years.  
There is some stuff in the ICU library that will help you figure out  
the position of the moon, which is also important in the Hebrew and  
Islamic calendars, but from there, it's up to you. There are some  
books on calendrical calculations that you might want to read...


Nick Zitzmann






Thanks Nick, I was beginning to think that this was going to be more  
complex than I had hoped.  I might just end up finding a large enough  
database of dates for relevant years and just reference that instead  
of calculating them.  At least until I can study up on this lunisolar  
business.


Kevin


___

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

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

2009-01-25 Thread Quincey Morris

On Jan 25, 2009, at 13:20, Jeff Johnson wrote:

If you want to implement the getter , then you don't need to  
implement countOfXxxx and objectInXxxxAtIndex:. Since your backing  
store is not an array, the implementation of the getter should  
create and return an array. In the docs for KVC compliance, it says  
that you should implement the getter OR implement the indexed  
accessors.


http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/Compliant.html


I *do* want to implement the getter (thereby gaining both KVC  
compliance and convenience). I *don't* need, therefore, the indexed  
accessors to provide KCV compliance, but I *do* need the indexed  
accessors to support the behavior of an array proxy.


Having both getter and indexed accessors doesn't break KVC compliance,  
it just breaks the ability for code to create a proxy, which is an  
entirely different matter. (The proxy is, after all, a kind of  
NSArray, so returning it from the getter would also be KVC-compliant.)


And I do want to return the proxy from my getter. Returning a  
"genuine" NSArray is not really an option. I'm not really talking  
about a single property -- there are lots of possible properties  
spread across lots of classes. Their storage and performance  
characteristics are not known in advance, nor is it even known if they  
have indexed accessors or not.


The NSArray proxy is the perfect wrapper for all these implementation  
details. The only problem is that I can't actually create it, because  
the only apparent way to do that is to call valueForKey:, and the  
presence of the getter makes that call mean something different.



___

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

Please do not post admin requests or moderator comments to the list.
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: Knowing when a NSArrayController is ready

2009-01-25 Thread Ben Trumbull
I would ask you the same question I just asked someone else on the  
list: are
you using the XML persistent storage format? Because, if so, you  
must expect
some delay, since even before you fetch any objects the entire XML  
file must

be loaded into memory and parsed.

I use XML because I want human readability for my data, so startup  
speed is

a sacrifice I am prepared to make.


Matt,

Have you considered an alternative solution where you use an SQLite  
store as a cache ?  You can import and export to the XML store, either  
by user action or automatically (like at quit time).  On launch you  
can even check if the timestamp on the XML file is changed, and  
reimport it if you need interoperability with other tools.


Many projects on many platforms use SQLite as an efficient cache for  
runtime operations, but not necessarily the canonical data format.


This would greatly improve your launch times, save times, memory  
utilization, and overall scalability.


- Ben

p.s. XML is human readable ? Like punch cards ?  You can pipe the  
output of /usr/bin/sqlite3 anywhere you want.  To each their own ...



My data consists of about 5000 items, but
they are very simple; dealing with complex objects would take  
considerably
longer, one assumes. In order to cave-man-instrument the startup  
procedure

via NSLog, I do NOT prepare content or even bind my array controller's
managed object content in the nib; instead, I do it all manually in
awakeFromNib. Here are some NSLog timings:

2009-01-24 10:37:09.157 [788] awakening from nib
2009-01-24 10:37:09.269 [788] binding to MOC
2009-01-24 10:37:09.359 [788] creating whole shebang
2009-01-24 10:37:09.360 [788] adding persistent store
2009-01-24 10:37:13.877 [788] calling fetch
2009-01-24 10:37:14.192 [788] done calling fetch

Notice the big delay between "adding persistent store" and "calling  
fetch";
that consists a single line of code (calling  
addPersistentStoreWithType:).
So the delay there is nothing but the XML file being loaded and  
parsed. m.



___

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

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

2009-01-25 Thread Jeff Johnson

On Jan 25, 2009, at 4:32 PM, Quincey Morris wrote:


On Jan 25, 2009, at 13:20, Jeff Johnson wrote:

If you want to implement the getter , then you don't need to  
implement countOfXxxx and objectInXxxxAtIndex:. Since your backing  
store is not an array, the implementation of the getter should  
create and return an array. In the docs for KVC compliance, it says  
that you should implement the getter OR implement the indexed  
accessors.


http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/Compliant.html


I *do* want to implement the getter (thereby gaining both KVC  
compliance and convenience). I *don't* need, therefore, the indexed  
accessors to provide KCV compliance, but I *do* need the indexed  
accessors to support the behavior of an array proxy.


Having both getter and indexed accessors doesn't break KVC  
compliance, it just breaks the ability for code to create a proxy,  
which is an entirely different matter. (The proxy is, after all, a  
kind of NSArray, so returning it from the getter would also be KVC- 
compliant.)


And I do want to return the proxy from my getter. Returning a  
"genuine" NSArray is not really an option. I'm not really talking  
about a single property -- there are lots of possible properties  
spread across lots of classes. Their storage and performance  
characteristics are not known in advance, nor is it even known if  
they have indexed accessors or not.


The NSArray proxy is the perfect wrapper for all these  
implementation details. The only problem is that I can't actually  
create it, because the only apparent way to do that is to call  
valueForKey:, and the presence of the getter makes that call mean  
something different.


Ok, I understand. The question is, other than saving a few characters,  
how is calling  more convenient than calling valueForKey:@""?  
If the property is mutable, then you're going to have to call  
mutableArrayValueForKey:@"" anyway, right?


If you're just dealing with a read-only property, I suppose that one  
option would be to give the property and getter a different name than  
the key. This could be justified in the sense that the property is  
public but the implementation via KVC is a private implementation  
detail. Then it would be safe to call valueForKey: in your getter.


-Jeff

___

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

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

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

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


Re: addSubview bottleneck

2009-01-25 Thread douglas welton

Hi Josh,

I would echo Andreas' advice and tell you to not use NSViews to  
accomplish this task.


I would suggest that you take a closer look at the problem domain and  
re-factor along the lines of the data you manage and the drawn  
representation of that data.  NSViews are great containers for  
drawing, but at what point does your program need to display 60,000  
things on the screen at once?  Does the user actually perceive the  
drawing as 60,000 objects or as one object?  If, most of the time, a  
user will only see a subset of the 60,000 objects, then perhaps you  
should rethink how you are doing your drawing.


My suggestion is that you keep your 60,000 objects in some "datasource- 
like" object that can be queried by the Custom View that actually does  
the drawing.  Let your custom view draw only those objects that are  
visible.  If the objects you are drawing can be handled by an existing  
NSCell type ( e.g., an image cell or text cell), then use a copy of  
that cell type to do your drawing, otherwise just do the drawing  
yourself.


regards,

douglas

On Jan 24, 2009, at 5:29 PM, Twisted Theory wrote:


Hi,

I am constructing an application that draws rooted trees (graphs  
with a
distinguished 'first' node) by creating an NSView subclass for each  
node and

adding them as subviews of the graph view.

There is a big problem when the number of nodes in the tree is  
large: adding

the subviews takes a very long time.  For example, one of my trees has
around 60,000 nodes.  It takes about 1.5 seconds to create all of the
objects, and about 200 seconds to add them as subviews.

Can anyone suggest a way to speed the process up?  Multithreading  
didn't

really improve matters.

Each node keeps track of its child nodes in an NSArray, and the  
subview

addition is recursive:

- (void) add
{
   NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc]  
init];


   [[parent superview] addSubview:self];
   for (Vertex * child in children)
   [child performSelectorOnMainThread:@selector(add)  
withObject:nil

waitUntilDone:NO];
   //[child add];

   [autoreleasepool release];
}

Thanks,

Josh
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/douglas_welton%40earthlink.net

This email sent to douglas_wel...@earthlink.net


___

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

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

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

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


Re: NSArray KVC proxy

2009-01-25 Thread Quincey Morris

On Jan 25, 2009, at 15:54, Jeff Johnson wrote:

Ok, I understand. The question is, other than saving a few  
characters, how is calling  more convenient than calling  
valueForKey:@""?


It makes quite a difference to readability, I think. Also, Refactor...  
works on property names but not on key strings, and that's fairly  
important to me. Also, the getter can cache the proxy, while (I  
assume) valueForKey: creates a new one each time it's called.


If the property is mutable, then you're going to have to call  
mutableArrayValueForKey:@"" anyway, right?


Yes. I thought I found a way of returning that conditionally from a  
single getter, but I think I was just mistaken. So, mutable access  
needs a different name, e.g. "mutableXxxx". (IAC, the method's return  
type really ought to be different -- NSMutableArray instead of NSArray.)


If you're just dealing with a read-only property, I suppose that one  
option would be to give the property and getter a different name  
than the key. This could be justified in the sense that the property  
is public but the implementation via KVC is a private implementation  
detail. Then it would be safe to call valueForKey: in your getter.


Yes. That's a possibility ("immutableXxxx"). The drawback is that it  
leaves a big hole. Part of what I'm doing is laying down coding  
patterns for others to follow when implementing classes, and, though a  
rule like "Don't ever write a getter for an array property" is easy to  
remember, it's even easier to forget.



___

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

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

2009-01-25 Thread John C. Randolph


On Jan 25, 2009, at 11:06 AM, Ashley Perrien wrote:

Is there a way to get the color of a pixel or area of an NSView  
during the drawRect method?


Sure.  Have a look at this:

http://developer.apple.com/samplecode/Color_Sampler/index.html

NSReadPixel() will tell you the color of the pixel nearest to the  
given location, in the current drawing context.


-jcr


"This is not a book to be tossed aside lightly. Rather, it should be  
hurled with great force." -Dorothy Parker


___

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

Please do not post admin requests or moderator comments to the list.
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: NSRunloop performSelector needs CFRunLoopWakeUp ?

2009-01-25 Thread Michael Ash
On Sun, Jan 25, 2009 at 12:47 PM, David Hoerl  wrote:
> Thanks to those who have posted on this, and suggested workarounds. However,
> in a simple non-threaded app, this call should work, no? And perhaps the 0
> time timer would also suffer the same fate.

Well as I said, the documentation says that it schedules your selector
for the next runloop pass, but it doesn't say anything about making
that pass actually happen in a timely fashion. A timer will not suffer
the same fate because a timer explicitly wakes up the runloop and
forces it to actually run when the time comes.

> PS: well, I re-read the Threading Programming Guide, and I saw
> "performSelectorOnMainThread", so tried it in my demo project. Bingo, it
> works as expected:
>
>  [self performSelectorOnMainThread:@selector(getNextTask) withObject:nil
> waitUntilDone:NO];
>
> Also, this worked too:
>
>  [self performSelector:@selector(getNextFrame) withObject:nil
> afterDelay:0.0];
>
> Both of these methods essentially queue the selector so it will be sent
> during the next run loop cycle, and NOT cause it to be executed immediately.
> It would appear that both are thread safe too.

They are thread safe, but the second one won't do what you expect in a
secondary thread. It will schedule the selector on the secondary
thread's runloop, not the main thread's runloop. But of course since
you're not multithreaded (my comment on that was way off-base due to
misreading your original post) it's not important.

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: Opening Symbolic Links

2009-01-25 Thread Gerriet M. Denkmann


On 25 Jan 2009, at 09:31, Rob Keniger  wrote:


On 24/01/2009, at 11:46 PM, Gerriet M. Denkmann wrote:


I have a text file, called Text.
I did in Terminal:
ln -s Text SymlinkToText

When I try to open SymlinkToText in TextEdit "SymlinkToText" is
shown in the Open Panel, but when I select it, the "Open"-button is
disabled.

Is this a bug or a feature (in 10.5.6) ?
I believe this did work in Tiger, but have no machine to test this.


Call [yourOpenPanel setResolvesAliases:YES] to make an open panel
resolve aliases/symlinks.


I tried this. Works as expected for Aliases. But has no effect on  
symbolic links.


And symbolic links behave really crazy:
ln -s a symA
Now I can open symA (and get the content of "a") at most once.
When I try to open symA again the "Open" button in the NSOpenPanel is  
disabled.


But when I do [ openPanel setCanChooseDirectories: YES ] I can open  
symA as often as I want.


The Finder and the OpenPanel show symA with a ► at the end (as it is  
done for folders). The Preview is correct though.


Is this a known feature or bug of 10.5.6?
Am I doing something wrong?
Does anybody seen this strange behaviour as well, or is it only me?

Kind regards,

Gerriet.

___

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

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


Does somebody know good tag-editor implementation?

2009-01-25 Thread Vitaly Ovchinnikov
Hello all,

I need to add tags to my records-editing application and do not want
to reinvent a wheel. Please point me to the applications that already
have good tag editor. By tags I mean words or phrases that can be
"linked" to the record. I need to enter these words manually or select
them from the list of previously entered words.

What is the best app to copy tags from?
Thanks.
___

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

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

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

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