Re: Cocoa Newbie Thread/Memory Problems

2010-03-17 Thread Bill Hernandez

On Mar 16, 2010, at 4:38 PM, Dave wrote:

> - (NSString*)makeURLString:(NString*) theBaseURL ForDate:(NSDate*)theDate 
> UsingDatabse:(NString*) theDatabaseType


Dave,

Does it matter that UsingDatabse is misspelled ?

Good Luck,

Bill Hernandez
Plano, Texas___

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

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


Directory to save file in NSSavePanel

2010-03-17 Thread Nikhil Khandelwal
Hi,

I am using NSSavePanel in my application. I am using "runModal" on this to show 
the save panel. The default location it shows to save the file is "Desktop" 
which I want to change to "Document". I tried "runModalForDirectory" as well 
however it uses the given file path as save location always.
Basically I want NSSavePanel to use "Documents" as default save location and if 
user change the location while saving the file, next time NSSavePanel should 
shows the changed location to save the file.

Thanks in advance,
Nikhil

DISCLAIMER
==
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.
___

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

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


Invalidated object on close of managed document

2010-03-17 Thread Gideon King
I open a file, then immediately close it. I get this error message saying that 
one of the objects has been invalidated, but I have no idea what is 
invalidating the object.

How do I debug this?

The NSManagedObject with ID:0x11a415320  has been 
invalidated.
0   CoreFoundation  0x7fff80e89444 
__exceptionPreprocess + 180
1   libobjc.A.dylib 0x7fff843970f3 objc_exception_throw 
+ 45
2   CoreData0x7fff8752641a 
-[_NSInvalidationFaultHandler fulfillFault:withContext:] + 106
3   CoreData0x7fff874c95de 
_PF_FulfillDeferredFault + 254
4   CoreData0x7fff874cd2d7 
_sharedIMPL_pvfk_core + 87
5   CoreData0x7fff874cd448 
-[NSManagedObject(_PFDynamicAccessorsAndPropertySupport) 
_genericValueForKey:withIndex:flags:] + 40
6   CoreData0x7fff874d2cde -[NSManagedObject 
valueForKey:] + 270
7   Foundation  0x7fff85713d20 
-[NSObject(NSKeyValueCoding) valueForKeyPath:] + 226
8   Foundation  0x7fff85713db6 
-[NSObject(NSKeyValueCoding) valueForKeyPath:] + 376
9   Foundation  0x7fff8571782f 
NSKeyValueWillChangeBySetting + 38
10  Foundation  0x7fff85717208 NSKeyValueWillChange 
+ 482
11  Foundation  0x7fff857ea0c2 
-[NSObject(NSKeyValueObservingPrivate) _willChangeValuesForKeys:] + 723
12  CoreData0x7fff874d4480 -[NSFaultHandler 
turnObject:intoFaultWithContext:] + 224
13  CoreData0x7fff874e59e4 
-[NSManagedObjectContext(_NSInternalAdditions) 
_disposeObjects:count:notifyParent:] + 420
14  CoreData0x7fff874e52d8 
-[NSManagedObjectContext(_NSInternalAdditions) _dispose:] + 376
15  CoreData0x7fff874e4fd2 
-[NSManagedObjectContext dealloc] + 258
16  CoreData0x7fff874d40a3 
-[NSManagedObjectContext release] + 51
17  AppKit  0x7fff8654e02b 
-[NSPersistentDocument setManagedObjectContext:] + 90
18  AppKit  0x7fff8654e213 
-[NSPersistentDocument dealloc] + 75
19  NovaMind5TP 0x0001000321e4 
-[NMPersistentDocument dealloc] + 791
20  CoreFoundation  0x7fff80e06d5e 
__CFArrayReleaseValues + 206
21  CoreFoundation  0x7fff80de4c83 _CFRelease + 179
22  CoreFoundation  0x7fff80e0e246 
_CFAutoreleasePoolPop + 230
23  Foundation  0x7fff8571a2f8 -[NSAutoreleasePool 
drain] + 158
24  AppKit  0x7fff860ba7db -[NSApplication run] 
+ 543
25  OmniAppKit  0x000100338774 -[OAApplication run] 
+ 132
26  AppKit  0x7fff860b3468 NSApplicationMain + 
364
27  NovaMind5TP 0x00011a47 main + 33
28  NovaMind5TP 0x00011a04 start + 52


Thanks

Gideon

___

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

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


Properly using setNeedDisplayInRect

2010-03-17 Thread Gustavo Pizano
Hello all

  normally I just redraw the whole view by sending the setNeedDisplay method, 
but in the case Im right now, I have placed Tracking areas, and when the mouse 
enter the TA Im coloring a bezier path corresponding the TA area (kinda of 
rollovers, but just for a few specific places that I need to be highlighted), 
so I was thinking in passing to the setNeeddipslayInRect method the TA rect, 
but its not clear for me how to just draw  the bTa background, becuase in the 
drawRect Method Im just checking if Im in a TA and then filling the path I 
created in the mouseDown method.

I check the Apple docs, and in the advance drawing techniques it says, like 
Draw Minimally, and they suggest using that method also... so how to make sure 
Im just drawing the backgrounds of the  active TA and not redrawing the whole 
view?


thanks

Gustavo
 ___

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

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


set file name in NSSavePanel

2010-03-17 Thread Nikhil Khandelwal
Hi,

Is there any way to to set the file name in NSSavePanel for 10.5.
I tried "setNameFieldStringValue" but this is available for 10.6 or later. Is 
there any similar method available for 10.5.

Thanks,
Nikhil

DISCLAIMER
==
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.
___

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

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

2010-03-17 Thread Rick C.
thank you for the replies.  no sub-processes but i can use the info you have 
provided to do some troubleshooting.  thank you very much and i'll let you  
know,

rick






From: Jens Alfke 
To: Rick C. 
Cc: cocoa dev 
Sent: Tue, March 16, 2010 11:37:08 PM
Subject: Re: first time launch message



On Mar 16, 2010, at 6:16 AM, Rick C. wrote:

normally after downloading an app via safari upon first launch it will give the 
message to the effect of "this is the first launch of something downloaded from 
the internet do you really want to open etc." i think you know what i'm 
referring to.  my question is a project i'm working on seems to give this 
message on the second launch instead of the first after being downloaded.  does 
anyone know what specifically causes this message and is there something within 
the app that triggers it that maybe i need to correct?  thank you,
>

This happens before any of the app code runs (since it’s warning the user about 
untrusted code.) Downloaded executable files have a special filesystem metadata 
attribute applied to them by the browser, and LaunchServices sees this 
attribute and pops up the warning before launching the app. If you OK the 
warning the attribute is removed.

I have no idea why this would be happening to you on the second launch. Does 
your app spawn subprocesses? I.e. some ported apps do weird stuff like making 
the main executable be a shell that just immediately launches another 
executable. I don’t know if this could confuse LaunchServices, but it’s a 
possibility.

You could troubleshoot this by waiting till the alert comes up, then using 
Activity Monitor to see if any of your code has been launched, and if so, 
sampling that process to see where it’s blocked.

—Jens



___

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

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

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

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


Re: set file name in NSSavePanel

2010-03-17 Thread Klaus Backert


On 17 Mar 2010, at 10:49, Nikhil Khandelwal wrote:


Is there any way to to set the file name in NSSavePanel for 10.5.
I tried "setNameFieldStringValue" but this is available for 10.6 or  
later. Is there any similar method available for 10.5.


According to the documentation of NSSavePanel the method

- (void)beginSheetForDirectory:(NSString *)path file:(NSString *)name  
modalForWindow:(NSWindow*)docWindow modalDelegate:(id)modalDelegate  
didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo


"Presents a Save panel as a sheet with a specified path and,  
optionally, a specified file in that path."

and
"name
Specifies a particular file in path that is selected when the Save  
panel is presented to a user. When nil, no file is initially selected."


Hope this helps.

Klaus

___

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

Please do not post admin requests or moderator comments to the list.
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: One NSTextView, several model objects - how to synchronise undo manager

2010-03-17 Thread Keary Suska
On Mar 16, 2010, at 6:09 PM, Rui Pacheco wrote:

> I've a window with a fairly complex layout - one NSTextView and several
> tables, all displaying different types of data. To keep things in order,
> I've created a model object that holds the data for all these interface
> elements. The window may also hold several instances of the model object and
> I list them in a table.
> 
> My problem is how to keep the undo manager for the text view synchronised
> with a particular instance of a model object. As the user switches between
> model objects, I want him to be able to do cmd + z transparently with the
> window knowing what changed in that particular instance.
> 
> Some research seems to indicate that using core data would give me this for
> free - make my model objects extend NSManagedObject and I would have undo
> for free. Is this correct?

More or less. You may want to keep in mind that "out of the box" that undos 
will be tracked in the order they are registered across all objects. I.e., user 
changes textfield value, tabs to textview and makes a change, then hits undo 
twice, the textfield change will get undone.

HTH,

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

___

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

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

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

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


Case sensitive fileName

2010-03-17 Thread gMail.com
Hi, I have a file path
/Folder/filename.txt
The API fileExistsAtPath says that it exists.
Now I need to get its real case sensitive file name, which is indeed e.g.
   "FileName.txt"
How can I get it in a fast way? I thought by its inode, but I can't really
know how to do that.

I know I can iterate along the contents of the parent directory and do a
case insensitive match of each item, but this is too long. I need to check
thousands files. Any fast idea?


Regards
--
Leonardo


___

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

Please do not post admin requests or moderator comments to the list.
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: One NSTextView, several model objects - how to synchronise undo manager

2010-03-17 Thread Rui Pacheco
Is there a way to bind the text view's undo manager to an instance of
NSUndoManager on my model object?

I can get to the text view undo manager but I don't seem to be able to set
it.

On 17 March 2010 13:34, Keary Suska  wrote:

> On Mar 16, 2010, at 6:09 PM, Rui Pacheco wrote:
>
> > I've a window with a fairly complex layout - one NSTextView and several
> > tables, all displaying different types of data. To keep things in order,
> > I've created a model object that holds the data for all these interface
> > elements. The window may also hold several instances of the model object
> and
> > I list them in a table.
> >
> > My problem is how to keep the undo manager for the text view synchronised
> > with a particular instance of a model object. As the user switches
> between
> > model objects, I want him to be able to do cmd + z transparently with the
> > window knowing what changed in that particular instance.
> >
> > Some research seems to indicate that using core data would give me this
> for
> > free - make my model objects extend NSManagedObject and I would have undo
> > for free. Is this correct?
>
> More or less. You may want to keep in mind that "out of the box" that undos
> will be tracked in the order they are registered across all objects. I.e.,
> user changes textfield value, tabs to textview and makes a change, then hits
> undo twice, the textfield change will get undone.
>
> HTH,
>
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
>
>


-- 
Best regards,
Rui Pacheco
___

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

Please do not post admin requests or moderator comments to the list.
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: One NSTextView, several model objects - how to synchronise undo manager

2010-03-17 Thread Keith Blount
I might be missing something, but can you not just use the NSTextView delegate 
message, -undoManagerForTextView:? This is what I do in my app. I have a single 
text view that can have various text storage objects swapped into it, and I 
have each of those text storages associated with a different NSUndoManager. I 
use -undoManagerForTextView: to return whichever undo manager corresponds to 
the current text object, so that the user's undoes affect the currently loaded 
text and the user can load up a text he or she worked on earlier and hitting 
undo will undo whatever they last did in that particular text.

Hope that helps.
All the best,
Keith

--- original message ---

Is there a way to bind the text view's undo manager to an instance of
NSUndoManager on my model object?

I can get to the text view undo manager but I don't seem to be able to set
it.

On 17 March 2010 13:34, Keary Suska  wrote:

> On Mar 16, 2010, at 6:09 PM, Rui Pacheco wrote:
>
> > I've a window with a fairly complex layout - one NSTextView and several
> > tables, all displaying different types of data. To keep things in order,
> > I've created a model object that holds the data for all these interface
> > elements. The window may also hold several instances of the model object
> and
> > I list them in a table.
> >
> > My problem is how to keep the undo manager for the text view synchronised
> > with a particular instance of a model object. As the user switches
> between
> > model objects, I want him to be able to do cmd + z transparently with the
> > window knowing what changed in that particular instance.
> >
> > Some research seems to indicate that using core data would give me this
> for
> > free - make my model objects extend NSManagedObject and I would have undo
> > for free. Is this correct?
>
> More or less. You may want to keep in mind that "out of the box" that undos
> will be tracked in the order they are registered across all objects. I.e.,
> user changes textfield value, tabs to textview and makes a change, then hits
> undo twice, the textfield change will get undone.
>
> HTH,
>
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
>
>



  
___

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

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

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

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


Re: Anyone using IKImageView?

2010-03-17 Thread Sandy McGuffog
I speak from memory here, but my recollection is that IKImageView does not like 
going in a scrollview; you put an NSScroller next to it, and hook that to one 
of the IKImageView's scroller outlets. Or something like that - there is a 
Apple demo app that shows this.

Sandy


On Mar 16, 2010, at 11:54 PM, Brian Postow wrote:

> I have an IKImageView inside a Scrollview (actually a bit of a scrollview 
> work-around, in order to get the scrollbars to actually appear and disappear 
> correctly) and I'm trying to use the select tool. 
> 
> However, the select box isn't appearing in the correct place when the 
> imageView isn't exactly the same size as the scrollview. It doesn't matter 
> whether thescrollview is looking at the top or bottom of the imageview, if 
> the image is bigger than the scrollview by N pixels, then the select box will 
> be N pixels higher than it should be.
> 
> I sort of expected that if it was just a matter of conflicting origins, then 
> either scrolling to the top or bottom of the image would make the problem 
> disappear, but it doesn't have any effect. 
> 
> Has anyone seen anything like this?
> 
> thanks.
> 
> 
> Brian Postow
> Senior Software Engineer
> Acordex Imaging Systems
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/mcguffogl%40gmail.com
> 
> This email sent to mcguff...@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: Anyone using IKImageView?

2010-03-17 Thread Brian Postow

On Mar 17, 2010, at 10:42 AM, Sandy McGuffog wrote:

> I speak from memory here, but my recollection is that IKImageView does not 
> like going in a scrollview; you put an NSScroller next to it, and hook that 
> to one of the IKImageView's scroller outlets. Or something like that - there 
> is a Apple demo app that shows this.


Really? Which one? IKImageViewDemo doesn't have scrollbars. 

Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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

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

2010-03-17 Thread Sandy McGuffog
ImageBrowser, I think.

Sandy

On Mar 17, 2010, at 5:22 PM, Brian Postow wrote:

> 
> On Mar 17, 2010, at 10:42 AM, Sandy McGuffog wrote:
> 
>> I speak from memory here, but my recollection is that IKImageView does not 
>> like going in a scrollview; you put an NSScroller next to it, and hook that 
>> to one of the IKImageView's scroller outlets. Or something like that - there 
>> is a Apple demo app that shows this.
> 
> 
> Really? Which one? IKImageViewDemo doesn't have scrollbars. 
> 
> Brian Postow
> Senior Software Engineer
> Acordex Imaging Systems
> 

___

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

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

2010-03-17 Thread gMail.com
Thanks, that's fine for 10.6, but I have to compile against 10.5...
I guess there should be a quick way with some C command, or Unix command or
even with the Carbon APIs, like PBGetCatInfo using the ioFRefNum...
Any idea?

Regards
--
Leonardo

> Da: Jeremy Pereira 
> Data: Wed, 17 Mar 2010 14:41:05 +
> A: "gMail.com" , Apple Cocoa Develop Develop
> 
> Cc: Jeremy Pereira 
> Oggetto: Re: Case sensitive fileName
> 
> NSURL* url = [NSURL fileURLWithPath: path];
> NSError* error = nil;
> NSArray* keysIWant = [NSArray arrayWithObject: NSURLNameKey];
> NSDictionary* resources = [url resourceValuesForKeys: keysIWant error:
> &error];
> if (resources != nil)
> {
> NSString* actualPath = [resources objectForKey: NSURLNameKey];
> NSLog(@"%@", actualPath);
> }

>> Hi, I have a file path
>>  /Folder/filename.txt
>> The API fileExistsAtPath says that it exists.
>> Now I need to get its real case sensitive file name, which is indeed e.g.
>> "FileName.txt"
>> How can I get it in a fast way? I thought by its inode, but I can't really
>> know how to do that.


___

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

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

2010-03-17 Thread Brian Postow

On Mar 17, 2010, at 11:47 AM, Sandy McGuffog wrote:

> ImageBrowser, I think.
> 
> Sandy

That's an ikimagebrowserview, not an ikimageview. I don't see a 
_verticalscrollbar in the outlets in IKImageView...

> 
> On Mar 17, 2010, at 5:22 PM, Brian Postow wrote:
> 
>> 
>> On Mar 17, 2010, at 10:42 AM, Sandy McGuffog wrote:
>> 
>>> I speak from memory here, but my recollection is that IKImageView does not 
>>> like going in a scrollview; you put an NSScroller next to it, and hook that 
>>> to one of the IKImageView's scroller outlets. Or something like that - 
>>> there is a Apple demo app that shows this.
>> 
>> 
>> Really? Which one? IKImageViewDemo doesn't have scrollbars. 
>> 
>> Brian Postow
>> Senior Software Engineer
>> Acordex Imaging Systems
>> 
> 
> 

Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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

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

2010-03-17 Thread Jens Alfke

On Mar 17, 2010, at 1:50 AM, Gustavo Pizano wrote:

> I was thinking in passing to the setNeeddipslayInRect method the TA rect, but 
> its not clear for me how to just draw  the bTa background, becuase in the 
> drawRect Method Im just checking if Im in a TA and then filling the path I 
> created in the mouseDown method.

As a first pass, don’t worry about it. Just leave your -drawRect method alone. 
You’ll already improve drawing performance because AppKit will clip your 
drawing to the ‘dirty’ area, so fewer pixels will be rendered and copied to the 
display.

If you try that and find that performance still isn’t good enough, then you can 
start optimizing your -drawRect method itself to eliminate unnecessary drawing 
calls.

—Jens___

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

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

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

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


Re: Case sensitive fileName

2010-03-17 Thread Jens Alfke

On Mar 17, 2010, at 6:35 AM, gMail.com wrote:

> Now I need to get its real case sensitive file name, which is indeed e.g.
>   "FileName.txt"
> How can I get it in a fast way? I thought by its inode, but I can't really
> know how to do that.

Have you tried -[NSString stringByStandardizingPath], or the BSD function 
realpath()? The docs don’t explicitly say they correct case, but it seems like 
the kind of thing they would do.

—Jens___

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

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

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

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


Re: Case sensitive fileName

2010-03-17 Thread Don Quixote de la Mancha
Does readdir work on Mac OS X?  I don't have a Mac handy right now to
check, but it should work because so many *NIX programs build on OS X
right out of the box.

More or less what you do is call opendir on a directory, then
rewinddir to set your iterator to the beginning of the directory, then
repeatedly call readdir to read each of the items in the directory.

This is actually a portable and standardized interface to reading the
directory inode.

Note that there is both a readdir system call and a readdir library
call.  You want the library call.  The system call is there for the
private use of the library call, and isn't meant to make sense or be
portable.

If readdir does work on OS X, it will get you the filename as it is
actually found in the filesystem - that is, with the case preserved.

Look up "man 3 readdir" and friends.

Don Quixote
-- 
Don Quixote de la Mancha
quix...@dulcineatech.com
http://www.dulcineatech.com

   Dulcinea Technologies Corporation: Software of Elegance and Beauty.
___

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

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

2010-03-17 Thread Michael Davey
I don't think that the OP wanted to iterate through the entire directory 
though...

On 17 Mar 2010, at 16:15, Don Quixote de la Mancha wrote:

> Does readdir work on Mac OS X?  I don't have a Mac handy right now to
> check, but it should work because so many *NIX programs build on OS X
> right out of the box.
> 
> More or less what you do is call opendir on a directory, then
> rewinddir to set your iterator to the beginning of the directory, then
> repeatedly call readdir to read each of the items in the directory.
> 
> This is actually a portable and standardized interface to reading the
> directory inode.
> 
> Note that there is both a readdir system call and a readdir library
> call.  You want the library call.  The system call is there for the
> private use of the library call, and isn't meant to make sense or be
> portable.
> 
> If readdir does work on OS X, it will get you the filename as it is
> actually found in the filesystem - that is, with the case preserved.
> 
> Look up "man 3 readdir" and friends.
> 
> Don Quixote
> -- 
> Don Quixote de la Mancha
> quix...@dulcineatech.com
> http://www.dulcineatech.com
> 
>   Dulcinea Technologies Corporation: Software of Elegance and Beauty.
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/frak.off%40gmail.com
> 
> This email sent to frak@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: Case sensitive fileName

2010-03-17 Thread Don Quixote de la Mancha
> I don't think that the OP wanted to iterate through the entire directory 
> though...

Maybe so, but I don't think there would be any real disadvantage to
doing so.  I'm pretty sure that just about any API that can retrieve a
filename from a directory will iterate through the whole directory
anyway.  So it wouldn't be any slower to roll the code himself.

A C function that used readdir to get the case-preserved filename
shouldn't be more than ten lines of code or so.

Don Quixote
-- 
Don Quixote de la Mancha
quix...@dulcineatech.com
http://www.dulcineatech.com

   Dulcinea Technologies Corporation: Software of Elegance and Beauty.
___

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

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

2010-03-17 Thread Matt Neuburg
On Wed, 17 Mar 2010 09:50:17 +0100, Gustavo Pizano
 said:
> I check the Apple docs, and in the advance drawing techniques it says, like
> Draw Minimally, and they suggest using that method also... so how to make sure
> Im just drawing the backgrounds of the  active TA and not redrawing the whole
> view?

drawRect hands you a parameter - the rect. So you write your code in such a
way that you only draw material that is within (or, usually easier, material
that intersects) that rect. m.

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



___

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

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

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

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


Re: Directory to save file in NSSavePanel

2010-03-17 Thread Matt Neuburg
On Wed, 17 Mar 2010 13:40:35 +0530, Nikhil Khandelwal
 said:

> I am using NSSavePanel in my application. I am using "runModal" on this to
> show the save panel. The default location it shows to save the file is
> "Desktop" which I want to change to "Document". I tried "runModalForDirectory"
> as well however it uses the given file path as save location always. Basically
> I want NSSavePanel to use "Documents" as default save location and if user
> change the location while saving the file, next time NSSavePanel should shows
> the changed location to save the file.

If you're willing to be Snow Leopard only, a combination of directoryURL and
setDirectoryURL might work. It's a little tricky otherwise because Mac OS X
does automatically remember the last place the user saved, so the idea is to
stay out of its way in that case. That info is kept in your user defaults so
you might be able to examine it. m.

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



___

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

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

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

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


Re: Case sensitive fileName

2010-03-17 Thread Kevin Wojniak
These two methods worked for me:

NSString *path = @"/FOLDER/FILENAME.txt";

NSLog(@"displayNameAtPath: %@", [[NSFileManager defaultManager] 
displayNameAtPath:path]);

FSRef ref;
HFSUniStr255 name255;
if (!FSPathMakeRef((const UInt8 *)[path fileSystemRepresentation], &ref, NULL) 
&&
!FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, &name255, NULL, NULL))
{
CFStringRef name = CFStringCreateWithCharacters(NULL, name255.unicode, 
name255.length);
if (name)
{
NSLog(@"FSGetCatalogInfo: %@", (NSString *)name);
CFRelease(name);
}
}



On Mar 17, 2010, at 8:54 AM, gMail.com wrote:

> Thanks, that's fine for 10.6, but I have to compile against 10.5...
> I guess there should be a quick way with some C command, or Unix command or
> even with the Carbon APIs, like PBGetCatInfo using the ioFRefNum...
> Any idea?
> 
> Regards
> --
> Leonardo
> 
>> Da: Jeremy Pereira 
>> Data: Wed, 17 Mar 2010 14:41:05 +
>> A: "gMail.com" , Apple Cocoa Develop Develop
>> 
>> Cc: Jeremy Pereira 
>> Oggetto: Re: Case sensitive fileName
>> 
>> NSURL* url = [NSURL fileURLWithPath: path];
>> NSError* error = nil;
>> NSArray* keysIWant = [NSArray arrayWithObject: NSURLNameKey];
>> NSDictionary* resources = [url resourceValuesForKeys: keysIWant error:
>> &error];
>> if (resources != nil)
>> {
>> NSString* actualPath = [resources objectForKey: NSURLNameKey];
>> NSLog(@"%@", actualPath);
>> }
> 
>>> Hi, I have a file path
>>> /Folder/filename.txt
>>> The API fileExistsAtPath says that it exists.
>>> Now I need to get its real case sensitive file name, which is indeed e.g.
>>> "FileName.txt"
>>> How can I get it in a fast way? I thought by its inode, but I can't really
>>> know how to do that.
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/kainjow%40kainjow.com
> 
> This email sent to kain...@kainjow.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


Cocoa sometimes raises "minor" exceptions without logging them

2010-03-17 Thread Jerry Krinock
Near the end of -applicationDidFinishLaunching, I bind to a user default, like 
this:

[doxtusMenu bind:@"showStatusMenu"
toObject:[NSUserDefaults standardUserDefaults]
 withKeyPath:constKeyShowStatusMenu
 options:0] ;

This code works perfectly.

However, when I'd run this app with breakpoints on, this would trigger a break 
in +[NSException raise:format:arguments:] where I have a breakpoint (call stack 
below).  I found that it only occurred when the user default for 
constKeyShowStatusMenu had never been set.  I fixed the problem by adding 
constKeyShowStatusMenu to my "default defaults" which get registered prior to 
this, via -registerDefaults.  OK.

I find it odd that this exception never get logged.  Running without 
breakpoints enabled, it seemed like nothing was wrong.  And I supposed it could 
be argued that nothing was wrong, since constKeyShowStatusMenu is a Boolean 
property, nil = NO, and I shouldn't really need to register that default 
default.

Apparently, Cocoa sometimes raises "minor" exceptions without logging them, so 
it's good idea to set a breakpoing in +[NSException raise:format:arguments:] 
and run with breakpoints enabled once in awhile.

#0  0x940ff0bd in +[NSException raise:format:arguments:]
#1  0x940ff0aa in +[NSException raise:format:]
#2  0x94b9d358 in -[NSObject(NSKeyValueCoding) setNilValueForKey:]
#3  0x94b9b702 in _NSSetNilValueForKey
#4  0x94ac1dd9 in _NSSetUsingKeyValueSetter
#5  0x94ac1d60 in -[NSObject(NSKeyValueCoding) setValue:forKey:]
#6  0x96b055e4 in -[NSObjectParameterBinder 
_updateObject:observedController:observedKeyPath:context:]
#7  0x96b04d81 in -[NSObjectParameterBinder 
_observeValueForKeyPath:ofObject:context:]
#8  0x96b049f9 in -[NSBinder _performConnectionEstablishedRefresh]
#9  0x96af7104 in -[NSObject(NSKeyValueBindingCreation) 
bind:toObject:withKeyPath:options:]
#10 0x000155f9 in -[BkmxAppDel finishLaunchingMore] at BkmxAppDel.m:964
#11 0x00015184 in -[BkmxAppDel applicationDidFinishLaunching:] at 
BkmxAppDel.m:901

___

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

Please do not post admin requests or moderator comments to the list.
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: Directory to save file in NSSavePanel

2010-03-17 Thread Corbin Dunn

On Mar 17, 2010, at 9:39 AM, Matt Neuburg wrote:

> On Wed, 17 Mar 2010 13:40:35 +0530, Nikhil Khandelwal
>  said:
> 
>> I am using NSSavePanel in my application. I am using "runModal" on this to
>> show the save panel. The default location it shows to save the file is
>> "Desktop" which I want to change to "Document". I tried 
>> "runModalForDirectory"
>> as well however it uses the given file path as save location always. 
>> Basically
>> I want NSSavePanel to use "Documents" as default save location and if user
>> change the location while saving the file, next time NSSavePanel should shows
>> the changed location to save the file.
> 
> If you're willing to be Snow Leopard only, a combination of directoryURL and
> setDirectoryURL might work. It's a little tricky otherwise because Mac OS X
> does automatically remember the last place the user saved, so the idea is to
> stay out of its way in that case. That info is kept in your user defaults so
> you might be able to examine it. m.

Actually, the behavior Nikhi requested is the default behavior if you pass 
'nil' for the directory in the runModalForDirectory methods (or use it for 
setDirectoryURL:)

If you are using nil, it should default to Documents the first time. If it 
didn't, then you probably need to wipe some user defaults (possibly in the 
global domain and for the app).

corbin


___

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

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

2010-03-17 Thread Aaron Burghardt
Jens gets the prize:

$ cat realpath_test.c

#include 
#include 
#include 

int main(int argc, char *argv[]) {

char resolved_name[PATH_MAX];

realpath(argv[1], resolved_name);

printf("%s\n", resolved_name);
}

$ gcc realpath_test.c -o realpath_test

$ ./realpath_test REALPATH_TEST.C
/private/tmp/realpath_test/realpath_test.c

-[NSString stringByStandardizingPath] did not work in one test.

Aaron

P.S. Be sure to pass -[NSString fileSystemRepresentation] to realpath().


On Mar 17, 2010, at 12:07 PM, Jens Alfke wrote:

> 
> On Mar 17, 2010, at 6:35 AM, gMail.com wrote:
> 
>> Now I need to get its real case sensitive file name, which is indeed e.g.
>>  "FileName.txt"
>> How can I get it in a fast way? I thought by its inode, but I can't really
>> know how to do that.
> 
> Have you tried -[NSString stringByStandardizingPath], or the BSD function 
> realpath()? The docs don’t explicitly say they correct case, but it seems 
> like the kind of thing they would do.
> 
> —Jens___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/aaron.burghardt%2Bcocoa-dev%40gmail.com
> 
> This email sent to aaron.burghardt+cocoa-...@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: Case sensitive fileName

2010-03-17 Thread Jens Alfke


On Mar 17, 2010, at 9:28 AM, Don Quixote de la Mancha wrote:

I don't think that the OP wanted to iterate through the entire  
directory though...


Maybe so, but I don't think there would be any real disadvantage to
doing so.


Performance.


 I'm pretty sure that just about any API that can retrieve a
filename from a directory will iterate through the whole directory
anyway.


No; retrieving a file by name is just a B+tree lookup in HFS. Walking  
through the directory is a lot more expensive.


—Jens

___

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

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

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

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


Re: Blocked Reads

2010-03-17 Thread Greg Guerin

colors wrote:

I am running into a problem with anti-virus software.  I need to be  
able to read a file from a USB CD and I need the read to actually  
go over the USB bus.



Why do you need the read to go over the USB bus?  If the OS itself  
has cached some disk data, why force it to be transferred over the  
bus again?


What are you trying to accomplish?



Does anyone have any thoughts about 1) what the AV SW is doing?,  
and 2) how to get around what it is doing?



If there were a simple way to get around the AV SW, then malware  
would be able to use it to get around the AV SW, thus nullifying the  
AV SW.


  -- GG

___

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

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

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

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


Re: Cocoa sometimes raises "minor" exceptions without logging them

2010-03-17 Thread Steven Degutis
I usually add a breakpoint on objc_exception_throw. Not sure how much of a
difference it makes... but yeah, I agree.

-Steven

On Wed, Mar 17, 2010 at 12:55 PM, Jerry Krinock  wrote:

>
> Apparently, Cocoa sometimes raises "minor" exceptions without logging them,
> so it's good idea to set a breakpoing in +[NSException
> raise:format:arguments:] and run with breakpoints enabled once in awhile.
>
>
___

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

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

2010-03-17 Thread Andreas Mayer


Am 17.03.2010 um 17:46 Uhr schrieb Kevin Wojniak:

NSLog(@"displayNameAtPath: %@", [[NSFileManager defaultManager]  
displayNameAtPath:path]);


Note that -displayNameAtPath: will give you the localized name if one  
should exist.


(For example you'll get 'Programme' for the 'Applications' folder if  
you happen to be on a German system.)


You can't use that as an input to file system functions.

Since the OP didn't say what he needs the filename for, - 
displayNameAtPath: may or may not be the right solution.



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: Cocoa sometimes raises "minor" exceptions without logging them

2010-03-17 Thread Matt Neuburg
On Wed, 17 Mar 2010 09:55:01 -0700, Jerry Krinock  said:
>... And I supposed it could be argued that nothing was wrong, since
constKeyShowStatusMenu is a Boolean property, nil = NO

There is no such thing as a "Boolean property" in the user defaults. The
only things that can go into the user defaults are plist-able values, and a
Boolean is not one of those. When you want to store YES and NO in the user
defaults, you store an NSNumber which is *wrapping* the Boolean value.
NSUserDefaults includes convenience methods for converting a Boolean to an
NSNumber for you (setBool:forKey:, boolForKey:) but the value in the
defaults is itself an NSNumber.

So you are trying to bind a menu item to something in the NSUserDefaults
that isn't there, and you're getting back nil. But nil is not an NSNumber,
or any other kind of plist-able. So the exception is correct.

My guess is that Cocoa is covering up the problem. It throws an exception
(as you discovered by breaking on raise), but in this case I'm betting that
it then proceeds to *handle* that exception (thinking to itself, well, this
is nil, so I'll tell the menu item that the value is NO). You are breaking
before the exception is handled so you're seeing the sausage being made.
That's just a guess, but it explains why nothing gets logged - the exception
never trickles up to the top level, for logging, because it's handled
immediately after the point at which you are breaking.

m.

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



___

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

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

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

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


Re: Cocoa Newbie Thread/Memory Problems

2010-03-17 Thread Dave

Hi Quincy,

Sorry for the typeos and lack of clarity in my last message and  
thanks a lot for your help. I was really tired when I sent the  
message last night, I should have waited until today to send it.


Basically what I was trying to get at is that I have a handler that  
gets called after the user clicks a button (in this case the  
"getData" action/event). As I said before, I based this app on the  
"XMLPerformance" sample code from Apple Developer. On that app, the  
user clicks a button which fires a new view controller which does the  
downloading and parsing work. Since the button that triggered the  
event is on the previous view and that view is now hidden, there is  
no chance that the user could click the button again before the  
download and parse operation has completed. However, on my App there  
is a button that is still visible while the download and parse  
operation is still running and the user can click it. From this I  
have two questions:

1. How can I disable the button to stop this happening?
2. If I want this to happen what is the best way to achieve it?

My App basically retrieves data from a URL based on a date, each URL  
request can result in 0 or more Items being download/parsed. The date  
is passed as a parameter in the URL string e.g. ? 
month=mar&day=16&dbase=rs_main. When it is first launched, it  
retreives the data for the current day, while this is downloading/ 
parsing the user could click on another button to get the data for  
the whole of "next week". This would cause 7 requests to be  
downloaded, one for each day, e.g. ?month=mar&day=17&dbase=rs_main  
then &day=18, &day=19 etc. The data is to be put into a table view  
and the user will be able to select a cell from the view and get the  
details for the a particular item. In pseudo code:


User Launches App.
Download/Parse Process is Started on the URL for the Current Date.  
The Table View begins to fill, the user can Scroll the Table View and  
"home in" on items.

User Clicks "Next Week".
Download/Parse Process is Started on the URL for the Current Date + 1  
Day. The new data gets added to the Table View, the user can Scroll  
the Table View and "home in" on items.
Download/Parse Process is Started on the URL for the Current Date + 2  
Days. The new data gets added to the Table View, the user can Scroll  
the Table View and "home in" on items.

.. and so on for each of the 7 days.

Also, the user can select a different database or can select multiple  
databases, in which case the request needs to be sent to each of the  
databases, this is passed to the server via the &dbase= parameter. If  
two databases were selected them clicking "Next Week" would result in  
14 requests being sent to the Server.


The XML for this is as follows:



Some String Data 1
 Some String Data 2 
 Some String Data 3
...
...
 Some String Data N



I am wondering if part of my problem is that I based this on the  
"XMLPerformance" sample code (which I suppose was more focused on XML  
parsing) rather than writing it all from scratch. The basic flow of  
this is:


ViewController creates a "ParserXML" class and sends a "start" message.

ParserXML is a subclass of ParserBase and between them they handle  
creating a new thread to handle the downloading and parsing of the  
XML data. When parsing each "Detail" item (see above XML) is put into  
a newly created NSDictionary with the keys and data set from the  
"Detail" item. e.g. for the above XML it would result in a  
NSDictionary item with key=="Some String Data  
1',key=="Some String Data 2", etc. Each completed  
NSDictionary item is put into an NSArray and when there are more than  
N items in the NSArray, a Call back to the main thread is made  
passing the NSArray as "theObject".


At present I am just logging the data in this call back as per my  
first post, but in the real app I will add the array to a Table View.


There are also call backs to signal the parse has finished and for an  
error condition.


Basically I need change the code so that the UI "action" method (e.g.  
"getData" in this case), just adds a request to a queue and returns.  
I am trying to figure out the best way to implement this given the  
code I have so far and wondering if it might be better to start again  
with a new model. If so, any suggestions on the best design model for  
this? Specifically I am wondering how I should pass the parameters  
(URLBaseString, Date, ContainerName, from the Main Thread View  
Controller to the Download/Parse secondary thread. At present it just  
assumes it is not already running so just creates a new one with  
disastrous consequences!


My thoughts so far.

I decided that the best way to handle this would be to add requests  
from to a "ParserQueue" and have the background thread loop until all  
re

Re: Case sensitive fileName

2010-03-17 Thread Don Quixote de la Mancha
On Wed, Mar 17, 2010 at 10:23 AM, Jens Alfke  wrote:
>>  I'm pretty sure that just about any API that can retrieve a
>> filename from a directory will iterate through the whole directory
>> anyway.
>
> No; retrieving a file by name is just a B+tree lookup in HFS. Walking
> through the directory is a lot more expensive.

Ah, I didn't realize.  I know this is going to sound pretty stupid,
this being an OS X list and all, but I wasn't considering the HFS
filesystem.  I was thinking about some ancient UNIX filesystem I
studied a while back in which the filenames within a directory were
all concatenated together into an unsorted list.

At the time I actually considered inventing my own filesystem, because
I read of a study that found that fully half the time spent within the
UNIX kernel was spent within the namei() function, which converts a
single pathname element into an inode number.  My proposal was to use
a hash table for the filenames, so that a filename lookup would
consist mostly of a binary search of integers, rather than a linear
search of string comparisons.

I'm pretty sure that kind of thing is now done by most modern filesystems.

However I would argue that he might still be better off using readdir.
 The OP said he needed the case-preserved filenames of thousands of
files.  If a given directory tends to contain many of the files he
wants to identify, then readdir would efficiently get the filenames of
all those files all at once.

Your realpath method while undoubtably better for a single file might
actually be slower than readdir if one uses it for many files that are
all in a single directory.

Don Quixote
-- 
Don Quixote de la Mancha
quix...@dulcineatech.com
http://www.dulcineatech.com

   Dulcinea Technologies Corporation: Software of Elegance and Beauty.
___

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

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

2010-03-17 Thread Jonathon Kuo
That's an awesome app. I've been looking at it, but it's a bit convoluted. I 
can't quite seem to isolate the basic mechanism at play here. It uses a 
NSTableView populated with a custom subclass of NSTextFieldCell that supports 
an image? I'm just looking to have a column of color swatches I can be notified 
when I click on them. Couldn't I do that with NSTextFields with 
setBackgroundColor:? The trick then is to get the on-click event.




On Mar 12, 2010, at 3:02 PM, Corbin Dunn wrote:

> Try the "AnimatedTableView" example. Feel free to post questions after you 
> run it. It has a custom mini color picker thingy.
> 
> corbin
> 
> On Mar 12, 2010, at 2:17 PM, Jonathon Kuo wrote:
> 
>> I need to generate an ad-hoc number of color swatches in a floating window 
>> so that when a user clicks on one of them, the 'active' color of a stylus 
>> will change to that color. Most likely NSColorWell is not the right tool for 
>> the job...
>> 
>> On Mar 12, 2010, at 2:10 PM, Kevin Wojniak wrote:
>> 
>>> Subclass and override mouseDown: - however if you're trying to intercept 
>>> right before the color panel is shown, or a drag starts, that may be 
>>> trickier.
>>> 
>>> What are you trying to do generally?
> 
> 

___

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

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


CoreData database sharing and migration

2010-03-17 Thread Tobias Jordan

Hi Folks,

I am wondering whether it is possible to create a database in core  
data that can be opened by more than one application at the same time.  
It is currently impossible to handle one SQLite database with two  
instances of the same app. The problem is if user1 quits the app, the  
data is saved but user2's instance of the app doesn't recognize this  
file system change and just overwrites its version in memory. So the  
data from user1 is gone. Is there a way I can handle this?


Second -- I am having more than two database versions now but still  
want to support my version 1.0 but the mapping model only allows one  
source model as well as only one target model. I would have to remove  
one version but that makes version 1.0 users' database unusable.


Has anyone gotten something like this to work?

Thanks a lot in advance!

Best regards,
Tobias J.
___

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

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


Threads Question

2010-03-17 Thread Philippe Sismondi
I am hoping to add some functionality to an existing open source app (Skim) 
that uses threads for fairly simple purposes. (I believe Grand Central Dispatch 
etc. are not an option - I don't know whether this would be useful anyway as I 
have not learned about GCD.)

I have read the Threading Programming Guide twice, but am still unsure how to 
design this. I am not very expert with threading.

From this app I want to launch another existing utility (ghostscript) and get 
its output back into the main app. Skim is a document-based app. The invocation 
of ghostscript will be done by means of the Open File menu item; a new 
MyDocument instance will be created thereby.

Because the length of time that this secondary task takes is highly variable, I 
want to be able to cancel its processing from the main app. So, I want to 
launch the secondary task in a separate thread to keep the main runloop 
responsive. (This is of course a very common GUI issue.)

I have some existing code from the main app that does this. As you may see 
below, it uses the beginModalSessionForWindow call, and calls runModalSession 
in a loop. The problem that I see is that this design does not really "respect" 
the intended use of beginModalSession et al. in that no real work is done in 
the loop - all work is done on the detached thread. I believe that in fact the 
loop is effectively a tight loop that chews up a lot of resources polling for 
the detached thread to complete.

As indicated by the comment in the code fragment below, using runModalForWindow 
seems to create some timing problems - it is possible that the detached thread 
may complete before runModalForWindow even starts.

My question may be a bit broad to answer here, but anyway, here it is:

Can anyone point me in the direction of a design that:

(a) allows the detached thread (actually the NSTask launched within the thread) 
to be terminated from a modal main thread window, and
(b) does not chew up resources in a busy-waiting loop?

Thanks, and here is the existing code fragment (from the Skim application):

/***/

- (NSInteger)runModalSelector:(SEL)selector withObject:(NSDictionary *)info
{

Nsmodalsession session = [NSApp beginModalSessionForWindow:[self window]];
BOOL didDetach = NO;
NSInteger rv = 0;

while (YES) {

  // we run this inside the modal session 
  // since the thread could end before runModalForWindow starts
if (NO == didDetach) {
[NSThread detachNewThreadSelector:selector toTarget:self 
withObject:info];
didDetach = YES;
}

rv = [NSApp runModalSession:session];
if (rv != NSRunContinuesResponse)
break;
}

[NSApp endModalSession:session];

// close the window when finished
[self close];

___

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

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

2010-03-17 Thread Jeremy Pereira

On 17 Mar 2010, at 13:35, gMail.com wrote:

> Hi, I have a file path
>  /Folder/filename.txt
> The API fileExistsAtPath says that it exists.
> Now I need to get its real case sensitive file name, which is indeed e.g.
> "FileName.txt"
> How can I get it in a fast way? I thought by its inode, but I can't really
> know how to do that.

The following seems to work on 10.6

NSString* path = @"/etc/HOSTS";
NSURL* url = [NSURL fileURLWithPath: path];
NSError* error = nil;
NSArray* keysIWant = [NSArray arrayWithObject: NSURLNameKey];
NSDictionary* resources = [url resourceValuesForKeys: keysIWant error: 
&error];
if (resources != nil)
{
NSString* actualPath = [resources objectForKey: NSURLNameKey];
NSLog(@"%@", actualPath);
}

Gives output: hosts



> 
> I know I can iterate along the contents of the parent directory and do a
> case insensitive match of each item, but this is too long. I need to check
> thousands files. Any fast idea?
> 
> 
> Regards
> --
> Leonardo
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
> 
> This email sent to a...@jeremyp.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: Case sensitive fileName

2010-03-17 Thread Jeremy Pereira

On 17 Mar 2010, at 16:07, Jens Alfke wrote:

> 
> On Mar 17, 2010, at 6:35 AM, gMail.com wrote:
> 
>> Now I need to get its real case sensitive file name, which is indeed e.g.
>> "FileName.txt"
>> How can I get it in a fast way? I thought by its inode, but I can't really
>> know how to do that.
> 
> Have you tried -[NSString stringByStandardizingPath], or the BSD function 
> realpath()? The docs don’t explicitly say they correct case, but it seems 
> like the kind of thing they would do.

The code:

const char* path = "/etc/HOSTS";
char realPath[PATH_MAX + 1];
memset(realPath, 0, PATH_MAX + 1);
printf("%s\n", realpath(path, realPath));

gives output /private/etc/hosts

so, depending on the application, it might be working too well as it resolves 
symlinks.

> 
> —Jens___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net
> 
> This email sent to a...@jeremyp.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


Programmatically binding Core Data to dynamic NSTableColumns

2010-03-17 Thread Michael LaMorte
I have a Core Data application with two entities: Item and Entries. Item has a 
dataType string variable. Item has a to-many inverse relationship to Entries. 
Entries has two variables: stringData and numberData.

I'm programmatically creating an NSTableColumn for each Item. The cell type of 
the column is defined by the Item's dataType variable. This part is working.

The goal is for each Item to have a column, and when clicking an Add New Entry 
button, a new Entry is created for each Item. The interface would add one row, 
with the value bound to the corresponding stringData or numberData for the 
Entry for that Item.

Right now, the Add New Entry button/method loops through the Items and creates 
a new Entry for each... that's working okay. Where I'm having problems is 
figuring out the bindings to properly display the columns. The bind statement 
I'm using is:

[itemColumn bind:@"value" toObject:entryArrayController 
withKeyPath:@"arrangedObjects.numberData" options:nil];

(It's in an if statement, so it binds to either numberData or stringData as 
appropriate.)

This results in 1 row being added for each Item, and the entire row is bound to 
the same value. So if I have 6 Items, I correctly have 6 columns (one for each 
Item) but clicking Add New Entry it incorrectly generates 6 rows, one for each 
Item.

I've tried many variations of the toObject and withKeyPath: values to no avail. 
I've looked through all the Key Value Coding and other Apple dev documentation 
and Googled like mad, but after 3 unproductive days I'm hoping someone here can 
help.

---
Michael A. LaMorte
Minder Softworks
a division of Springboard Enterprises Ltd

___

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

Please do not post admin requests or moderator comments to the list.
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: Programmatically binding Core Data to dynamic NSTableColumns

2010-03-17 Thread Bill Hernandez

On Mar 17, 2010, at 12:59 PM, Michael LaMorte wrote:

> I have a Core Data application with two entities: Item and Entries. Item has 
> a dataType string variable. Item has a to-many inverse relationship to 
> Entries. Entries has two variables: stringData and numberData.
> 
> I'm programmatically creating an NSTableColumn for each Item. The cell type 
> of the column is defined by the Item's dataType variable. This part is 
> working.
> 
> The goal is for each Item to have a column, and when clicking an Add New 
> Entry button, a new Entry is created for each Item. The interface would add 
> one row, with the value bound to the corresponding stringData or numberData 
> for the Entry for that Item.
> 
> Right now, the Add New Entry button/method loops through the Items and 
> creates a new Entry for each... that's working okay. Where I'm having 
> problems is figuring out the bindings to properly display the columns. The 
> bind statement I'm using is:
> 


> [itemColumn bind:@"value" toObject:entryArrayController 
> withKeyPath:@"arrangedObjects.numberData" options:nil];

if you are using a loop 

> arrangedObjects.numberData

wont work. See if [5302] below helps...

I extract the fieldnames from a tab delimited file, thus the reason for the 
variable names

for(NSString *tabDelimitedFieldName in theFieldNames)
{
// See NOTE : [5301]
NSTableColumn *aColumn = [[[NSTableColumn alloc] 
initWithIdentifier:tabDelimitedFieldName] autorelease];

NSString *tabDelimitedFieldNameCapitalized = 
[[tabDelimitedFieldName stringByReplacingOccurrencesOfString:@"_" withString:@" 
"] capitalizedString];
[[aColumn headerCell] 
setStringValue:tabDelimitedFieldNameCapitalized];
[aColumn setWidth:(CGFloat)93.0];

// [5302] This next line is key
NSString *theString = [NSString 
stringWithFormat:@"arrangedObjects.%@",tabDelimitedFieldName];
[aColumn bind:NSValueBinding toObject:(id)theArrayController 
withKeyPath:theString options:nil];

[theUserInterfaceTableView addTableColumn:aColumn];
}

> (It's in an if statement, so it binds to either numberData or stringData as 
> appropriate.)
> 
> This results in 1 row being added for each Item, and the entire row is bound 
> to the same value. So if I have 6 Items, I correctly have 6 columns (one for 
> each Item) but clicking Add New Entry it incorrectly generates 6 rows, one 
> for each Item.
> 
> I've tried many variations of the toObject and withKeyPath: values to no 
> avail. I've looked through all the Key Value Coding and other Apple dev 
> documentation and Googled like mad, but after 3 unproductive days I'm hoping 
> someone here can help.

Bill Hernandez
Plano, Texas

___

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

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

2010-03-17 Thread Sherm Pendley
On Wed, Mar 17, 2010 at 10:36 AM, Philippe Sismondi  wrote:

> So, I want to launch the secondary task in a separate thread to keep the main 
> runloop responsive.

NSTask only blocks the runloop if you call -waitUntilExit. So - don't
do that. :-)

sherm--

-- 
Cocoa programming in Perl:
http://www.camelbones.org
___

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

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

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

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


Re: Threads Question

2010-03-17 Thread Dave DeLong
And it also happens to have a very convenient -terminate method.  :)

Dave

On Mar 17, 2010, at 1:21 PM, Sherm Pendley wrote:

> On Wed, Mar 17, 2010 at 10:36 AM, Philippe Sismondi  
> wrote:
> 
>> So, I want to launch the secondary task in a separate thread to keep the 
>> main runloop responsive.
> 
> NSTask only blocks the runloop if you call -waitUntilExit. So - don't
> do that. :-)
> 
> sherm--


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: Case sensitive fileName

2010-03-17 Thread gMail.com
Thank you! I have used realpath, and it worked as like a charm!
Here's my code. One question only: is the NSUTF8StringEncoding correct?

- (NSString*)CaseSensitiveFilePath:(NSString*)filePath
{
const char*cFilePath = [mManager
fileSystemRepresentationWithPath:filePath];
if(cFilePath == 0 || *cFilePath == L'\0') return filePath;

intlen = PATH_MAX + 1;
charcRealPath[len];
memset(cRealPath, 0, len);
char*result = realpath(cFilePath, cRealPath);

//printf("CaseSensitiveFileName %s\n", result);
if(result != NULL) return [NSString stringWithCString:result
encoding:NSUTF8StringEncoding];
else return filePath;
}


Thank you again
--
Leonardo




>> 
>> On Mar 17, 2010, at 6:35 AM, gMail.com wrote:
>> 
>>> Now I need to get its real case sensitive file name, which is indeed e.g.
>>>  "FileName.txt"
>>> How can I get it in a fast way? I thought by its inode, but I can't really
>>> know how to do that.
>> 
>> Have you tried -[NSString stringByStandardizingPath], or the BSD function
>> realpath()? The docs don¹t explicitly say they correct case, but it seems
>> like the kind of thing they would do.
>> 
>> ‹Jens___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/aaron.burghardt%2Bcocoa-dev%
>> 40gmail.com
>> 
>> This email sent to aaron.burghardt+cocoa-...@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: Programmatically binding Core Data to dynamic NSTableColumns

2010-03-17 Thread Bill Hernandez

On Mar 17, 2010, at 2:17 PM, Bill Hernandez wrote:

>> (It's in an if statement, so it binds to either numberData or stringData as 
>> appropriate.)
> 

Michael,

Sorry I missed the part about the if statement...

I am running into a similar problem, the log shows the data (array of 
dictionaries), but I cannot seem to get the data to display in the 
NSTableView...

Best of Luck,

Bill Hernandez
Plano, Texas
___

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

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

2010-03-17 Thread Aaron Burghardt

On Mar 17, 2010, at 3:24 PM, gMail.com wrote:

> Thank you! I have used realpath, and it worked as like a charm!
> Here's my code. One question only: is the NSUTF8StringEncoding correct?
> 
> - (NSString*)CaseSensitiveFilePath:(NSString*)filePath
> {
>const char*cFilePath = [mManager
>fileSystemRepresentationWithPath:filePath];
>if(cFilePath == 0 || *cFilePath == L'\0') return filePath;
> 
>intlen = PATH_MAX + 1;
>charcRealPath[len];
>memset(cRealPath, 0, len);
>char*result = realpath(cFilePath, cRealPath);
> 
>//printf("CaseSensitiveFileName %s\n", result);
>if(result != NULL) return [NSString stringWithCString:result
>encoding:NSUTF8StringEncoding];
>else return filePath;
> }

Yes.  But, you should return:

 [mManager stringWithFileSystemRepresentation:result 
length:strlen(result)];

There are other potential transformations that the "file system representation" 
methods perform.

Aaron
___

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

Please do not post admin requests or moderator comments to the list.
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: Cocoa Newbie Thread/Memory Problems

2010-03-17 Thread Dave

I found the problem and it works! I had an extra:

self.mXMLSourceData = nil;

statement!

I am now wondering if all my alloc/release calls are ok!

Thanks again,
All the Best
Dave




___

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

Please do not post admin requests or moderator comments to the list.
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: Programmatically binding Core Data to dynamic NSTableColumns

2010-03-17 Thread Quincey Morris
On Mar 17, 2010, at 10:59, Michael LaMorte wrote:

> I have a Core Data application with two entities: Item and Entries. Item has 
> a dataType string variable. Item has a to-many inverse relationship to 
> Entries. Entries has two variables: stringData and numberData.
> 
> I'm programmatically creating an NSTableColumn for each Item. The cell type 
> of the column is defined by the Item's dataType variable. This part is 
> working.
> 
> The goal is for each Item to have a column, and when clicking an Add New 
> Entry button, a new Entry is created for each Item. The interface would add 
> one row, with the value bound to the corresponding stringData or numberData 
> for the Entry for that Item.
> 
> Right now, the Add New Entry button/method loops through the Items and 
> creates a new Entry for each... that's working okay. Where I'm having 
> problems is figuring out the bindings to properly display the columns. The 
> bind statement I'm using is:
> 
> [itemColumn bind:@"value" toObject:entryArrayController 
> withKeyPath:@"arrangedObjects.numberData" options:nil];
> 
> (It's in an if statement, so it binds to either numberData or stringData as 
> appropriate.)
> 
> This results in 1 row being added for each Item, and the entire row is bound 
> to the same value. So if I have 6 Items, I correctly have 6 columns (one for 
> each Item) but clicking Add New Entry it incorrectly generates 6 rows, one 
> for each Item.

You seem to be saying that each Item has its *own* Entries, but you fail to say 
what ties the Entries together that need to be shown in the same row.

You also don't say what your entryArrayController's content is. If it's simply 
using the set of Entries, then of course you're going to get 6 rows if you add 
6 entries.

Either the Items need to share Entries, so that each of the Entries corresponds 
to its own row in the table, or you need *something* that represents the row 
(with different Entries for each of the Items).

Incidentally, it's usual for entities to be singular rather than plural (Entry 
rather than Entries) and for to-many relationships to be plural (such as 
item.entries). The fact that you called your entity Entries suggests that 
you're not quite sure what the entity is supposed to represent.

In any case, you'll need to clarify your data model.


___

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

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


NSUndoManager _NSundoInvocation Over-Release

2010-03-17 Thread Keary Suska
I am getting an over-release of the NSUndoManager private ivar 
_NSundoInvocation, inside removeAllActionsWithTarget:. Does anyone know what I 
could be doing in my code that would cause this, or is this possibly a known 
bug?

TIA,

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

___

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

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

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

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


Re: Core Animation and interaction

2010-03-17 Thread john fogg
> There's a CoreAnimation sample project that does just this, called LightBoard.
> --Kyle Sluder

Thank you and thanks everyone else. I didn't find the LightBoard
sample but I found GeekGameBoard which helped me a lot.

John.
___

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

Please do not post admin requests or moderator comments to the list.
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: NSManagedObject awakeFromFetch not sent on secondary thread?

2010-03-17 Thread Ben Trumbull
> However I still don't understand why awakeFromFetch is not sent in secondary
> thread - I can't find any clue in documentation? Is this a bug or is it a
> feature? I'm running on 10.6.2.

Did you try setting the NSFetchRequest option -setReturnsObjectsAsFaults:NO ?  
The default setting will attempt to lazily copy the fetch results into the 
managed objects as much as possible (the data is still fetched eagerly from the 
database by -executeFetchRequest: as you can see with SQL logging) Perhaps you 
are always touching the objects on the main thread eagerly so there is no 
apparent difference there.

- 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


RESOLVED: Blocked Reads

2010-03-17 Thread r c
Thank you all for your ideas.  With various suggestions, I found a variation of 
the CDRomSample
code that seems to work well.  The sample does reads on the BSN Name of
the device root (i.e. /dev/rdisk#).  I have found that if I dig a
little deeper into the IORegistry for the device (i.e. /dev/rdisk#s0),
the code works.

Rich






colors wrote:

> I am running into a problem with anti-virus software.  I need to be able to 
> read a file from a USB CD and I need the read to actually go over the USB bus.


Why do you need the read to go over the USB bus?  If the OS itself has cached 
some disk data, why force it to be transferred over the bus again?

What are you trying to accomplish?



> Does anyone have any thoughts about 1) what the AV SW is doing?, and 2) how 
> to get around what it is doing?


If there were a simple way to get around the AV SW, then malware would be able 
to use it to get around the AV SW, thus nullifying the AV SW.

  -- GG

___

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

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

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

This email sent to iseecol...@sbcglobal.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


setStringValue problems with dynamically loaded views.

2010-03-17 Thread Kevin Brock
I have some framework code which dynamically loads some views from it's bundle, 
based on parameters that are known at runtime.

Calls to setStringValue appear to be having no effect for any of my 
NSTextFields, either labels or editable.

Here's code that loads a custom view containing a text field from the framework 
bundle and then sets the text.

@interface MyTextController  : NSViewController 
{   
IBOutlet NSTextField* textField;
}

@end

In the implementation:  

- (id)initWithText:(NSString*)field_contents
{
NSBundle* mybundle = [NSBundle 
bundleWithPath:@"/Library/Frameworks/MyFramework.framework"];
self = [self initWithNibName:@"MyEditText" bundle:mybundle];
if(self)
{
[textField setStringValue:field_contents];
}

return self;
}

The view is loaded successfully, and the text field shows up where it's 
supposed to in the top level window.

But the text isn't set. 

The .xib file shows that File's Owner is the correct subclass of 
NSViewController, and that the NSTextField control is connected to the 
textField outlet.  

Any ideas?

Kevin

___

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

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

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

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


re: CoreData database sharing and migration

2010-03-17 Thread Ben Trumbull
> I am wondering whether it is possible to create a database in core  
> data that can be opened by more than one application at the same time.  
> It is currently impossible to handle one SQLite database with two  
> instances of the same app. The problem is if user1 quits the app, the  
> data is saved but user2's instance of the app doesn't recognize this  
> file system change and just overwrites its version in memory. So the  
> data from user1 is gone. Is there a way I can handle this?
> 
> Second -- I am having more than two database versions now but still  
> want to support my version 1.0 but the mapping model only allows one  
> source model as well as only one target model. I would have to remove  
> one version but that makes version 1.0 users' database unusable.
> 
> Has anyone gotten something like this to work?

Yes, several Apple frameworks use Core Data databases from multiple processes 
simultaneously with a single user account and single physical machine.

Do you mean "more than one application simultaneously on more than one physical 
computer over NFS/AFP/SMB" ?  Don't do that.

Or do you mean an NSDocument based application using Core Data & an SQLite 
store ?  NSDocuments intentionally behave like TextEdit.  Last writer wins, 
overwites everything.  If so, you should be using a non-document based Core 
Data project template.

- Ben

___

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

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

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

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


Re: setStringValue problems with dynamically loaded views.

2010-03-17 Thread Kyle Sluder
On Wed, Mar 17, 2010 at 2:16 PM, Kevin Brock  wrote:
> - (id)initWithText:(NSString*)field_contents
> {
>        NSBundle* mybundle = [NSBundle 
> bundleWithPath:@"/Library/Frameworks/MyFramework.framework"];

You shouldn't hardcode bundle paths like this. You could use
+[NSBundle bundleWithIdentifier:] (preferred) or +[NSBundle
bundleForClass:] instead.

>        self = [self initWithNibName:@"MyEditText" bundle:mybundle];
>        if(self)
>        {
>                [textField setStringValue:field_contents];

-initWithNibName:bundle: doesn't actually load the nib, so at this
point textField hasn't been hooked up to anything yet. If you set a
breakpoint on this line you'll find that textField == nil. You will
need to move this logic elsewhere.

The documentation for NSViewController (perhaps the release notes?)
makes oblique reference to NSWindowController's -windowDidLoad method,
which is designed for just this kind of scenario. NSViewController
doesn't have an analog for -windowDidLoad; instead you are expected to
override -loadView, call super's implementation, and then perform your
setup. That is the approach I would recommend.

You could theoretically do it in -awakeFromNib, but that won't work if
your view controller exists as an object in another nib, since it will
get -awakeFromNib twice.

Hope that helps,
--Kyle Sluder
___

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

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

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

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


Re: CoreData database sharing and migration

2010-03-17 Thread Tobias Jordan

Hello Ben,

Thanks a lot for responding! My problem is as follows: The database  
which is currently a non-document based core data SQLite one is  
normally stored in the local User Library of the user. (/Users/user/ 
Library/Application Support/MyApp/database.db


But there are cases in which two (or more) different physical machines  
must have access to the database. For example two designers working on  
a project and they both need the same database so they can share their  
results. This means they create a new database on their server and  
link my app to this database.


As you've said, is there a way the data can be always immediately  
written to disk so there's no 'last writer wins'?


I am not using NSDocument based techniques -- it is really just one  
core data DB.


Thank you!

Regards,
Tobias


On Mar 17, 2010, at 10:29 PM, Ben Trumbull wrote:


I am wondering whether it is possible to create a database in core
data that can be opened by more than one application at the same  
time.

It is currently impossible to handle one SQLite database with two
instances of the same app. The problem is if user1 quits the app, the
data is saved but user2's instance of the app doesn't recognize this
file system change and just overwrites its version in memory. So the
data from user1 is gone. Is there a way I can handle this?

Second -- I am having more than two database versions now but still
want to support my version 1.0 but the mapping model only allows one
source model as well as only one target model. I would have to remove
one version but that makes version 1.0 users' database unusable.

Has anyone gotten something like this to work?


Yes, several Apple frameworks use Core Data databases from multiple  
processes simultaneously with a single user account and single  
physical machine.


Do you mean "more than one application simultaneously on more than  
one physical computer over NFS/AFP/SMB" ?  Don't do that.


Or do you mean an NSDocument based application using Core Data & an  
SQLite store ?  NSDocuments intentionally behave like TextEdit.   
Last writer wins, overwites everything.  If so, you should be using  
a non-document based Core Data project template.


- 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


Class instance defaults: e.g. NSBrowser

2010-03-17 Thread Andrew James
I am a relative newbie to Cocoa so I trying to make sure that my code reflects 
Cocoa's coding culture.

I'm interested in whether or not instances of Cocoa classes can be expected to 
display default behavior.  I'll use NSBrowser's - (BOOL)sendsActionOnArrowKeys 
as an example. In Apple's documentation there's no mention of the default.

For my purposes, I want to make sure from release to release that my NSBrowser 
instance does send an action when up/down keys are used.  Does that mean as a 
Cocoa developer I'm content to always code [ myBrowser 
setSendsActionOnArrowKeys: YES ] ? or Make sure the appropriate box is checked 
in Interface Builder?

Cheers,
--aj



___

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

Please do not post admin requests or moderator comments to the list.
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: CoreData database sharing and migration

2010-03-17 Thread Ben Trumbull

On Mar 17, 2010, at 2:59 PM, Tobias Jordan wrote:

> Hello Ben,
> 
> Thanks a lot for responding! My problem is as follows: The database which is 
> currently a non-document based core data SQLite one is normally stored in the 
> local User Library of the user. (/Users/user/Library/Application 
> Support/MyApp/database.db
> 
> But there are cases in which two (or more) different physical machines must 
> have access to the database.

Don't do that.  Network file systems do not provide real time distributed cache 
coherency.  NFS is not a free version of Oracle.

> For example two designers working on a project and they both need the same 
> database so they can share their results. This means they create a new 
> database on their server and link my app to this database.

Each machine can have its own database and they can share their results with 
NSDistributedNotification or some other IPC/networking protocol.  You can hook 
into the NSManagedObjectContextDidSaveNotification to track when one of the 
peers has committed changes locally.

- Ben

> 
> As you've said, is there a way the data can be always immediately written to 
> disk so there's no 'last writer wins'?
> 
> I am not using NSDocument based techniques -- it is really just one core data 
> DB.
> 
> Thank you!
> 
> Regards,
> Tobias
> 
> 
> On Mar 17, 2010, at 10:29 PM, Ben Trumbull wrote:
> 
>>> I am wondering whether it is possible to create a database in core
>>> data that can be opened by more than one application at the same time.
>>> It is currently impossible to handle one SQLite database with two
>>> instances of the same app. The problem is if user1 quits the app, the
>>> data is saved but user2's instance of the app doesn't recognize this
>>> file system change and just overwrites its version in memory. So the
>>> data from user1 is gone. Is there a way I can handle this?
>>> 
>>> Second -- I am having more than two database versions now but still
>>> want to support my version 1.0 but the mapping model only allows one
>>> source model as well as only one target model. I would have to remove
>>> one version but that makes version 1.0 users' database unusable.
>>> 
>>> Has anyone gotten something like this to work?
>> 
>> Yes, several Apple frameworks use Core Data databases from multiple 
>> processes simultaneously with a single user account and single physical 
>> machine.
>> 
>> Do you mean "more than one application simultaneously on more than one 
>> physical computer over NFS/AFP/SMB" ?  Don't do that.
>> 
>> Or do you mean an NSDocument based application using Core Data & an SQLite 
>> store ?  NSDocuments intentionally behave like TextEdit.  Last writer wins, 
>> overwites everything.  If so, you should be using a non-document based Core 
>> Data project template.
>> 
>> - Ben
>> 
> 


- 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


Float constants

2010-03-17 Thread Michael Vannorsdel
I've been working on some 64bit code cleaning but need some advice on float 
constants.  Currently on 32bit builds I use -fsingle-precision-constant since 
most of my code uses CGFloats and I'd like the constants to be the correct 
precision.  But in some places I do work with doubles and would like the 
constants involved to be double on 32bit and not float getting promoted.  I 
tried the L suffix on them but they still compile as floats.  So is there a way 
to force a constant to be a double when using 
-fsingle-precision-constant?___

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

Please do not post admin requests or moderator comments to the list.
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: setStringValue problems with dynamically loaded views.

2010-03-17 Thread Kevin Brock
On Mar 17, 2010, at 2:42 PM, Kyle Sluder wrote:
> -initWithNibName:bundle: doesn't actually load the nib, so at this
> point textField hasn't been hooked up to anything yet. If you set a
> breakpoint on this line you'll find that textField == nil. You will
> need to move this logic elsewhere.
> 
> The documentation for NSViewController (perhaps the release notes?)
> makes oblique reference to NSWindowController's -windowDidLoad method,
> which is designed for just this kind of scenario. NSViewController
> doesn't have an analog for -windowDidLoad; instead you are expected to
> override -loadView, call super's implementation, and then perform your
> setup. That is the approach I would recommend.

Thanks.  This fixed my problems!

Kevin


___

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

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

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

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


Re: Float constants

2010-03-17 Thread Sean McBride
On Wed, 17 Mar 2010 16:14:38 -0600, Michael Vannorsdel said:

>I've been working on some 64bit code cleaning but need some advice on
>float constants.  Currently on 32bit builds I use -fsingle-precision-
>constant since most of my code uses CGFloats and I'd like the constants
>to be the correct precision.  But in some places I do work with doubles
>and would like the constants involved to be double on 32bit and not
>float getting promoted.  I tried the L suffix on them but they still
>compile as floats.  So is there a way to force a constant to be a double
>when using -fsingle-precision-constant?

I don't see any Cocoa question here... The Xcode list would have been better.

But anyway, CGFloat is sometimes float sometimes double, so how does -
fsingle-precision-constant help you?

Still, CGFloat is a pain when using the 64 to 32 bit truncation warning
and doing something like:

NSRect foo = NSMakeRect (1.0, 2.0, ...)

it will warn building as 32 bit since it's implicitly converting double
to float.  You could do:

NSRect foo = NSMakeRect ((CGFloat)1.0, (CGFloat)2.0, ...)

But that's too ugly IMHO.  My solution is:

NSRect foo = NSMakeRect (1.0f, 2.0f, ...)

which has no warnings in 32 nor 64.  It would be nice if we could write
something like:

NSRect foo = NSMakeRect (1.0cg, 2.0cg, ...)

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

Please do not post admin requests or moderator comments to the list.
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: CoreData database sharing and migration

2010-03-17 Thread Tobias Jordan

Hi Ben,

Thanks so much for this brilliant suggestion, I haven't thought about  
something like this before but it's actually really fantastic.
About the second question -- do you know how to solve the migration  
with more than two data models?


- Tobias

On Mar 17, 2010, at 11:13 PM, Ben Trumbull wrote:



On Mar 17, 2010, at 2:59 PM, Tobias Jordan wrote:


Hello Ben,

Thanks a lot for responding! My problem is as follows: The database  
which is currently a non-document based core data SQLite one is  
normally stored in the local User Library of the user. (/Users/user/ 
Library/Application Support/MyApp/database.db


But there are cases in which two (or more) different physical  
machines must have access to the database.


Don't do that.  Network file systems do not provide real time  
distributed cache coherency.  NFS is not a free version of Oracle.


For example two designers working on a project and they both need  
the same database so they can share their results. This means they  
create a new database on their server and link my app to this  
database.


Each machine can have its own database and they can share their  
results with NSDistributedNotification or some other IPC/networking  
protocol.  You can hook into the  
NSManagedObjectContextDidSaveNotification to track when one of the  
peers has committed changes locally.


- Ben



As you've said, is there a way the data can be always immediately  
written to disk so there's no 'last writer wins'?


I am not using NSDocument based techniques -- it is really just one  
core data DB.


Thank you!

Regards,
Tobias


On Mar 17, 2010, at 10:29 PM, Ben Trumbull wrote:


I am wondering whether it is possible to create a database in core
data that can be opened by more than one application at the same  
time.

It is currently impossible to handle one SQLite database with two
instances of the same app. The problem is if user1 quits the app,  
the
data is saved but user2's instance of the app doesn't recognize  
this
file system change and just overwrites its version in memory. So  
the

data from user1 is gone. Is there a way I can handle this?

Second -- I am having more than two database versions now but still
want to support my version 1.0 but the mapping model only allows  
one
source model as well as only one target model. I would have to  
remove

one version but that makes version 1.0 users' database unusable.

Has anyone gotten something like this to work?


Yes, several Apple frameworks use Core Data databases from  
multiple processes simultaneously with a single user account and  
single physical machine.


Do you mean "more than one application simultaneously on more than  
one physical computer over NFS/AFP/SMB" ?  Don't do that.


Or do you mean an NSDocument based application using Core Data &  
an SQLite store ?  NSDocuments intentionally behave like  
TextEdit.  Last writer wins, overwites everything.  If so, you  
should be using a non-document based Core Data project template.


- Ben






- Ben





___

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

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

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

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


re: CoreData database sharing and migration

2010-03-17 Thread Steve Steinitz

Hello

On 17/3/10, cocoa-dev-requ...@lists.apple.com wrote:


Do you mean "more than one application simultaneously on more than one physical 
computer over NFS/AFP/SMB" ?  Don't do that.


When did that become the official policy, Ben?

I'm doing that with some success.  For the past three years, my 
client's point of sale system has been connecting from five 
machines to a single database on a Synology network drive over 
afp.  I had to write some code to periodically get the latest 
values from the database during idle time.  That was a little 
complicated but its working well now.


There are mysterious but harmless optimistic locking errors once 
in a while where no attributes appear have changed -- just to 
keep me on my toes, along with an occasional real data collision 
(two staff members carelessly editing the same object) but we've 
had no real issues in a year or so.


However, 10.6.2 has a bug where only one machine can connect to 
a Core Data store (its likely a sqlite-level connection issue -- 
but I'm not sure).  So, for a while we were down to one 
machine.  I eventually had to roll the five machines back to 
Leopard.  That remains a PR nightmare.


Best regards,

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: CoreData database sharing and migration

2010-03-17 Thread Ben Trumbull
> About the second question -- do you know how to solve the migration with more 
> than two data models?

From a specific NSPersistentStore's perspective there is only ever 1 data 
model.  When you use multiple models and merge them together, then *union* is 
"the" data model.  The object you pass to the NSPersistentStoreCoordinator 
initializer is the one true data model regardless of whether it only exists in 
memory or how many separate model files were used to compose it.

When you migrate a store that is built on the union of multiple models, you 
must migrate the union to a new union.  You cannot migrate things piecemeal.  
However, as you can merge models together at runtime, so too could you 
construct mapping models programmatically to handle the union.   However, 
that's probably more trouble than it's worth.  You should focus on migrating 
the union model that was used with the store as its own entity.

It might be easier to think about how you would give each schema a version 
number.  Each union of models is likely to be its own version, and you would 
migrate to a new union with a new version number.

- Ben


On Mar 17, 2010, at 3:28 PM, Tobias Jordan wrote:

> Hi Ben,
> 
> Thanks so much for this brilliant suggestion, I haven't thought about 
> something like this before but it's actually really fantastic.
> About the second question -- do you know how to solve the migration with more 
> than two data models?
> 
> - Tobias
> 
> On Mar 17, 2010, at 11:13 PM, Ben Trumbull wrote:
> 
>> 
>> On Mar 17, 2010, at 2:59 PM, Tobias Jordan wrote:
>> 
>>> Hello Ben,
>>> 
>>> Thanks a lot for responding! My problem is as follows: The database which 
>>> is currently a non-document based core data SQLite one is normally stored 
>>> in the local User Library of the user. (/Users/user/Library/Application 
>>> Support/MyApp/database.db
>>> 
>>> But there are cases in which two (or more) different physical machines must 
>>> have access to the database.
>> 
>> Don't do that.  Network file systems do not provide real time distributed 
>> cache coherency.  NFS is not a free version of Oracle.
>> 
>>> For example two designers working on a project and they both need the same 
>>> database so they can share their results. This means they create a new 
>>> database on their server and link my app to this database.
>> 
>> Each machine can have its own database and they can share their results with 
>> NSDistributedNotification or some other IPC/networking protocol.  You can 
>> hook into the NSManagedObjectContextDidSaveNotification to track when one of 
>> the peers has committed changes locally.
>> 
>> - Ben
>> 
>>> 
>>> As you've said, is there a way the data can be always immediately written 
>>> to disk so there's no 'last writer wins'?
>>> 
>>> I am not using NSDocument based techniques -- it is really just one core 
>>> data DB.
>>> 
>>> Thank you!
>>> 
>>> Regards,
>>> Tobias
>>> 
>>> 
>>> On Mar 17, 2010, at 10:29 PM, Ben Trumbull wrote:
>>> 
> I am wondering whether it is possible to create a database in core
> data that can be opened by more than one application at the same time.
> It is currently impossible to handle one SQLite database with two
> instances of the same app. The problem is if user1 quits the app, the
> data is saved but user2's instance of the app doesn't recognize this
> file system change and just overwrites its version in memory. So the
> data from user1 is gone. Is there a way I can handle this?
> 
> Second -- I am having more than two database versions now but still
> want to support my version 1.0 but the mapping model only allows one
> source model as well as only one target model. I would have to remove
> one version but that makes version 1.0 users' database unusable.
> 
> Has anyone gotten something like this to work?
 
 Yes, several Apple frameworks use Core Data databases from multiple 
 processes simultaneously with a single user account and single physical 
 machine.
 
 Do you mean "more than one application simultaneously on more than one 
 physical computer over NFS/AFP/SMB" ?  Don't do that.
 
 Or do you mean an NSDocument based application using Core Data & an SQLite 
 store ?  NSDocuments intentionally behave like TextEdit.  Last writer 
 wins, overwites everything.  If so, you should be using a non-document 
 based Core Data project template.
 
 - Ben
 
>>> 
>> 
>> 
>> - Ben
>> 
>> 
>> 
> 


___

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

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

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

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


Re: Float constants

2010-03-17 Thread Nick Zitzmann

On Mar 17, 2010, at 4:26 PM, Sean McBride wrote:

> But anyway, CGFloat is sometimes float sometimes double, so how does -
> fsingle-precision-constant help you?

For me, anyway, setting that compiler flag is SOP when building for 32-bit 
code. A lot of older 32-bit Cocoa code was written under the assumption that 
it's okay to use double constants in places that expect floats, because under 
Xcode's default warning set, nothing happens when the code does that. Changing 
them to float constants is tedious and causes a little (insignificant) 
precision loss when building for 64-bit, so I just keep them as double 
constants and use that flag to make them into float constants on 32-bit builds.

Of course, I don't think there is any one true way of tackling this problem...

Nick Zitzmann


___

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

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

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

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


Suppressing autocomplete on space

2010-03-17 Thread Daniel Thorpe
Hello everyone, 

I know this has briefly been asked before, but the answer provided (just 
subclass the field editor), isn't really very cocoaish, and the docs are a bit 
lacking on this, so I'm asking again...

Firstly, the problem...

My app has a few places where the user searches for a person, so I want to 
provide autocomplete against their Address Book. This is done in a 
NSSearchField, in a NSTextFieldCell in a NSTableView and in a normal 
NSTextField. All of these controls have my AppDelegate set as their delegate, 
and in that class I implement the NSControlTextEditing delegate method: 

- (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView 
completions:(NSArray *)words forPartialWordRange:(NSRange)charRange 
indexOfSelectedItem:(NSInteger *)index

to provide my array of names. My implementation of this method currently splits 
the textView's string up by spaces, and uses the first and last words to search 
for first and last names. The problem is that when the user types a space, 
because they are going to type the person's surname, the field autocompletes. 
This is bad because it might actually be the wrong name and we get a space 
appended to the completed name. Ideally, I only want to autocomplete on tab.

Now, I've tried implementing all manner of "textWill/DidEndEditing" delegate 
methods, for both NSControlTextEditing and NSTextViewDelegate protocols, and 
none of them seem to get called when the user presses space. So, what's going 
on? How can I get it to only autocomplete on tab, not space?

Also, if the answer really is "just override the field editor", how do I 
override one class (NSTextFieldCell?) to make it work with the three different 
input fields? And, lastly, what exactly do I do in the - 
(void)complete:(id)sender; method? Check the last character, and if it's not 
space call the super?


I think that's it, any ideas would be most welcome!

Cheers
Dan



___

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

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

2010-03-17 Thread Michael Vannorsdel
This is exactly why I do it for the 32bit builds.  What I'm trying to avoid in 
the sections that use doubles is having the constant generate a float load, 
double store, double load for each constant.  I'm still poking through the 
assembly to see if gcc is indeed doing this but I'm also checking if someone 
has experience with this and how to avoid causing unnecessary load/store/loads 
to promote the constants to doubles.  For instance if putting an explicit cast 
like (double)1.2345 will tell gcc to treat it as a double despite the single 
precision flag.


On Mar 17, 2010, at 4:52 PM, Nick Zitzmann wrote:

> For me, anyway, setting that compiler flag is SOP when building for 32-bit 
> code. A lot of older 32-bit Cocoa code was written under the assumption that 
> it's okay to use double constants in places that expect floats, because under 
> Xcode's default warning set, nothing happens when the code does that. 
> Changing them to float constants is tedious and causes a little 
> (insignificant) precision loss when building for 64-bit, so I just keep them 
> as double constants and use that flag to make them into float constants on 
> 32-bit builds.
> 
> Of course, I don't think there is any one true way of tackling this problem...

___

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

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

2010-03-17 Thread Ken Thomases
On Mar 17, 2010, at 12:35 PM, Andreas Mayer wrote:

> Am 17.03.2010 um 17:46 Uhr schrieb Kevin Wojniak:
> 
>> NSLog(@"displayNameAtPath: %@", [[NSFileManager defaultManager] 
>> displayNameAtPath:path]);
> 
> Note that -displayNameAtPath: will give you the localized name if one should 
> exist.
> 
> (For example you'll get 'Programme' for the 'Applications' folder if you 
> happen to be on a German system.)
> 
> You can't use that as an input to file system functions.
> 
> Since the OP didn't say what he needs the filename for, -displayNameAtPath: 
> may or may not be the right solution.

I think it will also hide file extensions for users who have that preference 
set.

Regards,
Ken

___

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

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

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

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


Re: Class instance defaults: e.g. NSBrowser

2010-03-17 Thread Keary Suska
On Mar 17, 2010, at 4:11 PM, Andrew James wrote:

> I am a relative newbie to Cocoa so I trying to make sure that my code 
> reflects Cocoa's coding culture.
> 
> I'm interested in whether or not instances of Cocoa classes can be expected 
> to display default behavior.  I'll use NSBrowser's - 
> (BOOL)sendsActionOnArrowKeys as an example. In Apple's documentation there's 
> no mention of the default.
> 
> For my purposes, I want to make sure from release to release that my 
> NSBrowser instance does send an action when up/down keys are used.  Does that 
> mean as a Cocoa developer I'm content to always code [ myBrowser 
> setSendsActionOnArrowKeys: YES ] ? or Make sure the appropriate box is 
> checked in Interface Builder?

There is no hard and fast rule that I know of--that is Cocoa-specific. I would 
assert that as a general rule if you rely on a behavior, then you should always 
explicitly set it. It disambiguates your code and is future proof in case Apple 
decides to change the documented default. You may also want to file a bug 
against the doc.

HTH,

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

___

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

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

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

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


Re: NSTrackingArea Problem

2010-03-17 Thread Richard Somers

On Mar 16, 2010, at 1:23 PM, Quincey Morris wrote:

I'm not sure what the answer is. It seems very context dependent,  
and maybe there are other relevant factors.


Thanks for your input.

After much testing I have arrived at the following conclusion.

NSTrackingArea when used with NSTrackingActiveWhenFirstResponder or  
NSTrackingActiveInKeyWindow may require the mouse to exit and re-enter  
the tracking area to activate the tracking. This will occur when the  
window resigns and then regains key status. (This appears to be an  
obscure bug.) The work around is to release and reinitialize the  
tracking area when the window becomes key.


--Richard

___

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

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


Multiple validation errors. Why?

2010-03-17 Thread Lynn Barton
I have a core data application. One entity is "Hit". This entity typically has 
no instances when the application starts, and gets populated during the 
execution of the program. All of the instances appear to be OK when viewed in a 
TableView. Some or all instances may get deleted before the application quits. 
If any instances remain when the app quits, I get a "multiple validation errors 
occured" message. The console has no error messages. In debugging, I have gone 
so far as supplying no data at all when adding any instances, so they get 
created with default values only. Still I get the error message. Some 
attributes are strings, some are 16 bit integers, and some are 32 bit integers. 
The string defaults are empty strings, and the integer defaults are zero. I am 
creating Hit instances with this method

NSManagedObject *newHit = [NSEntityDescription 
 
insertNewObjectForEntityForName:@"Hit" 
 
inManagedObjectContext:[appDelegate managedObjectContext]];

The app has three other entities, but they don't cause validation errors. Can 
anyone help?

Lynn Barton
___

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

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


User-space threads and NSAutoreleasePool

2010-03-17 Thread BJ Homer
Hi everyone,

Some setup, first. If you just want to jump to the question, jump to the
last paragraph.

OS X includes (as part of its UNIX heritage) functions for implementing
user-space threading.  (See, for example, the man page on
swapcontext.)
 This allows developers to swap out the current stack for another, in effect
allowing two threads of execution on a single thread. Using kernel-level
threads is, naturally, simpler, but due to the cost of kernel-level context
switches, they don't scale well. (You just can't run 500 threads at once
very well.) User-space threads require more programmer attention, certainly,
but also allow certain programming models that can't be done otherwise. For
example, they can be used for coroutines, cooperative threading, or all
sorts of esoteric-yet-sometimes-useful effects.

I say all that in an effort to avoid the frequent "you're fighting the
frameworks" responses. I'm well familiar with the frameworks, GCD, etc., and
in this particular case, user-space threads is what I need.

The problem is that when you call swapcontext() to switch the user-thread
running on a kernel-thread, the NSAutoreleasePool stack is not swapped out.
It remains rooted in thread-local storage. As a result, serious problems
result. Let me give an example.

- (void)doStuff {
  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
  // do some stuff that calls swapcontext()
  [pool drain];
}

-doStuff calls swapcontext(), trusting that the other user-thread will
eventually call swapcontext() and restore the flow to this user-thread.

Further, assume that the second user-thread also allocates an autorelease
pool before returning. Despite being on separate user-threads, there is
still only one kernel-thread. Since the autorelease pool stack is in
(kernel-)thread-local storage, the second user-thread's pool goes on top of
the same stack:

Autorelease pool stack: pool_from_uthread1 -> pool_from_uthread2

Now, when we swap back to the first user-thread, it will release its
autorelease pool. This, naturally, releases the second pool as well. When we
swap back to the second user-thread, anything that was autoreleased is now
dead and gone.

Okay, so that's the setup. Obviously, the problem is that the two user-space
threads are sharing an autorelease pool stack that is intended to be
thread-local. My question, then, is whether there exists a way to get and
set the autorelease pool stack, so that before calling swapcontext(), I
could put it in a state appropriate for this user-level thread? I assume it
is being stored in thread-local storage, but it's not in the NSThread
threadDictionary, which means it's probably set using pthread_setspecific.
Accessing that value would require the key used to store it, but naturally I
don't have access to that. So is there some existing function call that
allows such access?

Thanks for listening,

-BJ Homer
___

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

Please do not post admin requests or moderator comments to the list.
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: Checking integrity of a Core Data document with SQLite store

2010-03-17 Thread Dave Fernandes
Thanks, Ben and mmalc for the responses.

I found that prefetching the commonly accessed objects in my document's 
initWithContentsOfURL:ofType:error method finds the corruption pretty reliably. 
Hopefully, this is a reasonably robust check without being as i/o intensive as 
an integrity check.

It would be nice, though, to have a method that I was sure provided good 
coverage of the physical file. 

Dave

On 2010-03-15, at 11:03 PM, Ben Trumbull wrote:

> 
> On Mar 15, 2010, at 7:49 PM, Dave Fernandes wrote:
> 
>> 
>> On 2010-03-15, at 3:30 PM, Ben Trumbull wrote:
>> 
>>> Running an integrity check can be useful if you have previously gotten a 
>>> corrupt db error back from fetching or saving, or your app previously 
>>> crashed, or you have some other active indicator it might be worthwhile.  
>>> However, it's quiet expensive in I/O and you should not do it on every app 
>>> launch / document open.  Customers with account home directories on AFP, 
>>> NFS or SMB servers will be very unhappy, and if your files become large 
>>> enough so will people using local drives.
>> 
>> That's a shame. It would certainly be easier to check when opening the file 
>> than to scatter code all over the app to diagnose the problem. Is there a 
>> standard exception I can expect to get when fetching or saving? 
>> NSInternalInconsistencyException is the one I currently get.
> 
> You should generally get an NSError with the code that is 
> NSFileReadCorruptFileError.  In gdb, what does:
> 
> >future-break objc_exception_throw
> >future-break +[NSError errorWithDomain:code:userInfo:]
> 
> ...
> 
> >info threads
> >thread apply all bt
> 
> say ?
> 
> The only place you should get an exception is if you try to fault in an 
> object that is unreachable.  Either because the database was deleted or 
> corrupted, or because another thread / context deleted that object you wanted 
> before you and you only held the reference instead of getting all the data at 
> once (e.g. race on delete)
> 
> - Ben
> 

___

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

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

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

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


RE: Directory to save file in NSSavePanel

2010-03-17 Thread Nikhil Khandelwal
Thanks a lot for your help.
I implemented the behavior by using "runmodalForDirectory: file:". In this I 
took a bool variable which is false for first time and then true once save 
panel is opened. For first time I used "setDirectory:@'Documents'" and if user  
changed the location then "[savepanel directory]" and it is working fine for me 
on 10.5 and 10.6.

Thanks once again.
---Nikhil


-Original Message-
From: Corbin Dunn [mailto:corb...@apple.com]
Sent: Wednesday, March 17, 2010 10:43 PM
To: Matt Neuburg
Cc: Nikhil Khandelwal; cocoa-dev@lists.apple.com
Subject: Re: Directory to save file in NSSavePanel


On Mar 17, 2010, at 9:39 AM, Matt Neuburg wrote:

> On Wed, 17 Mar 2010 13:40:35 +0530, Nikhil Khandelwal
>  said:
>
>> I am using NSSavePanel in my application. I am using "runModal" on this to
>> show the save panel. The default location it shows to save the file is
>> "Desktop" which I want to change to "Document". I tried 
>> "runModalForDirectory"
>> as well however it uses the given file path as save location always. 
>> Basically
>> I want NSSavePanel to use "Documents" as default save location and if user
>> change the location while saving the file, next time NSSavePanel should shows
>> the changed location to save the file.
>
> If you're willing to be Snow Leopard only, a combination of directoryURL and
> setDirectoryURL might work. It's a little tricky otherwise because Mac OS X
> does automatically remember the last place the user saved, so the idea is to
> stay out of its way in that case. That info is kept in your user defaults so
> you might be able to examine it. m.

Actually, the behavior Nikhi requested is the default behavior if you pass 
'nil' for the directory in the runModalForDirectory methods (or use it for 
setDirectoryURL:)

If you are using nil, it should default to Documents the first time. If it 
didn't, then you probably need to wipe some user defaults (possibly in the 
global domain and for the app).

corbin



DISCLAIMER
==
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.
___

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

Please do not post admin requests or moderator comments to the list.
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: User-space threads and NSAutoreleasePool

2010-03-17 Thread Greg Guerin

BJ Homer wrote:


I say all that in an effort to avoid the frequent "you're fighting the
frameworks" responses. I'm well familiar with the frameworks, GCD,  
etc., and

in this particular case, user-space threads is what I need.

The problem is that when you call swapcontext() to switch the user- 
thread
running on a kernel-thread, the NSAutoreleasePool stack is not  
swapped out.



Two main questions come to mind:

Q1. What are you trying to accomplish?
Q2. Why do you think this would work?

More on Q1:  You said you need user-space threads, but you gave no  
reason or rationale.  If it's because you need 500 threads, then why  
do you need 500 threads?  Exactly what are you trying to accomplish?


More on Q2: The ucontext(3) functions appear to me to be more  
intended for signal-handling, specifically for alt-signal-stack  
handling.  The nature of signals is that they eventually return  
(nested), they don't work in a round-robin or any other scheduling.   
That's not a question, just prep.  The question is this: Are you sure  
the Objective-C runtime is compatible with ucontext user-threads?   
There are lots of things you can't do in signal-handlers, not even  
handlers written in plain C (ref: man sigaction, the list of safe  
functions).  If you can't call malloc() in a signal-handler (and I'm  
pretty sure you can't), what do you expect to happen with your  
Objective-C user-threads, since object allocation is tied to malloc()?


Oh, and as for "Unix heritage", the ucontext functions don't appear  
until 10.5.  Signal-handling with sigaction and alt-sig-stack are  
older, but their limitations are equally old: AFAIK it's never been  
safe to call malloc() in a signal handler.


  -- GG

___

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

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

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

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


Cocoa project structures

2010-03-17 Thread Scott Cherf
I'm looking for a good overview of cocoa/xcode project structures for medium to 
large scale applications, something that goes a bit past the MVC and presents 
some ways to decompose a larger project into smaller pieces. 

My problem is that I started with a small application that copies a directory 
from one format to another. It was small enough that all the whole UI and all 
three classes fit easily into a single nib. Now it's getting bigger and I'd 
like to start breaking it up into something that maybe has a single application 
delegate tied to the main menu that knows how to load nibs and run them so I 
can break out the 'import' methods and objects from the 'library' methods and 
objects and keep related parts together in their own nibs.

Can anyone point to a good example of an application that was written along the 
lines I'm describing, perhaps a book or tutorial?

Thanks,
Scott.

___

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

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

2010-03-17 Thread Scott Anguish

On Mar 17, 2010, at 9:21 PM, Scott Cherf wrote:

> I'm looking for a good overview of cocoa/xcode project structures for medium 
> to large scale applications, something that goes a bit past the MVC and 
> presents some ways to decompose a larger project into smaller pieces. 
> 
> My problem is that I started with a small application that copies a directory 
> from one format to another. It was small enough that all the whole UI and all 
> three classes fit easily into a single nib. Now it's getting bigger and I'd 
> like to start breaking it up into something that maybe has a single 
> application delegate tied to the main menu that knows how to load nibs and 
> run them so I can break out the 'import' methods and objects from the 
> 'library' methods and objects and keep related parts together in their own 
> nibs.
> 
> Can anyone point to a good example of an application that was written along 
> the lines I'm describing, perhaps a book or tutorial?
Yes.

Have a look at the Sketch example (either in Developer/Examples, or on the 
Apple Developer site.)

TextEdit is also a good example, although much smaller in 
scale.___

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

Please do not post admin requests or moderator comments to the list.
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: Checking integrity of a Core Data document with SQLite store

2010-03-17 Thread Ben Trumbull
The integrity check will do that, but there's no way to mitigate the I/O costs. 
 Conceptually, if you added a simple checksum, you'd still have to read the 
entire file to verify it matched the checksum.

This file corruption should be extremely rare, and should only occur after 
power loss or kernel panic or a user hitting the power button for an unclean 
reboot.  If not, please file a bug.  If so, but you have data you are willing 
to share with us, also please file a bug.

- Ben

On Mar 17, 2010, at 10:04 PM, Dave Fernandes wrote:

> Thanks, Ben and mmalc for the responses.
> 
> I found that prefetching the commonly accessed objects in my document's 
> initWithContentsOfURL:ofType:error method finds the corruption pretty 
> reliably. Hopefully, this is a reasonably robust check without being as i/o 
> intensive as an integrity check.
> 
> It would be nice, though, to have a method that I was sure provided good 
> coverage of the physical file. 
> 
> Dave
> 
> On 2010-03-15, at 11:03 PM, Ben Trumbull wrote:
> 
>> 
>> On Mar 15, 2010, at 7:49 PM, Dave Fernandes wrote:
>> 
>>> 
>>> On 2010-03-15, at 3:30 PM, Ben Trumbull wrote:
>>> 
 Running an integrity check can be useful if you have previously gotten a 
 corrupt db error back from fetching or saving, or your app previously 
 crashed, or you have some other active indicator it might be worthwhile.  
 However, it's quiet expensive in I/O and you should not do it on every app 
 launch / document open.  Customers with account home directories on AFP, 
 NFS or SMB servers will be very unhappy, and if your files become large 
 enough so will people using local drives.
>>> 
>>> That's a shame. It would certainly be easier to check when opening the file 
>>> than to scatter code all over the app to diagnose the problem. Is there a 
>>> standard exception I can expect to get when fetching or saving? 
>>> NSInternalInconsistencyException is the one I currently get.
>> 
>> You should generally get an NSError with the code that is 
>> NSFileReadCorruptFileError.  In gdb, what does:
>> 
>>> future-break objc_exception_throw
>>> future-break +[NSError errorWithDomain:code:userInfo:]
>> 
>> ...
>> 
>>> info threads
>>> thread apply all bt
>> 
>> say ?
>> 
>> The only place you should get an exception is if you try to fault in an 
>> object that is unreachable.  Either because the database was deleted or 
>> corrupted, or because another thread / context deleted that object you 
>> wanted before you and you only held the reference instead of getting all the 
>> data at once (e.g. race on delete)
>> 
>> - Ben
>> 
> 


___

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

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

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

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


Re: User-space threads and NSAutoreleasePool

2010-03-17 Thread BJ Homer
On Wed, Mar 17, 2010 at 11:47 PM, Greg Guerin  wrote:
>
> Two main questions come to mind:
>
> Q1. What are you trying to accomplish?
> Q2. Why do you think this would work?
>
> More on Q1:  You said you need user-space threads, but you gave no reason
> or rationale.  If it's because you need 500 threads, then why do you need
> 500 threads?  Exactly what are you trying to accomplish?
>

Q1: What am I trying to accomplish?

In this particular case, I'm working on an application that sends very large
HTTP PUT requests over an HTTP connection in a pipelined fashion. For
performance reasons, the server prefers to delay acknowledgement of these
files until it can process them in large groups. (Before it can send an ack,
it must update a database. Doing 400-500 single updates is far slower than
doing one transaction updating 400-500 records.) Hence, we pipeline the HTTP
requests, starting transfer of the second before the first one is finished.
There are a large number of servers that don't handle pipelining, but we'll
only we talking to one particular server, and we know it does.
 NSURLConnection does not (according to various mailing list messages)
implement pipelining, allegedly due to the lack of server support. There's
some suggestion that CFHTTPStream does support pipelining, but there's
little to no documentation about it, and I don't know if it will handle 500
at once.

If you can use user-space threads, this becomes simple; you send the first
file, and then when you're waiting for the ACK, you swap out and let another
file start sending. When the ack is received, the first user-thread is
rescheduled. We've developed an extremely high-performance cross-platform
library that handles all the scheduling directly. Then we've built another
library around that that handles all the particulars of our server protocol.

At the moment, I'm converting our OS X client to use this library. That's my
immediate motivation; if I can use an existing library, I'll save a large
amount of time, get a big performance boost, and have less code to test. To
a large extent, it is already working.


> More on Q2: The ucontext(3) functions appear to me to be more intended for
> signal-handling, specifically for alt-signal-stack handling.  The nature of
> signals is that they eventually return (nested), they don't work in a
> round-robin or any other scheduling.  That's not a question, just prep.  The
> question is this: Are you sure the Objective-C runtime is compatible with
> ucontext user-threads?  There are lots of things you can't do in
> signal-handlers, not even handlers written in plain C (ref: man sigaction,
> the list of safe functions).  If you can't call malloc() in a signal-handler
> (and I'm pretty sure you can't), what do you expect to happen with your
> Objective-C user-threads, since object allocation is tied to malloc()?
>

Q2: Why do I think this would work? Am I sure the Obj-C runtime is
compatible with ucontext user-threads?

No. There is, in general, relatively little information on use of ucontext
user-threads on OS X. Mostly, it exists in man pages. So far the only issue
I've run into is the autorelease pool issue mentioned previously, which
isn't (I suspect) actually a runtime issue at all. There may be other
issues, but that's part of the reason I'm asking on the list. I can work
around the autorelease pool issue if I have to (by limiting my use of
Objective-C objects and autorelease pools in such a way that I can guarantee
correctness), but if there are other known issues, I'd love to hear about
them.

It's true that ucontext stuff is often used for signal handling, but that's
not the only use case. My code does not relate to signal handling at all. As
mentioned above, all this ucontext stuff happening in a cross-platform
library. It's already running on Linux, where I suspect the
malloc-in-signal-handlers restrictions equally apply. I've also had it
running (to some extent) as well. In neither Linux nor my initial attempts
on OS X have I seen anything to indicate that object allocation was not
working. In fact, I have a fair amout of evidence that it is likely working
just fine. If object allocation was failing or otherwise unstable, my code
would be crashing all over the place, not just having autorelease pool
issues.

-BJ
___

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

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