Re: File still in use after closing document window

2008-06-02 Thread Antonio Nunes

On Jun 3, 2008, at 8:46 AM, Bill Bumgarner wrote:


The actual loading is done like this:

		self.masterPDFDocument = [[ANPDFDocument alloc] initWithURL:  
absoluteURL];


If your -setMasterPDFDocument: -- synthesized or manually written --  
follows traditional reatain/release rules, the above will result in  
the ANPDFDocument being over-retained.


The masterPDFDocument ivar is indeed a synthesized property, but the  
app is garbage collected, so I would expect the reference to be  
collected shortly after its host document is closed.


António

-
Forgiveness is not an occasional act;
it is a permanent attitude.

--Martin Luther King, Jr
-




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: File still in use after closing document window

2008-06-02 Thread Bill Bumgarner

On Jun 2, 2008, at 10:57 PM, Antonio Nunes wrote:

The actual loading is done like this:

		self.masterPDFDocument = [[ANPDFDocument alloc] initWithURL:  
absoluteURL];


If your -setMasterPDFDocument: -- synthesized or manually written --  
follows traditional reatain/release rules, the above will result in  
the ANPDFDocument being over-retained.


b.bum
___

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

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

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

This email sent to [EMAIL PROTECTED]


CoreData file format stability

2008-06-02 Thread Charles Srstka
Okay, after many years of pretty much only doing software that had to  
run on very old versions of Mac OS X, I've finally decided to do some  
stuff that might require Tiger or maybe even Leopard, so I've been  
able to start exploring some of the various new features Cocoa has  
picked up over the years, such as bindings and such. Now, I'm having a  
look at CoreData. It looks neat, but I do have a couple of questions/ 
concerns about it. The first of these is:


1) The file format for saved files. I'd rather not make some  
proprietary/closed Microsoft-ish thing - I'd like it to be possible  
for other programs to read/write my file format, including  
hypothetical programs that might get written for other platforms so  
that my file format could possibly be readable and writable by our  
Linux friends (and Windows carbon units as well). Since CoreData has a  
SQLite-based format, and since SQLite is available pretty much  
everywhere, this seems pretty good as long as I am able to figure out  
how CoreData sets up the tables and such in its documents, except for  
one concern: what if the layout of the SQLite file CoreData creates  
changes? If CoreData on 10.6, 10.7, etc. all generate SQLite files  
that are set up a bit differently from the way the previous version of  
OS X did it, that could create a very annoying moving target for  
anyone trying to access the files via a non-CoreData means. Now, one  
would think that would not be likely to happen, since it could  
potentially cause a very confusing situation where the same exact  
binary would create a different file format depending on which OS  
version it was running on, but then again this *is* Apple we're  
talking about, so I'm a little paranoid. Is there any documentation  
anywhere promising that the format of the CoreData save files won't  
change in future versions of the OS, or failing that, could one of the  
Apple employees here let me know if this is a valid concern or not?


2) Is CoreData able to edit files in place at all? The reason I am  
asking is because the documents my hypothetical app would work with  
could possibly become very large, maybe even in the 300-400 MB range.  
Would CoreData be able to just open the files, let me search them, add  
stuff to them, etc., like one would normally be able to do just by  
using SQLite directly, or would it be copying the whole thing into a  
store file somewhere or into RAM every time a file is opened?


Basically what I need to do at this stage is determine whether  
CoreData is suitable for my hypothetical app, or whether I should just  
roll something myself using the SQLite3 APIs directly. As always, any  
help is greatly appreciated.


Thanks,
Charles
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: File still in use after closing document window

2008-06-02 Thread Antonio Nunes

On Jun 2, 2008, at 2:06 PM, Hamish Allan wrote:


My NSDocument based app loads (imports) PDF files into its documents.


What code are you using to load them?


The actual loading is done like this:

		self.masterPDFDocument = [[ANPDFDocument alloc] initWithURL:  
absoluteURL];


Although I doubt it would have any influence: Before loading I also  
make sure the document ends up in the recent documents menu, since  
some trickery is involved to get all the openable files to show up in  
that place:


		// We want the original doc URL to be added to the recent menu  
BEFORE we change the URL to our native file type.

if (! loadedFromBundle) {
			[[NSDocumentController sharedDocumentController]  
noteNewRecentDocumentURL:[self fileURL]];

}

-António


There is a world of difference between
searching for happiness and choosing
to be happy.





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Hillegass book memory question

2008-06-02 Thread Adam Leonard

Hi,
I have the second edition still, but I assume this example has not  
changed much in the third edition.


Usually, yes, you must release anything you +alloc, -retain, -copy,  
etc. This is a bit of a special case though.


In this case, exactly one NSSpeechSynthesizer is allocated when the  
application is launched (in AppController's -init), and it is used for  
almost the entire life of the application; i.e., the same speech  
synthesizer is always used whenever one of the buttons is pressed  
until the user quits the application.
However, the operating system will always reclaim all memory you  
malloc'd when the application quits. It just takes the entire memory  
space your application used and say it is "free" for other  
applications to use.


So, it is very common to take advantage of this fact. The speech  
synthesizer object is automatically dealloc'd by the OS very soon  
after you are done using it, so there is no reason to explicitly  
release it yourself.

The Cocoa frameworks take this shortcut, as do most applications.

By the way, this shortcut is not just the result of laziness, it is  
actually faster. Instead of going through all the objects that are  
used throughout the life span of the app, and having the OS free all  
of them one at a time, the shortcut lets the OS group all these  
objects and free them at the same time.


It is, however, perfectly acceptable to override -dealloc in  
AppController and call [speachSynthesizer release]. I am sure this is  
discussed elsewhere in the book.



Hope that makes sense.

Adam Leonard

On Jun 2, 2008, at 9:39 PM, Ashley Perrien wrote:

I'm working my way through the 3rd edition and have a question  
specifically on speech synthesizer in chapter 5. It's my  
understanding that whenever something is retained or alloced they  
eventually need to be released. In the application built in the  
chapter, NSSpeechSynthesizer is alloced and an array is retained and  
neither are released. I know that for the very small and simple apps  
here, it doesn't really matter but how and where would you go about  
releasing those objects? If they shouldn't be released, why not?


Thanks for any enlightenment.

Ashley Perrien
___

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

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

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

This email sent to [EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Michael Ash
On Tue, Jun 3, 2008 at 10:47 AM, William Bumgarner <[EMAIL PROTECTED]> wrote:
> Certainly, there could be better support -- a better out of the box pattern 
> -- for dealing with the loading of auxiliary nibs.

NSWindowController and NSViewController handle approximately the
totality of auxiliary nib-loading needs. I would go so far as to say
that if you have a nib which doesn't fit into one of those two, you're
doing something wrong and should rebuild it. The problem with them is
simply that many people don't know about them, or don't know how to
use them. It took me a couple of years before I really realized that
every window should have its own NSWindowController which loads the
nib for that one window. Once I figured it out, life got a lot easier.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Solved (still open to suggestions): DTrace probe problem

2008-06-02 Thread radj
Finally got it to poll. I had to study signals and signal handling within
the driver. lol. I've tried it and atleast it helps me delay the actual
"initialization" of the driver while I run the D script.

Your quick responses were really helpful. Thanks alot, Bill!

DTrace rocks!

radj

On Mon, Jun 2, 2008 at 10:31 AM, Bill Bumgarner <[EMAIL PROTECTED]> wrote:

> On Jun 1, 2008, at 7:19 PM, radj wrote:
>
>> I can try that. Sounds like a good idea. Make the "waiting for the signal"
>> the first thing the driver will do. but how do you send a signal from within
>> DTrace to a specific process?
>>
>
> I have no idea if dtrace can send a signal.   I would send a kill -USR1 via
> a shell command...
>
> b.bum
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Key-Value pairs

2008-06-02 Thread Michael Ash
On Tue, Jun 3, 2008 at 5:41 AM, Hamish Allan <[EMAIL PROTECTED]> wrote:
> On Mon, Jun 2, 2008 at 10:30 PM, john darnell
> <[EMAIL PROTECTED]> wrote:
>
>> I just read Hillegass' chapter that introduces Key-Value coding.
>
>>  My question is, if this is such a necessary thing, why didn't the
>> designers simply design the compiler to auto-generate setter and getter
>> functions as per the requisite style in the first place?
>
> I haven't read Hillegaas' latest book, but perhaps in a less
> introductory chapter he will go on to talk about @synthesise, which
> does exactly what you're looking for.

Also even without @synthesize, KVC will work just fine with no
accessors present. The KVC implementation will happily extract the
value directly from your instance variable by using its name, or put a
new value into it.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Hillegass book memory question

2008-06-02 Thread Ashley Perrien
I'm working my way through the 3rd edition and have a question  
specifically on speech synthesizer in chapter 5. It's my understanding  
that whenever something is retained or alloced they eventually need to  
be released. In the application built in the chapter,  
NSSpeechSynthesizer is alloced and an array is retained and neither  
are released. I know that for the very small and simple apps here, it  
doesn't really matter but how and where would you go about releasing  
those objects? If they shouldn't be released, why not?


Thanks for any enlightenment.

Ashley Perrien
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Getting started with Core Animation

2008-06-02 Thread Matt Long
Hey Graham. I wrote a blog post not too long ago that demonstrates  
adding layers to a root layer. You can see it here: http://www.cimgf.com/2008/03/15/core-animation-tutorial-dashboard-effect/


I think you want to get the root content layer and then call  
insertSublayer or addSublayer to it. Here's what I do in the  
awakeFromNib in that blog post:


-(void)awakeFromNib;
{
[[window contentView] setWantsLayer:YES];
[window setFrame:[[NSScreen mainScreen] frame] display:NO  
animate:NO];


NSRect contentFrame = [[window contentView] frame];
CALayer *root = [[window contentView] layer];

// mainLayer is the layer that gets scaled. All of its sublayers
// are automatically scaled with it.
mainLayer = [CALayer layer];
mainLayer.frame = NSRectToCGRect(contentFrame);

// Make the background color to be a dark gray with a 50% alpha  
similar to

// the real Dashbaord.
mainLayer.backgroundColor = CGColorCreateGenericRGB(0.10, 0.10,  
0.10, 0.50);

[root insertSublayer:mainLayer above:0];

// Add a new layer to the mainlayer.
[self addNewLayer:nil];

scaleUp = YES;
}

You can get my demo project from here: 
http://www.cimgf.com/wp-content/uploads/2008/03/dashboardeffect.zip

HTH

-Matt



On Jun 2, 2008, at 9:51 PM, Graham Cox wrote:


Hi all,

I'm looking at Core Animation for the first time. Having a bit of  
trouble getting started with the simplest set-up I can imagine.


Goal - to add a single CALayer in my view so I can see it. Then, try  
some simple animations. I've tried a few different things but I just  
can't see any visible trace of my layer. Here's the code, part of my  
custom view (actually, almost all of it):


- (id)  initWithFrame:(NSRect)frame
{
   self = [super initWithFrame:frame];
   if (self)
{
CALayer* rootLayer = [CALayer layer];

theLayer = [CALayer layer];

CGRect  frame = {10,10,110,150};
CGColorRef  bk = CGColorCreateGenericRGB( 0.5, 0.5, 0, 1.0 
);

[theLayer setCornerRadius:10.0];
[theLayer setBorderWidth:4.0];
[theLayer setFrame:frame];
[theLayer setBackgroundColor:bk];

[rootLayer addSublayer:theLayer];

[self setLayer:rootLayer];
[self setWantsLayer:YES];

CGColorRelease( bk );
   }
   return self;
}


n.b. 'theLayer' is an ivar.

Initially I didn't have a separate rootLayer, but looking at some  
sample code it seems most code uses one. Even though there's no  
layer content set I should see the border and the background colour  
shouldn't I? What am I missing?


BTW, another things that's a little unclear - when the rootLayer is  
added to the view, does it adopt the view's frame? Or should I be  
setting this explicitly? Sample code appears to just let it use its  
defaults.



thanks for any insight,


Graham
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


A little extra cash...

2008-06-02 Thread J. Todd Slack

Hi All,

I am willing to pay a small sum (since I am an NPO) for someone who  
can create a small example all that creates as NSStatusMenu, fills it  
with a menu items and shows me how to call code (objective-C And  
AppleScript) when a menu option is selected.


Who is up to do this?

$100.00 sound OK?

I am missing something and would like a great example.

Stipulations main must be a .c so I can create an iTunesPlugin.

I started this here: 
http://thejasonandannettefoundation.org/public/jason/Ring-Maker-Plugin.zip

Hit em up..
-Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Getting started with Core Animation

2008-06-02 Thread Graham Cox

Hi all,

I'm looking at Core Animation for the first time. Having a bit of  
trouble getting started with the simplest set-up I can imagine.


Goal - to add a single CALayer in my view so I can see it. Then, try  
some simple animations. I've tried a few different things but I just  
can't see any visible trace of my layer. Here's the code, part of my  
custom view (actually, almost all of it):


- (id)  initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
CALayer* rootLayer = [CALayer layer];

theLayer = [CALayer layer];

CGRect  frame = {10,10,110,150};
CGColorRef  bk = CGColorCreateGenericRGB( 0.5, 0.5, 0, 1.0 
);

[theLayer setCornerRadius:10.0];
[theLayer setBorderWidth:4.0];
[theLayer setFrame:frame];
[theLayer setBackgroundColor:bk];

[rootLayer addSublayer:theLayer];

[self setLayer:rootLayer];
[self setWantsLayer:YES];

CGColorRelease( bk );
}
return self;
}


n.b. 'theLayer' is an ivar.

Initially I didn't have a separate rootLayer, but looking at some  
sample code it seems most code uses one. Even though there's no layer  
content set I should see the border and the background colour  
shouldn't I? What am I missing?


BTW, another things that's a little unclear - when the rootLayer is  
added to the view, does it adopt the view's frame? Or should I be  
setting this explicitly? Sample code appears to just let it use its  
defaults.



thanks for any insight,


Graham
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: trying to glue a cocoa ui to a pthread application / subclassing nsview

2008-06-02 Thread Quincey Morris


On Jun 2, 2008, at 19:49, Michael Toy wrote:

what I find is that my initWithFrame method is not being called ...  
so i have two questions ...


my drawRect: IS being called, so I know my custom view is being  
instantiated.  why is my init not being called? i thought i figured  
out the documentaiton enough to understand that the phrase "This  
method is the designated initializer for the NSView class. Returns  
an initialized object." meant that this was the only method i needed  
to write to have custom behavior at creation time.


forget that, is there another way to win?

thanks in advance, i am happy to accept pointers to the  
documentation i should have found.


If you designed your view in IB, so that it's in a nib file,  
initWithFrame is not necessarily called when your application runs.  
(initWithCoder may be called instead.) See:


	http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/SubclassingNSView/chapter_6_section_2.html#/ 
/apple_ref/doc/uid/TP40002978-CH7-SW20


In that case, it's simplest to put your custom initialization in  
awakeFromNib instead.


If you're creating your view programatically, then, yes, initWithFrame  
should be getting called.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: many-to-many relationships and retain cycles

2008-06-02 Thread Adam R. Maxwell

On Jun 2, 2008, at 10:01 AM, Jens Alfke wrote:


On 2 Jun '08, at 9:12 AM, Todd Ransom wrote:

It seems that what I need is a non-retaining array. I googled  
around a bit and was surprised that I could not find an existing  
implementation. It looks like I can create one by subclassing  
NSMutableArray, overriding the primitive methods, and using a  
CFArray as the backing store with NULL callbacks to avoid any kind  
of retain or release when objects are added or removed.


You can also do cool things like store integers and NULL values in  
CFArray/CFDictionary/CFSet with appropriate callbacks; OmniFoundation  
has some predefined callbacks that can be useful examples.


It's even easier than that, thanks to CF/NS bridging. You can just  
use the CFArray API to create an array with no-op retain/release  
callbacks, and then cast the CFArrayRef to NSArray* and use it as an  
NSArray.


Jens alludes to using NULL retain/release, and that's a subtlety that  
you might want to watch out for.  If you want NSArray semantics for  
things like indexOfObject:, you should write a callback function for  
equality that uses isEqual:.  If you pass NULL for the callbacks,  
you'll get pointer equality.


--
adam
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSPredicate: To be, or not to be

2008-06-02 Thread stephen joseph butler
On Mon, Jun 2, 2008 at 7:37 PM, Gerriet M. Denkmann
<[EMAIL PROTECTED]> wrote:
> On 3 Jun 2008, at 03:30, stephen joseph butler wrote:
>
>> I'm sorry. I forget that the Spotlight predicate strings are slightly
>> different from the regular ones. This works for me:
>>
>> NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K LIKE
>> %@", kMDItemTextContent, @"To be, or not to be"];
>
> This one also works for me. Only it kind of works too well, finding
> thousands of files.
>
> Another example:  finds
> ".../Test.txt" which only contains the line: "Briggel and Braggel" .
> But I really want only files which contain "Briggel Braggel" or "the Briggel
> Braggel of today".
>
> Again: How to create a predicate for an 10.4.11 NSMetadataQuery to find a
> string which includes blanks.
> Possible answers:
> Escape the blanks with ..., or
> Enclose whole string with ..., or something else ?

For me, the following only finds one match when run with "To be, or
not to be" (a file from Fink)... not the thousands you're getting. And
if I create only one file on my system with "Briggel and Braggel", I
get no hits for "Briggel Braggel" (and only one for the correct
phrase).

I'm not sure what's different about your code, but I suspect the
problem isn't the NSPredicate.

#include 
#import 

int main( int argc, const char * argv[] )
{
if (argc != 2)
{
NSLog( @"usage: %s ", argv[ 0 ] );
return 1;
}

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSString *value = [NSString stringWithCString:argv[ 1 ]];
NSPredicate *predicate = [NSPredicate predicateWithFormat:
  @"%K LIKE[cd] %@",
  kMDItemTextContent,
  value];
NSMetadataQuery *query = [[NSMetadataQuery alloc] init];

[query setPredicate:predicate];
[query startQuery];

while ([query isGathering])
[[NSRunLoop currentRunLoop]
 runMode:NSDefaultRunLoopMode
 beforeDate:[NSDate distantFuture]];

NSUInteger count = 0;
for (NSMetadataItem *item in [query results])
{
++count;

NSLog( @"%d:", count );
for (NSString *attribute in [item attributes])
{
NSLog(
  @"\t%@: %@",
  attribute,
  [item valueForAttribute:attribute]
);
}
NSLog(
  @"\t%@: %@",
  kMDItemPath,
  [item valueForAttribute:(NSString*)kMDItemPath]
);
}

[pool drain];
return 0;
}
___

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

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

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

This email sent to [EMAIL PROTECTED]


Keyboard Layout Services

2008-06-02 Thread Charles Jenkins
Hi! I'm looking to learn about modern, Cocoa equivalents for the deprecated 
functions described in the "Keyboard Layout Services Reference."

Apple's documentation kindly notes that these API's are deprecated in 10.5, but 
does not direct me to their replacements.

I need a way to save, change, and restore the current keyboard layout.

___

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

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

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

This email sent to [EMAIL PROTECTED]


trying to glue a cocoa ui to a pthread application / subclassing nsview

2008-06-02 Thread Michael Toy
trying to put a cocoa ui on an existing pthreads app.  need to figure out how 
to let some random thread report to the ui that re-drawing the view would be a 
good idea. 


here is what i am trying to do, and this could be quite stupid but this is the 
best i've been able to figure out all by myself.

in my view class i do

- (id)initWithFrame:(NSRect)frameRect
{
[super initWithFrame:frameRect];
cache_view_obect(self);
}

- (void)dataIsDirty
{
   [self setNeedsDisplay:YES];
}

in my application delegate i do

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
   NSView* dataview = get_cached_view();
   tell_pthread_app_about_nsview(dataview);
}

and then deep in my pthread code i do:

if (ns_view_object) {
  [ns_view_object performSelectorOnMainThread:dataDirtySelector withObject:nil 
waitUntilDone:NO];
}

what I find is that my initWithFrame method is not being called ... so i have 
two questions ...

my drawRect: IS being called, so I know my custom view is being instantiated.  
why is my init not being called? i thought i figured out the documentaiton 
enough to understand that the phrase "This method is the designated initializer 
for the NSView class. Returns an initialized object." meant that this was the 
only method i needed to write to have custom behavior at creation time.

forget that, is there another way to win?

thanks in advance, i am happy to accept pointers to the documentation i should 
have found.

-michael
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread William Bumgarner
 
On Monday, June 02, 2008, at 11:35AM, "Paul Sargent" <[EMAIL PROTECTED]> wrote:
>
>On 2 Jun 2008, at 18:50, Bill Bumgarner wrote:
>
>> While learning the retain/release paradigm is certainly useful, it  
>> is considerably more complex than GC.  It is also unnecessary while  
>> learning Cocoa.   Specifically, GC is intended to be a production  
>> quality solution that you can use in your Cocoa applications,  
>> without exception.   In Leopard, there have been a handful of bugs  
>> and they have been addressed through software updates -- not  
>> surprising given the rather sweeping and intrusive set of changes  
>> needed to support GC.   And GC will get better / faster in future  
>> releases.
>
>I agree with nearly everything you've said, except the (second half of  
>the) first statement.
>
>I wouldn't say retain/release is more complex than GC. I'd say using  
>retain/release in a medium->large size project is more complex than  
>using GC, but the base concept is a simpler one. Whilst learning,  
>getting retain/release wrong tends to be less confusing than getting  
>GC wrong. GC will make things disappear at random times, whereas  
>retain/release will tend to be deterministic in behaviour.

In GC, you keep things around by referring to them and they get cleaned up 
automatically when they are no longer referenced.If you want to casually 
refer to something, you can use a __weak reference (sorry, GCC made us __do 
__it) and the collector will automatically set your reference to nil when there 
are no more strong references.

Furthermore, as soon as you throw threading into the mix, GC remains dead 
simple while non-GC becomes rather nastily complex.  Specifically, non-GC 
requires that you consider the "threaded ownership" of an object in that every 
thread has its own isolated autorelease pool.   In other words, it is 
impossible to pass "ownership" of an object from one thread to another in some 
kind of automatically-released-if-not-needed-further fashion.

Without locking, you can't write a safe, atomic, non-GC setter method.  And if 
you want to not run the risk of deadlocks, you need to also deal with 
exceptions, too.   This is the reason why @property(atomic) is a boatload 
slower than @property(nonatomic) under non-GC -- there is a lot of subtlety to 
ensuring atomicity of object assignments in this case.

GC makes all of that automatic.   In GC, an assignment implies ownership and 
there is no race condition involved.  Nor are there any per-thread ownership 
issues to deal with when passing an object from one thread to a next.

So, no, I don't buy for a moment that non-GC is simpler than GC.   The case the 
OP had is an edge case and, with a bit of thought, becomes fairly obvious what 
has gone wrong;   the object is being collected because nothing is referring to 
it.  Note that the application did not crash, as would be typical in the non-GC 
case.   Given that the OP had to be manually loading a NIB in the first place 
in a context that is both not the main NIB file and not in a document based 
application, said NIB loading pattern is definitely moving outside of the realm 
of rank beginner.

Certainly, there could be better support -- a better out of the box pattern -- 
for dealing with the loading of auxiliary nibs.

>That's how all the senior programmers on this list learnt (although  
>they didn't have a choice). Why do we think that people following can  
>jump a few steps?

Because it wasn't possible to jump said steps when most of us learned to 
program Cocoa.  

Reference counting based development is an anachronism within Cocoa 
programming.   A very important, very well supported, anachronism.   Reference 
counting will be around for a long long time to come, certainly, but there is 
absolutely no reason to use reference counted based Cocoa development save for 
legacy reasons and a handful of project types that really really need the 
absolute and total determinism of a reference counted system (of which, "when 
-dealloc is executed" should not be a consideration).There are actually a 
number of very solid performance and maintainability reasons to avoid 
retain/release/autorelease.

b.bum
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSPredicate: To be, or not to be

2008-06-02 Thread Gerriet M. Denkmann


On 3 Jun 2008, at 03:30, stephen joseph butler wrote:


On Mon, Jun 2, 2008 at 11:08 AM, Gerriet M. Denkmann
<[EMAIL PROTECTED]> wrote:

Constucting the format properly (copying your suggestion):
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K  
contains %@",

kMDItemTextContent, @"To be, or not to be"];


I'm sorry. I forget that the Spotlight predicate strings are slightly
different from the regular ones. This works for me:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K LIKE
%@", kMDItemTextContent, @"To be, or not to be"];


This one also works for me. Only it kind of works too well, finding  
thousands of files.


Another example:  finds  
".../Test.txt" which only contains the line: "Briggel and Braggel" .
But I really want only files which contain "Briggel Braggel" or "the  
Briggel Braggel of today".


Again: How to create a predicate for an 10.4.11 NSMetadataQuery to  
find a string which includes blanks.

Possible answers:
Escape the blanks with ..., or
Enclose whole string with ..., or something else ?

Kind regards,

Gerriet.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Henry McGilton (Starbase)




On Jun 2, 2008, at 1:48 PM, Francis Perea wrote:


Hi all

For my part just to say that I've learned a lot after the beginning  
of this post.


The application is ready now, but I'll try to read and learn a lot  
more.


And as Paul says I'm having lots of fun with Cocoa :-)

Thanks all for your help and time.


As another long shot, which nobody appears to have mentioned:

Is the  'Release when closed'  check-box on the Interface
Builder Window Inspector checked  'off'  ?

Cheers,
  Henry


===+
  Henry McGilton, Boulevardier |Trilithon Software
   Objective-C/Java Composer   | Seroia Research
---+
  mailto:[EMAIL PROTECTED]   |   http://www.trilithon.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 [EMAIL PROTECTED]


Re: how to implement ETA

2008-06-02 Thread William Squires

The following answer assumes you're dealing with a situation in which:

1) You already have a window where you can show the results as a non- 
modal window
2) The process has a fixed number of 'units' to process (such as  
records in a database, bytes to d/l, etc...)


Here's my pseudo-code:

// Function prototypes
double Now(void); // this function returns the current time in  
microseconds.

void update(double total_time); // this function updates your window.

// a CONST for converting seconds -> microseconds.
const double conversion_factor = 1e6;

...

int i;
double time;
double delta_t;
double total_t; // total time remaining, NOT a countdown from now!

time = Now(); // seed our process estimate.
total_t = conversion_factor * 60.0 * 60.0; // 1 hr in us; a good  
guesstimate for d/l stuff.

update(total_t);
for (i = 1; i<=num_processing_units; ++i)
  {
  ... // do loop stuff.

  // Get the new delta_t...
  delta_t = (Now() - time);

  // and adjust the estimate based on it, which is (time per 'unit'  
* # 'units' remaining to process).

  total_t = delta_t * ((double) num_processing_units - i);
  update(total_t);
  }
update(0.0);
...

Note that the update() function should take into account the  
granularity of your display units (i.e. if you have something like:


Time remaining: 1 h 23 m

then your granularity is minutes, so ignore any change smaller than a  
minute, so that you don't needlessly update the display if delta_t  
happens to be less than 1e6 * 60 (60,000,000 microseconds = 1 minute).


On Jun 1, 2008, at 7:50 AM, Nick Rogers wrote:


Hi,
I want to show time remaining while executing a loop.
How to go about it?

WIshes,
nick
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/wsquires% 
40satx.rr.com


This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Drag-to-poof and tables

2008-06-02 Thread Graham Cox
I realised after I posted this that of course in this situation you  
don't *have* a receiving view which can manipulate the return value.


I had a look at an old piece of code that I thought was doing  
something similar and it turns out it's not quite the same - in my  
case I'm dragging something within a view without using the dragging  
protocol, and if it's dragged outside (which deletes it with a 'poof')  
I just fake it using a semi-transparent cursor image.


So I'm afraid I don't know - plenty of apps can do it though (i.e.  
dragging off a toolbar item) so presumably some combination of  
settings should work. I need to solve this myself in one of my apps so  
if I figure it out I'll let you know.


G.


On 3 Jun 2008, at 9:36 am, Graham Cox wrote:

I forget the exact details, (if I get more time I'll look them up  
for you) but instead of passing NO to slideback, pass YES, then be  
smarter about what you return from the drag receiver. A drop outside  
the table is a valid target in your design, so you should say so -  
return something other than NSDragOperationNone. The sender then  
won't show the slideback because the receiver did something with the  
drag (even if it was just a deletion).



hth,

G.


On 3 Jun 2008, at 7:09 am, Tomas Franzén wrote:


Hi,

I'm trying to figure out the best way to implement a scenario where  
there's a table where the user can drag rows to reorder (the easy  
part) but also drop them outside of the table to remove items with  
a poof. The way we do it now is to use slideBack:NO and implement  
draggedImage:endedAt:operation: and checking for  
NSDragOperationNone and determining if the cursor was outside of  
the table view. And if so, do the poof. This sorta-kinda works, but  
has some downsides. The drag image never slides back. This is fine  
when there's a poof, but not when the drag was ended with  
NSDragOperationNone inside of the table. Also, this poofs if the  
user presses the escape key, since that also sends  
NSDragOperationNone, which is horrible.


This way just feels like a dirty hack. There must be a better way.  
How have you implemented it in your own apps?


Thanks!

Tomas Franzén
Lighthead Software
http://www.lightheadsw.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/graham.cox%40bigpond.com

This email sent to [EMAIL PROTECTED]


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/graham.cox%40bigpond.com

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Spotlight multiple results for file

2008-06-02 Thread Sherm Pendley
On Mon, Jun 2, 2008 at 5:28 PM, Hamish Allan <[EMAIL PROTECTED]> wrote:

> Have a look at the archives for [EMAIL PROTECTED] The
> short answer is sort of, but you have to create cache files for each
> atomic entity.

If I recall correctly, that's why Mail.app switched from the
traditional single-file mbox format to storing one message per file.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.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 [EMAIL PROTECTED]


Re: Core Data "entity required" error

2008-06-02 Thread Melissa J. Turner

*Checks the oracle bones ... *

Does the store configuration for your SQL store contain all the  
entities in your model? If not, you need to make sure that all the  
entities for objects you're trying to save into the store are in it.


+Melissa

On Jun 2, 2008, at 10:07, Hamish Allan wrote:


On Mon, Jun 2, 2008 at 3:21 PM, Chataka <[EMAIL PROTECTED]> wrote:


On the console, I just get


entity required


That's it. Just two words.
Nothing else I can include...


Ah, I see! Sorry, how frustrating.

Try setting a breakpoint on NSLog() (or fprintf(), or syslog()) to see
if you can get a stack trace on that message.

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Will programmers new to Cocoa benefit from a Cocoa Design Patterns Book ?

2008-06-02 Thread Seth Willits

On 3 Jun 2008, at 00:05, Erik Buck <[EMAIL PROTECTED]> wrote:

So, will programmers new to Cocoa benefit from a Cocoa Design  
Patterns Book ?  I think all programmers will benefit from  
understanding design patterns at some point whether they use Cocoa  
or not.  How soon a new programmer should tackle design patterns  
depends a lot on the programmer.


I've been using Cocoa for years, and I know I'm looking forward to it.  
$40 or so is well worth finding one particular sentence which triggers  
a thought that leads to better code design. Needless to say, I've  
preordered it. Now if only it would actually allow me access to the  
Rough Cut...   >.<




--
Seth Willits




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Apple Remote and exclusivity

2008-06-02 Thread I. Savant

On Jun 2, 2008, at 7:36 PM, Elan Feingold wrote:

From the lack of responses I'm guessing I posted this to the wrong  
list :-) Can anyone suggest a better list to post to?


  Patience. You posted this recently. If someone has an answer,  
they'll give it to you.


--
I.S.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Drag-to-poof and tables

2008-06-02 Thread Graham Cox
I forget the exact details, (if I get more time I'll look them up for  
you) but instead of passing NO to slideback, pass YES, then be smarter  
about what you return from the drag receiver. A drop outside the table  
is a valid target in your design, so you should say so - return  
something other than NSDragOperationNone. The sender then won't show  
the slideback because the receiver did something with the drag (even  
if it was just a deletion).



hth,

G.


On 3 Jun 2008, at 7:09 am, Tomas Franzén wrote:


Hi,

I'm trying to figure out the best way to implement a scenario where  
there's a table where the user can drag rows to reorder (the easy  
part) but also drop them outside of the table to remove items with a  
poof. The way we do it now is to use slideBack:NO and implement  
draggedImage:endedAt:operation: and checking for NSDragOperationNone  
and determining if the cursor was outside of the table view. And if  
so, do the poof. This sorta-kinda works, but has some downsides. The  
drag image never slides back. This is fine when there's a poof, but  
not when the drag was ended with NSDragOperationNone inside of the  
table. Also, this poofs if the user presses the escape key, since  
that also sends NSDragOperationNone, which is horrible.


This way just feels like a dirty hack. There must be a better way.  
How have you implemented it in your own apps?


Thanks!

Tomas Franzén
Lighthead Software
http://www.lightheadsw.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/graham.cox%40bigpond.com

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Apple Remote and exclusivity

2008-06-02 Thread Elan Feingold
From the lack of responses I'm guessing I posted this to the wrong  
list :-) Can anyone suggest a better list to post to?


Many thanks,

-elan

On Mon, Jun 2, at 9:44 AM, Elan Feingold wrote:


Hi,

The app I'm working on makes use of the Apple Remote; specifically,  
it runs a helper app (daemon) so that the app can be started with a  
press of the Apple Remote Menu button, and then passes key presses  
it receives to the app via UDP messages.


I'm seeing two issues:

1) Even though I open the device with kIOHIDOptionsTypeSeizeDevice,  
I'm seeing times where it seems to lose exclusivity. I can't pin it  
to any specific event (i.e. wake from sleep, etc.), but it  
definitely seems to lose it after a period of time (hours, days).  
After that hitting the Menu button brings up both the application  
*and* Front Row, which is not exactly optimal :-)


I read somewhere that if an application loses focus and then regains  
it, it should reopen the device to assure exclusivity. I'm not sure  
how this would work with a daemon that doesn't ever have focus in  
the application sense.


2) I'm seeing cases where key-presses on the Apple Remote are lost.  
It might be correlated with the actual application using a bit more  
CPU. I'm not sure if the process doing the Apple Remote reception  
needs to be run at a higher priority?


Any help you could offer would be much appreciated!

Thanks,

-elan
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Will programmers new to Cocoa benefit from a Cocoa Design Patterns Book ?

2008-06-02 Thread Ian Robinson

When is it published? Ian

__
Ian Robinson - Belfast - UK
Soapbox - 

On 3 Jun 2008, at 00:05, Erik Buck <[EMAIL PROTECTED]> wrote:

In answering some private email about the forthcoming "Cocoa Design  
Patterns" book, I made the following observations.



 Design patterns describe high quality practical solutions to  
recurring programming problems and can sometimes be quite abstract.   
Design patterns state how to solve problems and why some solutions  
are preferred over others.  There are programming examples of  
patterns, but it is assumed that the patterns will be adapted as  
necessary on a case by case basis.  In other words, Design Patterns  
are not tutorials.



 The right time to introduce design patterns depends on the learning  
style of the individual programmer.  Some programmers are  
uncomfortable until they can see the "big picture".  Design patterns  
help show the big picture and provide rationale.  Other programmers  
are frustrated by theory and abstract ideas until they have mastered  
the details of a specific implementation.  For specific details,  
tutorials and focused sample programs are more satisfying than  
design patterns.



 To use an analogy, design patterns for construction/architecture  
describe the rationale for having more than one external door – e.g. 
 for emergency egress.   Design patterns for construction/architectu 
re identify and contrast the different styles of architecture such a 
s Queen Ann Victorian or Prairie Style or Neo-Classical.  A design p 
atterns book for construction/architecture might provide a few sampl 
e floor plans to illustrate the application of a pattern, but you wo 
n't find a complete design for your specific house in the book.  Nor 
 will you find instructions for how to nail two boards together.



 Why Focus on Design Patterns?


 I wrote “Cocoa Design Patterns” to help satisfy your  
intellectual curiosity.  It’s easy to lose sight of the overall arch 
itecture and rationale of Cocoa. Many programmers comment that they  
feel lost in the multitude of classes, functions, and data structure 
s that Cocoa provides. They can’t see the forest because they‘re  
concentrating too much on individual trees. The patterns used in Coc 
oa provide a structure and organization that will help you find your 
 way. The patterns show how to reuse groups of cooperating classes e 
ven when the relationships between the classes are not fully explain 
ed in the documentation for individual classes.



 So, will programmers new to Cocoa benefit from a Cocoa Design  
Patterns Book ?  I think all programmers will benefit from  
understanding design patterns at some point whether they use Cocoa  
or not.  How soon a new programmer should tackle design patterns  
depends a lot on the programmer.



 Any programmer who is familiar with the famous Design Patterns book  
by the Gang of Four and enjoyed that book will enjoy "Cocoa Design  
Patterns".


___

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

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

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

This email sent to [EMAIL PROTECTED]

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: QCView loadCompositionFromFile

2008-06-02 Thread Marco Masser

I'm trying to load a composition into a QCView using the
loadCompositionFromFile.  I was obtaining the path from a  
NSOpenPanel but
loadCompositionFromFile was returning NO.  I tried passing in a hard  
coded
path as a parameter, getting the same result NO.I'm sure the  
paths are
right as I could open the compositions in the terminal with the 2  
paths.

Any ideas to what I am doing wrong?


Could you please post some code and maybe the path you're using?  
Something has to be wrong, otherwise you wouldn't get that error.
Also, when passing a path that works in the terminal, did you consider  
that any whitespaces are escaped in the terminal while they shouldn't  
be escaped in your code?


Cheers,

Marco
___

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

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

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

This email sent to [EMAIL PROTECTED]


Will programmers new to Cocoa benefit from a Cocoa Design Patterns Book ?

2008-06-02 Thread Erik Buck
In answering some private email about the forthcoming "Cocoa Design Patterns" 
book, I made the following observations.
   
   
  Design patterns describe high quality practical solutions to recurring 
programming problems and can sometimes be quite abstract.  Design patterns 
state how to solve problems and why some solutions are preferred over others.  
There are programming examples of patterns, but it is assumed that the patterns 
will be adapted as necessary on a case by case basis.  In other words, Design 
Patterns are not tutorials.
   
   
  The right time to introduce design patterns depends on the learning style of 
the individual programmer.  Some programmers are uncomfortable until they can 
see the "big picture".  Design patterns help show the big picture and provide 
rationale.  Other programmers are frustrated by theory and abstract ideas until 
they have mastered the details of a specific implementation.  For specific 
details, tutorials and focused sample programs are more satisfying than design 
patterns.
   
   
  To use an analogy, design patterns for construction/architecture describe the 
rationale for having more than one external door – e.g. for emergency egress.   
Design patterns for construction/architecture identify and contrast the 
different styles of architecture such as Queen Ann Victorian or Prairie Style 
or Neo-Classical.  A design patterns book for construction/architecture might 
provide a few sample floor plans to illustrate the application of a pattern, 
but you won't find a complete design for your specific house in the book.  Nor 
will you find instructions for how to nail two boards together.
   
   
  Why Focus on Design Patterns?
   
   
  I wrote “Cocoa Design Patterns” to help satisfy your intellectual curiosity.  
It’s easy to lose sight of the overall architecture and rationale of Cocoa. 
Many programmers comment that they feel lost in the multitude of classes, 
functions, and data structures that Cocoa provides. They can’t see the forest 
because they‘re concentrating too much on individual trees. The patterns used 
in Cocoa provide a structure and organization that will help you find your way. 
The patterns show how to reuse groups of cooperating classes even when the 
relationships between the classes are not fully explained in the documentation 
for individual classes.
   
   
  So, will programmers new to Cocoa benefit from a Cocoa Design Patterns Book ? 
 I think all programmers will benefit from understanding design patterns at 
some point whether they use Cocoa or not.  How soon a new programmer should 
tackle design patterns depends a lot on the programmer.
   
   
  Any programmer who is familiar with the famous Design Patterns book by the 
Gang of Four and enjoyed that book will enjoy "Cocoa Design Patterns".
   
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Key-Value pairs

2008-06-02 Thread I. Savant


On Jun 2, 2008, at 5:30 PM, john darnell wrote:

This is a discussion on theory and not a request for any practical  
help.

Please also be advised I am not trying to bash Cocoa or Objective-C; I
am simply curious why the designers of same built the language the way
they did.  Understanding theory can sometimes geometrically improve
performance.


  Ominous, but okay. :-)



 My question is, if this is such a necessary thing, why didn't the
designers simply design the compiler to auto-generate setter and  
getter

functions as per the requisite style in the first place?


  They did. In Objective-C 2.0, released with Leopard.

--
I.S.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Key-Value pairs

2008-06-02 Thread Mike Abdullah


On 2 Jun 2008, at 22:30, john darnell wrote:


Hello everyone:

This is a discussion on theory and not a request for any practical  
help.

Please also be advised I am not trying to bash Cocoa or Objective-C; I
am simply curious why the designers of same built the language the way
they did.  Understanding theory can sometimes geometrically improve
performance.

I just read Hillegass' chapter that introduces Key-Value coding.  To
refresh everyone's memory, key-value coding is the convention that  
says

for every object the programmer defines, setting up a setter function
and a getter function as so:

/*  Please note that I have really shortchanged the code so as not to
waste time or space with stuff we already know will be there.
   Please also note that Outlook capitalizes lines behind my back and
be generous...*/
NSString *myString;

-(NSString *) myString
  return myString;

- (void) setMyString:(NSString *) aString
  myString = aString;

Is considered a good idea and is also a convention that ensures that
such objects like NSArrayController can work with your code with a
minimum of additional code.  I am simplifying this horribly, I admit  
and
will humbly bow to correction and chastisement if I have mis-stated  
the

concept.

 My question is, if this is such a necessary thing, why didn't the
designers simply design the compiler to auto-generate setter and  
getter

functions as per the requisite style in the first place?


I would say this is because what you describe is a feature of ObjC,  
whilst KVC is a convention of Cocoa. ObjC precedes Cocoa and so it's  
not a standard practice the compiler is really aware of. However, with  
ObjC 2.0 we now more-or-less have support for this.


Plus, often you want to add a little more custom code to the accessor,  
but that's not all that good of a reason.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Key-Value pairs

2008-06-02 Thread Hamish Allan
On Mon, Jun 2, 2008 at 10:30 PM, john darnell
<[EMAIL PROTECTED]> wrote:

> I just read Hillegass' chapter that introduces Key-Value coding.

>  My question is, if this is such a necessary thing, why didn't the
> designers simply design the compiler to auto-generate setter and getter
> functions as per the requisite style in the first place?

I haven't read Hillegaas' latest book, but perhaps in a less
introductory chapter he will go on to talk about @synthesise, which
does exactly what you're looking for.

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Key-Value pairs

2008-06-02 Thread john darnell
Hello everyone:

This is a discussion on theory and not a request for any practical help.
Please also be advised I am not trying to bash Cocoa or Objective-C; I
am simply curious why the designers of same built the language the way
they did.  Understanding theory can sometimes geometrically improve
performance.

I just read Hillegass' chapter that introduces Key-Value coding.  To
refresh everyone's memory, key-value coding is the convention that says
for every object the programmer defines, setting up a setter function
and a getter function as so:

/*  Please note that I have really shortchanged the code so as not to
waste time or space with stuff we already know will be there.  
Please also note that Outlook capitalizes lines behind my back and
be generous...*/
NSString *myString;

-(NSString *) myString
   return myString;

- (void) setMyString:(NSString *) aString
   myString = aString;

Is considered a good idea and is also a convention that ensures that
such objects like NSArrayController can work with your code with a
minimum of additional code.  I am simplifying this horribly, I admit and
will humbly bow to correction and chastisement if I have mis-stated the
concept. 

  My question is, if this is such a necessary thing, why didn't the
designers simply design the compiler to auto-generate setter and getter
functions as per the requisite style in the first place?

Offhand I can think of one reason they might have not done so:
unintended conflicts.  Requiring the programmer to explicitly state
these functions makes sure that they run into conflicts up front and can
account for them.  

But couldn't this have been resolved (as is done in C++ when attempting
to indicate a pure virtual function) with an additional
label...something like this:

NSString *MyString = -1;  // add auto setter and getter functions

It might have saved some code on the programmer's part.

Just a thought for discussion; nothing further.

R, 
John A.M. Darnell 
Team Leader 
Walsworth Publishing Company 
Brookfield, MO 
John may also be reached at [EMAIL PROTECTED] 
  
Trivia Question:  In SciFi Channel's hit series, FARSCAPE, who played
the voice of Pilot?
Answer:  The voice of Pilot was played by Lani Tupu, the same actor who
played the villain-turned-refugee, Crais.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Spotlight multiple results for file

2008-06-02 Thread Hamish Allan
On Mon, Jun 2, 2008 at 10:26 PM, Dex Morgan <[EMAIL PROTECTED]> wrote:

> I've made a custom format used in a program of mine and I would to make a
> spotlight importer. I've looked at same examples and everything looks good;
> hovewer I've a question: is there a way to get multiple results item for a
> single file? My file contains lots of messages and I would to report
> messages items in results list instead of putting the simple file location.

Have a look at the archives for [EMAIL PROTECTED] The
short answer is sort of, but you have to create cache files for each
atomic entity.

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Spotlight multiple results for file

2008-06-02 Thread Dex Morgan

Hello guys,
I've made a custom format used in a program of mine and I would to  
make a spotlight importer. I've looked at same examples and everything  
looks good; hovewer I've a question: is there a way to get multiple  
results item for a single file? My file contains lots of messages and  
I would to report messages items in results list instead of putting  
the simple file location.

TIA
malcom
___

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

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

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

This email sent to [EMAIL PROTECTED]


Drag-to-poof and tables

2008-06-02 Thread Tomas Franzén

Hi,

I'm trying to figure out the best way to implement a scenario where  
there's a table where the user can drag rows to reorder (the easy  
part) but also drop them outside of the table to remove items with a  
poof. The way we do it now is to use slideBack:NO and implement  
draggedImage:endedAt:operation: and checking for NSDragOperationNone  
and determining if the cursor was outside of the table view. And if  
so, do the poof. This sorta-kinda works, but has some downsides. The  
drag image never slides back. This is fine when there's a poof, but  
not when the drag was ended with NSDragOperationNone inside of the  
table. Also, this poofs if the user presses the escape key, since that  
also sends NSDragOperationNone, which is horrible.


This way just feels like a dirty hack. There must be a better way. How  
have you implemented it in your own apps?


Thanks!

Tomas Franzén
Lighthead Software
http://www.lightheadsw.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 [EMAIL PROTECTED]


QCView loadCompositionFromFile

2008-06-02 Thread andrew

Hey,

I'm trying to load a composition into a QCView using the
loadCompositionFromFile.  I was obtaining the path from a NSOpenPanel but
loadCompositionFromFile was returning NO.  I tried passing in a hard coded
path as a parameter, getting the same result NO.I'm sure the paths are
right as I could open the compositions in the terminal with the 2 paths. 
Any ideas to what I am doing wrong?

Thanks.  

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Bill Bumgarner

On Jun 2, 2008, at 11:40 AM, mmalc crawford wrote:

On Jun 2, 2008, at 10:50 AM, Bill Bumgarner wrote:
If your window is sometimes disappearing under GC -- is sometimes  
being collected prior to when you think it should be -- that means  
that the collector doesn't believe that the window object is being  
used by your application.  To the collector, being visible doesn't  
count as "in use".
In GC, "in use" is defined entirely by whether or not you have a  
reference to an object.  A pointer to the object somewhere in  
scanned memory (of which, any Objective-C object's data will be  
"scanned memory").



I wonder if this might be misleading.
Simply because you have a (strong) reference to an object does not  
*necessarily* mean that it won't be treated as garbage.


Several objects may have strong references to each other (creating  
what in a managed memory environment would be a retain cycle), but  
if none of them is a root object, and none of them can be reached  
via strong references from a root object, then they will all be  
treated as garbage -- see the "F-G-H" example at .


You are absolutely correct.   The collector will happily collect  
strongly referenced subgraphs of objects when the only strong  
references are within the subgraph.


You need to have a rooted reference to an object to ensure that it is  
not collected.  That is, you need to refer to an object -- directly or  
indirectly through a chain of strong references -- via a strong  
reference from some object that the collector will not collect.


Under Cocoa, that typically means NSApplication or some global  
variable.  For example, NSApplication has a delegate [strong reference  
under GC] and your delegate could have a connection to the window  
[strong reference].


b.bum

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Francis Perea

Hi all

For my part just to say that I've learned a lot after the beginning of  
this post.


The application is ready now, but I'll try to read and learn a lot more.

And as Paul says I'm having lots of fun with Cocoa :-)

Thanks all for your help and time.

Att.

Francis Perea

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Leopard (10.5+): Any Upper-Level (Cocoa) access to Mail?

2008-06-02 Thread has


[EMAIL PROTECTED] wrote:

I'm searching for a Cocoa/ObjC routine to access/check Mail;  
specifically #read & #unread mail messages.


Use AppleScript or one of the ObjC-Apple event bridges to control  
Mail. For example, using objc-appscript:



#import "MLGlue/MLGlue.h"

// To generate Mail glue: osaglue -o MLGlue -p ML Mail


void CountMessagesInMailbox(MLReference *box) {
int totalCount, unreadCount;
NSString *name;

totalCount = box messages] count] send] intValue];
unreadCount = [[[box unreadCount] getItem] intValue];
name = [[box name] getItem];
printf("Mailbox %s contains %i read and %i unread messages.\n",
[name UTF8String], totalCount - unreadCount, 
unreadCount);
}


int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int i;

	MLApplication *mail = [[MLApplication alloc] initWithBundleID:  
@"com.apple.mail"];


printf("Standard mailboxes:\n");
CountMessagesInMailbox([mail draftsMailbox]);
CountMessagesInMailbox([mail inbox]);
CountMessagesInMailbox([mail outbox]);
CountMessagesInMailbox([mail sentMailbox]);

printf("\nUser-defined mailboxes...\n");
int boxCount = mail mailboxes] count] send] intValue];
	for (i = 1; i <= boxCount; i++) { // note: application references are  
1-indexed

CountMessagesInMailbox([[mail mailboxes] at: i]);
}
[mail release];
[pool drain];
return 0;
}


Regardless of what IPC bridge you use, I'd suggest that questions on  
how to perform specific operations on Mail are best directed to the  
AppleScript-users mailing list  as that's where most experienced Mail scripters can be found.  
Obviously, any answers you get will be phrased in AppleScript, so  
you'll want to learn the AppleScript language in order to translate it  
back to ObjC. I'd suggest a copy of Matt Neuburg's "AppleScript: The  
Definitive Guide" as a programmer-friendly introduction to the beast.  
I'm also working on ObjC syntax support in ASTranslate (a very handy  
tool that converts AppleScript commands to their appscript  
equivalents) which I hope to have done fairly soon.


HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.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 [EMAIL PROTECTED]


Re: NewBie: Trying to load a html file bundled with app...

2008-06-02 Thread I. Savant
> Is their a way I can modify this to load a htm file that is included in the
> app bundle:

  Yes. Get the main bundle for the application and ask it for the path
to the resource (given its name and type), then create a URL from
that. The rest you know ...See NSBundle for the details.

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Categories (was Re: Cocoa et al as HCI usability problem)

2008-06-02 Thread Georg Tuparev


On May 20, 2008, at 10:46 AM, Bill Bumgarner wrote:


On May 20, 2008, at 1:07 AM, Peter Duniho wrote:
But personally, it makes me nervous to have a language that allows  
the implementation of a class to change according to other code not  
related to the class.  It's one thing if you're just adding a  
method that you want to use somewhere else.  But in Objective-C you  
can also add a method that overrides a base class method, or would  
not normally exist in the class but which has meaning to some other  
code that might check for it.


I have been programming in Obj-C against the Cocoa APIs (and their  
predecessors) since 1989-- with quite a few other random APIs and  
environments over the years, too-- and I can unequivocally say that  
the ability to override existing functionality in categories is just  
damned dangerous.


When I found out about C#'s "extension methods", I wrote about it  
here:


http://www.friday.com/bbum/2007/01/31/c-30-now-with-categories/

And then followed up with a second post here:

http://www.friday.com/bbum/2007/02/02/c-30-categories-followup/

In any case, you are absolutely correct that categories are  
dangerous and the above includes an anecdote documenting a  
particularly egregious related problem.  Most extremely powerful  
tools are.  Sometimes one must question whether or not said power is  
gratuitous or truly useful and this particular feature falls in  
"gratuitous".


Reminds me of this classic story:

http://artlung.com/smorgasborg/C_R_Y_P_T_O_N_O_M_I_C_O_N.shtml

In particular, search for "hole hawg".

Given that the Cocoa development community has obviously expanded  
quite substantially in recent months and many of you are coming to  
Cocoa with deep experience in other environments and languages,  
please file bugs / feature requests / feedback through Apple's  
bugreporter system (http://bugreport.apple.com/).


thanks,
b.bum


I am late with my comment - sorry.

I studied in the oldest german university - Heidelberg. During the  
long history of the town there were three or four major fires that  
burned almost all houses. Still, about 1000 years after the first of  
these fires the parents were teaching their kids how to handle the  
matches. Why? Because people learned to take calculated risks - if the  
potential benefits are bigger then the dangers.


Granted, compared with you I am a real greenhorn - I start programming  
my NeXT pizza box in 1991. Nevertheless, I can say that the ability to  
override existing functionality in categories saved me a lot of coding  
- although, or perhaps because, it is damned dangerous, and therefore  
powerful. And I do not know a developer with several years of Cocoa- 
related coding under the belt who did not used this at least to fix  
bugs created by someone else. And this is not the only application...


cheers

Georg Tuparev
Tuparev Technologies
Klipper 13
1186 VR Amstelveen
The Netherlands
Mobile: +31-6-55798196

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSPredicate: To be, or not to be

2008-06-02 Thread stephen joseph butler
On Mon, Jun 2, 2008 at 11:08 AM, Gerriet M. Denkmann
<[EMAIL PROTECTED]> wrote:
> Constucting the format properly (copying your suggestion):
> NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K contains %@",
> kMDItemTextContent, @"To be, or not to be"];

I'm sorry. I forget that the Spotlight predicate strings are slightly
different from the regular ones. This works for me:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K LIKE
%@", kMDItemTextContent, @"To be, or not to be"];
___

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

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

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

This email sent to [EMAIL PROTECTED]


NewBie: Trying to load a html file bundled with app...

2008-06-02 Thread Mark Bateman

Hi,

I'm currently using this code line to load a http web page:

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL  
URLWithString:@"http://www.abc123.com";]]];


Is their a way I can modify this to load a htm file that is included  
in the app bundle:


Thanks,

Mark.

___

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

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

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

This email sent to [EMAIL PROTECTED]


My windows don't cascade

2008-06-02 Thread Stefan Haller
I have an NSDocument-based application that is still pretty close to the
Xcode template for "Cocoa Document-based application"; i.e. I subclass
NSDocument but not NSWindowController, and I implement -windowNibName
but not -makeWindowControllers.

When I open a new document, it doesn't cascade; it opens with the same
frame as the previous one.

Setting a breakpoint at -[NSWindow cascadeTopLeftFromPoint:] shows that
it is indeed called, from this stack:

  #0  0x94f5d6a4 in -[NSWindow cascadeTopLeftFromPoint:] ()
  #1  0x94f415e6 in -[NSWindowController _windowDidLoad] ()
  #2  0x94edf476 in -[NSWindowController window] ()
  #3  0x94edf376 in -[NSWindowController showWindow:] ()
  #4  0x94edf2b9 in -[NSDocument showWindows] ()
  #5  0x94edd580 in -[NSDocumentController 
openUntitledDocumentAndDisplay:error:] ()

however, the argument to cascadeTopLeftFromPoint appears to be always
(0,0).  Any idea what could cause this?

Thanks,
   Stefan


-- 
Stefan Haller
Ableton
http://www.ableton.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 [EMAIL PROTECTED]


Re: many-to-many relationships and retain cycles

2008-06-02 Thread Todd Ransom
Thanks guys. I decided to just use CFArrayCreateMutable in my accessor  
instead of creating a subclass and it's working beautifully.


Todd Ransom
Return Self Software
http://returnself.com



On Jun 2, 2008, at 1:01 PM, Jens Alfke wrote:



On 2 Jun '08, at 9:12 AM, Todd Ransom wrote:

An actor has a scenesForActor mutableArray and a scene has an  
actorsForScene mutableArray. This all works great except that it  
creates retain cycles and neither actor nor scene objects are ever  
released if they have a relationship.


Yeah, this is a common design problem that comes up with ref-counted  
object models.[1]


In general, if you don't have some sort of weak reference mechanism,  
the solution is to explicitly tell an object to clean itself up when  
it's being removed. In your app there is probably some kind of top- 
level "Stage" or "Play" object that contains the scenes and actors;  
in which case it probably has a "removeScene:" or "removeActor:"  
method. That method could call a "removedFromStage" method on the  
object being removed, which in turn would clear out its references  
to other objects.


In general, if a subgraph of your object graph can form a cycle, you  
detect when that subgraph will be disconnected, and tell its objects  
to break all the links between themselves that could form a cycle.  
(In Smalltalk-80 this was a common enough task that there was a  
standard method defined on Object to do this, that subclasses would  
override if they had loopy references.)


It seems that what I need is a non-retaining array. I googled  
around a bit and was surprised that I could not find an existing  
implementation. It looks like I can create one by subclassing  
NSMutableArray, overriding the primitive methods, and using a  
CFArray as the backing store with NULL callbacks to avoid any kind  
of retain or release when objects are added or removed.


It's even easier than that, thanks to CF/NS bridging. You can just  
use the CFArray API to create an array with no-op retain/release  
callbacks, and then cast the CFArrayRef to NSArray* and use it as an  
NSArray.


—Jens

[1] It was a big issue in Smalltalk-80, especially because the  
runtime could only handle 32,768 objects at once(!) and, worse, the  
runtime was persistent: the way you saved was to snapshot the entire  
object space to disk. So "lost" groups of cyclic objects would build  
up over time, until you ran out of free object space. There was a  
tool that did a real mark-and-sweep collection and would get rid of  
them, but you had to let it run for a few hours. These were not fast  
machines by today's standards...


___

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

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

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

This email sent to [EMAIL PROTECTED]


Apple Remote and exclusivity

2008-06-02 Thread Elan Feingold

Hi,

The app I'm working on makes use of the Apple Remote; specifically, it  
runs a helper app (daemon) so that the app can be started with a press  
of the Apple Remote Menu button, and then passes key presses it  
receives to the app via UDP messages.


I'm seeing two issues:

1) Even though I open the device with kIOHIDOptionsTypeSeizeDevice,  
I'm seeing times where it seems to lose exclusivity. I can't pin it to  
any specific event (i.e. wake from sleep, etc.), but it definitely  
seems to lose it after a period of time (hours, days). After that  
hitting the Menu button brings up both the application *and* Front  
Row, which is not exactly optimal :-)


I read somewhere that if an application loses focus and then regains  
it, it should reopen the device to assure exclusivity. I'm not sure  
how this would work with a daemon that doesn't ever have focus in the  
application sense.


2) I'm seeing cases where key-presses on the Apple Remote are lost. It  
might be correlated with the actual application using a bit more CPU.  
I'm not sure if the process doing the Apple Remote reception needs to  
be run at a higher priority?


Any help you could offer would be much appreciated!

Thanks,

-elan
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSXMLDocument and relative DTD?

2008-06-02 Thread Alexander von Below

Thanks, I guess I will file it then.

I am not the most knowledgeable guy about tcpdump, but at least -  
validateWithError: does not generate any packets to or from the host  
(I can see the packets on a non-validating init, though)


Unless there is any more input, I will consider it a bug

Thanks for your input

Alex

Am 02.06.2008 um 16:42 schrieb Jens Alfke:



On 2 Jun '08, at 7:02 AM, Alexander von Below wrote:

When validating the document, either on initWithURL or explicitly,  
validation fails with
Error Domain=NSXMLParserErrorDomain Code=1549 UserInfo=0x14845c70  
"Line 2: failed to load external entity "foo/bar/faz.dtd"


This sounds like it could be a bug in NSXML. One possible experiment  
is to run tcpdump or tcpflow, and see what HTTP traffic the app  
generates while it's validating the XML. Does it even attempt to  
load any HTTP resources? Of course that doesn't suggest any  
workarounds, but it gives you more info to put in your bug report...


—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 [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Paul Sargent


On 2 Jun 2008, at 12:16, Francis Perea wrote:


Hi Paul.

I've disabled GC as Michael and you propose and the application it's  
working right now.


I've had to "retain" both properties of the model class (generator)  
and the instance of that class in the controller class  
(generatorcontroller).


There's a few simple rules that specify when you have to retain  
something, and when you don't. The document Graham gave you goes  
through them.


I don't want to repeat them here because I'd probably get it slightly  
wrong and people love to argue over the fine detail. We found that out  
in another thread recently.


I've also had to implement both dealloc method of both classes so  
that all retained objects get released.


Is that right?


Yes, that's exactly the reason for dealloc.

And a final question, I would like to know if my application frees  
up all memory it uses after stopping and it has no memory leaks; I  
think Instruments is the utility Apple provides for that matter,  
isn't it?


An application will automatically free everything when it quits.

If you want a way of seeing if you've released everything you  
allocated, then it's worth looking back in the archive a couple of  
weeks, as there was a thread talking about how to do it. I think the  
conclusion was "put a sleep statement before the app quits". That way  
you have some time to see the final state.


In that case I should read Instruments help so that I know how to  
get that information, cos I've tried to use it but it doesn't seem  
very friendly to me :-(


Instruments is one tool that can do it. Also there's the 'leaks'  
command line tool, and ObjectAlloc (which appears to be an Instruments  
template now).


Don't worry too much about getting rid of all memory leaks while  
you're learning. There's lot's of stuff to learn, and as you get more  
experience you'll start to see the patterns. If you get problems with  
over releasing something (which will often cause you to crash), search  
for NSZombiesEnabled in the docs.


Have fun.
___

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

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

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

This email sent to [EMAIL PROTECTED]


[Moderator] Re: Leopard (10.5+): Any Upper-Level (Cocoa) access to Mail?

2008-06-02 Thread Scott Anguish
This question has been asked three or four times in the last week. A  
search of the list archives would have determined how to do that.


In addition, if you're NDA aware, you would know that asking the  
question here in that context is violating that NDA.


Please do some search the archives before posting a question on the  
list, and don't violate your NDA.


scott
[moderator]


On Jun 2, 2008, at 11:45 AM, [EMAIL PROTECTED] wrote:

I would like to talk to Mail.app / ditto for (NDA - aware) iPhone  
platform.

Ric.

On 06/02/2008 08:53 Michael Watson wrote ..
Are you trying to talk to Mail.app, or are you looking for a  
generic e-

mail framework?


--
m-s

On 02 Jun, 2008, at 11:34, [EMAIL PROTECTED] wrote:


I'm searching for a Cocoa/ObjC routine to access/check Mail;
specifically #read & #unread mail messages.
Is there such a routine or need I go do a BSD Mail access?

So far, I've found the NSMailDelivery.h within the  
message.framework.

But much of the code appears to be deprecated for OS 5 & beyond.

Regards,
Ric.
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/mikey-san
%40bungie.org

This email sent to [EMAIL PROTECTED]

___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread mmalc crawford


On Jun 2, 2008, at 10:50 AM, Bill Bumgarner wrote:

If your window is sometimes disappearing under GC -- is sometimes  
being collected prior to when you think it should be -- that means  
that the collector doesn't believe that the window object is being  
used by your application.  To the collector, being visible doesn't  
count as "in use".
In GC, "in use" is defined entirely by whether or not you have a  
reference to an object.  A pointer to the object somewhere in  
scanned memory (of which, any Objective-C object's data will be  
"scanned memory").



I wonder if this might be misleading.
Simply because you have a (strong) reference to an object does not  
*necessarily* mean that it won't be treated as garbage.


Several objects may have strong references to each other (creating  
what in a managed memory environment would be a retain cycle), but if  
none of them is a root object, and none of them can be reached via  
strong references from a root object, then they will all be treated as  
garbage -- see the "F-G-H" example at .


mmalc

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Leopard (10.5+): Any Upper-Level (Cocoa) access to Mail?

2008-06-02 Thread Paul Sargent


On 2 Jun 2008, at 16:45, [EMAIL PROTECTED] wrote:

I would like to talk to Mail.app / ditto for (NDA - aware) iPhone  
platform.

Ric.


You're probably looking at using the scripting bridge/AppleScript to  
talk to Mail.app.

I know nothing about it, but it's where I'd start looking.

Obviously you're aware that nobody can tell you how to do it on the  
iPhone.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Paul Sargent


On 2 Jun 2008, at 18:50, Bill Bumgarner wrote:

While learning the retain/release paradigm is certainly useful, it  
is considerably more complex than GC.  It is also unnecessary while  
learning Cocoa.   Specifically, GC is intended to be a production  
quality solution that you can use in your Cocoa applications,  
without exception.   In Leopard, there have been a handful of bugs  
and they have been addressed through software updates -- not  
surprising given the rather sweeping and intrusive set of changes  
needed to support GC.   And GC will get better / faster in future  
releases.


I agree with nearly everything you've said, except the (second half of  
the) first statement.


I wouldn't say retain/release is more complex than GC. I'd say using  
retain/release in a medium->large size project is more complex than  
using GC, but the base concept is a simpler one. Whilst learning,  
getting retain/release wrong tends to be less confusing than getting  
GC wrong. GC will make things disappear at random times, whereas  
retain/release will tend to be deterministic in behaviour.


... and it's good grounding. Learning some of the old styles of  
writing Cocoa apps (e.g. accessor methods before properties, custom  
controllers before bindings) makes learning the newer styles that much  
easier. You don't need to write big projects without the nice new  
technologies. Just do a few test apps with them and understand why you  
want them.


That's how all the senior programmers on this list learnt (although  
they didn't have a choice). Why do we think that people following can  
jump a few steps?


That's my opinion anyway. (Feel free to disagree, but we probably  
don't need another big thread about it)

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: core data: awakeFromFetch, awakeFromInsert, didTurnIntoFault

2008-06-02 Thread Hamish Allan
On Mon, Jun 2, 2008 at 4:34 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> however, if i then redo the action, neither awakeFromFetch nor
> awakeFromInsert is called, and thus i'm left without my observing in place.

I had the same problem recently, and wrote a workaround for it:

http://www.cocoabuilder.com/archive/message/cocoa/2008/5/4/205828

It relies on a private API, but hopefully the bug will be fixed before
the API changes. I forgot to file a bug at the time, but have just
done so (rdar://problem/5979409/) -- please do the same if you'd like
to see it fixed sooner.

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: PDFDocuments and CGPDFDocuments

2008-06-02 Thread John Calhoun

On May 31, 2008, at 3:43 PM, Kevin Ross wrote:
My ultimate goal is an application that is like a printer's PDF  
workflow, that will allow page manipulations like resizing /  
cropping / adding bleed information, and imposing multiple pages  
onto one with crop marks and the like.  After researching it seems  
like some of the functions (imposition with crop marks, page  
cropping/scaling with/without preserving aspects, etc) are best  
suited for quartz, while the rest (page reordering/inserting,  
rotating, etc) have Cocoa APIs.



Well, FWIW, Apple's Preview is cropping in PDF Kit ... basically you  
call -[setBoundsForBox:] on the PDFPage in question.


Additionally you should probably look into subclassing PDFPage.   
Within that domain you can overlay crop marks, apply additional  
transforms, etc.


See PDFCalendar sample code for a PDFPage subclassing example.

John Calhoun—___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Bill Bumgarner

On Jun 2, 2008, at 10:31 AM, Michael Vannorsdel wrote:

On Jun 2, 2008, at 5:24 AM, Francis Perea wrote:


Hi Graham, thanks for your reply.

I didn't know I could set any memory setting trough Interface  
Builder!


After your question I looked into and I've seen that it states as  
Beffered.


I've tried to use the Retained option, thinking that this way I  
shouldn't use the retain message, but with Retained the windows  
appears but doesn't accept any interaction.


I'd take a deep look into de Memory Management doc you suggest.


While learning the retain/release paradigm is certainly useful, it is  
considerably more complex than GC.  It is also unnecessary while  
learning Cocoa.   Specifically, GC is intended to be a production  
quality solution that you can use in your Cocoa applications, without  
exception.   In Leopard, there have been a handful of bugs and they  
have been addressed through software updates -- not surprising given  
the rather sweeping and intrusive set of changes needed to support  
GC.   And GC will get better / faster in future releases.


If your window is sometimes disappearing under GC -- is sometimes  
being collected prior to when you think it should be -- that means  
that the collector doesn't believe that the window object is being  
used by your application.  To the collector, being visible doesn't  
count as "in use".


In GC, "in use" is defined entirely by whether or not you have a  
reference to an object.  A pointer to the object somewhere in scanned  
memory (of which, any Objective-C object's data will be "scanned  
memory").


So, when your NIB is loaded, who hangs on to a reference to the  
window.  It doesn't sound like anything does.   The easiest way to fix  
this would be to create an outlet in your file's owner and connect  
that outlet as a reference to the window.  Now, as long as the file's  
owner has a strong reference to *it*, then your window sticks around.


Note that in document based applications, the NSDocument  
infrastructure takes care of keeping things referenced that need to  
stick around.


This sounds like you have a non-document based application and your  
main window is disappearing out from under you.  From the documentation:


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


b.bum___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Michael Vannorsdel
The retained option for windows in IB applies to the window's back  
buffer settings.  Retained means it only buffers sections offscreen  
and onscreen drawing is done directly instead of to a back buffer  
first.  Not related to the window's retain count.



On Jun 2, 2008, at 5:24 AM, Francis Perea wrote:


Hi Graham, thanks for your reply.

I didn't know I could set any memory setting trough Interface Builder!

After your question I looked into and I've seen that it states as  
Beffered.


I've tried to use the Retained option, thinking that this way I  
shouldn't use the retain message, but with Retained the windows  
appears but doesn't accept any interaction.


I'd take a deep look into de Memory Management doc you suggest.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: many-to-many relationships and retain cycles

2008-06-02 Thread j o a r


On Jun 2, 2008, at 10:04 AM, Jens Alfke wrote:

If you're only targeting Leopard or later, you might want to take a  
look at "NSPointerArray".


That is So. Awesome. I've been using Leopard for like two years now,  
and I'd never noticed this class before. Thanks for the tip!



It is pretty awesome. It was introduced together with the new  
NSMapTable and NSHashTable classes [*], primarily to support using  
Cocoa together with Garbage Collection.


j o a r


[*] Not to be confused with the older C-API with the same name

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSColorWell and alpha

2008-06-02 Thread Sean McBride
Also note NSColor's setIgnoresAlpha:, especially the last sentence.

"If the application doesn't support alpha, no opacity slider is
displayed in the color panel, and colors dragged in or pasted have their
alpha values set to 1.0. Applications that need to import alpha can
invoke this method with flag set to NO and explicitly make colors opaque
in cases where it matters to them. Note that calling this with a value
of YES overrides any value set with the NSColorPanel method setShowsAlpha:."


On 6/1/08 9:33 AM, Ken Ferry said:

>This is controlled by -[NSColorPanel setShowsAlpha:].
>
>Try calling [[NSColorPanel sharedColorPanel] setShowsAlpha:YES].
>
>-Ken
>
>On Sun, Jun 1, 2008 at 9:23 AM, Mike <[EMAIL PROTECTED]> wrote:
>> I have NSColorWell on my form bind to NSColor property in my
>> Controller-object.
>> In IB there is an alpha-slider available in  that colorwell to modify color
>> opacity value but during runtime there isn't such.
>> Is that bydesign or am I missing something?

--

Sean McBride, B. Eng [EMAIL PROTECTED]
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 [EMAIL PROTECTED]


Re: Converting string to double: NSString or NSScanner

2008-06-02 Thread Sean McBride
On 5/31/08 10:35 PM, Michael Vannorsdel said:

>Basically NSString's floatValue and doubleValue methods only work when
>the numbers use the US style dot separator (as opposed to other locale
>separators such as a comma).  If your NSString might contain non-US
>separators (or other formatting differences) you'll have to use
>NSScanner to do a localized scan of the NSString to extract the
>correct number.  If you tried to use NSString's doubleValue on
>something like "12,34" you would get 12.000.

NSNumberFormatter would be another option.

--

Sean McBride, B. Eng [EMAIL PROTECTED]
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 [EMAIL PROTECTED]


Re: Core Data "entity required" error

2008-06-02 Thread Hamish Allan
On Mon, Jun 2, 2008 at 3:21 PM, Chataka <[EMAIL PROTECTED]> wrote:

> On the console, I just get
>
>> entity required
>
> That's it. Just two words.
> Nothing else I can include...

Ah, I see! Sorry, how frustrating.

Try setting a breakpoint on NSLog() (or fprintf(), or syslog()) to see
if you can get a stack trace on that message.

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data "entity required" error

2008-06-02 Thread Quincey Morris


On Jun 2, 2008, at 07:21, Chataka wrote:


On the console, I just get

> entity required

That's it. Just two words.
Nothing else I can include...


Typically, frameworks errors are NSLog'ed, so they will at least  
include the application name and process id.


So, you haven't established that this is a Core Data error. In fact,  
it looks like an error message written to stderr from:


-- your own code, OR

-- a C library

The next step would be to try to use the debugger to find the exact  
point in your code where the error occurs.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: many-to-many relationships and retain cycles

2008-06-02 Thread Jens Alfke


On 2 Jun '08, at 9:32 AM, j o a r wrote:

If you're only targeting Leopard or later, you might want to take a  
look at "NSPointerArray".


That is So. Awesome. I've been using Leopard for like two years now,  
and I'd never noticed this class before. Thanks for the tip!


An array you can store nil pointers in! Imagine that!
*swoons onto a divan*

—Jens

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 [EMAIL PROTECTED]

Re: many-to-many relationships and retain cycles

2008-06-02 Thread Jens Alfke


On 2 Jun '08, at 9:12 AM, Todd Ransom wrote:

An actor has a scenesForActor mutableArray and a scene has an  
actorsForScene mutableArray. This all works great except that it  
creates retain cycles and neither actor nor scene objects are ever  
released if they have a relationship.


Yeah, this is a common design problem that comes up with ref-counted  
object models.[1]


In general, if you don't have some sort of weak reference mechanism,  
the solution is to explicitly tell an object to clean itself up when  
it's being removed. In your app there is probably some kind of top- 
level "Stage" or "Play" object that contains the scenes and actors; in  
which case it probably has a "removeScene:" or "removeActor:" method.  
That method could call a "removedFromStage" method on the object being  
removed, which in turn would clear out its references to other objects.


In general, if a subgraph of your object graph can form a cycle, you  
detect when that subgraph will be disconnected, and tell its objects  
to break all the links between themselves that could form a cycle. (In  
Smalltalk-80 this was a common enough task that there was a standard  
method defined on Object to do this, that subclasses would override if  
they had loopy references.)


It seems that what I need is a non-retaining array. I googled around  
a bit and was surprised that I could not find an existing  
implementation. It looks like I can create one by subclassing  
NSMutableArray, overriding the primitive methods, and using a  
CFArray as the backing store with NULL callbacks to avoid any kind  
of retain or release when objects are added or removed.


It's even easier than that, thanks to CF/NS bridging. You can just use  
the CFArray API to create an array with no-op retain/release  
callbacks, and then cast the CFArrayRef to NSArray* and use it as an  
NSArray.


—Jens

[1] It was a big issue in Smalltalk-80, especially because the runtime  
could only handle 32,768 objects at once(!) and, worse, the runtime  
was persistent: the way you saved was to snapshot the entire object  
space to disk. So "lost" groups of cyclic objects would build up over  
time, until you ran out of free object space. There was a tool that  
did a real mark-and-sweep collection and would get rid of them, but  
you had to let it run for a few hours. These were not fast machines by  
today's standards...

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 [EMAIL PROTECTED]

Re: Get Value from NSArrayController Binding

2008-06-02 Thread Kyle Sluder
On Mon, Jun 2, 2008 at 12:08 PM, Christian Isaacs
<[EMAIL PROTECTED]> wrote:
> 1)  How do I get the title value from my Events NSArrayController Object?
>  I've tried [eventTableView valueForKey:@"Events.arrangedObjects.title"] and
> different variations of it.

There are a few problem here.

1) You're asking the wrong object.  Why are you sending messages to
the table view to get things from the array controller?
2) The name of an object in the NIB is absolutely and totally
meaningless.  It's just a label for you when you use IB.  The only way
to access an object inside a NIB is to wire it up to an outlet that
you can somehow reach from the code in question.  So your attempts to
use a keypath to get at the array controller are misguided.
3) You don't understand how NSTableColumns use their cells.  You
provide an NSCell to the table column.  The column reuses that cell
for every row by calling -setObjectValue: with the proper object for
the row and then -drawWithFrame:inView:.  You might want to override
-setObjectValue: to invoke -setTitle: with the string you wish to
display.

HTH,
--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 [EMAIL PROTECTED]


NSPersistentDocument's metadata APIs, when can I set my metadata before saving?

2008-06-02 Thread Sean McBride
Hi all,

I am trying to make use of NSPersistentDocument's metadata APIs.  I'm
having trouble with the 'when' more than the 'how'.

Which method of the saving process should I override to call
setMetadata:forPersistentStoreWithURL:error:?

All the metadata APIs want the NSURL of the store, which seems to be a
problem when a document is saved the first time.

 says: "When a document is saved, Core
Data calls the NSPersistentDocument method
writeToURL:ofType:forSaveOperation:originalContentsURL:error:. You can
override this method to add metadata to the new store before it is
saved."  The sample overrides the method and first does:

 if ([self fileURL] != nil)
   [self setMetadataForStoreAtURL:[self fileURL]];

but 'fileURL' returns nil when a document is being saved for the first
time.  If I try using the URL passed in writeToURL I get the exception
"*** -metadataForPersistentStoreWithURL:error: cannot be sent to an
abstract object of class NSPersistentStore: Create a concrete instance!"

Thanks,

--

Sean McBride, B. Eng [EMAIL PROTECTED]
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 [EMAIL PROTECTED]


Re: many-to-many relationships and retain cycles

2008-06-02 Thread Michael Vannorsdel
I've never tried it personally, but you might make a CFMutableArray  
with NULL callbacks and then cast it to an NSMutableArray since  
they're bridged types.



On Jun 2, 2008, at 10:36 AM, Todd Ransom wrote:

Unfortunately I need to target Tiger also. Thanks for the info,  
though, this will be useful to know in a year or so. ;)


Todd Ransom
Return Self Software
http://returnself.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 [EMAIL PROTECTED]


Re: many-to-many relationships and retain cycles

2008-06-02 Thread Todd Ransom
Unfortunately I need to target Tiger also. Thanks for the info,  
though, this will be useful to know in a year or so. ;)


Todd Ransom
Return Self Software
http://returnself.com



On Jun 2, 2008, at 12:32 PM, j o a r wrote:



On Jun 2, 2008, at 9:12 AM, Todd Ransom wrote:

It seems that what I need is a non-retaining array. I googled  
around a bit and was surprised that I could not find an existing  
implementation. It looks like I can create one by subclassing  
NSMutableArray, overriding the primitive methods, and using a  
CFArray as the backing store with NULL callbacks to avoid any kind  
of retain or release when objects are added or removed. Still, I  
thought I would ask around and see if anyone else has done this  
before I embark on trying to subclass a class cluster.


Has anyone out there created a non-retaining array class or come up  
with another solution to this problem? Or is there anything in  
particular I should watch out for when subclassing NSMutableArray?



If you're only targeting Leopard or later, you might want to take a  
look at "NSPointerArray".


j o a r




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: many-to-many relationships and retain cycles

2008-06-02 Thread j o a r


On Jun 2, 2008, at 9:12 AM, Todd Ransom wrote:

It seems that what I need is a non-retaining array. I googled around  
a bit and was surprised that I could not find an existing  
implementation. It looks like I can create one by subclassing  
NSMutableArray, overriding the primitive methods, and using a  
CFArray as the backing store with NULL callbacks to avoid any kind  
of retain or release when objects are added or removed. Still, I  
thought I would ask around and see if anyone else has done this  
before I embark on trying to subclass a class cluster.


Has anyone out there created a non-retaining array class or come up  
with another solution to this problem? Or is there anything in  
particular I should watch out for when subclassing NSMutableArray?



If you're only targeting Leopard or later, you might want to take a  
look at "NSPointerArray".


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSPredicate: To be, or not to be

2008-06-02 Thread Gerriet M. Denkmann


On 2 Jun 2008, at 16:52, [EMAIL PROTECTED] wrote:


On Sun, Jun 1, 2008 at 9:10 PM, Gerriet M. Denkmann
<[EMAIL PROTECTED]> wrote:

Following your suggestion, I changed my predicateFormat to:
@"%@ contains kMDItemTextContent" which translates into:
 and behaves more or  
less

exactly like LIKE.

So again: how to search kMDItemTextContent for a string containing  
spaces?

(10.4.11).


This came up in the last question you asked. You're not constructing
your formats properly.

[NSPredicate predicateWithFormat:@"%K contains %@",
kMDItemTextContent, @"To be, or not to be"]


Constucting the format properly (copying your suggestion):
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K  
contains %@", kMDItemTextContent, @"To be, or not to be"];


results in:
[...] Exception raised during posting of notification.  Ignored.   
exception: NSComparisonPredicate with left expression which is not  
NSKeyPathExpressionType given to NSMetadataQuery ("To be, or not to  
be" IN kMDItemTextContent)


So: what am I doing wrong?

Kind regards

Gerriet.

___

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

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

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

This email sent to [EMAIL PROTECTED]


many-to-many relationships and retain cycles

2008-06-02 Thread Todd Ransom
I have an application that allows users to create relationships  
between certain objects. For instance, there are scene objects and  
actor objects (like in a movie). The user can add multiple actors to a  
scene and an actor can participate in multiple scenes. A classic many- 
to-many relationship. This is implemented using NSMutableArrays in  
each object. An actor has a scenesForActor mutableArray and a scene  
has an actorsForScene mutableArray. This all works great except that  
it creates retain cycles and neither actor nor scene objects are ever  
released if they have a relationship.


It seems that what I need is a non-retaining array. I googled around a  
bit and was surprised that I could not find an existing  
implementation. It looks like I can create one by subclassing  
NSMutableArray, overriding the primitive methods, and using a CFArray  
as the backing store with NULL callbacks to avoid any kind of retain  
or release when objects are added or removed. Still, I thought I would  
ask around and see if anyone else has done this before I embark on  
trying to subclass a class cluster.


Has anyone out there created a non-retaining array class or come up  
with another solution to this problem? Or is there anything in  
particular I should watch out for when subclassing NSMutableArray?


thanks,
Todd Ransom
Return Self Software
http://returnself.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 [EMAIL PROTECTED]


Get Value from NSArrayController Binding

2008-06-02 Thread Christian Isaacs

Hello Everyone!
I currently have an AppContoller with a method named events that  
returns an NSArray.  This NSArray contains a collection of events  
returned by the CalCalendarStore eventsWithPredicate method.  In IB I  
have an NSArrayController named Events that is bound to my  
AppController events NSArray.  I also have an NSTableView with one  
column and it's value is bound to Events.arrangedObjects.title.   
Everything works perfectly!


However, I then sub-classed NSCell to do some custom drawing of the  
cell and would like to put the title of an event in the cell.  I am  
using the following code to populate the the NSTableView with my  
custom cells:


EventCell *customEventCell = [[[EventCell alloc]  
initWithEventAttributes:*TITLE VALUE GOES HERE*  
eventStartTime:calItemStartDate eventEndTime:calItemEndDate]  
autorelease];
[[eventTableView tableColumnWithIdentifier:@"events"]  
setDataCell:customEventCell];


So here's my question:

1)  How do I get the title value from my Events NSArrayController  
Object?  I've tried [eventTableView  
valueForKey:@"Events.arrangedObjects.title"] and different variations  
of it.



Thanks,
Christian

www.sippingbits.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 [EMAIL PROTECTED]


ANN: “Cocoa Design Patterns” content availa ble via the Safari Rough Cuts

2008-06-02 Thread Erik Buck
ANN: The publisher of the upcoming “Cocoa Design Patterns” book has made 
approximately half of the content available via the Safari Rough Cuts system.  
Customers can (for a fee) start reading and commenting on the book now while it 
is still in development.  Readers get early access to the content and can 
provide feedback to the author(s) while there is still opportunity to 
incorporate the feedback in the printed version.
  http://safari.informit.com/9780321591210
   
  Cocoa Design Patterns
  By: Erik M. Buck
  Last Updated on Safari: 2008/06/02
  Publisher: Addison Wesley Professional
  Pages: 400  
   
  Overview
  This is the Rough Cut version of the printed book.
  Much of the technology embodied by Apple's Cocoa software development 
frameworks has been in commercial use since 1988, and in spite of many years of 
use, the Cocoa frameworks are still revolutionary. Cocoa technology has been 
marketed with a variety of names including NeXTstep, OpenStep*, Rhapsody, and 
Yellow Box. In recent years, Apple has expanded the frameworks dramatically and 
added new tools to raise the bar for Cocoa programmer productivity beyond its 
already famously high levels.
  Programmers are often overwhelmed by the breadth and sophistication of Cocoa 
when they first start using the frameworks. Cocoa is huge, but it's also 
elegant in its consistency and simplicity which result from the application of 
patterns throughout its design. Understanding the patterns enables the most 
effective use of the frameworks and serves as a guide for writing your own 
applications.
This book explains the object-oriented design patterns found in Apple's Cocoa 
frameworks. Design patterns aren't unique to Cocoa; they're recognized in most 
reusable software libraries and available in any software development 
environment. Design patterns simply identify recurring software problems and 
best practices for solving them. The primary goal of this book is to supply 
insight into the design and rationale of Cocoa, but with that insight, you'll 
be able to effectively re-use the tried and true patterns in your own software 
- even if you aren't using Cocoa.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Leopard (10.5+): Any Upper-Level (Cocoa) access to Mail?

2008-06-02 Thread fclee
I would like to talk to Mail.app / ditto for (NDA - aware) iPhone platform.
Ric.

On 06/02/2008 08:53 Michael Watson wrote ..
> Are you trying to talk to Mail.app, or are you looking for a generic e- 
> mail framework?
> 
> 
> --
> m-s
> 
> On 02 Jun, 2008, at 11:34, [EMAIL PROTECTED] wrote:
> 
> > I'm searching for a Cocoa/ObjC routine to access/check Mail;  
> > specifically #read & #unread mail messages.
> > Is there such a routine or need I go do a BSD Mail access?
> >
> > So far, I've found the NSMailDelivery.h within the message.framework.
> > But much of the code appears to be deprecated for OS 5 & beyond.
> >
> > Regards,
> > Ric.
> > ___
> >
> > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> >
> > Please do not post admin requests or moderator comments to the list.
> > Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> >
> > Help/Unsubscribe/Update your Subscription:
> > http://lists.apple.com/mailman/options/cocoa-dev/mikey-san 
> > %40bungie.org
> >
> > This email sent to [EMAIL PROTECTED]
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: Leopard (10.5+): Any Upper-Level (Cocoa) access to Mail?

2008-06-02 Thread Michael Watson
Are you trying to talk to Mail.app, or are you looking for a generic e- 
mail framework?



--
m-s

On 02 Jun, 2008, at 11:34, [EMAIL PROTECTED] wrote:

I'm searching for a Cocoa/ObjC routine to access/check Mail;  
specifically #read & #unread mail messages.

Is there such a routine or need I go do a BSD Mail access?

So far, I've found the NSMailDelivery.h within the message.framework.
But much of the code appears to be deprecated for OS 5 & beyond.

Regards,
Ric.
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/mikey-san 
%40bungie.org


This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Leopard (10.5+): Any Upper-Level (Cocoa) access to Mail?

2008-06-02 Thread fclee
I'm searching for a Cocoa/ObjC routine to access/check Mail; specifically #read 
& #unread mail messages.
Is there such a routine or need I go do a BSD Mail access?

So far, I've found the NSMailDelivery.h within the message.framework.
But much of the code appears to be deprecated for OS 5 & beyond.

Regards,
Ric.
___

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

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

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

This email sent to [EMAIL PROTECTED]

core data: awakeFromFetch, awakeFromInsert, didTurnIntoFault

2008-06-02 Thread [EMAIL PROTECTED]
in a couple of my classes subclassed from NSManagedObject, i provide 
the methods: awakeFromFetch, awakeFromInsert, & didTurnIntoFault. in 
the awake messages, after calling the appropriate super methods, i 
establish some observers like:


[[NSNotificationCenter defaultCenter] addObserver: self ...];

and in the didTurnIntoFault method, i remove myself as an observer. i 
just noticed that if i create a new one of these entities and then 
undo it, the sequence of events is as expected:

awakeFromInsert
didTurnIntoFault
however, if i then redo the action, neither awakeFromFetch nor 
awakeFromInsert is called, and thus i'm left without my observing in 
place.


should i be handling this some other way? if so, how? (pointers to 
documentation would be sufficient). if this is the proper approach, 
how do i re-establish my observing?


th;anx,
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 [EMAIL PROTECTED]


Re: How does NSWorkspace -isFilePackageAtPath: work?

2008-06-02 Thread Milen Dzhumerov

Hi Daniel,

I believe NSWorkspace creates a CFURL from the path you're given and  
then uses LSCopyItemInfoForURL requesting kLSRequestAllFlags.


Then you can use the LSItemInfoRecord provided which has a  
LSItemInfoFlags which in turn has bit flags for the following (and  
more as well) kLSItemInfoIsPackage, kLSItemInfoIsApplication and  
kLSItemInfoIsContainer.


Regards,
Milen

On 2 Jun 2008, at 15:30, Daniel Dalquen wrote:


Hi all,

I am working on client for online storage and the app should not  
download any files unless the user tells it to. Still it should  
recognize bundles and display them as files instead of directories.


Does anybody know how the NSWorkspace method -isFilePackageAtPath:  
determines whether the file at the path is a bundle or not? Does it  
just look at the directory structure only or does it read some  
files? Is there a way to find out?


Thanks,
Daniel
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/md207%40doc.ic.ac.uk

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How does NSWorkspace -isFilePackageAtPath: work?

2008-06-02 Thread Jens Alfke


On 2 Jun '08, at 7:30 AM, Daniel Dalquen wrote:

Does anybody know how the NSWorkspace method -isFilePackageAtPath:  
determines whether the file at the path is a bundle or not? Does it  
just look at the directory structure only or does it read some  
files? Is there a way to find out?


I think it's a combination of (a) does the directory look like a  
bundle, i.e. contains a "Contents" directory; and (b) does the  
directory name's extension match that of a bundle-based type  
registered with Launch Services. (This is why sometimes if you see a  
bundle-based document for an app you don't have, it looks like a  
folder.)


The LaunchServices documentation might explain in detail.

—Jens

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 [EMAIL PROTECTED]

Re: NSXMLDocument and relative DTD?

2008-06-02 Thread Jens Alfke


On 2 Jun '08, at 7:02 AM, Alexander von Below wrote:

When validating the document, either on initWithURL or explicitly,  
validation fails with
Error Domain=NSXMLParserErrorDomain Code=1549 UserInfo=0x14845c70  
"Line 2: failed to load external entity "foo/bar/faz.dtd"


This sounds like it could be a bug in NSXML. One possible experiment  
is to run tcpdump or tcpflow, and see what HTTP traffic the app  
generates while it's validating the XML. Does it even attempt to load  
any HTTP resources? Of course that doesn't suggest any workarounds,  
but it gives you more info to put in your bug report...


—Jens

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 [EMAIL PROTECTED]

How does NSWorkspace -isFilePackageAtPath: work?

2008-06-02 Thread Daniel Dalquen

Hi all,

I am working on client for online storage and the app should not  
download any files unless the user tells it to. Still it should  
recognize bundles and display them as files instead of directories.


Does anybody know how the NSWorkspace method -isFilePackageAtPath:  
determines whether the file at the path is a bundle or not? Does it  
just look at the directory structure only or does it read some files?  
Is there a way to find out?


Thanks,
Daniel
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data "entity required" error

2008-06-02 Thread Chataka

On the console, I just get

> entity required

That's it. Just two words.
Nothing else I can include...

Chataka

On 2008/06/02, at 20:59, Hamish Allan wrote:


On Mon, Jun 2, 2008 at 3:01 AM, Chataka <[EMAIL PROTECTED]> wrote:


I am developing a non-document-based Core Data application and
am facing a trouble with "entity required" error message.

When I quit the app, the error message is shown on the console and
the app fails to save data, although it has to save on quit.

I guess from the error message that some Core Data entity is missing,
but as the error message is too vague, I am at a loss identifying
what entity the error message is implying.

My question is that is there any way to find out "what entity" is  
required?

Is there any way to get detailed information on "entity required"
error message?


If *you* think the error message is too vague, imagine how *we* feel,
when you don't even include it in your post ;)

Hamish


___

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

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

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

This email sent to [EMAIL PROTECTED]


NSXMLDocument and relative DTD?

2008-06-02 Thread Alexander von Below

Hello Cocoa Pros,

I am loading an NSXMLDocument from a webserver, and it contians a  
correct relative DTD, i.e. "relative to the location of the resource  
within which the entity declaration occurs"(1).


When validating the document, either on initWithURL or explicitly,  
validation fails with


Error Domain=NSXMLParserErrorDomain Code=1549 UserInfo=0x14845c70  
"Line 2: failed to load external entity "foo/bar/faz.dtd"


(where the dtd exists at http://example.com/foo/bar/faz.dtd, and the  
document itself at http://example.com/foobar.xml). If I create a local  
copy of the xml file containing an absolute URI for the DTD, the  
document can be validated.


Any hints would be appreciated!

Thanks

Alex


1) http://www.w3.org/TR/2006/REC-xml-20060816/#NT-ExternalID
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Advanced Mac OS X Bootcamp

2008-06-02 Thread Conrad Taylor
Hi, from the web site the price includes the following:Price

A five-day class, a student guide, a luxury room, three delicious meals a
day, a stylish "Big Nerd Ranch" t-shirt, and transportation to and from the
airport for only $3500. Plan to arrive on Sunday evening and depart on
Friday afternoon.


Good luck,


-Conrad

On Mon, Jun 2, 2008 at 6:09 AM, <[EMAIL PROTECTED]> wrote:

> I'm currently in Atlanta, GA.
> I would seriously think of attending if I don't have to pay for lodging.
> I sent a query to BigNerdRanch but didn't receive a reply.
> Ric.
>
> On 06/01/2008 22:08 Adam Gerson wrote ..
> > I signed up for the Advanced Mac OS X Bootcamp at The Big Nerd Ranch.
> > They don't yet have enough people to hold the class and I want it to
> > happen so I am hoping more people will sign up. I took the Objective-C
> > & Cocoa Bootcamp at the BNR and it was a fantastic experience.
> >
> > Dec 8 - 12
> >
> > Advanced Mac OS X Bootcamp is an all-inclusive 5-day Advanced Mac OS X
> > training course for students who have read and understood the first
> > nine chapters of Cocoa Programming for Mac OS X. The class is
> > intensive, and students should be prepared to work hard.
> >
> > http://www.bignerdranch.com/classes/advanced_mac_os_x.shtml
> > ___
> >
> > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> >
> > Please do not post admin requests or moderator comments to the list.
> > Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> >
> > Help/Unsubscribe/Update your Subscription:
> > http://lists.apple.com/mailman/options/cocoa-dev/fclee%40dialup4less.com
> >
> > This email sent to [EMAIL PROTECTED]
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/conradwt%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Advanced Mac OS X Bootcamp

2008-06-02 Thread fclee
I'm currently in Atlanta, GA.
I would seriously think of attending if I don't have to pay for lodging.
I sent a query to BigNerdRanch but didn't receive a reply.
Ric.

On 06/01/2008 22:08 Adam Gerson wrote ..
> I signed up for the Advanced Mac OS X Bootcamp at The Big Nerd Ranch.
> They don't yet have enough people to hold the class and I want it to
> happen so I am hoping more people will sign up. I took the Objective-C
> & Cocoa Bootcamp at the BNR and it was a fantastic experience.
> 
> Dec 8 - 12
> 
> Advanced Mac OS X Bootcamp is an all-inclusive 5-day Advanced Mac OS X
> training course for students who have read and understood the first
> nine chapters of Cocoa Programming for Mac OS X. The class is
> intensive, and students should be prepared to work hard.
> 
> http://www.bignerdranch.com/classes/advanced_mac_os_x.shtml
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/fclee%40dialup4less.com
> 
> This email sent to [EMAIL PROTECTED]
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: File still in use after closing document window

2008-06-02 Thread Hamish Allan
On Mon, Jun 2, 2008 at 8:10 AM, Antonio Nunes <[EMAIL PROTECTED]> wrote:

> My NSDocument based app loads (imports) PDF files into its documents.

What code are you using to load them?

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data "entity required" error

2008-06-02 Thread Hamish Allan
On Mon, Jun 2, 2008 at 3:01 AM, Chataka <[EMAIL PROTECTED]> wrote:

> I am developing a non-document-based Core Data application and
> am facing a trouble with "entity required" error message.
>
> When I quit the app, the error message is shown on the console and
> the app fails to save data, although it has to save on quit.
>
> I guess from the error message that some Core Data entity is missing,
> but as the error message is too vague, I am at a loss identifying
> what entity the error message is implying.
>
> My question is that is there any way to find out "what entity" is required?
> Is there any way to get detailed information on "entity required"
> error message?

If *you* think the error message is too vague, imagine how *we* feel,
when you don't even include it in your post ;)

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Francis Perea

Hi Graham, thanks for your reply.

I didn't know I could set any memory setting trough Interface Builder!

After your question I looked into and I've seen that it states as  
Beffered.


I've tried to use the Retained option, thinking that this way I  
shouldn't use the retain message, but with Retained the windows  
appears but doesn't accept any interaction.


I'd take a deep look into de Memory Management doc you suggest.

Thanks again for your help.

Att.

Francis Perea


El 02/06/2008, a las 13:11, Graham Cox escribió:


What settings have you applied to your window in Interface Builder?


generator=[[[Generator alloc]init] retain];



unrelated to your immediate problem, but in a non-GC application,  
this would be retaining twice - probably not what you intended. This  
suggests your understanding of memory management might be a bit  
shaky, so a general review might help.


http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html


hth,

G.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Francis Perea

Hi Paul.

I've disabled GC as Michael and you propose and the application it's  
working right now.


I've had to "retain" both properties of the model class (generator)  
and the instance of that class in the controller class  
(generatorcontroller).


I've also had to implement both dealloc method of both classes so that  
all retained objects get released.


Is that right?

And a final question, I would like to know if my application frees up  
all memory it uses after stopping and it has no memory leaks; I think  
Instruments is the utility Apple provides for that matter, isn't it?


In that case I should read Instruments help so that I know how to get  
that information, cos I've tried to use it but it doesn't seem very  
friendly to me :-(


Thanks all a lot for your explanations and your time, it's getting me  
clear.


Att.

Francis Perea


El 02/06/2008, a las 11:50, Paul Sargent escribió:



As Michael says, retain and release become null-operations when  
garbage collection is switched on (so code can be written to run as  
both GC and non-GC).


If nothing is holding onto a pointer to your window then it'll be  
collected by the garbage collector. Something has to hold on to a  
pointer to it.


I believe it's worth writing an application or two without using  
garbage collection if you're starting out. GC is one area in Cocoa  
that's a bit like magic if you don't understand how it works.  
Learning everything else with 'magic stuff' happening can be  
difficult. Retain and Release are pretty simple, and as long as you  
stay within Objective C (i.e. don't start using the CoreFoundation C  
API) managing it all is pretty straight forward.


Once you're comfortable with that, switch GC back on and get used to  
how it works.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Graham Cox

What settings have you applied to your window in Interface Builder?


generator=[[[Generator alloc]init] retain];



unrelated to your immediate problem, but in a non-GC application, this  
would be retaining twice - probably not what you intended. This  
suggests your understanding of memory management might be a bit shaky,  
so a general review might help.


http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html


hth,

G.




On 2 Jun 2008, at 5:58 pm, Francis Perea wrote:


Hi all, this is my first post to the list so I'll present myself.

My name is Francis Perea and I've been a programmer for a long time  
(C, Pascal, PHP, Visual Basic) but I'm totally new to Mac  
Development and I'm doing my bests to finish my first little Mac OS  
X application with Objective-C and Cocoa.


By the momment all goes nice except a little trouble that is driving  
me crazy.


The main window of the application shows sometimes, that is the  
window appears but instantly it disappears.


One each of every four or five times I run the application, the  
window remains open and the application runs perfectly, but that's  
only when the window wants to remain.


When the main window disappears the application remain open and I  
can even call the about window but I can't recover the main one.


The code has two classes one for the model (generator) and another  
for the controller (generatorcontroller).


I've made lots of changes trying to discover why, but no results. I  
suppose I has to be something with the init method of the model, but  
I'm unable to determine it.


Garbage Collection is on in Xcode.

Any light in my way, plis?

Here it is the code in case anyone can help me.

Thanks in advance,

Francis Perea


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Paul Sargent



El 02/06/2008, a las 10:45, Michael Vannorsdel escribió:

This will happen if the window is deallocated.  It's probably  
getting cleaned up by garbage collection.




On 2 Jun 2008, at 10:05, Francis Perea wrote:

I've also supposed it was happening that, and I've tried to correct  
it by using retain in each one of init methods of both classes, but  
no results.


What I mean is, in every init method, when I call the [super init]  
I've tried [[super init] retain]. But no way.


As Michael says, retain and release become null-operations when  
garbage collection is switched on (so code can be written to run as  
both GC and non-GC).


If nothing is holding onto a pointer to your window then it'll be  
collected by the garbage collector. Something has to hold on to a  
pointer to it.


I believe it's worth writing an application or two without using  
garbage collection if you're starting out. GC is one area in Cocoa  
that's a bit like magic if you don't understand how it works. Learning  
everything else with 'magic stuff' happening can be difficult. Retain  
and Release are pretty simple, and as long as you stay within  
Objective C (i.e. don't start using the CoreFoundation C API) managing  
it all is pretty straight forward.


Once you're comfortable with that, switch GC back on and get used to  
how it works.___


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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Michael Vannorsdel
Retain and release have no effect on ObjC types when using garbage  
collection.  If your code is written relying on retain counting then  
you should turn off garbage collection since you're trying to manage  
the memory yourself (and probably designed the code as such).  Garbage  
collection has specific requirements on how you treat objects to help  
the collector know what to deallocate and what to keep around.


If you really want to stick with GC, read the docs on it to understand  
how it works and how it determines what and when to deallocate.



On Jun 2, 2008, at 3:05 AM, Francis Perea wrote:


Hi Michael.

I've also supposed it was happening that, and I've tried to correct  
it by using retain in each one of init methods of both classes, but  
no results.


What I mean is, in every init method, when I call the [super init]  
I've tried [[super init] retain]. But no way.


Any other suggestion?

Thanks for your reply.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Francis Perea

Hi Michael.

 I've also supposed it was happening that, and I've tried to correct  
it by using retain in each one of init methods of both classes, but no  
results.


What I mean is, in every init method, when I call the [super init]  
I've tried [[super init] retain]. But no way.


Any other suggestion?

Thanks for your reply.

Att.

Francis Perea

El 02/06/2008, a las 10:45, Michael Vannorsdel escribió:

This will happen if the window is deallocated.  It's probably  
getting cleaned up by garbage collection.



On Jun 2, 2008, at 2:36 AM, Francis Perea wrote:


i Wayne, first of all thanks for your quick reply.

Sorry to say that the Console says nothing :-(

--
[Session started at 2008-06-02 10:33:15 +0200.]

The Debugger has exited with status 0.

-

This is the log I get when I run the App, the Main window flashes  
and disappears. The app keeps running and when I close it, the log  
says that Debugger exited with 0 (Successful) status.


Any other clue?

Thanks again.


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/francis%40francisperea.org

This email sent to [EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core data. Programmatically setting relationships

2008-06-02 Thread Steven Hamilton
Apologies for being vague, I really should learn to proof read  
properly before pressing send.


I've sussed it out. I point the relationship attribute (wrong word I  
know) at the instance of the new object.



On 02/06/2008, at 12:48 AM, mmalc crawford wrote:



On Jun 1, 2008, at 1:28 AM, Steven Hamilton wrote:

What I can't do is set change the relationships. In my tableView  
I'm displaying the Account name in the toAccount and fromAccount  
columns. I want to be able to type a new Account.name in there and  
have the Transaction object update the relationship to the new  
Account accordingly. Reading the core data docs I can't for the  
life of me figure out how to do this. I believe I need to take the  
name from the tableColumn, figure out which account it belongs to  
then somehow set that as the relationship by using KVC.



The documentation explains how to manipulate relationships here:



Other than that, it's not clear what you're trying to achieve.
"I want to be able to type a new Account.name in there" -- type in  
where?  What transaction are you trying to update?  How would you  
have done this if you weren't using Core Data?


mmalc



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Michael Vannorsdel
This will happen if the window is deallocated.  It's probably getting  
cleaned up by garbage collection.



On Jun 2, 2008, at 2:36 AM, Francis Perea wrote:


i Wayne, first of all thanks for your quick reply.

Sorry to say that the Console says nothing :-(

--
[Session started at 2008-06-02 10:33:15 +0200.]

The Debugger has exited with status 0.

-

This is the log I get when I run the App, the Main window flashes  
and disappears. The app keeps running and when I close it, the log  
says that Debugger exited with 0 (Successful) status.


Any other clue?

Thanks again.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Francis Perea

Hi Wayne, first of all thanks for your quick reply.

Sorry to say that the Console says nothing :-(

--
[Session started at 2008-06-02 10:33:15 +0200.]

The Debugger has exited with status 0.

-

This is the log I get when I run the App, the Main window flashes and  
disappears. The app keeps running and when I close it, the log says  
that Debugger exited with 0 (Successful) status.


Any other clue?

Thanks again.


El 02/06/2008, a las 10:06, Wayne Packard escribió:

When the window closes spontaneously, is anything printed to the  
Console (press shift-command-R to display it in Xcode)?


wp

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Wayne Packard
When the window closes spontaneously, is anything printed to the  
Console (press shift-command-R to display it in Xcode)?


wp

On Jun 2, 2008, at 12:58 AM, Francis Perea wrote:


Hi all, this is my first post to the list so I'll present myself.

My name is Francis Perea and I've been a programmer for a long time  
(C, Pascal, PHP, Visual Basic) but I'm totally new to Mac  
Development and I'm doing my bests to finish my first little Mac OS  
X application with Objective-C and Cocoa.


By the momment all goes nice except a little trouble that is driving  
me crazy.


The main window of the application shows sometimes, that is the  
window appears but instantly it disappears.


One each of every four or five times I run the application, the  
window remains open and the application runs perfectly, but that's  
only when the window wants to remain.


When the main window disappears the application remain open and I  
can even call the about window but I can't recover the main one.


The code has two classes one for the model (generator) and another  
for the controller (generatorcontroller).


I've made lots of changes trying to discover why, but no results. I  
suppose I has to be something with the init method of the model, but  
I'm unable to determine it.


Garbage Collection is on in Xcode.

Any light in my way, plis?

Here it is the code in case anyone can help me.

Thanks in advance,

Francis Perea



#import 


@interface Generator : NSObject {
NSString *cadena;
NSMutableArray *valores;
}
@property(copy) NSString *cadena;
@property(copy) NSMutableArray *valores;
-(void)Enciende:(int) x:(int) y:(int) state;
@end

--
#import "Generator.h"
#import "globales.h"

@implementation Generator
@synthesize cadena;
@synthesize valores;

- (id)init{
 int i;
 self=[super init];
 valores=[[NSMutableArray arrayWithCapacity:COLS] retain];
 for(i=0; i0] atIndex:i];

 return self;
}

- (void)Enciende:(int) x:(int) y: (int) state{
 if (state) {[valores replaceObjectAtIndex:x withObject:[NSNumber  
numberWithInt:BitOr([[valores objectAtIndex:x] intValue],(64>>y))]];}
 else {[valores replaceObjectAtIndex:x withObject:[NSNumber  
numberWithInt:BitAnd([[valores objectAtIndex:x]  
intValue],BitNot(64>>y))]];}
 cadena=[NSString stringWithFormat:@"{0x%x,0x%x,0x%x,0x%x,0x%x}", 
[[valores objectAtIndex:0] intValue],[[valores objectAtIndex:1]  
intValue],[[valores objectAtIndex:2] intValue],[[valores  
objectAtIndex:3] intValue],[[valores objectAtIndex:4] intValue]];

}
@end



#import 
#import "Generator.h"

@interface GeneratorController : NSObject {
IBOutlet NSMatrix  *botones;
IBOutlet id Col1, Col2, Col3, Col4, Col5, CopiaC, BorraTodo;
Generator *generator;
}
- (void)awakeFromNib;
- (IBAction)Maneja:(id)sender;
- (IBAction)Copia:(id)sender;
- (IBAction)Borra:(id)sender;
- (void)Refresca;
@end
-

#import "GeneratorController.h"

@implementation GeneratorController
- (id)init
{
self=[super init];
generator=[[[Generator alloc]init] retain];
return self;
}

- (void)awakeFromNib
{
[self Refresca];
}

- (void)Refresca
{
[Col1 setStringValue: [NSString stringWithFormat:@"%0.2X", 
[[generator.valores objectAtIndex:0] intValue]]];

[Col1 display];
[Col2 setStringValue: [NSString stringWithFormat:@"%0.2X", 
[[generator.valores objectAtIndex:1] intValue]]];

[Col2 display];
[Col3 setStringValue: [NSString stringWithFormat:@"%0.2X", 
[[generator.valores objectAtIndex:2] intValue]]];

[Col3 display];
[Col4 setStringValue: [NSString stringWithFormat:@"%0.2X", 
[[generator.valores objectAtIndex:3] intValue]]];

[Col4 display];
[Col5 setStringValue: [NSString stringWithFormat:@"%0.2X", 
[[generator.valores objectAtIndex:4] intValue]]];

[Col5 display];
}

- (IBAction)Maneja:(id)sender
{
 int col, row;
 [sender getRow :&row column:&col ofCell:[sender selectedCell]];
 [generator Enciende:col :row :[[sender selectedCell] state]];
 [self Refresca];
}

- (IBAction)Copia:(id)sender
{
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
[pasteboard declareTypes: [NSArray arrayWithObject:  
NSStringPboardType] owner: NULL];

[pasteboard setString:generator.cadena forType: NSStringPboardType];
}

- (IBAction)Borra:(id)sender
{
int col,row;
for (row=0; row<7; row++)
 for (col=0; col<5; col++){
  [generator Enciende:col :row :NSOffState];
  [botones setState:NSOffState atRow:row column:col];
 }
 [self Refresca];
}
@end


___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

Please do not post admin requests or moderator c

Main window disappears. Sometimes.

2008-06-02 Thread Francis Perea

Hi all, this is my first post to the list so I'll present myself.

My name is Francis Perea and I've been a programmer for a long time  
(C, Pascal, PHP, Visual Basic) but I'm totally new to Mac Development  
and I'm doing my bests to finish my first little Mac OS X application  
with Objective-C and Cocoa.


By the momment all goes nice except a little trouble that is driving  
me crazy.


The main window of the application shows sometimes, that is the window  
appears but instantly it disappears.


One each of every four or five times I run the application, the window  
remains open and the application runs perfectly, but that's only when  
the window wants to remain.


When the main window disappears the application remain open and I can  
even call the about window but I can't recover the main one.


The code has two classes one for the model (generator) and another for  
the controller (generatorcontroller).


I've made lots of changes trying to discover why, but no results. I  
suppose I has to be something with the init method of the model, but  
I'm unable to determine it.


Garbage Collection is on in Xcode.

Any light in my way, plis?

Here it is the code in case anyone can help me.

Thanks in advance,

Francis Perea



#import 


@interface Generator : NSObject {
NSString *cadena;
NSMutableArray *valores;
}
@property(copy) NSString *cadena;
@property(copy) NSMutableArray *valores;
-(void)Enciende:(int) x:(int) y:(int) state;
@end

--
#import "Generator.h"
#import "globales.h"

@implementation Generator
@synthesize cadena;
@synthesize valores;

- (id)init{
  int i;
  self=[super init];
  valores=[[NSMutableArray arrayWithCapacity:COLS] retain];
  for(i=0; i0] atIndex:i];

  return self;
}

- (void)Enciende:(int) x:(int) y: (int) state{
  if (state) {[valores replaceObjectAtIndex:x withObject:[NSNumber  
numberWithInt:BitOr([[valores objectAtIndex:x] intValue],(64>>y))]];}
  else {[valores replaceObjectAtIndex:x withObject:[NSNumber  
numberWithInt:BitAnd([[valores objectAtIndex:x]  
intValue],BitNot(64>>y))]];}
  cadena=[NSString stringWithFormat:@"{0x%x,0x%x,0x%x,0x%x,0x%x}", 
[[valores objectAtIndex:0] intValue],[[valores objectAtIndex:1]  
intValue],[[valores objectAtIndex:2] intValue],[[valores objectAtIndex: 
3] intValue],[[valores objectAtIndex:4] intValue]];

}
@end



#import 
#import "Generator.h"

@interface GeneratorController : NSObject {
IBOutlet NSMatrix  *botones;
IBOutlet id Col1, Col2, Col3, Col4, Col5, CopiaC, BorraTodo;
Generator *generator;
}
- (void)awakeFromNib;
- (IBAction)Maneja:(id)sender;
- (IBAction)Copia:(id)sender;
- (IBAction)Borra:(id)sender;
- (void)Refresca;
@end
-

#import "GeneratorController.h"

@implementation GeneratorController
- (id)init
{
 self=[super init];
 generator=[[[Generator alloc]init] retain];
 return self;
}

- (void)awakeFromNib
{
 [self Refresca];
}

- (void)Refresca
{
 [Col1 setStringValue: [NSString stringWithFormat:@"%0.2X", 
[[generator.valores objectAtIndex:0] intValue]]];

 [Col1 display];
 [Col2 setStringValue: [NSString stringWithFormat:@"%0.2X", 
[[generator.valores objectAtIndex:1] intValue]]];

 [Col2 display];
 [Col3 setStringValue: [NSString stringWithFormat:@"%0.2X", 
[[generator.valores objectAtIndex:2] intValue]]];

 [Col3 display];
 [Col4 setStringValue: [NSString stringWithFormat:@"%0.2X", 
[[generator.valores objectAtIndex:3] intValue]]];

 [Col4 display];
 [Col5 setStringValue: [NSString stringWithFormat:@"%0.2X", 
[[generator.valores objectAtIndex:4] intValue]]];

 [Col5 display];
}

- (IBAction)Maneja:(id)sender
{
  int col, row;
  [sender getRow :&row column:&col ofCell:[sender selectedCell]];
  [generator Enciende:col :row :[[sender selectedCell] state]];
  [self Refresca];
}

- (IBAction)Copia:(id)sender
{
 NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
 [pasteboard declareTypes: [NSArray arrayWithObject:  
NSStringPboardType] owner: NULL];

 [pasteboard setString:generator.cadena forType: NSStringPboardType];
}

- (IBAction)Borra:(id)sender
{
 int col,row;
 for (row=0; row<7; row++)
  for (col=0; col<5; col++){
   [generator Enciende:col :row :NSOffState];
   [botones setState:NSOffState atRow:row column:col];
  }
  [self Refresca];
}
@end


___

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

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

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

This email sent to [EMAIL PROTECTED]


  1   2   >