Re: Long load time of managed object context

2009-01-24 Thread Diederik Hoogenboom

Hi Matteo,

How do you load your model? Do you pass [NSBundle allBundles] to  
NSManagedObjectModel's mergedModelFromBundles: ?


Maybe your application bundle contains more than one model (e.g. from  
linked frameworks) which can confuse CoreData (i.e. slow down or  
generate errors).



- Diederik




On 16 jan 2009, at 13:03, Matteo Manferdini wrote:


Hi everyone,

I'm testing performance in my application, to see how it behaves with
a big load of data inside of it. My application is core data based and
uses array controllers in entity mode to fetch data.

What I discovered is that my app fetched all the managed objects
present in core data, so I set the fetch predicate of array
controllers at startup. This reduced dramatically the number of
objects fetched. The problem though is that my app still takes a lot
of time to start when is full of data.

I ran the app within instruments, and the core data fetches instrument
confirms that this is not the problem (my app fetches only 20-30
objects when starts). But running it under Shark I can see that for
4-5 seconds after startup the only call on the stack is to the app
managed object context. So I think it has something to do with
interaction between managed object context and data stored, even if I
don't fetch all the data. If I empty the app or leave little data
inside of it, it starts very quickly.

Does somebody know why this happens? Am I missing something obvious?
Why does it take so much to the managed object context to load if I
only fetch few objects? I always read that core data scales well and
the programming guide states that 10.000 objects are not much for core
data, but in my app it makes a big difference, so I'm wondering where
I am wrong.

Thank you very much.
Cheers.

Matteo Manferdini
Pawn Software
www.pawn-soft.com
___

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

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

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

This email sent to maili...@obviousmatter.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: NSNumberFormatter setFormat: in 10.3.9

2009-01-24 Thread Jonathan Fewtrell
Yes, I saw that. Maybe I misunderstood it. I thought that if the app  
was running under 10.3.9 the formatter would always be created as 10.0  
format since the 10.4 format stuff didn't exist in the 10.3  
frameworks. Isn't that right?


Jon



I believe that in 10.5, the default formatter behavior is 10.4 instead
of 10.0 (in 10.4 the default behavior was still 10.0).  Check out:

http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/DataFormatting/DataFormatting.html

Neil

On Jan 23, 2009, at 12:30 PM, Jonathan Fewtrell wrote:


My app, developed on 10.5 but targeted at 10.3.9 and above, contains
the following code:

NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setFormat:@#0;#0;#0];

It compiles without warnings.

When running on 10.3.9 it crashes with EXC_BAD_ACCESS in -
[NSNumberFormatter setFormat:]. It works fine on 10.4 and 10.5.

For such a simple bit of code, I struggle to see what could be
wrong. A previous version, developed on 10.4, did not show this
problem, so I'm wondering if it's a build setting problem. If it is,
I can't see which one.

I can see from the archives that NSNumberFormatter has various
issues, but they do not seem to me to be relevant here.

Any insight appreciated.

___

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

Please do not post admin requests or moderator comments to the list.
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-24 Thread jonat...@mugginsoft.com


On 24 Jan 2009, at 02:43, David LeBer wrote:

This may be a stupid question, but I've had reason to wonder a  
number of times.


If I have an NSArrayController in a nib, bound to a MOC, configured  
with an Entity name and set to prepare content:


Is there a way to be notified when it has finished loading and  
arranging it's objects?



Hi David

Adding an observer on the controller's arrangedObjects property should  
do the trick.


[arrayController addObserver:self forKeyPath:@arrangedObjects  
options:0 context:(void *)ControllerContentContext];


In a persistent document based app, for example, the controller's MO  
content is not yet available in - (void)windowControllerDidLoadNib: 
(NSWindowController *)windowController.
Adding the observer means you can set up any dependent code when the  
binding/core data machinery has finished doing its thing.




;david

--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site:   http://codeferous.com
blog:   http://davidleber.net
profile:http://www.linkedin.com/in/davidleber
twitter:http://twitter.com/rebeld
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.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/jonathan%40mugginsoft.com

This email sent to jonat...@mugginsoft.com


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: Poof! Recently-saved Core Data document suddenly gets dirty

2009-01-24 Thread Quincey Morris

On Jan 23, 2009, at 22:44, Jerry Krinock wrote:

I realize I could probably paper over this problem by disabling undo  
registration during the import


The stack trace clearly shows that an undo action is being recorded,  
which means that some property has been changed. (Changed in the  
sense that KVO-notifications were produced, which is what the undo  
mechanism notices, AFAIK. The actual values of the properties are  
likely irrelevant.)


Core Data is fanatically correct about recording changes as undo  
actions, and it's really, really difficult to find out what it thinks  
has changed, sometimes. It's possible that the delayed-action effect  
on dirtiness is a deferred processPendingChanges happening. It's  
possible that coalescing of changes by processPendingChanges might be  
suppressing change notifications.


So, disabling undo at times when you don't want any undo isn't really  
papering over a problem. It's more of a defense against Core-Data- 
induced madness.


Or, given your heroic investigations, you could almost justify  
submitting a bug report and hoping Apple will debug the rest of the  
problem for you.


Or, you could turn Core Data undo off completely, and handle undo  
yourself. Getting undo for free in Core Data is a benefit only if it  
causes less work for you, not more.



___

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

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

2009-01-24 Thread Kyle Sluder
On Sat, Jan 24, 2009 at 3:49 AM, Jonathan Fewtrell
jonathanfewtr...@mac.com wrote:
 Yes, I saw that. Maybe I misunderstood it. I thought that if the app was
 running under 10.3.9 the formatter would always be created as 10.0 format
 since the 10.4 format stuff didn't exist in the 10.3 frameworks. Isn't that
 right?

Yes, that's correct.  Your format string seems to be correct as well.

Are you sure you haven't called a 10.4-only method against the number
formatter before calling -setFormat: ?
___

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

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


Targetting Tiger

2009-01-24 Thread Thomas Davie

Hi,
  I'm in a sticky situation.  I personally have no machine capable of  
running tiger, but my customer needs me to provide a tiger version of  
my app.  I attempted to create a build that targeted tiger, but they  
are reporting that it is failing.


What's going wrong:
The application crashes almost immediately (on tiger, but not leopard)  
while loading its nib, here's the back trace:

Thread: 0

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:  KERN_PROTECTION_FAILURE (0x0002) at 0x

Thread 0 Crashed:
0   libobjc.A.dylib 0x90a594c7 objc_msgSend + 23
1   com.apple.AppKit0x932639d8 loadNib + 303
2   com.apple.AppKit   	0x932633d9 +[NSBundle(NSNibLoading)  
_loadNibFile:nameTable:withZone:ownerBundle:] + 918
3   com.apple.AppKit   	0x9326303a +[NSBundle(NSNibLoading)  
loadNibFile:externalNameTable:withZone:] + 164
4   com.apple.AppKit   	0x93262f7c +[NSBundle(NSNibLoading)  
loadNibNamed:owner:] + 392

5   com.apple.AppKit0x93262cc3 NSApplicationMain + 433
6   com.davie.klondike  0x237a _start + 216
7   com.davie.klondike  0x22a1 start + 41

Thread 0 crashed with X86 Thread State (32-bit):
 eax: 0x  ebx: 0x927db6ae  ecx: 0x90ac0010  edx: 0x0041
 edi: 0x0008  esi: 0xbaf8  ebp: 0xbb88  esp: 0xbac4
  ss: 0x001f  efl: 0x00010202  eip: 0x90a594c7   cs: 0x0017
  ds: 0x001f   es: 0x001f   fs: 0x   gs: 0x0037



What I've done to try and get it to run on tiger:
Set the following build settings in my target:
ARCHS = $(ARCHS_STANDARD_32_BIT)
SDKROOT = macosx10.4
MACOSX_DEPLOYMENT_TARGET = 10.4
GCC_ENABLE_OBJC_GC = unsupported
In the xib file, set the target to 10.4 (I've also tried saving a  
version 2.0 nib instead of a xib).


I'm building using Xcode 3.1.2.

If anyone could point me to what setting I've missed, or some  
documentation I can read on this, I'd be really grateful.


Thanks

Bob
___

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

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

2009-01-24 Thread Jonathan Fewtrell


On 24 Jan 2009, at 09:27, Kyle Sluder wrote:


On Sat, Jan 24, 2009 at 3:49 AM, Jonathan Fewtrell
jonathanfewtr...@mac.com wrote:
Yes, I saw that. Maybe I misunderstood it. I thought that if the  
app was
running under 10.3.9 the formatter would always be created as 10.0  
format
since the 10.4 format stuff didn't exist in the 10.3 frameworks.  
Isn't that

right?


Yes, that's correct.  Your format string seems to be correct as well.

Are you sure you haven't called a 10.4-only method against the number
formatter before calling -setFormat: ?


Yes. The only possibly relevant code I have is in the class's  
+initialize method:


+ (void)initialize
{
	if ( [NSNumberFormatter  
instancesRespondToSelector:@selector(setFormatterBehavior:)] ) {

NSLog(@They do respond);
[NSNumberFormatter setDefaultFormatterBehavior:1000];
}
}

I put this in to force 10.0 behaviour when running on 10.5. The log  
message is not called on 10.3.9, confirming that the  
+setDefaultFormatterBehavior method is not called under 10.3.9.  
Anyway, the problem still exists even if I remove the +initialize  
method.


I've also tried different format strings. And retyping the whole thing  
to make sure no invisible characters crept in. Makes no difference.


Bafflement reigns.


___

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

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


Forcing allocation of a subclass

2009-01-24 Thread Antonio Nunes

Hi,

I need to be able to force the requested allocation of a cocoa class  
to always return an instance of my subclass. I have looked into ways  
of doing that.


I have a solution that seems to work, by using a category on the class  
to replace the regular invocation, but from the archives I understand  
that is a Bad Idea that can lead to all manner of unpredictable and  
hard to trace errors. The current implementation looks like this:


@implementation PDFDocument (PDFDocument_Alloc)

+ (id)alloc
{
if ([[self class] isEqual:[PDFDocument class]]) {
return [ANPDFDocument alloc];
} else {
return [super alloc];
}
}

@end

As I wrote, this appears to work fine. But if indeed this technique is  
better avoided, what would be the best alternative? I have looked at  
class_replaceMethod, but am having difficulties implementing it. What  
would be the best way to implement a safe alternative to the method  
listed above?


-António

---
Some things have to be believed to be seen.

--Ralph Hodgson
---



___

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

Please do not post admin requests or moderator comments to the list.
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-24 Thread Mike Abdullah
I would recommend against the category approach. As your search of the  
archives no doubt explained, there's no guarantee that PDFDocument may  
at some point internally use its own category that would override yours.


I don't know exactly how you'd do what you want (+poseAsClass: is  
deprecated) with the runtime functions, but may I advise that whatever  
your eventually solution you replace +allocWithZone: rather than +alloc


Mike.

On 24 Jan 2009, at 09:19, Antonio Nunes wrote:


Hi,

I need to be able to force the requested allocation of a cocoa class  
to always return an instance of my subclass. I have looked into ways  
of doing that.


I have a solution that seems to work, by using a category on the  
class to replace the regular invocation, but from the archives I  
understand that is a Bad Idea that can lead to all manner of  
unpredictable and hard to trace errors. The current implementation  
looks like this:


@implementation PDFDocument (PDFDocument_Alloc)

+ (id)alloc
{
if ([[self class] isEqual:[PDFDocument class]]) {
return [ANPDFDocument alloc];
} else {
return [super alloc];
}
}

@end

As I wrote, this appears to work fine. But if indeed this technique  
is better avoided, what would be the best alternative? I have looked  
at class_replaceMethod, but am having difficulties implementing it.  
What would be the best way to implement a safe alternative to the  
method listed above?


-António

---
Some things have to be believed to be seen.

--Ralph Hodgson
---



___

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

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

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

This email sent to cocoa...@mikeabdullah.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: Using the security framework

2009-01-24 Thread Michael Ash
On Fri, Jan 23, 2009 at 10:59 PM, Joe Turner joetur...@me.com wrote:
 Okay, so, it seems everyone was right :) I went to cocoabuilder to find some
 of the responses to this, that I never got.

 Anyways, it seems I can just call AEWP() once, and it should stay suid.

 So, my last question to everyone is, how do I know if the tool is suid. I
 mean, I could implement some sort of lock-unlock thing, and then I would be
 pretty sure, but is there anyway to know for sure?

 And, is there a way to take SUID away from it? So, if I want to lock it, it
 would work.

man 2 stat to check the bit, man 2 chmod to set it.

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: Turn autosaving on forever - is it OK?

2009-01-24 Thread Michael Ash
On Fri, Jan 23, 2009 at 9:41 PM, Vitaly Ovchinnikov
vitaly.ovchinni...@gmail.com wrote:
 Michael, cocoa's embedded autosaving saves to separate file and leave
 the main document dirty. It helps only in case of power lost or
 software hang. But as it runs in background, some conflicts are
 possible. That's what I wanted to know.

Ah, I didn't realize that. Well, one of my three potential reasons
goes away then, but the other two remain. I don't know how important
they are, but they're at least plausible

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


Opening Invisible Files

2009-01-24 Thread Gerriet M. Denkmann
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.


___

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

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


Opening Symbolic Links

2009-01-24 Thread Gerriet M. Denkmann


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.

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

2009-01-24 Thread Joe Turner

Cool, thanks!

Then I now have another question: Why not just run chmod on my utility  
when it's 'unlocked', and change the userID to 0. Then when it's  
locked, change it back to 501?


Or, is this exactly what AEWP() will do?

Thanks!

Cheers,

Joe Turner
On Jan 24, 2009, at 6:47 AM, Michael Ash wrote:


On Fri, Jan 23, 2009 at 10:59 PM, Joe Turner joetur...@me.com wrote:
Okay, so, it seems everyone was right :) I went to cocoabuilder to  
find some

of the responses to this, that I never got.

Anyways, it seems I can just call AEWP() once, and it should stay  
suid.


So, my last question to everyone is, how do I know if the tool is  
suid. I
mean, I could implement some sort of lock-unlock thing, and then I  
would be

pretty sure, but is there anyway to know for sure?

And, is there a way to take SUID away from it? So, if I want to  
lock it, it

would work.


man 2 stat to check the bit, man 2 chmod to set it.

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

This email sent to joetur...@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: NSNumberFormatter setFormat: in 10.3.9

2009-01-24 Thread Jonathan Fewtrell


On 23 Jan 2009, at 18:30, Jonathan Fewtrell wrote:

My app, developed on 10.5 but targeted at 10.3.9 and above, contains  
the following code:


NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setFormat:@#0;#0;#0];

It compiles without warnings.

When running on 10.3.9 it crashes with EXC_BAD_ACCESS in - 
[NSNumberFormatter setFormat:]. It works fine on 10.4 and 10.5.


For such a simple bit of code, I struggle to see what could be  
wrong. A previous version, developed on 10.4, did not show this  
problem, so I'm wondering if it's a build setting problem. If it is,  
I can't see which one.


I can see from the archives that NSNumberFormatter has various  
issues, but they do not seem to me to be relevant here.



I have now established that the problem only occurs if the above code  
is in a framework bundle rather than an app bundle. And it only occurs  
if that framework was built on 10.5 (specifically XCode 3.1.2 on OS X  
10.5.6). If it is built from the exact same source files on 10.4  
(XCode 2.4.1; OS X 10.4.11) the problem does not occur.

___

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

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


Not Resolving Aliases

2009-01-24 Thread Gerriet M. Denkmann


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?

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


iPhone Compositing Filters

2009-01-24 Thread David Blanton
CoreImage is not available on iPhone so the CALayer property  
compositingFilter is undefined.


The docs say that by default a layer is composited using source- 
over.  Is this true for iPhone as well?


David Blanton





___

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

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

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

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


Re: Targetting Tiger

2009-01-24 Thread Steve Christensen
Your build settings below look reasonable, but given where the crash  
is happening it looks like the problem is with your main nib file. Is  
it possible that it contains a new Leopard-only view class, for  
example? Does IB show any incompatibilities with your xib or nib with  
a 10.4 target?


And I'd suggest getting your hands on a 10.4 system of your own,  
particularly if current or future customers have that as a  
requirement. My customer does so I'm doing all my development with  
Xcode 2.5 on a 10.4.11 system. I make sure everything works on 10.4  
first, then also make sure that nothing weird happens on 10.5.


steve


On Jan 24, 2009, at 1:44 AM, Thomas Davie wrote:

  I'm in a sticky situation.  I personally have no machine capable  
of running tiger, but my customer needs me to provide a tiger  
version of my app.  I attempted to create a build that targeted  
tiger, but they are reporting that it is failing.


What's going wrong:
The application crashes almost immediately (on tiger, but not  
leopard) while loading its nib, here's the back trace:

Thread: 0

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:  KERN_PROTECTION_FAILURE (0x0002) at 0x

Thread 0 Crashed:
0   libobjc.A.dylib 0x90a594c7 objc_msgSend + 23
1   com.apple.AppKit0x932639d8 loadNib + 303
2   com.apple.AppKit   	0x932633d9 +[NSBundle(NSNibLoading)  
_loadNibFile:nameTable:withZone:ownerBundle:] + 918
3   com.apple.AppKit   	0x9326303a +[NSBundle(NSNibLoading)  
loadNibFile:externalNameTable:withZone:] + 164
4   com.apple.AppKit   	0x93262f7c +[NSBundle(NSNibLoading)  
loadNibNamed:owner:] + 392

5   com.apple.AppKit0x93262cc3 NSApplicationMain + 433
6   com.davie.klondike  0x237a _start + 216
7   com.davie.klondike  0x22a1 start + 41

Thread 0 crashed with X86 Thread State (32-bit):
 eax: 0x  ebx: 0x927db6ae  ecx: 0x90ac0010  edx: 0x0041
 edi: 0x0008  esi: 0xbaf8  ebp: 0xbb88  esp: 0xbac4
  ss: 0x001f  efl: 0x00010202  eip: 0x90a594c7   cs: 0x0017
  ds: 0x001f   es: 0x001f   fs: 0x   gs: 0x0037



What I've done to try and get it to run on tiger:
Set the following build settings in my target:
ARCHS = $(ARCHS_STANDARD_32_BIT)
SDKROOT = macosx10.4
MACOSX_DEPLOYMENT_TARGET = 10.4
GCC_ENABLE_OBJC_GC = unsupported
In the xib file, set the target to 10.4 (I've also tried saving a  
version 2.0 nib instead of a xib).


I'm building using Xcode 3.1.2.

If anyone could point me to what setting I've missed, or some  
documentation I can read on this, I'd be really grateful.


___

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

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

2009-01-24 Thread David Blanton
I agree with Steve as this is exactly how I develop to be sure 10.4  
and 10.5 work.


On Jan 24, 2009, at 8:56 AM, Steve Christensen wrote:

And I'd suggest getting your hands on a 10.4 system of your own,  
particularly if current or future customers have that as a  
requirement. My customer does so I'm doing all my development with  
Xcode 2.5 on a 10.4.11 system. I make sure everything works on 10.4  
first, then also make sure that nothing weird happens on 10.5.


David Blanton





___

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

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

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

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


Re: NSCaledarDate's deprecation

2009-01-24 Thread Paul Bruneau

Please excuse this possibly dumb question but here it is:

Why spend so much time and effort to remove some code that is going to  
keep running fine for years?


The class isn't even deprecated yet. It's in this weird going to be  
deprecated limbo. How many years does it take between when something  
is deprecated and when it actually breaks? (not a rhetorical question)

___

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

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

2009-01-24 Thread Matt Long
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.  
Someone correct me if I'm wrong as I haven't actually done this, but  
can' t you simply get an external drive you connect through USB and  
install tiger onto it while leaving your current system in tact on the  
internal drive?


It's going to be a nightmare to debug the environment if you don't  
have a dev environment to match. I've (hate to admit it) tried this  
before. It did not work out well and the customer was pretty  
frustrated as I was trying to get them to try my debug builds and  
report back to me. Not one of my brighter moments. ;-)


Seems like getting a tiger system set up shouldn't be too tough. Or am  
I way off here?


Best regards,

-Matt



On Jan 24, 2009, at 8:56 AM, Steve Christensen wrote:

Your build settings below look reasonable, but given where the crash  
is happening it looks like the problem is with your main nib file.  
Is it possible that it contains a new Leopard-only view class, for  
example? Does IB show any incompatibilities with your xib or nib  
with a 10.4 target?


And I'd suggest getting your hands on a 10.4 system of your own,  
particularly if current or future customers have that as a  
requirement. My customer does so I'm doing all my development with  
Xcode 2.5 on a 10.4.11 system. I make sure everything works on 10.4  
first, then also make sure that nothing weird happens on 10.5.


steve


On Jan 24, 2009, at 1:44 AM, Thomas Davie wrote:

 I'm in a sticky situation.  I personally have no machine capable  
of running tiger, but my customer needs me to provide a tiger  
version of my app.  I attempted to create a build that targeted  
tiger, but they are reporting that it is failing.


What's going wrong:
The application crashes almost immediately (on tiger, but not  
leopard) while loading its nib, here's the back trace:

Thread: 0

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:  KERN_PROTECTION_FAILURE (0x0002) at 0x

Thread 0 Crashed:
0   libobjc.A.dylib 0x90a594c7 objc_msgSend + 23
1   com.apple.AppKit0x932639d8 loadNib + 303
2   com.apple.AppKit   	0x932633d9 +[NSBundle(NSNibLoading)  
_loadNibFile:nameTable:withZone:ownerBundle:] + 918
3   com.apple.AppKit   	0x9326303a +[NSBundle(NSNibLoading)  
loadNibFile:externalNameTable:withZone:] + 164
4   com.apple.AppKit   	0x93262f7c +[NSBundle(NSNibLoading)  
loadNibNamed:owner:] + 392

5   com.apple.AppKit0x93262cc3 NSApplicationMain + 433
6   com.davie.klondike  0x237a _start + 216
7   com.davie.klondike  0x22a1 start + 41

Thread 0 crashed with X86 Thread State (32-bit):
eax: 0x  ebx: 0x927db6ae  ecx: 0x90ac0010  edx: 0x0041
edi: 0x0008  esi: 0xbaf8  ebp: 0xbb88  esp: 0xbac4
 ss: 0x001f  efl: 0x00010202  eip: 0x90a594c7   cs: 0x0017
 ds: 0x001f   es: 0x001f   fs: 0x   gs: 0x0037



What I've done to try and get it to run on tiger:
Set the following build settings in my target:
ARCHS = $(ARCHS_STANDARD_32_BIT)
SDKROOT = macosx10.4
MACOSX_DEPLOYMENT_TARGET = 10.4
GCC_ENABLE_OBJC_GC = unsupported
In the xib file, set the target to 10.4 (I've also tried saving a  
version 2.0 nib instead of a xib).


I'm building using Xcode 3.1.2.

If anyone could point me to what setting I've missed, or some  
documentation I can read on this, I'd be really grateful.


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/matt.long%40matthew-long.com

This email sent to matt.l...@matthew-long.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: Log4Cocoa

2009-01-24 Thread Timothy Reaves


On Jan 23, 2009, at 3:33 PM, Joel Norvell wrote:

This doesn't answer the original question, but I believe it is  
pertinent to this thread.


It is also possible to log from within Xcode, something I hadn't  
realized until I saw the video of an excellent talk Joar Wingfors  
gave at a Silicon Valley Cocoaheads.


Joel

http://video.google.com/videoplay?docid=3598467380866353869

http://theocacao.com/downloads/DebuggingWithXcode.pdf





	Thanks for the links.  Logging for development debugging is only one  
small use case for logging though.  And the people using Apple's log  
service only see one additional use case, which is for logging on the  
developers machine.  But these two use cases aren't that important to  
software that is sold for use.  If a developer (individual or team)  
has software that they have to support, and users report defects, that  
is where things like NSLog  ASL fail, and a true logging framework is  
needed.


	When trying to figure out a customers issue, you can have them  
manually open the system log file and search for specific info.  You  
also can't have the app always logging debug level detail, as this not  
only consumes large amounts of disk space and impacts performance  
greatly, but is almost useless to the developer (I've seen apps  
produce logs in the gigabyte size).


	Frameworks like Log4Cocoa are a means of doing just about anything  
you want with logging.  In production software, it's valuable because  
it allows a compiled application to change it'[s logging behavior with  
either a restart (if using a config file), or by a few settings in the  
a preferences window and no need to restart.  The app then can produce  
a log file with very detailed logging around the suspected classes/ 
subsystems that are of interest, while leaving the rest of the system  
only logging at an error level (for example).  The app can then even  
send that log file to he developer automatically, or the user can  
compress it an e-mail it.  These kinds of things are not possible with  
NSLog or ASL, without building a log framework around them.


	If the software you are writing is for in-house use, or your own use,  
then perhaps NSLog  ASL are what's best for you.  And perhaps for  
most Mac software that is the case.  But there are development  
projects out there that simply need more.

___

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

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

On Jan 24, 2009, at 1:19 AM, Antonio Nunes wrote:
I need to be able to force the requested allocation of a cocoa class  
to always return an instance of my subclass. I have looked into ways  
of doing that.


First things first

Why?

Or, more specifically, why do you want to make some bit of framework  
code which currently allocates an instance of A allocate an instance  
of SubA instead?


This is an inherently fragile path to follow.

I have a solution that seems to work, by using a category on the  
class to replace the regular invocation, but from the archives I  
understand that is a Bad Idea that can lead to all manner of  
unpredictable and hard to trace errors. The current implementation  
looks like this:


@implementation PDFDocument (PDFDocument_Alloc)

+ (id)alloc
{
if ([[self class] isEqual:[PDFDocument class]]) {
return [ANPDFDocument alloc];
} else {
return [super alloc];
}
}

@end


This is an excellent demonstration of why category based overrides are  
rife with danger.   The above code is making a boatload of assumptions.


Not the least of which, it assumes that PDFDocument doesn't already  
override +alloc.  If it does, the above breaks it.


The code also assumes that everything that uses PDFDocument is  
perfectly fine with a subclass of PDFDocument instead.   Likely a safe  
assumption for external-to-the-PDF-framework clients, but maybe not so  
much for the internal implementation details of the PDF framework  
itself.


Finally, it assumes that PDFDocument, in and of itself, has nothing  
within itself that uses, say, -isMemberOfClass: to guide behavior.


There are even more ways that the above might break stuff, but you get  
the idea.


However, if you do decide to go down this path, you'll want to test  
across every architecture and bit-width as allocation behavior is one  
of those things that might optimized at such a specific level.


And you would be counting on the allocation behavior to never change  
over releases or updates.


As I wrote, this appears to work fine. But if indeed this technique  
is better avoided, what would be the best alternative? I have looked  
at class_replaceMethod, but am having difficulties implementing it.  
What would be the best way to implement a safe alternative to the  
method listed above?


I would use method_exchangeImplementations(), if absolutely positively  
necessary.   It is about the most innocuous of an otherwise noxious  
encapsulation breaking implementation pattern.


The real question, though, is what are you trying to do?

b.bum

___

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

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

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

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


Re: Forcing allocation of a subclass

2009-01-24 Thread Antonio Nunes

On 24 Jan 2009, at 18:09, Bill Bumgarner wrote:

Or, more specifically, why do you want to make some bit of framework  
code which currently allocates an instance of A allocate an instance  
of SubA instead?


Because of, what I assume to be, a bug in PDFClerkThumbnailView which  
when one drags multiple pages from or within it, puts the pages in a  
PDFDocument instead of in the subclass of PDFDocument, which is where  
the pages live. Dragging a single page works as expected and the page  
is of the correct subclass. Dragging multiple pages leads to errors. I  
filed a bug report for this a while back, but I really need a safe  
workaround until the issue is fixed. (Assuming Apple considers it a  
bug too. I have never received feedback on it.)


This is an excellent demonstration of why category based overrides  
are rife with danger.   The above code is making a boatload of  
assumptions.


I know. That's why I wrote that I understand it is not the way to go,  
but yet that it _appears_ to work.


I would use method_exchangeImplementations(), if absolutely  
positively necessary.   It is about the most innocuous of an  
otherwise noxious encapsulation breaking implementation pattern.


Thanks. I found that a few hours ago and was able to create the  
exchange. However, writing a correct replacement method is another  
thing altogether. The following doesn't work:


Early in application startup:
	Method originalMethod = class_getClassMethod([PDFDocument class],  
@selector(alloc));
	Method replacedMethod = class_getClassMethod([PDFDocument class],  
@selector(allocReplacement));

method_exchangeImplementations(originalMethod, replacedMethod);

Addition to PDFDocument:
+ (id)allocReplacement
{
if ([[self class] isEqual:[PDFDocument class]]) {
return [ANPDFDocument alloc];
} else {
return [super alloc];
}
}

I get the impression it replaces alloc for everything, not just for  
the PDFClerkDocument class. So the app crashes immediately after the  
implementation exchange. Which doesn't surprise me really. But: Is  
there a way to make this work using method_exchangeImplementations, or  
maybe for the particular problem at hand, is there a better way of  
making the PDFThumbnailView use the correct PDFDocument (sub)class   
when it deals with multiple selections.


Just to make this clear: I would really rather not create this  
workaround, but I can't really afford not to let users drag multiple  
pages in the PDFClerkThumbnailView either.


-António



There is nothing as strong as real gentleness, and
there is nothing as gentle as real strength.





___

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

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

It looks like you can set to prepare content AND call fetchWithRequest:

http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CoreData/ 
Articles/cdBindings.html


If the automatically prepares content flag (see, for example,  
setAutomaticallyPreparesContent:) is set for a controller, the  
controller's initial content is fetched from its managed object  
context using the controller's current fetch predicate. It is  
important to note that the controller's fetch is executed as a  
delayed operation performed after its managed object context is set  
(by nib loading)—this therefore happens after awakeFromNib and  
windowControllerDidLoadNib:. This can create a problem if you want to  
perform an operation with the contents of an object controller in  
either of these methods, since the controller's content is nil. You  
can work around this by executing the fetch manually with  
fetchWithRequest:merge:error:. You pass nil as the fetch request  
argument to use the default request, as illustrated in the following  
code fragment.




On Jan 24, 2009, at 12:59 PM, Matt Neuburg wrote:


On Sat, 24 Jan 2009 09:07:59 +, jonat...@mugginsoft.com
jonat...@mugginsoft.com said:


On 24 Jan 2009, at 02:43, David LeBer wrote:


This may be a stupid question, but I've had reason to wonder a
number of times.

If I have an NSArrayController in a nib, bound to a MOC, configured
with an Entity name and set to prepare content:

Is there a way to be notified when it has finished loading and
arranging it's objects?


Hi David

Adding an observer on the controller's arrangedObjects property  
should

do the trick.

[arrayController addObserver:self forKeyPath:@arrangedObjects
options:0 context:(void *)ControllerContentContext];

In a persistent document based app, for example, the controller's MO
content is not yet available in - (void)windowControllerDidLoadNib:
(NSWindowController *)windowController.
Adding the observer means you can set up any dependent code when the
binding/core data machinery has finished doing its thing.


Is that really true? I'm not saying you're wrong; I'm really  
asking. When I
posed the same question a couple of years back, I was told that the  
solution
is, do *not* set to prepare content; instead, load the data  
yourself by

calling fetchWithRequest:

[arrayController fetchWithRequest:nil merge:NO error:error];

When that call returns, the data is ready. I just now tried adding
addObserver: to the mix, just as an experiment, and logging reveals  
that I

get two corresponding calls to observeValueForKeyPath:, *before*
fetchWithRequest: has returned. The two calls are quite far apart  
(half a
second or so). Well, I sure wouldn't want to run my dependent  
code half a
second too early. So I'm not convinced that this approach is  
entirely safe,

at least not without some further modification... m.

--
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide - Second Edition!
http://www.amazon.com/gp/product/0596102119



___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes% 
40utoronto.ca


This email sent to dave.fernan...@utoronto.ca


___

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

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


Le 24 janv. 09 à 18:51, Antonio Nunes a écrit :


On 24 Jan 2009, at 18:09, Bill Bumgarner wrote:

Or, more specifically, why do you want to make some bit of  
framework code which currently allocates an instance of A allocate  
an instance of SubA instead?


Because of, what I assume to be, a bug in PDFClerkThumbnailView  
which when one drags multiple pages from or within it, puts the  
pages in a PDFDocument instead of in the subclass of PDFDocument,  
which is where the pages live. Dragging a single page works as  
expected and the page is of the correct subclass. Dragging multiple  
pages leads to errors. I filed a bug report for this a while back,  
but I really need a safe workaround until the issue is fixed.  
(Assuming Apple considers it a bug too. I have never received  
feedback on it.)


This is an excellent demonstration of why category based overrides  
are rife with danger.   The above code is making a boatload of  
assumptions.


I know. That's why I wrote that I understand it is not the way to  
go, but yet that it _appears_ to work.


I would use method_exchangeImplementations(), if absolutely  
positively necessary.   It is about the most innocuous of an  
otherwise noxious encapsulation breaking implementation pattern.


Thanks. I found that a few hours ago and was able to create the  
exchange. However, writing a correct replacement method is another  
thing altogether. The following doesn't work:


Early in application startup:
	Method originalMethod = class_getClassMethod([PDFDocument class],  
@selector(alloc));
	Method replacedMethod = class_getClassMethod([PDFDocument class],  
@selector(allocReplacement));

method_exchangeImplementations(originalMethod, replacedMethod);

Addition to PDFDocument:
+ (id)allocReplacement
{
if ([[self class] isEqual:[PDFDocument class]]) {
return [ANPDFDocument alloc];
} else {
return [super alloc];
}
}



First, as it was said, the designated allocation method is  
allocWithZone and not alloc.


Then, you call alloc in a recursive way in your method. alloc was  
replaced by your allocReplacement, so calling alloc call  
allocReplacement, even in you replacement implementation.


see http://developer.apple.com/samplecode/MethodReplacement/listing3.html

Then, alloc is a class method, so self is already the class. No need  
to do [self class]


It should be

Method originalMethod = class_getClassMethod([PDFDocument class],  
@selector(allocWithZone:));
Method replacedMethod = class_getClassMethod([PDFDocument class],  
@selector(allocWithZoneReplacement:));

method_exchangeImplementations(originalMethod, replacedMethod);

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


___

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

Please do not post admin requests or moderator comments to the list.
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: Long load time of managed object context

2009-01-24 Thread Matt Neuburg

 Date: Fri, 16 Jan 2009 13:03:24 +0100
 From: Matteo Manferdini mat.maili...@gmail.com
 Subject: Long load time of managed object context
 
 I'm testing performance in my application, to see how it behaves with
 a big load of data inside of it. My application is core data based and
 uses array controllers in entity mode to fetch data.
 
 What I discovered is that my app fetched all the managed objects
 present in core data, so I set the fetch predicate of array
 controllers at startup. This reduced dramatically the number of
 objects fetched. The problem though is that my app still takes a lot
 of time to start when is full of data.
 
 I ran the app within instruments, and the core data fetches instrument
 confirms that this is not the problem (my app fetches only 20-30
 objects when starts). But running it under Shark I can see that for
 4-5 seconds after startup the only call on the stack is to the app
 managed object context. So I think it has something to do with
 interaction between managed object context and data stored, even if I
 don't fetch all the data. If I empty the app or leave little data
 inside of it, it starts very quickly.
 
 Does somebody know why this happens? Am I missing something obvious?
 Why does it take so much to the managed object context to load if I
 only fetch few objects? I always read that core data scales well and
 the programming guide states that 10.000 objects are not much for core
 data, but in my app it makes a big difference, so I'm wondering where
 I am wrong.

You don't say what format you're using, but if you're using XML, the entire
XML file has to be loaded and parsed, even before you fetch any objects. 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


Re: Knowing when a NSArrayController is ready

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


On 24 Jan 2009, at 17:59, Matt Neuburg wrote:


On Sat, 24 Jan 2009 09:07:59 +, jonat...@mugginsoft.com
jonat...@mugginsoft.com said:


On 24 Jan 2009, at 02:43, David LeBer wrote:


This may be a stupid question, but I've had reason to wonder a
number of times.

If I have an NSArrayController in a nib, bound to a MOC, configured
with an Entity name and set to prepare content:

Is there a way to be notified when it has finished loading and
arranging it's objects?


Hi David

Adding an observer on the controller's arrangedObjects property  
should

do the trick.

[arrayController addObserver:self forKeyPath:@arrangedObjects
options:0 context:(void *)ControllerContentContext];

In a persistent document based app, for example, the controller's MO
content is not yet available in - (void)windowControllerDidLoadNib:
(NSWindowController *)windowController.
Adding the observer means you can set up any dependent code when the
binding/core data machinery has finished doing its thing.


Is that really true? I'm not saying you're wrong; I'm really asking.  
When I
posed the same question a couple of years back, I was told that the  
solution
is, do *not* set to prepare content; instead, load the data  
yourself by

calling fetchWithRequest:

[arrayController fetchWithRequest:nil merge:NO error:error];

I have been utilising the NSPersistentDocument sample code with  
bindings and prepareContent enabled.
Going back to my code I see that I was actually observing the content  
of an NSObjectController not the arrangedObjects of an  
NSArrayController.

Apologies for that.
This observation seems to work okay, but there may well be issues as  
you suggest observing arrangedObjects.



When that call returns, the data is ready. I just now tried adding
addObserver: to the mix, just as an experiment, and logging reveals  
that I

get two corresponding calls to observeValueForKeyPath:, *before*
fetchWithRequest: has returned. The two calls are quite far apart  
(half a
second or so). Well, I sure wouldn't want to run my dependent code  
half a
second too early. So I'm not convinced that this approach is  
entirely safe,

at least not without some further modification... m.


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.


--
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide - Second Edition!
http://www.amazon.com/gp/product/0596102119





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

2009-01-24 Thread Jean-Daniel Dupas


Le 24 janv. 09 à 19:20, Jean-Daniel Dupas a écrit :



Le 24 janv. 09 à 18:51, Antonio Nunes a écrit :


On 24 Jan 2009, at 18:09, Bill Bumgarner wrote:

Or, more specifically, why do you want to make some bit of  
framework code which currently allocates an instance of A allocate  
an instance of SubA instead?


Because of, what I assume to be, a bug in PDFClerkThumbnailView  
which when one drags multiple pages from or within it, puts the  
pages in a PDFDocument instead of in the subclass of PDFDocument,  
which is where the pages live. Dragging a single page works as  
expected and the page is of the correct subclass. Dragging multiple  
pages leads to errors. I filed a bug report for this a while back,  
but I really need a safe workaround until the issue is fixed.  
(Assuming Apple considers it a bug too. I have never received  
feedback on it.)


This is an excellent demonstration of why category based overrides  
are rife with danger.   The above code is making a boatload of  
assumptions.


I know. That's why I wrote that I understand it is not the way to  
go, but yet that it _appears_ to work.


I would use method_exchangeImplementations(), if absolutely  
positively necessary.   It is about the most innocuous of an  
otherwise noxious encapsulation breaking implementation pattern.


Thanks. I found that a few hours ago and was able to create the  
exchange. However, writing a correct replacement method is another  
thing altogether. The following doesn't work:


Early in application startup:
	Method originalMethod = class_getClassMethod([PDFDocument class],  
@selector(alloc));
	Method replacedMethod = class_getClassMethod([PDFDocument class],  
@selector(allocReplacement));

method_exchangeImplementations(originalMethod, replacedMethod);

Addition to PDFDocument:
+ (id)allocReplacement
{
if ([[self class] isEqual:[PDFDocument class]]) {
return [ANPDFDocument alloc];
} else {
return [super alloc];
}
}



First, as it was said, the designated allocation method is  
allocWithZone and not alloc.


Then, you call alloc in a recursive way in your method. alloc was  
replaced by your allocReplacement, so calling alloc call  
allocReplacement, even in you replacement implementation.


see http://developer.apple.com/samplecode/MethodReplacement/listing3.html

Then, alloc is a class method, so self is already the class. No need  
to do [self class]


It should be

Method originalMethod = class_getClassMethod([PDFDocument class],  
@selector(allocWithZone:));
Method replacedMethod = class_getClassMethod([PDFDocument class],  
@selector(allocWithZoneReplacement:));

method_exchangeImplementations(originalMethod, replacedMethod);

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



Sorry, this is not
return [super allocWithZoneReplacement:aZone];
but
return [self allocWithZoneReplacement:aZone];


___

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

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


Le 24 janv. 09 à 19:20, Bill Bumgarner a écrit :


Thanks. I found that a few hours ago and was able to create the  
exchange. However, writing a correct replacement method is another  
thing altogether. The following doesn't work:


Early in application startup:
	Method originalMethod = class_getClassMethod([PDFDocument class],  
@selector(alloc));
	Method replacedMethod = class_getClassMethod([PDFDocument class],  
@selector(allocReplacement));

method_exchangeImplementations(originalMethod, replacedMethod);

Addition to PDFDocument:
+ (id)allocReplacement
{
if ([[self class] isEqual:[PDFDocument class]]) {
return [ANPDFDocument alloc];
} else {
return [super alloc];
}
}

I get the impression it replaces alloc for everything, not just for  
the PDFClerkDocument class. So the app crashes immediately after  
the implementation exchange. Which doesn't surprise me really. But:  
Is there a way to make this work using  
method_exchangeImplementations, or maybe for the particular problem  
at hand, is there a better way of making the PDFThumbnailView use  
the correct PDFDocument (sub)class when it deals with multiple  
selections.


Just to make this clear: I would really rather not create this  
workaround, but I can't really afford not to let users drag  
multiple pages in the PDFClerkThumbnailView either.


Ahh... yes -- my suggestion was slightly misleading.

class_getClassMethod() will walk the class hierarchy and return a  
super's implementation, if the method itself is not found in the  
subclass.


This is expected, and not a problem with exchange implementation.

You'll need to detect whether or not the method already exists in  
the targeted class.  You can use class_copyMethodList() to grab the  
methods specific to the class and then hunt about within to see if  
the targeted method is implemented.


Not require here, but my way to do this is the following one:

  Method originalMethod = class_getClassMethod([PDFDocument class],  
@selector(allocWithZone:));
  Method superMethod =  
class_getClassMethod(class_getSuperclass([PDFDocument class]),  
@selector(allocWithZone:));	

  if (superMethod == originalMethod) {
// PDF Document does not override allowWithZone:
  }

If so, the method_exchangeImplementations() pattern will work.  If  
not, you'll need to add the method to the class via class_addMethod().


Normally, when doing this kind of thing, you absolutely positively  
must call the original implementation of the method -- whether it be  
in the class or in the superclass -- to ensure that you preserve any  
existing behaviors.




Yes, but to call the original impl, you don't use super. You call  
[self allocReplacement]


+alloc, though, is slightly different in that classes typically only  
override +alloc when they want to do some kind of custom allocation  
behavior and, by doing so, they would almost never (but not never)  
call through to super's implementation.


And so, exchanging alloc is not different than exchanging any other  
method.


If you are actually replacing +alloc (which, in this case, it seems  
not), well that can be very very tricky.


b.bum


___

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

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

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

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


Re: Knowing when a NSArrayController is ready

2009-01-24 Thread Matt Neuburg
On or about 1/24/09 10:17 AM, thus spake jonat...@mugginsoft.com
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.

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


Re: Using the security framework

2009-01-24 Thread Joe Turner

I think I figured out how SD does it:

When you unlock SD!, it calls AEWP() on SDAgent. Then, SDAgent calls  
setuid(0) to make itself root. With it as root, when it calls SDCopy,  
or SDDiskTool, it calls it with AEWP, and since it's root, it doesn't  
need the user's password to do this!


This is just my guess. But it sounds fairly right :)

Cheers,

Joe Turner
On Jan 24, 2009, at 6:47 AM, Michael Ash wrote:


On Fri, Jan 23, 2009 at 10:59 PM, Joe Turner joetur...@me.com wrote:
Okay, so, it seems everyone was right :) I went to cocoabuilder to  
find some

of the responses to this, that I never got.

Anyways, it seems I can just call AEWP() once, and it should stay  
suid.


So, my last question to everyone is, how do I know if the tool is  
suid. I
mean, I could implement some sort of lock-unlock thing, and then I  
would be

pretty sure, but is there anyway to know for sure?

And, is there a way to take SUID away from it? So, if I want to  
lock it, it

would work.


man 2 stat to check the bit, man 2 chmod to set it.

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

This email sent to joetur...@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: Targetting Tiger

2009-01-24 Thread Marcus


24 jan 2009 kl. 16.56 skrev Steve Christensen:

And I'd suggest getting your hands on a 10.4 system of your own,  
particularly if current or future customers have that as a  
requirement. My customer does so I'm doing all my development with  
Xcode 2.5 on a 10.4.11 system. I make sure everything works on 10.4  
first, then also make sure that nothing weird happens on 10.5.


I don't know if it will be much of a help, but Xcode 2.5 can be  
installed side by side with Xcode 3 on Leopard.




smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Targetting Tiger

2009-01-24 Thread John Joyce
Your best bet is to purchase a used Mac that can run Tiger and use it  
for test builds. There is a huge installed userbase of Tiger still,  
remember it has been the longest single incarnation of OS X. (as a  
result of this long life of Tiger, there are lots of affordable used  
macs that can do the work. An iBook G4 or even a dual-processor G4  
PowerMac, or a G5 iMac would be totally affordable and reasonable  
options that would handle it well.)


You second best bet, install Xcode 2.5 on Leopard. This will be very  
near to the same as what can actually run on Tiger and will help you  
be sure that you're developing using Nibs and items that can compile  
on Tiger.



___

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

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

2009-01-24 Thread Chris Hanson

On Jan 24, 2009, at 8:48 AM, Matt Long 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.


Macs typically doesn't support operating system releases earlier than  
the one with which it shipped, because earlier releases don't include  
the appropriate hardware drivers.


  -- Chris

___

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

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


NSRunloop performSelector needs CFRunLoopWakeUp ?

2009-01-24 Thread David Hoerl
I have a few hundred tasks to handle, and am using NSRunLoop's 
performSelector to get the scheduled:


-(void)nextTask:(SEL)sel
{
[[NSRunLoop mainRunLoop] performSelector:sel target:self argument:nil order:0
modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];

CFRunLoopRef crf = [[NSRunLoop mainRunLoop] getCFRunLoop];
CFRunLoopWakeUp(crf);

}

One process sends the first message to the worker object. When the 
first task is done,  nextTask: is used to schedule the next one.


Well, it was bizarre - before the CFRunLoopWakeUp addition, only 6 or 
7 of the tasks would run, then the process would stall. NSLogs showed 
the performSelector message, then nothing.


But, wait, there's more! If I clicked on a window, or clicked on a 
menu, then 7 more tasks would run, then another stall. Every click 
caused 7 more messages.


In desperation I added the CFRunLoopWakeUp() call; now it runs as I 
would expect.


There is an oblique reference to CFRunLoopWakeUp in the Threading 
Programming Guide (where documentation on Run Loop Management has 
moved), but the usages is for a different purpose (it would seem).


What seems really odd is that I have used this technique in the past 
without issue. The current app is single threaded.


Can anyone shed any light on why the CFRunLoopWakeUp() call is 
necessary? Is there some other issue I'm missing?


David
PS: Xcode 3.1.2, Leopard 32bit app

PSS: yes, I did google on NSRunLoop performSelector 
CFRunLoopWakeUp, and did find the below note from 2002. However, 
there is not mention of this in the Threading Programming Guide. Note 
that [NSRunLoop  performSelector] results in the creation of a very 
short timer:


If you add a timer to the main thread's run loop (which presumably
you've squirreled away somewhere), be sure to use CFRunLoopWakeUp() on
the CFRunLoopRef of the NSRunLoop.  Cocoa won't do that for you
currently (and it's not clear it should -- might degrade the performance
unnecessarily).

Chris Kane
Cocoa Frameworks, Apple






___

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

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

On 24 Jan 2009, at 19:20, Bill Bumgarner wrote:

If so, the method_exchangeImplementations() pattern will work.  If  
not, you'll need to add the method to the class via class_addMethod().


Let's see if I understand this correctly: you mean I need to add  
alloc, or as suggested, allocWithZone: zone to the PDFClerkDocument  
class, and after that, I suppose, exchange the method implementations?


Make use of Bill's and Jean-Daniel's suggestions I now have:

	Method originalMethod = class_getClassMethod([PDFDocument class],  
@selector(allocWithZone:));
	Method superMethod =  
class_getClassMethod(class_getSuperclass([PDFDocument class]),  
@selector(allocWithZone:));	

if (superMethod == originalMethod) {
// PDF Document does not override allocWithZone:
		IMP replacement = class_getMethodImplementation([PDFDocument class],  
@selector(replacementAllocWithZone:));

BOOL success = class_addMethod([PDFDocument class],
   
@selector(allocWithZone:),
   
replacement,
   
@@:@);
}   

I verified that the method is added correctly. However, the  
replacement method appears not to be called, so I must be doing  
something wrong.


From my understanding, the second argument to class_addMethod is the  
name the added method will have, so that should be  
replacementAllocWithZone, the third argument is the IMP of the  
replacement, and the last argument is the array of characters  
describing the of the method arguments, resp an object as the return  
type, self and cmd and the NSZone object. Is this correct?


-António

---
Some things have to be believed to be seen.

--Ralph Hodgson
---



___

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

Please do not post admin requests or moderator comments to the list.
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-24 Thread Stephen J. Butler
On Sat, Jan 24, 2009 at 2:42 PM, David Hoerl dho...@mac.com wrote:
 I have a few hundred tasks to handle, and am using NSRunLoop's
 performSelector to get the scheduled:

 -(void)nextTask:(SEL)sel
 {
 [[NSRunLoop mainRunLoop] performSelector:sel target:self argument:nil
 order:0
modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];

 CFRunLoopRef crf = [[NSRunLoop mainRunLoop] getCFRunLoop];
 CFRunLoopWakeUp(crf);

 }

[snip]

 What seems really odd is that I have used this technique in the past without
 issue. The current app is single threaded.

I'm kind of confused as to how 10.5 extended NSRunLoop. On the one
hand, there's this +[NSRunLoop mainRunLoop] method that seems to imply
you can play with the main runloop from other threads. On the other,
the documentation is still littered with warnings that NSRunLoop is
not thread safe. Talk about mixed messages!

Also, -[NSObject
performSelectorOnMainThread:withObject:waitUntilDone:] now uses
NSRunLoopCommonModes -- instead of NSRunLoopDefaultModes -- when it
places the selector in the runloop. And NSRunLoopCommonModes is a new
constant in 10.5.

So I guess my question is what happens when you change your code to this:

-(void)nextTask:(SEL)sel
{
  [self performSelectorOnMainThread:sel withObject:nil waitUntilDone:NO];
}
___

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

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

2009-01-24 Thread Steve Christensen

On Jan 24, 2009, at 9:22 AM, Thomas Davie wrote:


On 24 Jan 2009, at 17:48, Matt Long 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.
Fraid not, the two machines I have available to develop on are too  
new to run tiger – there's no drivers for them.


It's going to be a nightmare to debug the environment if you don't  
have a dev environment to match. I've (hate to admit it) tried  
this before. It did not work out well and the customer was pretty  
frustrated as I was trying to get them to try my debug builds  
and report back to me. Not one of my brighter moments. ;-)
Yep, I can imagine, the working on tiger criteria kinda got sprung  
on me, I'm thinking at the moment that the best solution is to buy  
an ancient mac, and test it on that.


Is an iMac from 2008 ancient? That's what I'm using with Tiger.

steve

___

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

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

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

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


Re: Targetting Tiger

2009-01-24 Thread Thomas Davie


On 24 Jan 2009, at 22:17, Steve Christensen wrote:


On Jan 24, 2009, at 9:22 AM, Thomas Davie wrote:


On 24 Jan 2009, at 17:48, Matt Long 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.
Fraid not, the two machines I have available to develop on are too  
new to run tiger – there's no drivers for them.


It's going to be a nightmare to debug the environment if you don't  
have a dev environment to match. I've (hate to admit it) tried  
this before. It did not work out well and the customer was pretty  
frustrated as I was trying to get them to try my debug builds  
and report back to me. Not one of my brighter moments. ;-)
Yep, I can imagine, the working on tiger criteria kinda got sprung  
on me, I'm thinking at the moment that the best solution is to buy  
an ancient mac, and test it on that.


Is an iMac from 2008 ancient? That's what I'm using with Tiger.


I didn't claim that all machines that can run Tiger are ancient – I  
implied that all cheep machines capable of running tiger are ancient.


Bob___

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

Please do not post admin requests or moderator comments to the list.
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-24 Thread Joe Turner
So, you are saying that I must create an install tool, that installs  
my utility that will run as root?

On Jan 24, 2009, at 2:23 PM, Chris Hanson wrote:

The proper way to construct everything you've described is discussed  
in the Authorization Services Programming Guide.


Authorization Services Programming Guide

http://developer.apple.com/documentation/Security/Conceptual/authorization_concepts/index.html

The current, most up-to-date and correct example of constructing an  
application with a helper that performs privileged operations  
securely on its behalf is BetterAuthorizationSample which replaces  
the previous MoreAuthSample example code.


BetterAuthorizationSample

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

It is critical to your users' security that you understand  
everything presented in the above programming guide and example  
before you attempt to write code that needs to run with elevated  
privileges.  You must not simply use  
AuthorizationExecuteWithPrivileges to run arbitrary code or scripts  
as root.  You must install your helper tool securely.  There's a  
lot to do if you want to run code with elevated privileges, and it  
must be done correctly; the rationale for the design recommended by  
the Programming Guide and BetterAuthorizationSample is documented in  
Design and Implementation Rationale.txt within the example:


BetterAuthorizationSample - Design and Implementation Rationale

http://developer.apple.com/samplecode/BetterAuthorizationSample/listing4.html

Unfortunately, when it comes to system security there's no I'm  
just… or I simply want to…  All i's must be dotted and all t's  
crossed, or you risk compromising your users' security.  Fortunately  
there's extensive documentation on how to manage the complexity  
involved, and you can provide a decent user experience if you do the  
cooking by the book.


  -- Chris



___

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

Please do not post admin requests or moderator comments to the list.
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: Switching NSDocument based application to tabbed views interface

2009-01-24 Thread Fritz Anderson

On 22 Jan 2009, at 1:00 PM, Klaus Backert wrote:

It's the difference between Search for: All of the words and  
Search for: Any of the words. You can choose this in the Advanced  
search. The default is _Any_, because of which more than 40.000  
results are found in this case.


Well, that's embarrassing. Sometimes I don't look closely enough.  
Google spoiled me.


— 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


Creating a managed object without adding it to the context?

2009-01-24 Thread Ulai Beekam

Hi,


How do I programmatically create a managed object (with respect to some entity 
in a particular context of course) but WITHOUT adding it to the context?


The reason I want this is to be able to take that new managed object and add it 
via an NSArrayController (one that is connected to said context of course) 
instead. That way I will get all the benefits of the array controller, such as 
the newly inserted object getting selected in a table view that is bound to the 
array controller.


Regards,
U

_
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx___

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

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

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

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


Re: Forcing allocation of a subclass

2009-01-24 Thread Jean-Daniel Dupas


Le 24 janv. 09 à 22:13, Antonio Nunes a écrit :

Sorry, sent this before I had finished making the necessary changes,  
I don't think I need to exchange any implementations if I add the  
method with the correct selector (allocWithZone:)


===

On 24 Jan 2009, at 19:20, Bill Bumgarner wrote:

If so, the method_exchangeImplementations() pattern will work.  If  
not, you'll need to add the method to the class via  
class_addMethod().


Let's see if I understand this correctly: you mean I need to add  
alloc, or as suggested, allocWithZone: zone to the PDFClerkDocument  
class, and after that, I suppose, exchange the method implementations?


No, you don't have to do this if you use exchangeMethod correctly.
You may want to add one to not affect other objects, but it is not  
required.


Just in case:

Calling the original implementation in a method you have exchanged is  
done using


[self replacedMethodName]

and in a method added at runtime, you have to call

[super originalMethodName]



Make use of Bill's and Jean-Daniel's suggestions I now have:

	Method originalMethod = class_getClassMethod([PDFDocument class],  
@selector(allocWithZone:));
	Method superMethod =  
class_getClassMethod(class_getSuperclass([PDFDocument class]),  
@selector(allocWithZone:));	

if (superMethod == originalMethod) {
// PDF Document does not override allocWithZone:
		IMP replacement = class_getMethodImplementation([PDFDocument  
class], @selector(replacementAllocWithZone:));

BOOL success = class_addMethod([PDFDocument class],
   
@selector(allocWithZone:),
   
replacement,
   
@@:@);
}   


I verified that the method is added correctly. However, the  
replacement method appears not to be called, so I must be doing  
something wrong.


From my understanding, the second argument to class_addMethod is the  
name the added method will have, so that should be  
replacementAllocWithZone, the third argument is the IMP of the  
replacement, and the last argument is the array of characters  
describing the of the method arguments, resp an object as the return  
type, self and cmd and the NSZone object. Is this correct?



Yes it is, but if you don't want to bother with the type string, just  
query it using runtime functions:


And you want to add a class method, not an instance method. You have  
to add this method to the 'PDFDocument class' meta-class.


  Method originalMethod = class_getClassMethod([PDFDocument class],  
@selector(allocWithZone:));
  Method superMethod =  
class_getClassMethod(class_getSuperclass([PDFDocument class]),  
@selector(allocWithZone:));


  Method replacedMethod = class_getClassMethod([PDFDocument class],  
@selector(replacementAllocWithZone:));

  if (superMethod == originalMethod) {
class_addMethod(object_getClass([PDFDocument class]),  
@selector(allocWithZone:),

method_getImplementation(replacedMethod),
method_getDescription(replacedMethod)-types);
  }


___

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

Please do not post admin requests or moderator comments to the list.
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: Creating a managed object without adding it to the context?

2009-01-24 Thread Jerry Krinock

On 2009 Jan 24, at 14:13, Ulai Beekam wrote:

How do I programmatically create a managed object (with respect to  
some entity in a particular context of course) but WITHOUT adding it  
to the context?


I do not believe this is possible.  A managed object without a context  
would not be managed.


The reason I want this is to be able to take that new managed object  
and add it via an NSArrayController (one that is connected to said  
context of course) instead. That way I will get all the benefits of  
the array controller, such as the newly inserted object getting  
selected in a table view that is bound to the array controller.



You indicated in your first sentence that you know which managed  
object context the new object is destined for.  I don't see the  
problem.  Just insert it when you create it.




 
___


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

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

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

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


Re: Targetting Tiger

2009-01-24 Thread Steve Christensen

On Jan 24, 2009, at 11:34 AM, Marcus wrote:


24 jan 2009 kl. 16.56 skrev Steve Christensen:

And I'd suggest getting your hands on a 10.4 system of your own,  
particularly if current or future customers have that as a  
requirement. My customer does so I'm doing all my development with  
Xcode 2.5 on a 10.4.11 system. I make sure everything works on  
10.4 first, then also make sure that nothing weird happens on 10.5.


I don't know if it will be much of a help, but Xcode 2.5 can be  
installed side by side with Xcode 3 on Leopard.


That's true, but then you couldn't -test- your code on a 10.4 system  
to make sure it actually works.


steve

___

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

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

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

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


Re: Knowing when a NSArrayController is ready

2009-01-24 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
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 changed my store type to SQLite and noted an immediate improvement  
in load times.


The biggest boost by far though came from setting NSObjectController  
setUsesLazyFetching:YES.
The 10.5 release notes state that this can give a big boost and for an  
NSArrayController bound to an NSTableView it seems very true.
The only down side is that searches are noticeably slower as the data  
has to be retrieved from the store, if not already present, at search  
time.


I did not use -fetchWithRequest but left - prepareContent = YES. All  
bindings were set in the nib.
Core data has improved a lot of the years so perhaps the prohibition  
on - prepareContent no longer applies.
But I agree that pulling all this stuff out of the nib lets you get a  
lot close to the action.


Obviously the complexity of the model and the number/complexity of  
derived properties will be a factor too.
My model is very simple, the most complex bit being extracting an  
NString rep of an RTF data object for search purposes.
The NSTableView data now appears in about 1/5 of the time it did  
previously!


With regard to your earlier point I put an observer on the  
NSArrayController's arrangedObjects and received a single notification  
as expected.

So I don't know why you were getting two notifications.

Thanks for your response - it put me on the right track!


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





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

2009-01-24 Thread Chris Hanson

On Jan 24, 2009, at 1:41 PM, Joe Turner wrote:

So, you are saying that I must create an install tool, that installs  
my utility that will run as root?


I am saying that, in order to maintain your users' system security,  
you must follow the guidance in the Authorization Services Programming  
Guide and BetterAuthorizationSample example code when implementing  
software that needs to run with elevated privileges.


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.


You can still ship your application as a drag-install; for example,  
your application itself can include an installer package to do the  
actual installation of the tool it uses and its launchd plist, and  
open the package in Installer.app if the tool needs to be installed.


  -- Chris

___

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

Please do not post admin requests or moderator comments to the list.
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: Creating a managed object without adding it to the context?

2009-01-24 Thread Ben Trumbull

On 2009 Jan 24, at 14:13, Ulai Beekam wrote:


How do I programmatically create a managed object (with respect to
some entity in a particular context of course) but WITHOUT adding it
to the context?


I do not believe this is possible.  A managed object without a context
would not be managed.


The second does not imply the first.  You can simply pass in nil to  
the designated initializer.  The object will not be managed.  No  
saving, no undo, no MOC notifications, etc.  The biggest issue is that  
without a MOC, no one is observing relationship changes, so it's  
trivially easy to corrupt an object graph by failing to maintain  
inverses by hand.


In theory, if an entity had no relationships this would work fine.


The reason I want this is to be able to take that new managed object
and add it via an NSArrayController (one that is connected to said
context of course) instead. That way I will get all the benefits of
the array controller, such as the newly inserted object getting
selected in a table view that is bound to the array controller.



You indicated in your first sentence that you know which managed
object context the new object is destined for.  I don't see the
problem.  Just insert it when you create it.


You can simply call -insertObject on the MOC with the new MO when you  
are ready.  However, any changes you make to the object between the  
time of +alloc and -insertObject: will be unobserved.  All the same  
issues about using -awakeFromInsert instead of -initWithEntity:... to  
perform initializations on modeled properties apply here.


- 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


iPhone Compositing

2009-01-24 Thread David Blanton


CoreImage is not available on iPhone so the CALayer property  
compositingFilter is undefined.


The docs say that by default a layer is composited using source- 
over.  Is this true for iPhone as well?


David Blanton


___

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

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

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

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


iPhone Vibrate

2009-01-24 Thread David Blanton

I want to be sensitive to battery usage in the iPhone.

When calling

AudioServicesPlayAlertSound ( kSystemSoundID_Vibrate  );

How much battery does this use?  I may be calling this 'alot' in my  
application.





David Blanton





___

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

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

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

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


RE: Creating a managed object without adding it to the context?

2009-01-24 Thread Ulai Beekam

 You indicated in your first sentence that you know which managed  
 object context the new object is destined for.  I don't see the  
 problem.  Just insert it when you create it.

My problem is that when I add directly to the managed object context, the item 
is not getting selected automatically in the array controller (by the way, I 
see the selection visually by means of the table view bound to the array 
controller) even if I have checked the select on insert checkbox on the array 
controller in Interface Builder.
That's why I asked about this. But yes, when I come to think about it now as 
you say it, it kind of makes little sense to be creating a managed object that 
is not in the context.
_
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx___

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

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

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

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


Re: iPhone Vibrate

2009-01-24 Thread Ricky Sharp


On Jan 24, 2009, at 5:31 PM, David Blanton wrote:


I want to be sensitive to battery usage in the iPhone.

When calling

AudioServicesPlayAlertSound ( kSystemSoundID_Vibrate  );

How much battery does this use?  I may be calling this 'alot' in my  
application.



Reposting messages will not get them answered any quicker.  In fact,  
you risk them not being answered at all.


Having said that, this is really the wrong forum for iPhone-specific  
questions such as this one.  It's best to ask on the dedicated iPhone  
developer forums when you log in to your iPhone dev account.


___
Ricky A. Sharp mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.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: Log4Cocoa

2009-01-24 Thread Robert Kukuchka

I'm in the process of kicking it's tires, and I'm liking it so far.

Logging frameworks are one of those things that I'm surprised we don't  
see more Open Source solutions. Probably because logging frameworks  
aren't necessarily glorious, but they're incredibly utilitarian and in  
my opinion necessary.


I look forward to playing more with Log4Cocoa!

On 24-Jan-09, at 9:10 AM, Rob Ross wrote:

I have never used the Log4Cocoa implementation, but I use the Java  
version (log4j) every day. It's got a great API so if Log4Cocoa uses  
most of the same API I would definitely say use it.  It's simple,  
lightweight, and you can learn enough to cover 80% of your needs in  
a just a few hours. It's also configureable enough to most likely  
handle that remaining 20% of things you want to do with it.


Rob


On Jan 21, 2009, at 2:20 PM, Robert Kukuchka wrote:

Apparently this Log4Cocoa project is based off of a Java project  
which is highly configurable. I'm trying to do an evaluation on the  
code from SF: http://sourceforge.net/projects/log4cocoa/
Files were updated in 08, but mailing list last updated in 06. Not  
sure if it's dead or what...



On 21-Jan-09, at 1:48 PM, jonat...@mugginsoft.com wrote:



On 21 Jan 2009, at 21:40, Robert Kukuchka wrote:

I was hoping to find something with built in log level support  
and non-recompile options to turn logging modules on / off


On .NET you can accomplish this with the Enterprise Library  
Logging Application Block, which is very highly configurable.
I looked around for similar functionality in Cocoa frameworks  
about a year ago and did not find anything remotely similar.


But maybe it is hiding out there in the bushes somewhere...



On 21-Jan-09, at 1:15 PM, Kyle Sluder wrote:

On Wed, Jan 21, 2009 at 2:58 PM, Robert Kukuchka rkukuc...@gmail.com 
 wrote:

 I'm looking into logging frameworks and see references to this
project. Does anyone know if this project is still running? I  
was hoping to
find some examples of how to get things setup. Anyone here use  
it within a
commercial application? Our Mac team is small, so if I don't  
have to roll

my own, I'd rather not.


Why not use ASL, since it's built into the OS?
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/asl.3.html

--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/jonathan%40mugginsoft.com

This email sent to jonat...@mugginsoft.com


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/rkukuchka%40gmail.com

This email sent to rkukuc...@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/rob.ross%40gmail.com

This email sent to rob.r...@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


Coverflow like background drawing?

2009-01-24 Thread Alex Kac
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?


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

The optimist proclaims that we live in the best of all possible  
worlds; and the pessimist fears this is true.

-- James Clabell




___

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

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


Le 25 janv. 09 à 01:10, Alex Kac a écrit :

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?


Coverflow does not draw in the background, it load image in background  
(and maybe resize them to improve drawing).


Drawing 5 or more images should not be slow enough to have to bother  
with threading.


And if it's not fast enough using Cocoa, convert your image into  
OpenGL texture and use OpenGL to draw them.





___

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

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

2009-01-24 Thread Clark Cox
On Sat, Jan 24, 2009 at 8:48 AM, Matt Long matt.l...@matthew-long.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.

-- 
Clark S. Cox III
clarkc...@gmail.com
___

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

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

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

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


Re: Opening Invisible Files

2009-01-24 Thread Rob Keniger


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.

--
Rob Keniger



___

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

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

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

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


Re: Opening Symbolic Links

2009-01-24 Thread Rob Keniger


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.


--
Rob Keniger



___

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

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

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

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


Re: Not Resolving Aliases

2009-01-24 Thread Michael Ash
On Sat, Jan 24, 2009 at 9:54 AM, Gerriet M. Denkmann
gerr...@mdenkmann.de 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.

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: NSCaledarDate's deprecation

2009-01-24 Thread Michael Ash
On Sat, Jan 24, 2009 at 4:14 PM, Nick Zitzmann n...@chronosnet.com wrote:

 On Jan 24, 2009, at 9:40 AM, Paul Bruneau wrote:

 Why spend so much time and effort to remove some code that is going to
 keep running fine for years?


 Because you don't know that. Stuff can change at any time and break your
 application in unexpected ways in the future, though you do get advance
 warning. Some people around here might remember the chaos that ensued when
 Apple shipped Mac OS 7.0 18 years ago. Mac OS 7 introduced real 32-bit
 addressing, which completely blew away every app that assumed that the top 8
 bits of a pointer were unused by the OS (in Mac OS 6 and earlier, the OS
 used 4-byte pointers, but the top byte wasn't doled out by the OS).

Bad analogy. That top byte was always marked as reserved. Applications
that noticed it was unused and used it were violating Apple's API
contract.

Apple has, as far as I know, never actually removed or disabled a Mac
OS X API without also crossing a binary compatibility boundary. (E.g.
they removed the GUI bits of Carbon, but only if you cross into 64-bit
land.)

NSCalendarDate isn't even deprecated yet. Apple is not going to remove
it in any way that would break currently shipping code. They *may*
remove it the next time they cross a binary compatibility boundary,
but that would only happen after they *officially* deprecate it
(instead of this will be deprecated weasel word nonsense) and then
your currently shipping code will still be unaffected; only if you try
to make your code cross that boundary will you encounter problems.

In conclusion, rewriting a bunch of code that uses a class that isn't
even deprecated yet, just discouraged, is pointless unless you get
some other benefit from doing so. With NSCalendarDate, that other
benefit is being able to use non-Gregorian calendars. If that helps
you, great, if you're married to Gregorian for reasons other than
using NSCalendarDate then there's absolutely no reason to switch now.

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-24 Thread Michael Ash
On Sat, Jan 24, 2009 at 6:08 PM, Chris Hanson c...@me.com 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?

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: Nib memory management under Garbage Collection

2009-01-24 Thread Rob Keniger


On 16/01/2009, at 2:26 PM, mmalc Crawford wrote:

Since the collector follows strong references from root objects,  
and treats as garbage all objects that cannot be reached from a root  
object, you must ensure that there are strong references to all top- 
level objects in a nib file (including for example, stand-alone  
controllers)—otherwise they will be collected. You can create a  
strong reference simply by adding an outlet to the File's Owner and  
connecting it to a top-level object. (In practice this is rarely  
likely to be an issue.)


Nib Files: http://developer.apple.com/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcEssentials.html 




Just following up on this thread for the archives, there is a  
definitive guide for Nib Memory Management under GC and non-GC on this  
page:


http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/LoadingResources/CocoaNibs/chapter_3_section_4.html#/ 
/apple_ref/doc/uid/1051i-CH4-SW6



--
Rob Keniger



___

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

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

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

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


Re: Creating a managed object without adding it to the context?

2009-01-24 Thread Jerry Krinock


On 2009 Jan 24, at 15:51, Ulai Beekam wrote:

My problem is that when I add directly to the managed object  
context, the item is not getting selected automatically in the array  
controller (by the way, I see the selection visually by means of the  
table view bound to the array controller) even if I have checked the  
select on insert checkbox on the array controller in Interface  
Builder.


I'm still confused about what you're having trouble with.  But,  
inserting a managed object and selecting it in a table controlled by  
an array controller is a very standard design, like this...


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

When you run that sample project, click Add, fill in a name and you  
see your new Employee gets selected in the table.  Just study how it's  
done there.


___

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

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


On Jan 24, 2009, at 10:18 PM, Michael Ash wrote:


On Sat, Jan 24, 2009 at 3:42 PM, David Hoerl dho...@mac.com wrote:


[...]


The current app is single threaded.

Can anyone shed any light on why the CFRunLoopWakeUp() call is  
necessary? Is

there some other issue I'm missing?


Look at the big master list of what Cocoa classes are thread safe:


The OP wrote that his app is single threaded, so the lack of NSRunLoop  
thread safety shouldn't be a problem.  It sounds like the event loop  
is blocking the runloop, so maybe posting a custom event would work as  
well as tickling the runloop...but that's just a guess.


--
Adam



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: NSRunloop performSelector needs CFRunLoopWakeUp ?

2009-01-24 Thread Michael Ash
On Sat, Jan 24, 2009 at 11:07 PM, Adam R. Maxwell amaxw...@mac.com wrote:

 On Jan 24, 2009, at 10:18 PM, Michael Ash wrote:

 On Sat, Jan 24, 2009 at 3:42 PM, David Hoerl dho...@mac.com wrote:

 [...]

 The current app is single threaded.

 Can anyone shed any light on why the CFRunLoopWakeUp() call is necessary?
 Is
 there some other issue I'm missing?

 Look at the big master list of what Cocoa classes are thread safe:

 The OP wrote that his app is single threaded, so the lack of NSRunLoop
 thread safety shouldn't be a problem.  It sounds like the event loop is
 blocking the runloop, so maybe posting a custom event would work as well as
 tickling the runloop...but that's just a guess.

Man, missing one tiny sentence is enough to make a guy look like an
idiot. Oh well, thanks for pointing it out.

I think you're right about the event. Reading the documentation:

This method sets up a timer to perform the aSelector message on the
current thread's run loop at the start of the next run loop
iteration.

I think the words the next run loop iteration are key here. It will
invoke your method at the next run loop iteration... but it won't make
that iteration happen any sooner!

For what the OP wants, I think the best thing would be to just avoid
that method. Use -performSelector:withObject:afterDelay: (with a 0
delay) or a non-repeating NSTimer (with a 0 interval).

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


Fwd: ibplugin - framework - application

2009-01-24 Thread Richard Humiston
I may have found a solution.  I built a separate framework containing  
the same objects and incorporated it into my app.  The app functions  
without the plugin or plugin framework being installed in library/ 
frameworks.  The framework and plugin need  to be installed in order  
to open the nib file to work with the interface, but I guess that  
makes sense.


Rich


Begin forwarded message:


From: Richard Humiston rhumis...@comcast.net
Date: January 23, 2009 9:09:35 PM EST
To: cocoa-dev@lists.apple.com
Subject: ibplugin - framework - application

I built an ibplugin and framework for a custom control using the ib  
plugin programming guide documentation.  The plugin works fine.   
Shows up in the library.  I can drag it to a window, configure with  
a custom inspector, etc.  When I create an Xcode project and use the  
control in a nib file and build the application, everything works as  
expected.  I noticed if I remove the frameworks from library/ 
frameworks, the nib file is not abel to load.  If I put the  
frameworks back in library/frameworks, the app functions again.


I also noticed that the plugin needs the framework in order to  
function in IB.  I would like to incorporate the frameworks into my  
app rather than have it in library/frameworks, but then the plugin  
won't function in IB while I'm building the interface.  It looks  
like most of the posts here are concerned with ibplugins and  
frameworks as they apply to IB.  Is there a solution to this problem?


thank you,

Rich




___

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

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


building a file path

2009-01-24 Thread mathew

hello,

i'm writing some code that saves a file on the iphone,
there's no user intervention / file dialog involved.


so once i've found the documents directory

code

	NSArray *paths =  
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,  
NSUserDomainMask, YES);


if ([paths count]  1)
{
//failed
return;
}

NSString* path = [paths objectAtIndex:0];

/code

should I just manually build a file path string by adding /myfolder/ 
myfile.xml' to 'path'


or is there a correct way to do it that doesn't involve hard coding  
the slashes into the filepath?




cheers
thanks for your help

mathew
___

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

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


addSubview bottleneck

2009-01-24 Thread Twisted Theory
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/archive%40mail-archive.com

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


Re: building a file path

2009-01-24 Thread Dave DeLong

You should use the path methods on NSString:

NSString * filePath = [[path  
stringByAppendingPathComponent:@myfolder]  
stringByAppendingPathComponent:@myfile.xml];


Cheers,

Dave

On 23 Jan, 2009, at 11:00 PM, mathew wrote:

should I just manually build a file path string by adding /myfolder/ 
myfile.xml' to 'path'


or is there a correct way to do it that doesn't involve hard coding  
the slashes into the filepath?

___

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

Please do not post admin requests or moderator comments to the list.
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-24 Thread Scott Anguish
CovertFlow source code is in the Developer/SampleCode directory. You  
should be able to see it there.



On 24-Jan-09, 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?


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

The optimist proclaims that we live in the best of all possible  
worlds; and the pessimist fears this is true.

-- James Clabell




___

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

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

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

This email sent to sc...@cocoadoc.com


___

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

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

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

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


Re: Using the security framework

2009-01-24 Thread Chris Hanson

On Jan 24, 2009, at 6:29 PM, Michael Ash wrote:


On Sat, Jan 24, 2009 at 6:08 PM, Chris Hanson c...@me.com 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.


  -- Chris

___

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

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

But you can also code sign nowadays
On Jan 24, 2009, at 11:54 PM, 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 c...@me.com 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.


 -- Chris

___

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

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

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

This email sent to joetur...@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: Forcing allocation of a subclass

2009-01-24 Thread Antonio Nunes

On 24 Jan 2009, at 23:19, Jean-Daniel Dupas wrote:

Calling the original implementation in a method you have exchanged  
is done using


[self replacedMethodName]

and in a method added at runtime, you have to call

[super originalMethodName]

[...]
if you don't want to bother with the type string, just query it  
using runtime functions:


And you want to add a class method, not an instance method. You have  
to add this method to the 'PDFDocument class' meta-class.


  Method originalMethod = class_getClassMethod([PDFDocument class],  
@selector(allocWithZone:));
  Method superMethod =  
class_getClassMethod(class_getSuperclass([PDFDocument class]),  
@selector(allocWithZone:));


  Method replacedMethod = class_getClassMethod([PDFDocument class],  
@selector(replacementAllocWithZone:));

  if (superMethod == originalMethod) {
class_addMethod(object_getClass([PDFDocument class]),  
@selector(allocWithZone:),

method_getImplementation(replacedMethod),
method_getDescription(replacedMethod)-types);
  }




Thanks for supplying the last bits to the puzzle Jean-Daniel. Initial  
testing seems to indicate the replacement is working. This is what I  
have now:


Early during app startup is the code adding the replacement method to  
the class, as quoted above.


In a category on PDFDocument is the replacement method itself, which  
now reads:


@implementation PDFDocument (PDFDocument_Alloc)

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

@end

Many thanks to both Bill and Jean-Daniel for helping me through this,  
while pointing out the potential pit-falls. Here's to hoping an update  
to Leopard will soon allow me to disable this unfortunate workaround  
for it and future updates.


-António

---
Don't believe everything you think
---




___

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

Please do not post admin requests or moderator comments to the list.
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: Creating a managed object without adding it to the context?

2009-01-24 Thread Andreas Mayer


Am 24.01.2009 um 23:51 Uhr schrieb Jerry Krinock:


On 2009 Jan 24, at 14:13, Ulai Beekam wrote:

How do I programmatically create a managed object (with respect to  
some entity in a particular context of course) but WITHOUT adding  
it to the context?


I do not believe this is possible.  A managed object without a  
context would not be managed.


It is possible. Just pass nil as context:

NSEntityDescription *entityDescription = [[theManagedObjectModel  
entitiesByName] objectForKey:@EntityName];
NSManagedObject *newObject = [[NSManagedObject alloc]  
initWithEntity:entityDescription insertIntoManagedObjectContext:nil];


The reason I want this is to be able to take that new managed  
object and add it via an NSArrayController (one that is connected  
to said context of course) instead. That way I will get all the  
benefits of the array controller, such as the newly inserted object  
getting selected in a table view that is bound to the array  
controller.


You indicated in your first sentence that you know which managed  
object context the new object is destined for.  I don't see the  
problem.  Just insert it when you create it.


I am using the method shown above when I don't want to insert an  
unfinished object. I.e. I have some sort of input form and want to  
bind the fields to my model's properties. But I don't want the new  
object to show up in any list view before data input is finished.


So I create a new object that is not yet part of the managed object  
context and insert it after editing is finished.


(You also need some place to store that object that you can bind to  
while editing; like a property of a window controller or such.)



Andreas
___

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

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

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

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


Re: Creating a managed object without adding it to the context?

2009-01-24 Thread Andreas Mayer


Am 25.01.2009 um 00:51 Uhr schrieb Ulai Beekam:

My problem is that when I add directly to the managed object  
context, the item is not getting selected automatically in the array  
controller (by the way, I see the selection visually by means of the  
table view bound to the array controller) even if I have checked the  
select on insert checkbox on the array controller in Interface  
Builder.


IIRC that happens when you insert the object directly into the managed  
object context without going through the array controller.


I.e. by using NSManagedObject's

-initWithEntity:insertIntoManagedObjectContext:

instead of NSArrayController's

-addObject:

That's why I asked about this. But yes, when I come to think about  
it now as you say it, it kind of makes little sense to be creating a  
managed object that is not in the context.


I beg to differ. :)  See my previous post.


Andreas
___

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

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

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

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


Re: addSubview bottleneck

2009-01-24 Thread Andreas Mayer


Am 24.01.2009 um 23:29 Uhr schrieb Twisted Theory:

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.


Yes. Do not use subviews. Instead create your own view subclass and  
use cells.


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];
}


Why do you create a new autorelease pool here? Since this method seems  
to be called once for each node, you will create an additional  
autorelease pool every time. Also I don't see any objects created here  
that would go into that pool. So, unless I missed something important,  
you are creating and destroying 6 additional, totally useless  
objects.


But you can get rid of this anyway if you use a custom view and just  
use your model for drawing in -drawRect:. No need to duplicate that  
hierarchy.



Andreas
___

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

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

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

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