Re: Is this normal behavior ?

2008-08-10 Thread Negm-Awad Amin

probably you did somthing wrong. :-)


Am Fr,08.08.2008 um 21:48 schrieb Filip vdm:


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]


Amin Negm-Awad
[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]


How increase the default http request timeout?

2008-08-10 Thread Yogesh Potdar
Hi All,

In my cocoa app, I'm using API CFReadStream for http connection. The server
is taking too long to respond as the response size is more than 4 MB and
also the connection speed is slow. If the response size is small (less than
1 MB) no timeout occurs. I have tried with different buffer sizes but could
not get the expected results.

Can anybody suggest how to increase the timeout while using CFReadStream
API.

Thanks and regards,
Yogesh Potdar
Persistent Systems Limited.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 versioning woes

2008-08-10 Thread Quincey Morris

On Aug 10, 2008, at 22:08, Graham Perks wrote:

Well that was too easy. I even started off on the right track  
yesterday before getting derailed.


This'll work:

- (id)initWithContentsOfURL:(NSURL *)absoluteURL ofType:(NSString  
*)typeName error:(NSError **)outError

{
   // Migrate? Optional, but it'd be good to check here if this  
upgrade needs to happen.


   NSError *error = nil;
   NSURL *momURL = [NSURL fileURLWithPath:[MyDocument  
pathForModelNamed:@"MyDocument 3"]];
   NSManagedObjectModel *newMoM = [[NSManagedObjectModel alloc]  
initWithContentsOfURL:momURL];
   NSPersistentStoreCoordinator *psc =  
[[NSPersistentStoreCoordinator alloc]  
initWithManagedObjectModel:newMoM];

   NSDictionary *optionsDictionary =
   [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]

forKey:NSMigratePersistentStoresAutomaticallyOption];


   id store = [psc addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
  URL:absoluteURL
  options:optionsDictionary
error:&error];

   if (nil == store) {
   [[NSApplication sharedApplication] presentError:error];
   }

   // Migration has happened.
   [psc release];
   [newMoM release];

   self = [super initWithContentsOfURL:absoluteURL ofType:typeName  
error:outError];


   return self;
}


Er, I think this is a little bit wrong, because it doesn't handle  
errors properly. If you get an error from addPersistentStoreWithType,  
you'll report it, then get a secondary error from [super  
initWithContentsOfURL:...]. And you can't return early if an error  
occurs, because this is an initializer and returning early (without  
calling a designated super initializer) will return an uninitialized  
MyDocument object which *may* crash your application. Nor can you  
return nil -- the NSDocument class reference says it's not allowed.


It's possible that simply calling [super init] before returning self,  
after an error, will make this safe, but I still think you're better  
off doing the migration in a subclass of NSDocumentController, before  
even trying to create the MyDocument object. (The identical migration  
code will work there, because it doesn't depend on a MyDocument  
instance.) -[NSDocumentController  
openDocumentWithContentsOfURL:display:error:] is the method you'd need  
to override.


The other consideration to keep in mind is that automation migration  
(NSMigratePersistentStoresAutomaticallyOption) is probably going to  
end up keeping the whole persistent store in memory (twice -- the old  
one and the new one -- plus the property data caches that core data  
uses). If your stores are more than a few hundred megabytes, this  
might perform *really* badly.



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why use NSObjectController?

2008-08-10 Thread Seth Willits

On Aug 10, 2008, at 10:14 PM, mmalc crawford wrote:

Any time you want to ensure that pending edits in the view layer are  
committed to your underlying model objects -- for example, if the  
user has entered a new value in a text field then saves a document  
before "exiting" the field (and causing the change to be committed).



A... That's very useful. I see that Cocoa Bindings Programming  
Topics -> How Do Bindings Work -> The Supporting Technologies in  
Detail -> NSEditor/NSEditorRegistration attempts to mention that. It's  
not quite as clear as your single sentence though. :-)


Thanks!

--
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: Get specified window from nib

2008-08-10 Thread Kyle Sluder
On Sun, Aug 10, 2008 at 10:01 PM, Fosse <[EMAIL PROTECTED]> wrote:
> I have one nib containing more than ten dialogs and want to get the
> specified window after nib is loading..

Typically you'll have one window per nib.  Putting ten windows in a
single nib is a bit awkward.

> If I use FileOwner and binding, I need to add a lot of Outlets in the
> fileOwner class and create the binding in the IB..

Why?  Surely these windows aren't talking to each other, since they're
views and their information should be shared by using a common model
object.  Consider whether you've properly factored your app under the
MVC paradigm.

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


Re: Does [NSApp setApplicationIconImage] leak memory?

2008-08-10 Thread Kyle Sluder
On Sun, Aug 10, 2008 at 8:04 PM, Matt Neuburg <[EMAIL PROTECTED]> wrote:
> That's perhaps perfectly true. But "later" could be a LOT later - and in the
> meantime quite a lot of memory could pile up. For example, it is the nature
> of the Cocoa event loop that the autorelease pool gets cleaned out when the
> user switches to another app and back to your app. But that might not happen
> for quite some time.

I was under the impression that Cocoa flushed the top autorelease pool
at the top of the runloop.  But this is an Implementation Detail,
after all.

> To cite an example in my own life, in an app where I
> was creating a lot of autoreleased strings as I gathered data from a huge
> MySQL database, I actually caused my computer to freeze up for lack of
> memory. When I created my own autorelease pool and released it every n times
> thru the loop, the problem went away. This is, indeed, an *extremely* common
> technique for doing exactly what you say - making it happen "now".

Believe me, I'm very familiar with this technique.  I have an app that
draws a lot of little rounded rectangles, and it's important that I
don't just create a ton of autoreleased NSBezierPaths, but instead
explicitly alloc and release them.  Otherwise my working set grows
dramatically.

> So, to resume, it may in fact be that the OP's app is NOT truly "leaking" -
> but rather, that exactly what I'm describing here is what's happening to
> him: the built-in autorelease pool is just piling up and not getting
> released, because the event loop hasn't exited yet. The fact that the
> problem he is seeing does in fact go away for him when he does what I
> suggested is an indication that it is. This is one of the possible
> conclusions towards which, in my Socratic little way, I'm trying to lead the
> OP. Stay tuned. m.

Or maybe it has something to do with him explicitly retaining the
autoreleased NSArrays he's creating, and inappropriately using usleep
instead of an NSTimer...

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


Re: Why use NSObjectController?

2008-08-10 Thread mmalc crawford


On Aug 10, 2008, at 10:08 PM, Seth Willits wrote:


On Aug 10, 2008, at 9:54 PM, mmalc crawford wrote:


What is it that NSObjectController offers me?


An implementation of the NSEditor and NSEditorRegistration protocols.

Ah.
Now I'll just have to figure out when I'd want to use those...

Any time you want to ensure that pending edits in the view layer are  
committed to your underlying model objects -- for example, if the user  
has entered a new value in a text field then saves a document before  
"exiting" the field (and causing the change to be committed).


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: Why use NSObjectController?

2008-08-10 Thread Seth Willits

On Aug 10, 2008, at 9:54 PM, mmalc crawford wrote:


What is it that NSObjectController offers me?



An implementation of the NSEditor and NSEditorRegistration protocols.



Ah.

Now I'll just have to figure out when I'd want to use those...



--
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: Core Data versioning woes

2008-08-10 Thread Graham Perks
Well that was too easy. I even started off on the right track  
yesterday before getting derailed.


This'll work:

- (id)initWithContentsOfURL:(NSURL *)absoluteURL ofType:(NSString  
*)typeName error:(NSError **)outError

{
// Migrate? Optional, but it'd be good to check here if this  
upgrade needs to happen.


NSError *error = nil;
NSURL *momURL = [NSURL fileURLWithPath:[MyDocument  
pathForModelNamed:@"MyDocument 3"]];
NSManagedObjectModel *newMoM = [[NSManagedObjectModel alloc]  
initWithContentsOfURL:momURL];
NSPersistentStoreCoordinator *psc =  
[[NSPersistentStoreCoordinator alloc]  
initWithManagedObjectModel:newMoM];

NSDictionary *optionsDictionary =
[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]
 
forKey:NSMigratePersistentStoresAutomaticallyOption];


id store = [psc addPersistentStoreWithType:NSSQLiteStoreType
 configuration:nil
   URL:absoluteURL
   options:optionsDictionary
 error:&error];

if (nil == store) {
[[NSApplication sharedApplication] presentError:error];
}

// Migration has happened.
[psc release];
[newMoM release];

self = [super initWithContentsOfURL:absoluteURL ofType:typeName  
error:outError];


return self;
}

This uses a pathForModelNamed method I ripped from Apple's MigrationV2  
sample.  It just hunts down the model's .mom file.  "MyDocument 3" is  
the latest version of the model.


The first section does the migration and leaves the original file  
upgraded. Then, as normal, we call super to actually load the file.


There's no need to override configurePersistentStoreCoordinatorForURL  
at all. I'll add some code using  
isConfiguration:compatibleWithStoreMetadata: to check if the upgrade  
is even needed, and that should wrap it up.


What a day.

Cheers,
Graham Perks.
http://www.asinglepixel.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: Why use NSObjectController?

2008-08-10 Thread mmalc crawford


On Aug 10, 2008, at 8:23 PM, Seth Willits wrote:


What is it that NSObjectController offers me?


An implementation of the NSEditor and NSEditorRegistration protocols.

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: Why use NSObjectController?

2008-08-10 Thread Seth Willits

On Aug 10, 2008, at 9:39 PM, Gordon Apple wrote:


I don't use CoreData.  Frankly, the main use I have made of
NSObjectController is to decrease my typing in IB bindings.  For  
example, my
inspectors have a large number of controls that are bound through a  
fairly

long chain of references to their controllers.  By using an
NSObjectController to handle the long chain, my individual bindings  
are much

shorter.  Your mileage may vary.


So far that's the only use I've found for it. :)

It seems like it's really there just as somewhat of an abstract base  
class for the other controllers, but then I wonder why the  
CurrencyConverter example uses it, because it works perfectly fine by  
simply binding directly to the Converter object itself.



--
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: Why use NSObjectController?

2008-08-10 Thread Gordon Apple
I don't use CoreData.  Frankly, the main use I have made of
NSObjectController is to decrease my typing in IB bindings.  For example, my
inspectors have a large number of controls that are bound through a fairly
long chain of references to their controllers.  By using an
NSObjectController to handle the long chain, my individual bindings are much
shorter.  Your mileage may vary.


On 8/10/08 11:29 PM, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:

> On Aug 10, 2008, at 10:23 PM, Seth Willits wrote:
>> What is it that NSObjectController offers me?
> 
> Great question. You are on the long steep ascent to Bindings
> understanding. For me the top is still way up there shrouded in clouds.
> 
> I'll take a stab at answering your question:
> 
> 1) NSObjectController fits in with Core Data
> 2) It works with a managed object context to give you undo and redo
> for "free"
> 3) It's subclasses are perhaps more handy, e.g. NSArrayController.
> 
> Notice my answer contains no detail whatsoever. I still have much to
> learn.
> 
> There's actually a good & useful sample using NSObjectController,
> http://developer.apple.com/samplecode/DepartmentAndEmployees/listing12.html
> 
> Cheers,
> Graham.

G. Apple



___

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

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

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

This email sent to [EMAIL PROTECTED]


NSPopupButton, Null Placeholder, image

2008-08-10 Thread Chris Idou
I've figured out how to have a little cog action menu using NSPopupButton.

Now I want to have one where the items of the menu are dynamically changed 
using a binding. That works, but it destroys the little cog image.

So then I notice the Null Placeholder option, which seems good because it 
treats the first slot specially, but it still blanks it out.

Can anyone give me a hint how to best deal with this?





  
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why use NSObjectController?

2008-08-10 Thread Graham Perks

On Aug 10, 2008, at 10:23 PM, Seth Willits wrote:

What is it that NSObjectController offers me?


Great question. You are on the long steep ascent to Bindings  
understanding. For me the top is still way up there shrouded in clouds.


I'll take a stab at answering your question:

1) NSObjectController fits in with Core Data
2) It works with a managed object context to give you undo and redo  
for "free"

3) It's subclasses are perhaps more handy, e.g. NSArrayController.

Notice my answer contains no detail whatsoever. I still have much to  
learn.


There's actually a good & useful sample using NSObjectController, 
http://developer.apple.com/samplecode/DepartmentAndEmployees/listing12.html

Cheers,
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: Core Data question

2008-08-10 Thread Chris Hanson

On Aug 10, 2008, at 8:37 PM, Graham Perks wrote:


On Aug 10, 2008, at 10:30 PM, Chris Hanson wrote:
you should not need to do a thing to ensure that the other is set  
after doing the first.  That's what marking relationships as  
inverses means; Core Data will set them for you automatically.


Thanks for that Chris, I did not know that. Still, it doesn't harm  
to set things twice.


Actually, it could add an extra undoable action.  If you just leave  
the inverse to Core Data, setting both the relationship and its  
inverse will definitely be a single undoable operation.


Also, imagine you have some additional logic implemented in the  
setters; that will be invoked twice.  Obviously it should be safe to  
invoke twice, but depending on the amount of work it does you might  
not want it to be.


  -- Chris

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data question

2008-08-10 Thread Graham Perks

On Aug 10, 2008, at 10:30 PM, Chris Hanson wrote:
you should not need to do a thing to ensure that the other is set  
after doing the first.  That's what marking relationships as  
inverses means; Core Data will set them for you automatically.


Thanks for that Chris, I did not know that. Still, it doesn't harm to  
set things twice.


Sandro, glad to hear the code worked!

Cheers,
Graham.
http://www.asinglepixel.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: Core Data question

2008-08-10 Thread Chris Hanson

On Aug 10, 2008, at 6:51 PM, Graham Perks wrote:

I do this, where I have an EventImage that refers back to a main  
Event, "self" is the managed object for the Event, which is your  
Account:



   // create new EventImage, this would be akin to your  
AccountDetails

imageHolder = (EventImage*)
   [NSEntityDescription  
insertNewObjectForEntityForName:@"EventImage"
 inManagedObjectContext: 
[self managedObjectContext]];


   [imageHolder setImage:image]; // set some data in the new  
object


// Add reference from Event to it's Image
   [self setValue:imageHolder forKey:@"imageHolder"];

	// Add the reverse relationship, from the image back to the  
event.

   [imageHolder setValue:self forKey:@"event"];


If your Event.imageHolder and EventImage.event relationships are  
inverses of each other, you should not need to do a thing to ensure  
that the other is set after doing the first.  That's what marking  
relationships as inverses means; Core Data will set them for you  
automatically.


  -- Chris

___

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

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

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

This email sent to [EMAIL PROTECTED]


Why use NSObjectController?

2008-08-10 Thread Seth Willits



This is something I still don't quite understand: Why should I bind to  
an NSObjectController bound to an object, instead of just binding to  
the object itself? Say for instance that I bind the values of a bunch  
of controls to [File's Owner].value1, [File's Owner].value2, [File's  
Owner].value3 Should I be using an NSObjectController bound to  
File's Owner, and then bind the controls to the object controller? If  
so, why?


What if I instead bound the controls to [File's Owner].someObj.value1,  
[File's Owner].someObj.value2, [File's Owner].someObj.value3, etc.?  
Malcolm briefly alludes to created an NSObjectController bound to  
[File's Owner].someObj and then binding the controls to [Object  
Controller].value[N] instead. Why would I do this though? Simply for  
brevity?


What is it that NSObjectController offers me?


Thanks!

--
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: Core Data versioning woes

2008-08-10 Thread Quincey Morris

On Aug 10, 2008, at 19:28, Graham Perks wrote:


On Aug 10, 2008, at 2:06 PM, Graham Perks wrote:

The document that's open post-migration is the "foo~" version


Is this a "feature" of migration? I tried the most basic migration  
app I could build. And when I try to save, it says "This document  
has been renamed to "test2~". While that's different from the  
message my real application gives, it's still completely bizarre.  
Why should a user care about the tilde filename at all?


Note that, at first, the document name in the title bar is the  
correct, non-tilde version, until you hit Save. Then the title bar  
name grows a tilde!!


I don't exactly remember the series of failed attempts I went through  
to get migration working, but this was possibly one of them. I think  
the problem you're running into is that migrating within the context  
of a NSPersistentDocument has pitfalls not present when migrating a  
non-document Core Data store, and its hard to tell from the  
documentation what works for documents and what does not. In  
particular, I don't think you can easily migrate the store after the  
NSPersistentDocument object has already been created.


The way I got it to work was to follow the strategy outlined in:

	http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdImporting.html#/ 
/apple_ref/doc/uid/TP40003174-SW2


in the subsection titled "Document Based Example", but instead of  
implementing the data import loop I triggered the migration (for which  
there is useful sample code in the Core Data migration guide, but I  
expect you've written suitable code for this already). This basically  
performs the migration outside the context of a NSPersistentDocument,  
and just opens the result at the end. To make this work, I had to  
create my own temporary file for the result, manually rename out the  
old file with a "~" at the end of the migration, manually rename in  
the new file, and then open the new file. (The sample code shows how  
to subclass NSDocumentController to make this work.)


I may well have ended up reinventing some stuff that can be done  
automatically, but at least I got it working without sacrificing the  
last shreds of my sanity.



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


handling errors from NSNumberFormatter - how to determine exact nature of the error?

2008-08-10 Thread Rua Haszard Morris
I'm using a NSNumberFormatters in a modal dialog to validate text  
fields. I want to give the user a specific and appropriate error  
message if they try to OK the dialog with an invalid number in a  
field. For example I want different error messages for "no string  
entered", "non numeric string entered", "value larger than max",  
"value less than min".


In my implementation of  
control:didFailToFormatString:errorDescription: I get notified that a  
format failed, but the description is always "Formatting error". I  
tried calling getObjectValue:forString:range:error: on the formatter,  
but as far as I can tell the NSError returned is the same for each  
error condition.


So.. I could check the passed in string myself, for length, validity,  
then max/min, and generate my error message accordingly, but then I'm  
reimplementing the validation?


Is there a better way to achieve this?

thanks
Rua HM.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 question

2008-08-10 Thread Sandro Noel

Graham.
Wow, that worked ...
Thank you so Much !

Sandro.

On 10-Aug-08, at 9:51 PM, Graham Perks wrote:


On Aug 10, 2008, at 8:39 PM, Sandro Noel wrote:

So I think my question here, is, what should I use when inserting a  
detail object to properly set the relationship to Account.
some example on how I should approach the problem would be nice, or  
a step-by-step :D


I do this, where I have an EventImage that refers back to a main  
Event, "self" is the managed object for the Event, which is your  
Account:



// create new EventImage, this would be akin to your  
AccountDetails

imageHolder = (EventImage*)
[NSEntityDescription  
insertNewObjectForEntityForName:@"EventImage"
  inManagedObjectContext: 
[self managedObjectContext]];


[imageHolder setImage:image]; // set some data in the  
new object


// Add reference from Event to it's Image
[self setValue:imageHolder forKey:@"imageHolder"];

	// Add the reverse relationship, from the image back to the  
event.

[imageHolder setValue:self forKey:@"event"];



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: When the getter returns a BOOL, is "is" the preferred prefix?

2008-08-10 Thread mm w
is or should

On Fri, Aug 8, 2008 at 9:15 PM, Ken Thomases <[EMAIL PROTECTED]> wrote:
> On Aug 8, 2008, at 10:53 PM, Sumner Trammell wrote:
>
>> We know that Cocoa strongly suggests using setFoo and foo for setters
>> and getters.
>>
>> Sometimes I see setters and getters using the idiom setFoo and isFoo.
>> For example, in NSToolbar, you have setVisible and isVisible.
>>
>> When the getter returns a BOOL, is "is" the preferred prefix?
>
> http://developer.apple.com/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html#//apple_ref/doc/uid/20001282-1004202-BCIGGFCC
>
>
>> Side question: do KVC and KVO still work when the getter is prefixed with
>> "is" ?
>
> Yes, as I. Savant already pointed out.  Moreover, if "is" broke KVC and KVO,
> it would be actively discouraged and you probably wouldn't see it in Apple's
> classes.
>
> Cheers,
> 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/openspecies%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>



-- 
-mmw
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 question

2008-08-10 Thread Sandro Noel

Graham.
Thank you for the code.

so what I should do if I understand your code, is fetch my account's  
managed object,

before i insert any details.

Sandro.

On 10-Aug-08, at 9:51 PM, Graham Perks wrote:


On Aug 10, 2008, at 8:39 PM, Sandro Noel wrote:

So I think my question here, is, what should I use when inserting a  
detail object to properly set the relationship to Account.
some example on how I should approach the problem would be nice, or  
a step-by-step :D


I do this, where I have an EventImage that refers back to a main  
Event, "self" is the managed object for the Event, which is your  
Account:



// create new EventImage, this would be akin to your  
AccountDetails

imageHolder = (EventImage*)
[NSEntityDescription  
insertNewObjectForEntityForName:@"EventImage"
  inManagedObjectContext: 
[self managedObjectContext]];


[imageHolder setImage:image]; // set some data in the  
new object


// Add reference from Event to it's Image
[self setValue:imageHolder forKey:@"imageHolder"];

	// Add the reverse relationship, from the image back to the  
event.

[imageHolder setValue:self forKey:@"event"];



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 versioning woes

2008-08-10 Thread Steve Steinitz

Hello Mr Crawford,

Oops, didn't want to hijack Graham's nice clean thread.  However...

On 10/8/08, mmalc crawford wrote:


ps. one special problem I have is that I don't want the migration to
happen automatically because four users share the same database.




"If your application does support versioning and you choose to use
custom version skew detection and migration bootstrapping, before
opening a store you should check (using
isConfiguration:compatibleWithStoreMetadata:) whether its schema is
compatible with the coordinator’s model: if it is, you can use
addPersistentStoreWithType:configuration:URL:options:error: to open
the store directly; if it is not, you must migrate the store first
then open it (again
usingaddPersistentStoreWithType:configuration:URL:options:error:)."


Thanks for looking up that reference.  I saw it when I printed 
out and

carefully read the versioning document, text marker in hand.  I confess,
I only understood about 25% of it, felt it lacking and 
discovered that

the process, as described, didn't work -- at least in my
non-document-based app, as described in another thread.

With the delicate state of the built-in versioning/migration 
code, i.e.

treacherous to get it working at all, 'version skew detection' and
'migration bootstrapping' sound scary :) and lack definitions, 
let alone

explanations & sample code, in the documentation.

Moreover, I don't see how the referenced doc snippet relates to my
multi-user scenario -- I really wish I did.  Regardless of 
whatever it

is trying to say, I would be nervous migrating automatically with
multiple users.  Do you disagree?  Having everyone quit the app 
while I

do the migration makes me more comfortable.  Then, they can Sparkle
(update) their app to the latest version and access the newly-migrated
database.

Thanks again,

Steve

ps. Sorry, Graham, for the brief hijack

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 versioning woes

2008-08-10 Thread Graham Perks

On Aug 10, 2008, at 2:06 PM, Graham Perks wrote:

The document that's open post-migration is the "foo~" version


Is this a "feature" of migration? I tried the most basic migration app  
I could build. And when I try to save, it says "This document has been  
renamed to "test2~". While that's different from the message my real  
application gives, it's still completely bizarre. Why should a user  
care about the tilde filename at all?


Note that, at first, the document name in the title bar is the  
correct, non-tilde version, until you hit Save. Then the title bar  
name grows a tilde!!


This is so odd I've uploaded the project: http://asinglepixel.com/cdtest2.zip

Included is a "test2" file that is the document saved in the version 1  
format. Open that up, click Save and watch the title bar.


Model v1 contains a single entity with a "name" attribute. v2 adds an  
"address" attribute. The only code change from the Core Data template  
was an addition in MyDocument.m,  
configurePersistentStoreCoordinatorForURL to tell the store to support  
versioning.


What am I missing here?

Cheers,
Graham.
http://www.asinglepixel.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]


Bindings created reference objects

2008-08-10 Thread Dustin Robert Kick
I have a program I'm developing where there will be one list, shown in  
an NSTableView that has source objects, and a second list that  
contains counted reference objects from the first list, also shown in  
an NSTableView, and you add objects by selecting in the first list,  
and clicking a button that adds (or increments the count of) the  
objects from the first to the second.


Ok, so I've solved how to do this without bindings,  I've created a  
supercontroller to handle two NSArrayControllers, with the required  
IBAction to send the selected data in the first to the second, after  
processing.  Is there a way to do this without a custom class?  I'm  
thinking there might be with NSButton's bindings for Argument,  
somehow, but I'm wondering if it'll be a fruitless search, since I  
don't know how/if such things can be passed to the creation of a Core  
Data Entity through the add: action without the same or more work than  
I've already done, or if it would be worth it.  Seems like I could  
just override add: to take the Argument bound by the button, and use  
addObjects: or whatever lower level function add: uses, to create  
relationships in the a new entity from the buttons Argument binding.   
Anyway, just wondering if anyone has thoughts on this line.


Dustin  
KC9MEL  




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: Core Data versioning woes

2008-08-10 Thread Graham Perks

On Aug 10, 2008, at 8:12 PM, Steve Steinitz wrote:

Perhaps you feel like you are talking to yourself but I assure you
myself and others are watching your progress.


Thanks, Steve. For posterity's sake, if, I should say WHEN, this error  
pops up:


Can't merge models with two different entities named 'Entity'

then you have two versions of the data model included in the Target.  
Change the Xcode settings so only the most recent model version is in  
the target.


Now, if you STILL get that error - and you will! - then realize that  
Xcode does not remove the file even if you uncheck the Target checkbox  
for a file. So do a Clean before rebuilding, and the error will be gone.


(I'm still puzzling out why I get the tilde version of the migrated  
file opened.)


Cheers,
Graham Perks
http://www.asinglepixel.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: Get specified window from nib

2008-08-10 Thread Graham Perks

On Aug 10, 2008, at 9:01 PM, Fosse wrote:


I have one nib containing more than ten dialogs and want to get the
specified window after nib is loading..


Perhaps NSNib's instantiateNibWithOwner:(id)owner topLevelObjects: 
(NSArray **)topLevelObjects ? You'll get an array of top level  
objects, which will presumably contain your dialogs... If it were me  
I'd just join them up in IB. You only need to do it once.


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]


Get specified window from nib

2008-08-10 Thread Fosse
I have one nib containing more than ten dialogs and want to get the
specified window after nib is loading..

If I use FileOwner and binding, I need to add a lot of Outlets in the
fileOwner class and create the binding in the IB..   Is there a more
convenient way to get the specified  window by passing the window name and
nib reference like Carbon?

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: Core Data question

2008-08-10 Thread Graham Perks
One more thing, since you are getting traps on insert. If you have  
derived your own NSManagedObject subclass and are overriding  
awakeFromInsert:, check you are calling [super awakeFromInsert]...


On Aug 10, 2008, at 8:39 PM, Sandro Noel wrote:
So I think my question here, is, what should I use when inserting a  
detail object to properly set the relationship to Account.
some example on how I should approach the problem would be nice, or  
a step-by-step :D


Cheers,
Graham Perks.
http://www.asinglepixel.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: Core Data question

2008-08-10 Thread Graham Perks

On Aug 10, 2008, at 8:39 PM, Sandro Noel wrote:

So I think my question here, is, what should I use when inserting a  
detail object to properly set the relationship to Account.
some example on how I should approach the problem would be nice, or  
a step-by-step :D


I do this, where I have an EventImage that refers back to a main  
Event, "self" is the managed object for the Event, which is your  
Account:



// create new EventImage, this would be akin to your  
AccountDetails

imageHolder = (EventImage*)
[NSEntityDescription  
insertNewObjectForEntityForName:@"EventImage"
  inManagedObjectContext: 
[self managedObjectContext]];


[imageHolder setImage:image]; // set some data in the new  
object


// Add reference from Event to it's Image
[self setValue:imageHolder forKey:@"imageHolder"];

// Add the reverse relationship, from the image back to the event.
[imageHolder setValue:self forKey:@"event"];

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 versioning woes

2008-08-10 Thread mmalc crawford


On Aug 10, 2008, at 6:12 PM, Steve Steinitz wrote:


ps. one special problem I have is that I don't want the migration to
happen automatically because four users share the same database.




"If your application does support versioning and you choose to use  
custom version skew detection and migration bootstrapping, before  
opening a store you should check (using  
isConfiguration:compatibleWithStoreMetadata:) whether its schema is  
compatible with the coordinator’s model: if it is, you can use  
addPersistentStoreWithType:configuration:URL:options:error: to open  
the store directly; if it is not, you must migrate the store first  
then open it (again  
usingaddPersistentStoreWithType:configuration:URL:options:error:)."


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: Core Data question

2008-08-10 Thread mmalc crawford


On Aug 10, 2008, at 6:39 PM, Sandro Noel wrote:

So I think my question here, is, what should I use when inserting a  
detail object to properly set the relationship to Account.
some example on how I should approach the problem would be nice, or  
a step-by-step









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: Core Data question

2008-08-10 Thread Sandro Noel

Greetings.

I've read the documentation on core data over again, and I'm still  
confused about how to manipulate relationships.
every time I try an insert/add and there is a relationship involved,  
the insert crashes.

(programatically that is, bindings work just fine)

maybe, the way I think it is just not right, you see I think it in  
terms of SQL,
I've done SQL fir the past 17 years, so. it's kind of hard to think  
otherwise.


table Account
table Account details.
Relationship: Account <---one to many--->> AcountDetails

If I want to insert an account detail, the foreign key of that account  
detail will be linked to the Primary key of the Account.
usually I use the auto-incremented id's, if I enforce integrity on  
that relationship, there is no way I will be able to insert

an account detail if the account I want to link to is non existent.

If I want to use an specific account i'll just query the database and  
ask the user to choose an account, i'll keep it's ID

and use it for the future inserts.

In Core Data, I'm out of clues on how to insert an object that has a  
relationship.
I've tried to query the account table for the NSManagedObject, and  
assign it to the property account in my account details object.
but that failed. Then I tried using the account name as a string and  
assign it to the same property, and, well it failed.


So I think my question here, is, what should I use when inserting a  
detail object to properly set the relationship to Account.
some example on how I should approach the problem would be nice, or a  
step-by-step :D


Thank you in advance!
Sandro.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 versioning woes

2008-08-10 Thread Steve Steinitz
Hi Graham,

On 10/8/08, Graham Perks wrote:

>>Now when I save my document I get a sheet saying, "This 
>>document's  file has been changed by another application since 
>>you opened or  saved it", and asking if I want to save or not. 
>>Eh? What's that all  about?
>
>The document that's open post-migration is the "foo~" version - 
>the  backup of the old file. So of course it can't save it. How 
>did I mess  things up to get the tilde backup version open 
>following migration?  The upgraded file "foo" is correctly in 
>place, and can be edited once  opened normally.

Perhaps you feel like you are talking to yourself but I assure you
myself and others are watching your progress.  The migration, in its
current state, presents many difficulties and deserves further attention
from Apple.

I eventually had to roll back to my 10.4 migration which is working well
but is messy and hard to maintain.  So, we're counting on you and other
brave pioneers to pave the way.

Steve

ps. one special problem I have is that I don't want the migration to
happen automatically because four users share the same database.  The
file-level information you describe may help that.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa-dev Digest, Vol 5, Issue 1427

2008-08-10 Thread Steve Steinitz

Hi Graham,

On 10/8/08, Graham Perks wrote:

Now when I save my document I get a sheet saying, "This 
document's  file has been changed by another application since 
you opened or  saved it", and asking if I want to save or not. 
Eh? What's that all  about?


The document that's open post-migration is the "foo~" version - 
the  backup of the old file. So of course it can't save it. How 
did I mess  things up to get the tilde backup version open 
following migration?  The upgraded file "foo" is correctly in 
place, and can be edited once  opened normally.


Perhaps you feel like you are talking to yourself but I assure you
myself and others are watching your progress.  The migration, in its
current state, presents many difficulties and deserves further attention
from Apple.

I eventually had to roll back to my 10.4 migration which is 
working well
but is messy and hard to maintain.  So, we're counting on you 
and other

brave pioneers to pave the way.

Steve

ps. one special problem I have is that I don't want the 
migration to
happen automatically because four users share the same 
database.  The

file-level information you describe may help that.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Challenge 18 in Hillegass Book

2008-08-10 Thread Erik Buck

But the question I think is still valid and one I'm I'm trying to
figure out myself. How, for instance, would you have the view request
data from the document (or any other object for that matter). I
understand that it may not always be the best design choices but how
is it done? Posting notifications is about the only way I can think of
and perhaps sending self as the context info.

Ashley Perrien


How would you have a view request data from the documet ?

- You could use a Data Source like NSTableView and let the document  
instance be the Data Source (connected via File's Owner).
- You could use NSViewController instances like NSCollectionView and  
give each NSViewController a pointer to a document.
- You could send a message up the responder chain on the usually valid  
assumption that the right document instance will be in the responder  
chain.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Challenge 18 in Hillegass Book

2008-08-10 Thread Dave Carrigan


On Aug 10, 2008, at 5:22 PM, Ashley Perrien wrote:

But the question I think is still valid and one I'm I'm trying to  
figure out myself. How, for instance, would you have the view  
request data from the document (or any other object for that matter).


id doc = [[[self window] windowController] document]

--
Dave Carrigan
[EMAIL PROTECTED]
Seattle, WA, USA



PGP.sig
Description: This is a digitally signed message part
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Challenge 18 in Hillegass Book

2008-08-10 Thread Ashley Perrien

On Sat, Aug 9, 2008 at 8:54 PM, James Gorham <[EMAIL PROTECTED]> wrote:
I think that's where I'm unclear. Making the Document class aware  
of the
view is easy enough with an IBOutlet. But how to properly make the  
view

aware of the document I'm unsure of.


You're missing the point.  You don't connect your NSDocument (model)
to your views, you have a controller in between.  This controller is
responsible for noticing/being notified when the document changes so
it can update the view, and it is also responsible for noticing/being
notified when the view changes so it can update the document.


But the question I think is still valid and one I'm I'm trying to  
figure out myself. How, for instance, would you have the view request  
data from the document (or any other object for that matter). I  
understand that it may not always be the best design choices but how  
is it done? Posting notifications is about the only way I can think of  
and perhaps sending self as the context info.


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: Does [NSApp setApplicationIconImage] leak memory?

2008-08-10 Thread Matt Neuburg
On or about 8/10/08 4:37 PM, thus spake "Kyle Sluder"
<[EMAIL PROTECTED]>:

> On Fri, Aug 8, 2008 at 9:02 AM, Matt Neuburg <[EMAIL PROTECTED]> wrote:
>> Wrap each call to setApplicationIconImage in an autorelease pool creation
>> and release, like this:
>> 
>>NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
>>[NSApp setApplicationIconImage: whatever];
>>[pool release];
> 
> Okay, sorry for jumping in late, but I don't understand how this would
> solve the problem.  Since we're talking about NSApplication, AppKit
> has already created an NSAutoreleasePool, so it's not like
> -setApplicationIconImage: is autoreleasing an object when there's no
> autorelease pool stack.  Therefore, regardless of whether it's an
> AppKit autorelease pool or your own autorelease pool, any autoreleased
> object will still only get one -release message.  Creating your own
> autorelease pool should only make it happen "now" instead of "later".

That's perhaps perfectly true. But "later" could be a LOT later - and in the
meantime quite a lot of memory could pile up. For example, it is the nature
of the Cocoa event loop that the autorelease pool gets cleaned out when the
user switches to another app and back to your app. But that might not happen
for quite some time. To cite an example in my own life, in an app where I
was creating a lot of autoreleased strings as I gathered data from a huge
MySQL database, I actually caused my computer to freeze up for lack of
memory. When I created my own autorelease pool and released it every n times
thru the loop, the problem went away. This is, indeed, an *extremely* common
technique for doing exactly what you say - making it happen "now". You can
read up on Cocoa memory management here:

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

Notice in particular this phrase:

> If you write a loop that creates many temporary objects, you may create an
> autorelease pool inside the loop to dispose of those objects before the next
> iteration. This can help reduce the maximum memory footprint of the
> application.

So, to resume, it may in fact be that the OP's app is NOT truly "leaking" -
but rather, that exactly what I'm describing here is what's happening to
him: the built-in autorelease pool is just piling up and not getting
released, because the event loop hasn't exited yet. The fact that the
problem he is seeing does in fact go away for him when he does what I
suggested is an indication that it is. This is one of the possible
conclusions towards which, in my Socratic little way, I'm trying to lead the
OP. Stay tuned. m.
 
-- 
matt neuburg, phd = [EMAIL PROTECTED], http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, http://tinyurl.com/2ouo3b
Take Control of Customizing Leopard, http://tinyurl.com/2t9629
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: including a cocoa bundle in a carbon app

2008-08-10 Thread Uli Kusterer

On 10.08.2008, at 19:38, Bob Sabiston wrote:
 I got my Cocoa bundle to compile on the Intel machine.  It still  
doesn't load within my app, though.  Is there something special I  
need to do to include it in my project? I just dragged it in on the  
left, amongst all the other types of files, and it gave me a menu of  
targets from which I selected the correct one.  But the load is  
still failing.  I'm using the function below, gotten from Apple's  
examples.  Anyone know what could be the problem?  CFBundleCreate is  
just setting bundlePtr to 0, I don't know why.



 I've done stuff like that and it worked fine for me (heck, I've  
loaded CFM bundles into Mach-O apps). What template did you use as a  
basis for your bundle? You keep saying bundle, but the variable names  
mention frameworks. Now, there are different ways of building stuff  
like that. E.g. frameworks contain a path they expect to be loaded at  
(installation path setting), while bundles as they're used for plugins  
generally don't.


 Did you perhaps mix those up? Alternately, are you perhaps mixing  
debug and release builds? Anything not 100% homogeneous in there?


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Does [NSApp setApplicationIconImage] leak memory?

2008-08-10 Thread Kyle Sluder
On Fri, Aug 8, 2008 at 9:02 AM, Matt Neuburg <[EMAIL PROTECTED]> wrote:
> Wrap each call to setApplicationIconImage in an autorelease pool creation
> and release, like this:
>
>NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
>[NSApp setApplicationIconImage: whatever];
>[pool release];

Okay, sorry for jumping in late, but I don't understand how this would
solve the problem.  Since we're talking about NSApplication, AppKit
has already created an NSAutoreleasePool, so it's not like
-setApplicationIconImage: is autoreleasing an object when there's no
autorelease pool stack.  Therefore, regardless of whether it's an
AppKit autorelease pool or your own autorelease pool, any autoreleased
object will still only get one -release message.  Creating your own
autorelease pool should only make it happen "now" instead of "later".

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


Re: Hiding the disclosure triangle of a specific group item in a bound NSOutlineView

2008-08-10 Thread Kyle Sluder
On Sun, Aug 10, 2008 at 7:29 PM, Markus Spoettl
<[EMAIL PROTECTED]> wrote:
> Thanks a lot, works perfectly!

No problem, but please do file an enhancement request
(http://bugreport.apple.com) so that this becomes part of the standard
NSOutlineView API.  It's one of the few (if not the only) things
lacking in a full source list implementation.  It'll probably be
marked as a duplicate, but the engineers can best gauge the demand for
a feature by how many enhancement requests are filed against it.

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


Re: How to switch off NSCollectionView fade animations

2008-08-10 Thread Kyle Sluder
On Sun, Aug 10, 2008 at 3:22 PM, Markus Spoettl
<[EMAIL PROTECTED]> wrote:
> So I'd really really like to completely switch animation off for the
> collection view if that is possible. Is it?

Dunno if it's possible.  If you want to try to hack around it, see if
NSCollectionView posts any notifications when it's starting to
animate.  Then have your views listen for those notifications and, in
-drawRect:, draw some sort of cached bitmap representation or other
efficient output.

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]


Re: Hiding the disclosure triangle of a specific group item in a bound NSOutlineView

2008-08-10 Thread Markus Spoettl

On Aug 10, 2008, at 4:27 PM, Kyle Sluder wrote:

From the documentation:

"You can override this method in a subclass to return a custom frame
for the outline button cell. If your override returns an empty rect,
no outline cell is drawn for that row. You might do that, for example,
so that the disclosure triangle will not be shown for a row that
should never be expanded."

Then you'll want to manually expand all of those entries.  And then
you'll want to file a bug with Apple to make this part of the
NSOutlineView API.



Thanks a lot, works perfectly!

Regards
Markus
--
__
Markus Spoettl



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: Hiding the disclosure triangle of a specific group item in a bound NSOutlineView

2008-08-10 Thread Kyle Sluder
On Sun, Aug 10, 2008 at 7:13 PM, Markus Spoettl
<[EMAIL PROTECTED]> wrote:
>  I have an NSOutlineView based source list bound to a tree controller and I
> can't figure out how to create a group item that does not have a disclosure
> triangle - as an example, the MAILBOXES folder group in Mail.app does that.

The way to do it right now is to subclass NSOutlineView and override
-frameOfOutlineCellAtRow:.

>From the documentation:
"You can override this method in a subclass to return a custom frame
for the outline button cell. If your override returns an empty rect,
no outline cell is drawn for that row. You might do that, for example,
so that the disclosure triangle will not be shown for a row that
should never be expanded."

Then you'll want to manually expand all of those entries.  And then
you'll want to file a bug with Apple to make this part of the
NSOutlineView API.

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


Hiding the disclosure triangle of a specific group item in a bound NSOutlineView

2008-08-10 Thread Markus Spoettl

Hi List,

  I have an NSOutlineView based source list bound to a tree  
controller and I can't figure out how to create a group item that does  
not have a disclosure triangle - as an example, the MAILBOXES folder  
group in Mail.app does that.


I thought it might be possible by returning NO for the - 
shouldCollapseItem: and -shouldExpandItem: delegate methods for the  
group item in question but that doesn't do have that effect. It makes  
the item non-expandable/non-collapsable but it still shows its  
disclosure triangle. I also set the datasource (the outline is bound)  
and implemented the datasource method


- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable: 
(id)item


but that never gets called.

Any ideas on how to make the disclosure triangle disappear for a  
specific item? Is this only possible in data source driven outline  
views?


Regards
Markus
--
__
Markus Spoettl



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: including a cocoa bundle in a carbon app

2008-08-10 Thread Nick Zitzmann


On Aug 10, 2008, at 4:29 PM, Bob Sabiston wrote:

Now I am all in Xcode, compiling the app, the bundle, everything in  
Xcode and everything on an Intel Imac.  And it isn't working,   
that's why the question.



And you're using exactly the same compiler, the same compiler version,  
the same SDK, etc...?


Nick Zitzmann


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: including a cocoa bundle in a carbon app

2008-08-10 Thread Bob Sabiston

On Aug 10, 2008, at 2:40 PM, Bob Sabiston wrote:

2)  the bundle right now is compiling for i386, the native  
architecture of this machine.  does it need to be compiled for all  
4?  it should at least run on this machine if everything, app and  
bundle, is being compiled for this architecture, right?



You said the original project was a CodeWarrior project, right? That  
means the project uses PPC code.


Yeah but right after that I said that now I have moved to Xcode, Intel  
and the brave new world.  I only mention Codewarrior as an example of  
how what I am doing can work, the same code does work, in a more  
unlikely environment than my current all-Intel one.


Now I am all in Xcode, compiling the app, the bundle, everything in  
Xcode and everything on an Intel Imac.  And it isn't working,  that's  
why the question.


Bob

___

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

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

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

This email sent to [EMAIL PROTECTED]


CGPDF - Setting /Rotation

2008-08-10 Thread Pedro Cuenca

Hello,

I have some code that generates PDF data, and I would need to set the 
/Rotation entry of some of the pages. The following code correctly sets 
the /MediaBox entry to the rectangle specified in the page dictionary:


CGRect mediaBox = CGRectMake( 0.0, 0.0, 1024.0, 768.0 );
NSDictionary * pageInfo =
[
 NSDictionary dictionaryWithObjectsAndKeys:
 [NSData dataWithBytes: &mediaBox length: sizeof(mediaBox)], 
kCGPDFContextMediaBox,

 nil
];
CGPDFContextBeginPage( pdfContext, (CFDictionaryRef) pageInfo );

However, any attempt to set the @"Rotation" dictionary key seems to be 
ignored. I have tried using different types (NSNumber, NSString, NSData) 
for the value with the same unsuccessful result.


I couldn't find detailed documentation or sample code about 
CGPDFContextBeginPage(), although the documentation states it is 
preferred to CGContextBeginPage() since 10.4.


Is there anything I am missing, or is simply the Rotation key silently 
ignored? If so, can you hint towards any direction I could explore to 
generate this value in my PDF output?


Thanks,

--
Pedro
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: including a cocoa bundle in a carbon app

2008-08-10 Thread Nick Zitzmann


On Aug 10, 2008, at 2:40 PM, Bob Sabiston wrote:

2)  the bundle right now is compiling for i386, the native  
architecture of this machine.  does it need to be compiled for all  
4?  it should at least run on this machine if everything, app and  
bundle, is being compiled for this architecture, right?



You said the original project was a CodeWarrior project, right? That  
means the project uses PPC code. Applications cannot load code bundles  
or frameworks that were compiled for a CPU architecture other than the  
application's architecture, including 64-bit variants. There is no Mac  
OS 7 "mixed mode" in Mac OS X.


So either move your CodeWarrior project to Xcode if possible, and if  
not, then make the bundle compile for PPC only.


Nick Zitzmann


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: including a cocoa bundle in a carbon app

2008-08-10 Thread Bob Sabiston


On Aug 10, 2008, at 12:48 PM, Kyle Sluder wrote:

On Sun, Aug 10, 2008 at 1:38 PM, Bob Sabiston <[EMAIL PROTECTED]>  
wrote:
This bundle works when compiled in Xcode 2.4.1 on a G5 and then  
included in

a Codewarrior project.  But I haven't gotten it to work with the same
project on Intel in Xcode yet.  It is probably something simple  
that I'm

missing.


1) Is there a reason you're not using NSBundle, or maybe just
returning the CFBundleRef from your function?  Your use of an
out-pointer-to-CFBundleRef instead of a return value seems
unnecessary.

2) Are you sure the bundle itself is compiled for all four
architectures (x86, x86_64, ppc, and ppc64)?

--Kyle Sluder


1) No reason, except that I don't know what I'm doing, and that  
function came from Apple's example of how to include Cocoa in Carbon.


2)  the bundle right now is compiling for i386, the native  
architecture of this machine.  does it need to be compiled for all 4?   
it should at least run on this machine if everything, app and bundle,  
is being compiled for this architecture, right?


Bob

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Problem with friend function and gcc 4.2 with

2008-08-10 Thread Roni Music


You can read a discussion regarding this problem here:
http://bytes.com/forum/thread828536.html

it seems gcc 4.0 had a bug which is corrected in gcc 4.2



Message: 12
Date: Sat, 9 Aug 2008 09:36:17 -0600
From: Ken Worley <[EMAIL PROTECTED]>
Subject: Re: Problem with friend function and gcc 4.2 with
To: cocoa-dev cocoa-dev 
Cc: Roni Music <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

FWIW, it does in fact compile in 4.2 (and in 4.0) when formatted as
you suggest. I still believe the original format is correct and that
4.2 is the version with the bug. The info Clark Cox pointed out seems
to support that. In any case, a bug has been filed, so I'll know
Apple's point of view eventually :) Thanks for the input (and thanks
also to Clark and Thomas for responding).

rdar://6135771

Ken

On Aug 8, 2008, at 10:42 PM, Roni Music wrote:



I'm not a C++ expert but your code below should not compile (as I
see it)

You should declare the friend function inside the class:

class test1
{
public:

friend test1* newtest1(int x);
/*
the function newtest1() is now a friend to test1 class and may
access private member variables
and functions such as finishinit()
*/

snip
};

then define the function outside the class:

test1* newtest1(int x)
{
test1* anobj = new test1();
anobj->finishinit(x);
return anobj;
}

So if you code worked with gcc 4.0 and not gcc 4.2, then it seems
gcc 4.2 now works according to the C++ standard
and gcc 4.0 did not

Rolf





Message: 10
Date: Fri, 8 Aug 2008 16:41:42 -0600
From: Ken Worley <[EMAIL PROTECTED]>
Subject: Re: Problem with friend function and gcc 4.2 with
objective-c++
To: cocoa-dev cocoa-dev 
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=WINDOWS-1252; format=flowed;
delsp=yes

Hmmm, no response as of yet. I went ahead and submitted a bug against
Xcode: rdar://6135771
We'll see what happens.

Ken
On Aug 7, 2008, at 4:09 PM, Ken Worley wrote:


Hi all,

I'm using Xcode 3.1 and just switched to gcc 4.2 from 4.0, but I've
run into a problem with friend functions when compiling in
objective-
c++. I contrived an example that illustrates the problem:

1. Created new Cocoa project
2. Forced compilation of all files to use objective-c++
3. Changed content of main.m to below...

This project builds fine using gcc 4.0, but when I switch the
compiler setting to use gcc 4.2, I get the errors listed below. Any
clues would certainly be appreciated if I'm doing something wrong.
If not, I guess I'll file a bug...

Here's main.m:

#import 

class test1
{
public:

friend test1* newtest1(int x)
{
test1* anobj = new test1();
anobj->finishinit(x);
return anobj;
}

virtual ~test1()
{
}

private:

int avalue;

test1()
{
avalue = 0;
}

void finishinit(int x)
{
avalue = x;
}
};

int main(int argc, char *argv[])
{
test1* tobj = newtest1(5);
delete tobj;

  return NSApplicationMain(argc,  (const char **) argv);
}


Here's the build log:

Building target "Untitled" of project "Untitled" with configuration
"Debug" - (1 error)
   cd /Users/ken/Desktop/Untitled
  /Xcode3.1/Developer/usr/bin/gcc-4.2 -x objective-c++ -arch i386 -
fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks
-O0 -Wreturn-type -Wunused-variable -isysroot /Xcode3.1/Developer/
SDKs/MacOSX10.5.sdk -mfix-and-continue -fvisibility-inlines-hidden -
mmacosx-version-min=10.5 -gdwarf-2 -iquote /Users/ken/Desktop/
Untitled/build/Untitled.build/Debug/Untitled.build/Untitled-
generated-files.hmap -I/Users/ken/Desktop/Untitled/build/
Untitled.build/Debug/Untitled.build/Untitled-own-target-headers.hmap
-I/Users/ken/Desktop/Untitled/build/Untitled.build/Debug/
Untitled.build/Untitled-all-target-headers.hmap -iquote /Users/ken/
Desktop/Untitled/build/Untitled.build/Debug/Untitled.build/Untitled-
project-headers.hmap -F/Users/ken/Desktop/Untitled/build/Debug -I/
Users/ken/Desktop/Untitled/build/Debug/include -I/Users/ken/Desktop/
Untitled/build/Untitled.build/Debug/Untitled.build/DerivedSources -
include /var/folders/JE/JEJ3RSLHE9uIDGjXTRTisTI/-Caches-/
com.apple.Xcode.501/SharedPrecompiledHeaders/Untitled_Prefix-
brblicjbwwpqhfahflncgqpvarno/Untitled_Prefix.pch -c /Users/ken/
Desktop/Untitled/main.m -o /Users/ken/Desktop/Untitled/build/
Untitled.build/Debug/Untitled.build/Objects-normal/i386/main.o
/Users/ken/Desktop/Untitled/main.m: In function 'int main(int,
char**)':
/Users/ken/Desktop/Untitled/main.m:43: error: 'newtest1' was not
declared in this scope
/Users/ken/Desktop/Untitled/main.m:43: error: 'newtest1' was not
declared in this scope
Build failed (1 error)

Thanks,
Ken

--
Ken Worley
Software Engineer, Tiberius, Inc.



___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/coc

Hillegass' chapter #11: Core Data

2008-08-10 Thread Niklas Saers

Hi all,
I'm going through Hillegass' book 3rd edition, and I've come to the  
chapter I'm most excited about: Core Data. I came to the very exciting  
words "You are done. Build and run the application", but I must have  
missed something important: my window doesn't show! Would any of you  
be so kind to please point me in the right direction as to why my  
window doesn't load?


Further more, in my logs I get the message: "[  
valueForUndefinedKey:]: this class is not key value coding-compliant  
for the key photo" for both photo and datePurchased. What does this  
mean? I haven't added photo nor datePurchased to the table, I have  
kept them in the detail part of the window


The zipped project (40kb) is at http://www.yousendit.com/download/Q01HcmxRdWNHa05jR0E9PQ 
 for the next 7 days


Thank you VERY much in advance :-)

Cheers

Nik


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Memory Leaks & Instruments Questions

2008-08-10 Thread Michael Kaye

Hi all,

Relative newbie here so please be gentle :-)

I've ben running my app with leaks in Instruments and it is reporting  
a fair number of leaks.


On analyzing these leaks, they all appear to be related to apple  
frameworks methods/code and never as a direct result of any objects  
I've instantiated.


Therefore my question is, is whether this is correct and what you  
would normally expect to see? Or are the leaks indirectly caused by  
something I am doing? If the former should I just ignore them and if  
the latter how do I track down exactly where it is occurring.


Whilst we are on it, I have a second question and that is whether  
should I expect any singleton object to "appear" as a memory leak in  
Instruments. Obviously the point of a singleton is is that it has one  
instance and any instance variables exist with no dealloc. So does  
Instruments handle this or just report them as a leak?


Anyway I hope something can offer me some sound advice. Thanks in  
advance.


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]


How to switch off NSCollectionView fade animations

2008-08-10 Thread Markus Spoettl

Hello List,

  is there a way to switch off the fade-in and fade-out animation  
that take place when NSCollectionView shows new or hides removed  
items? Those things can really decrease performance when it displays a  
lot of collection items that have complex drawing routines. On top of  
it I keep getting assertion failures when the bound array changes  
while the collection view is hidden (bug reported already).


So I'd really really like to completely switch animation off for the  
collection view if that is possible. Is it?


I'm using Xcode 3.0 on 10.5.4

Regards
Markus
--
__
Markus Spoettl



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: Core Data versioning woes

2008-08-10 Thread Graham Perks
Now when I save my document I get a sheet saying, "This document's  
file has been changed by another application since you opened or  
saved it", and asking if I want to save or not. Eh? What's that all  
about?


The document that's open post-migration is the "foo~" version - the  
backup of the old file. So of course it can't save it. How did I mess  
things up to get the tilde backup version open following migration?  
The upgraded file "foo" is correctly in place, and can be edited once  
opened normally.


Cheers,
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: Core Data versioning woes

2008-08-10 Thread Graham Perks
So after some too-late coding and placing my NSLogs in the wrong  
place, I now find the normal Multiple Validation Errors. After dumping  
the extra messages in NSDetailedErrorsKey I see the offenders are  
items that are marked as transient but non-optional.  They're set in  
my entity's awakeFromFetch but since my entity class isn't used during  
migration, these fields were never getting set. As non-optional,  
that's a validation error.


Setting those transient fields to optional made the migration work.  
Yippee!


Now when I save my document I get a sheet saying, "This document's  
file has been changed by another application since you opened or saved  
it", and asking if I want to save or not. Eh? What's that all about?


Someone else had the same warning: http://lists.apple.com/archives/applescript-users/2008/Feb/msg00401.html 
 but no answer was offered there.


Any clues?

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: Lazy Loading of images

2008-08-10 Thread Kyle Sluder
On Fri, Aug 8, 2008 at 9:52 AM, Johannes Fahrenkrug
<[EMAIL PROTECTED]> wrote:
> I'd like to display placeholder images until the table cell gets
> displayed and then load the actual thumbnail, replacing the
> placeholder image with the real thumbnail once it has loaded.
> What would be the best way to do this? I'm thinking of something on
> the lines of a proxy object...

Are you using the NSTableView data source API?  I think that would be
easier for what you want to do.  I'd create a placeholder NSImage at
first, and when I'm asked for the data for my NSImage column, if I
haven't yet finished downloading the image for that particular row,
give the NSTableView my placeholder image.  Then, once the image has
finished downloading, call [myTableView
setNeedsDisplayInRect:NSIntersectionRect([myTableView
rectForColumn:indexOfImageColumn], [myTableView
rectForRow:rowOfUpdatedItem])].

Remember that the rows of an NSTableView don't actually exist as one
large dataset, so there isn't a one-to-one table cell to NSCell
correspondence.  Instead, each NSTableColumn has its own cell, that it
uses like a rubber stamp.  When a region of the table is marked as
dirty (setNeedsDisplay:/setNeedsDisplayInRect:), the table view
figures out which columns are affected, and tells them to draw
themselves.  Each column then asks for the data for each table cell
that needs to be redrawn, and passes this value off to the NSCell
assigned to that column, which does the real drawing.

So your image column has an NSImageCell.  When you start scrolling,
the NSTableView figures out which logical row and column numbers have
just been revealed by your scrolling maneuver, and kicks off the above
process.  Your data source is asked "alright, row 12 column 2 needs to
be painted, gimme the data", and then hands that data off to the cell
belonging to the column.  The dirty little secret is that from the
table view's perspective, there aren't actually any rows at all; it
just does a bunch of math based on where the scroll point is located
to convert graphics coordinates to logical rows.  Your data source is
none the wiser.

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


Re: Web links with PyObjC

2008-08-10 Thread Kyle Sluder
On Sun, Aug 10, 2008 at 12:26 AM, Aaron <[EMAIL PROTECTED]> wrote:
> I hope I've posted in the right list. I'm a student  developer (first-time
> for the Mac), and I've been toying around with PyObjC, and I would like to
> know how to make an NSimage (arrow) open a link in the default browser. The
> code is all in Python.

NSImage has nothing to do with user interface.  Did you mean
NSImageView?  Since you're describing the semantics of a button, you
should probably be using NSButton instead.  Perhaps make it
borderless.  Then set target/action as normal.

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


Re: including a cocoa bundle in a carbon app

2008-08-10 Thread Kyle Sluder
On Sun, Aug 10, 2008 at 1:38 PM, Bob Sabiston <[EMAIL PROTECTED]> wrote:
> This bundle works when compiled in Xcode 2.4.1 on a G5 and then included in
> a Codewarrior project.  But I haven't gotten it to work with the same
> project on Intel in Xcode yet.  It is probably something simple that I'm
> missing.

1) Is there a reason you're not using NSBundle, or maybe just
returning the CFBundleRef from your function?  Your use of an
out-pointer-to-CFBundleRef instead of a return value seems
unnecessary.

2) Are you sure the bundle itself is compiled for all four
architectures (x86, x86_64, ppc, and ppc64)?

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


including a cocoa bundle in a carbon app

2008-08-10 Thread Bob Sabiston

Hi,

  I got my Cocoa bundle to compile on the Intel machine.  It still  
doesn't load within my app, though.  Is there something special I need  
to do to include it in my project? I just dragged it in on the left,  
amongst all the other types of files, and it gave me a menu of targets  
from which I selected the correct one.  But the load is still  
failing.  I'm using the function below, gotten from Apple's examples.   
Anyone know what could be the problem?  CFBundleCreate is just setting  
bundlePtr to 0, I don't know why.


This bundle works when compiled in Xcode 2.4.1 on a G5 and then  
included in a Codewarrior project.  But I haven't gotten it to work  
with the same project on Intel in Xcode yet.  It is probably something  
simple that I'm missing.


Thanks for any suggestions!
Bob


void myLoadPrivateFrameworkBundle(CFStringRef framework, CFBundleRef  
*bundlePtr)

{
CFBundleRef appBundle = NULL;
CFURLRef baseURL = NULL;
CFURLRef bundleURL = NULL;

appBundle = CFBundleGetMainBundle();
require(appBundle, CantFindMainBundle);

baseURL = CFBundleCopyPrivateFrameworksURL(appBundle);
require(baseURL, CantCopyURL);

bundleURL =  
CFURLCreateCopyAppendingPathComponent(kCFAllocatorSystemDefault,  
baseURL, framework, false);

require(bundleURL, CantCreateBundleURL);

*bundlePtr = CFBundleCreate(NULL, bundleURL);

CFRelease(bundleURL);
CantCreateBundleURL:
CFRelease(baseURL);
CantCopyURL:
CantFindMainBundle:
return;
}

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Bindings array count to a label ( was Re: KVC beginners question )

2008-08-10 Thread Keary Suska
8/10/08 10:52 AM, also sprach [EMAIL PROTECTED]:

> I did see the array operators ... and in IB ... i have the label set
> up to BIND ValueWithPattern ... bound to the controller, keypath
> "[EMAIL PROTECTED]".
> 
> I'm sure i'm just missing something VERY obvious/simple. sigh.

We need more info then. What is not working? Do you get an exception? Do you
always get a count of 0? Do you get a count, but it never changes? All of
these issues can have different causes.
 
> On Aug 10, 2008, at Sun-08 /10 /08-12:37 PM, Keary Suska wrote:
> 
>> 8/10/08 10:09 AM, also sprach [EMAIL PROTECTED]:
>> 
>>> I am attempting to understand KVC and am having a bit of trouble
>>> understanding some of the examples, as well as the documentation.
>>> 
>>> What i'd like to be able to do is have a label in a window
>>> automagically updated with the current count of an array. I've tried
>>> several things in IB and in code but do not actually get the "count"
>>> of the items in the array.
>>> 
>>> in the controller, the array is called "browserData" and basically
>>> drives a coverflow view and an IKBrowserView. the label is to show
>>> how
>>> many objects are in the array.
>>> 
>>> I very much see the value in KVC/O and am wanting to make this a part
>>> of my basic coding practices but for some reason ( maybe lack of
>>> coffee/caffeine at this point) is preventing me from actually
>>> grasping
>>> it.
>> 
>> You need an array operator:
>> http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Con
>> cepts/ArrayOperators.html#//apple_ref/doc/uid/20002176-184206


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


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Challenge 18 in Hillegass Book

2008-08-10 Thread Kyle Sluder
On Sat, Aug 9, 2008 at 8:54 PM, James Gorham <[EMAIL PROTECTED]> wrote:
> I think that's where I'm unclear. Making the Document class aware of the
> view is easy enough with an IBOutlet. But how to properly make the view
> aware of the document I'm unsure of.

You're missing the point.  You don't connect your NSDocument (model)
to your views, you have a controller in between.  This controller is
responsible for noticing/being notified when the document changes so
it can update the view, and it is also responsible for noticing/being
notified when the view changes so it can update the document.

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


Bindings array count to a label ( was Re: KVC beginners question )

2008-08-10 Thread Jack Carbaugh
I did see the array operators ... and in IB ... i have the label set  
up to BIND ValueWithPattern ... bound to the controller, keypath  
"[EMAIL PROTECTED]".


I'm sure i'm just missing something VERY obvious/simple. sigh.

Thanks !!!

Jack
On Aug 10, 2008, at Sun-08 /10 /08-12:37 PM, Keary Suska wrote:


8/10/08 10:09 AM, also sprach [EMAIL PROTECTED]:


I am attempting to understand KVC and am having a bit of trouble
understanding some of the examples, as well as the documentation.

What i'd like to be able to do is have a label in a window
automagically updated with the current count of an array. I've tried
several things in IB and in code but do not actually get the "count"
of the items in the array.

in the controller, the array is called "browserData" and basically
drives a coverflow view and an IKBrowserView. the label is to show  
how

many objects are in the array.

I very much see the value in KVC/O and am wanting to make this a part
of my basic coding practices but for some reason ( maybe lack of
coffee/caffeine at this point) is preventing me from actually  
grasping

it.


You need an array operator:
http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Con
cepts/ArrayOperators.html#//apple_ref/doc/uid/20002176-184206

HTH,

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


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/intrntmn%40aol.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: KVC beginners question

2008-08-10 Thread Keary Suska
8/10/08 10:09 AM, also sprach [EMAIL PROTECTED]:

> I am attempting to understand KVC and am having a bit of trouble
> understanding some of the examples, as well as the documentation.
> 
> What i'd like to be able to do is have a label in a window
> automagically updated with the current count of an array. I've tried
> several things in IB and in code but do not actually get the "count"
> of the items in the array.
> 
> in the controller, the array is called "browserData" and basically
> drives a coverflow view and an IKBrowserView. the label is to show how
> many objects are in the array.
> 
> I very much see the value in KVC/O and am wanting to make this a part
> of my basic coding practices but for some reason ( maybe lack of
> coffee/caffeine at this point) is preventing me from actually grasping
> it.

You need an array operator:
http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Con
cepts/ArrayOperators.html#//apple_ref/doc/uid/20002176-184206

HTH,

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


___

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

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

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

This email sent to [EMAIL PROTECTED]


Insert token at selection of NSTokenField?

2008-08-10 Thread Vincent E.

Hi,

I'm wondering if there is any secret technique for inserting a token  
into an NSTokenField at the current cursor position.
I have already tried to code it myself and aborted as my code turned  
out to be way too unreliable.
So before I spend another day trying to get it done myself I thought I  
should better ask the crowd.


Getting/setting the NSEditor's selection range is fairly simple but  
how do I tell the NSTokenField
to not insert the new token at the very end of the NSTokenFieldbut at  
the current selection range?
(And replace the selection with the new token or split plaintext  
segments if necessary)


Any hints? Has nobody ever needed this? The web doesn't say anything  
helpful either.


Cheers,
Vincent
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 versioning woes

2008-08-10 Thread Graham Perks
Astonishing: The migration happens for sure: I end up with a "foo.new"  
file adjacent to my original file. If I delete the original and open  
the .new file, it is the migrated version complete will all data,  
including the new attribute (with its default value) that I added in  
the new data model version!


So the migration happened... I have a .new file which is the upgraded  
file... but what would stop the upgrade process copying the .new file  
over the original data file?


The original file is not locked or readonly. Isn't it supposed to  
backup the old file to foo.~  ? That hasn't happened. Why not? No  
useful errors in the console. Any ideas on what to check?


Cheers,
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: Core Data versioning woes

2008-08-10 Thread Graham Perks
I've got a little further.  I made both model versions identical. Then  
reset the file back to the old version. Doc opened OK. Add one  
attribute to the file, reset the file, and I now get:


Error Domain=NSCocoaErrorDomain Code=256 "The file could not be opened."

from initWithContentsOfUrl:... Not very useful. Nothing from Core Data  
about why the file couldn't be opened. I do get the "blah.new" file  
adjacent to my data file, so I know migration has been attempted.


I swear Core Data costs me as much time as it saves me :-)

Graham.

On Aug 10, 2008, at 12:36 AM, Graham Perks wrote:

Wow, versioning looks SO much better in 10.5. I had my own code for  
10.4, I am glad to delete 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]


CGImage failed to write Exif Auxiliary metadata to image

2008-08-10 Thread Rawitat Pulam

Hi,

I'm having problems trying to write photo metadata. Actually, I want  
to copy all metadata I could get via the  
CGImageSourceCopyPropertiesAtIndex function to the destination image  
(CGImageDestinationRef).


Reading the metadata isn't a problem. I could get all that are  
available. Simple NSLog of the properties confirmed this.


The problem is when writing the metadata to the destination image. I  
tried both CGImageDestinationAddImage and use the properties as the  
option dictionary, and also tried CGImageDestinationSetProperties.  
Both didn't work. The metadata in the ExifAux dictionary of the  
properties, read correctly from the function mentioned above, failed  
to be written to the output image. I happen to need one of the  
metadata in that dictionary (LensModel).


I looked in the CGImage Properties, it should support the Exif  
Auxiliary metadata and even have key defined for lens model. However,  
somehow it can't write the output image with that dictionary.


I'm using Mac OS X 10.5 and ImageIO framework 2.0.2 and already have  
Xcode set the project so it use 10.5 SDK, not 10.4.


Is there anyway I could overcome this? Or is it a limitation of  
current CF/ImageIO framework?


Best regards,
Rawitat Pulam


Rawitat Pulam
Lecturer
Department of Computing, Faculty of Science
Silpakorn University, Sanam Chandra Palace Campus
Nakornpathom, Thailand

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


KVC beginners question

2008-08-10 Thread Jack Carbaugh
I am attempting to understand KVC and am having a bit of trouble  
understanding some of the examples, as well as the documentation.


What i'd like to be able to do is have a label in a window  
automagically updated with the current count of an array. I've tried  
several things in IB and in code but do not actually get the "count"  
of the items in the array.


in the controller, the array is called "browserData" and basically  
drives a coverflow view and an IKBrowserView. the label is to show how  
many objects are in the array.


I very much see the value in KVC/O and am wanting to make this a part  
of my basic coding practices but for some reason ( maybe lack of  
coffee/caffeine at this point) is preventing me from actually grasping  
it.


Thanks in advance for any help/guidance.

Jack
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Accessing member variables from another thread crashes

2008-08-10 Thread Steve Christensen

On Aug 9, 2008, at 5:24 PM, Dennis Harms wrote:

I've created a class with some member variables of type NSString*.  
In the
init function of the class, I write something into those strings.  
Now I call
a function of the initialized class instance as a new thread and  
try to read
from those member variables. This leads to a crash... Can someone  
give me a

hint as to why this won't work?

Here's my code, shrunk down to just the problematic part:

-- MyClass.h -
@interface MyClass: NSObject
{
@private
NSString* baseURL;
}

- (id) initWithHost: (NSString*) _url;
- (void) doSomething: (id) object;

@end
--

-- MyClass.m -
@implementation MyClass

- (id) initWithHost: (NSString*) _url
{
self = [super init];
baseURL = [NSString stringWithString: _url];


One thing I notice right off is that you're initializing an instance  
variable using a method that creates an autoreleased string, which  
will go away next time through the application's event loop. How  
about "baseURL = [_url retain];" instead? If the string pointed to by  
_url is really immutable, you just need to increment the retain count  
so it'll continue to exist for the lifetime of your object (and then  
be sure to call [_url release] in your object's dealloc method so you  
don't leak memory).



return self;
}

- (void) doSomething: (id) object
{
NSString *url = [NSString stringWithString: baseURL];  // <--  
the crash

occurs even when just reading the member


You might check that baseURL is still valid just before executing  
this statement when you have your app set up to execute this in other  
than the main thread. Making the change, above, will likely fix the  
crash.


Also, why are you calling -stringWithString: here? You already have a  
perfectly good string in baseURL. Use it directly.



}

@end
--

I've tried calling the function in the same thread, as well as three
different ways of calling it in a seperate thread. Every time there's
another thread involved, it crashes when accessing the member  
variable. If

the function doesn't access any members, the code works just fine...

instance = [[MyClass alloc] initWithHost: txtHost.text];
[instance doSomething: nil];   // Works
[instance performSelectorInBackground: @selector(doSomething:)  
withObject:

nil];   // Doesn't work
[[[NSThread alloc] initWithTarget: instance selector:
@selector(doSomething:) object: nil] start];   // Doesn't work
[NSThread detachNewThreadSelector: @selector(doSomething:) toTarget:
instance withObject: nil];   // Doesn't work


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Accessing member variables from another thread crashes

2008-08-10 Thread Dave Fernandes
This isn't really a multithreading issue, it is a memory management  
issue. the string you have created is autoreleased, you must retain  
it if you want it to remain in memory. See:


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


On Aug 9, 2008, at 8:24 PM, Dennis Harms wrote:

I'm new to Cocoa and objective C development and I've got a big  
problem with

multithreading:

I've created a class with some member variables of type NSString*.  
In the
init function of the class, I write something into those strings.  
Now I call
a function of the initialized class instance as a new thread and  
try to read
from those member variables. This leads to a crash... Can someone  
give me a

hint as to why this won't work?

Here's my code, shrunk down to just the problematic part:

-- MyClass.h -
@interface MyClass: NSObject
{
@private
NSString* baseURL;
}

- (id) initWithHost: (NSString*) _url;
- (void) doSomething: (id) object;

@end
--

-- MyClass.m -
@implementation MyClass

- (id) initWithHost: (NSString*) _url
{
self = [super init];
baseURL = [NSString stringWithString: _url];
return self;
}

- (void) doSomething: (id) object
{
NSString *url = [NSString stringWithString: baseURL];  // <--  
the crash

occurs even when just reading the member
}

@end
--

I've tried calling the function in the same thread, as well as three
different ways of calling it in a seperate thread. Every time there's
another thread involved, it crashes when accessing the member  
variable. If

the function doesn't access any members, the code works just fine...

instance = [[MyClass alloc] initWithHost: txtHost.text];
[instance doSomething: nil];   // Works
[instance performSelectorInBackground: @selector(doSomething:)  
withObject:

nil];   // Doesn't work
[[[NSThread alloc] initWithTarget: instance selector:
@selector(doSomething:) object: nil] start];   // Doesn't work
[NSThread detachNewThreadSelector: @selector(doSomething:) toTarget:
instance withObject: nil];   // Doesn't work

Thanks,
  Dennis
___

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

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

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


This email sent to [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: Accessing member variables from another thread crashes

2008-08-10 Thread Keary Suska
8/9/08 6:24 PM, also sprach [EMAIL PROTECTED]:

> baseURL = [NSString stringWithString: _url];

Are you aware that the string in this case is autoreleased, and what that
implies? If not, search for "memory management" and you are sure to find the
memory management guidelines/rules for Cocoa.

Best,

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


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Controlling line-breaking in a text view

2008-08-10 Thread John Joyce
You might consider subclassing, but you might also want to read a lot  
more stuff first.

Cocoa (and Carbon) text facilities are pretty deep.

There is nothing about a bug in the text system. It is just that the  
text handling in Cocoa is very sophisticated and is designed to handle  
things depending on language and locale and function. Where and how to  
break words and what is a word can be a very complex subject, even  
just in one language. Even in page layout for print media, some things  
are hand-tooled.


For your purposes, you might want something that recognizes a path or  
URL and formats it.


Text Layout Programming Guide
file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Conceptual/TextLayout/TextLayout.html

NSTypesetter Class
file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTypesetter_Class/Reference/Reference.html

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: CGImage masking via CGCreateImageWithMask getting odd results

2008-08-10 Thread Jean-Daniel Dupas


Le 10 août 08 à 06:08, Nick Veys a écrit :


I'm getting some interesting results with an image mask I'm trying to
apply.  I'm trying to vignette away the edges of some small images and
instead of getting transparency behind them, I'm getting the black
(presumably from the mask).

I'm simply calling CGImageCreateWithMask(image, mask) with two
CGImageRefs, image is 'image.png', attached.  mask is 'mask.png',
attached.  The result I'm seeing is 'result.png', also attached.
Instead of seeing through, I see black (the background is white...)!
Argh.  I've played with the views behind it and set their colors to
all kinds of fun things and I never see that color, just the black
from the mask.  Am I completely misinterpreting what the mask is?

From the docs it says if the mask is an image, which it is via

verification with CGImageIsMask(), it uses the grayscale as an alpha
value, so it would effectively fade the corners of my images into the
layer behind it.

Even stranger, if I go and put a few lines across the image, say a
solid black line, a 50% gray line, and a 25% gray line, I see on the
final composited image a solid black line, a 50% transparent line and
a 25% transparent line ('lines.png', attached).  So there seems to be
some logic behind the operation that's occurring, it's just definitely
not what I'm looking for.

Any info is appreciated!


Have a look at the Core Graphics doc.

http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_images/chapter_12_section_6.html

There ii some sample image to explain how mask works.
First, you have to create a mask using CGImageMaskCreate().
This function look complex, but if you already have a CGImage, you can  
convert it into a mask using this call:
CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(image),  
CGImageGetHeight(image),
 
CGImageGetBitsPerComponent(image), CGImageGetBitsPerPixel(image),
CGImageGetBytesPerRow(image),  
CGImageGetDataProvider(image), NULL, false);


A mask is an image where white describe zone that should be ignored,  
and black zone that will be display (the opposite of your mask in fact).




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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, dynamic accessors and compiler warnings

2008-08-10 Thread Jim Correia

On Aug 10, 2008, at 10:02 AM, Chris Idou wrote:

The Core data doco suggests that if you have a 1:M accessor for  
FooBar that you define in a header:


- (void)addFooBarObject:(FooBar *)value;

In order to suppress compiler warnings for using this dynamically  
generated method. However this creates its own "incomplete  
implementation" compiler warning for the class.


(Actually the doco uses a category rather than a class, but the  
principle should be the same).


Do what the documentation suggests, and you'll avoid the warning.

That is, declare your dynamic accessor methods on a category which has  
no matching @implementation.


Jim

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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, dynamic accessors and compiler warnings

2008-08-10 Thread Chris Idou
The Core data doco suggests that if you have a 1:M accessor for FooBar that you 
define in a header:

- (void)addFooBarObject:(FooBar *)value;

In order to suppress compiler warnings for using this dynamically generated 
method. However this creates its own "incomplete implementation" compiler 
warning for the class.

(Actually the doco uses a category rather than a class, but the principle 
should be the same).

How do I suppress compiler warnings for core-data 1:M accessors with custom 
classes?





  
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 versioning woes

2008-08-10 Thread Graham Perks
Wow, versioning looks SO much better in 10.5. I had my own code for  
10.4, I am glad to delete it.


I got a quick demo versioning app going, thanks to some excellent  
advice at http://www.timisted.net/blog/archive/core-data-migration/.   
The docs should really include that NSDocument override for   
configurePersistentStoreCoordinatorForURL:.


Anyway, in my real application I am having trouble. I created a new  
model version with an extra dummy field. Created the mapping file. And  
now I get an empty document shown with the following error in the  
console:


*** -[NSConcreteValue count]: unrecognized selector sent to instance  
0x16577ca0


I get that line twice. Any ideas?  I don't know where to even start  
with that one.


My 10.4-style versioning code I optimistically removed from the  
project. Please don't make me bring that mess back :-)


Thanks,
Graham Perks.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Web links with PyObjC

2008-08-10 Thread Aaron

Hello!

I hope I've posted in the right list. I'm a student  developer (first- 
time for the Mac), and I've been toying around with PyObjC, and I  
would like to know how to make an NSimage (arrow) open a link in the  
default browser. The code is all in Python.


Thanks,
Aaron T.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Accessing member variables from another thread crashes

2008-08-10 Thread Dennis Harms
I'm new to Cocoa and objective C development and I've got a big problem with
multithreading:

I've created a class with some member variables of type NSString*. In the
init function of the class, I write something into those strings. Now I call
a function of the initialized class instance as a new thread and try to read
from those member variables. This leads to a crash... Can someone give me a
hint as to why this won't work?

Here's my code, shrunk down to just the problematic part:

-- MyClass.h -
@interface MyClass: NSObject
{
@private
NSString* baseURL;
}

- (id) initWithHost: (NSString*) _url;
- (void) doSomething: (id) object;

@end
--

-- MyClass.m -
@implementation MyClass

- (id) initWithHost: (NSString*) _url
{
self = [super init];
baseURL = [NSString stringWithString: _url];
return self;
}

- (void) doSomething: (id) object
{
NSString *url = [NSString stringWithString: baseURL];  // <-- the crash
occurs even when just reading the member
}

@end
--

I've tried calling the function in the same thread, as well as three
different ways of calling it in a seperate thread. Every time there's
another thread involved, it crashes when accessing the member variable. If
the function doesn't access any members, the code works just fine...

instance = [[MyClass alloc] initWithHost: txtHost.text];
[instance doSomething: nil];   // Works
[instance performSelectorInBackground: @selector(doSomething:) withObject:
nil];   // Doesn't work
[[[NSThread alloc] initWithTarget: instance selector:
@selector(doSomething:) object: nil] start];   // Doesn't work
[NSThread detachNewThreadSelector: @selector(doSomething:) toTarget:
instance withObject: nil];   // Doesn't work

Thanks,
  Dennis
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


CGImage masking via CGCreateImageWithMask getting odd results

2008-08-10 Thread Nick Veys
I'm getting some interesting results with an image mask I'm trying to
apply.  I'm trying to vignette away the edges of some small images and
instead of getting transparency behind them, I'm getting the black
(presumably from the mask).

I'm simply calling CGImageCreateWithMask(image, mask) with two
CGImageRefs, image is 'image.png', attached.  mask is 'mask.png',
attached.  The result I'm seeing is 'result.png', also attached.
Instead of seeing through, I see black (the background is white...)!
Argh.  I've played with the views behind it and set their colors to
all kinds of fun things and I never see that color, just the black
from the mask.  Am I completely misinterpreting what the mask is?
>From the docs it says if the mask is an image, which it is via
verification with CGImageIsMask(), it uses the grayscale as an alpha
value, so it would effectively fade the corners of my images into the
layer behind it.

Even stranger, if I go and put a few lines across the image, say a
solid black line, a 50% gray line, and a 25% gray line, I see on the
final composited image a solid black line, a 50% transparent line and
a 25% transparent line ('lines.png', attached).  So there seems to be
some logic behind the operation that's occurring, it's just definitely
not what I'm looking for.

Any info is appreciated!
<><><><>___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: Controlling line-breaking in a text view

2008-08-10 Thread Matt Neuburg
I wonder if this is a larger bug in the text system? I was going to suggest
just inserting the Unicode character "zero-width no-break space" (U+FEFF)
after the slash, but when I tried it (in TextEdit) I got the very phenomenon
you describe - the break occurs before "delete", not after.

I was able to solve the problem, though, by also inserting a "zero-width
space" (U+200B) before the slash... So there's a solution for you, but it
seems unnecessarily elaborate. m.

On Sat, 9 Aug 2008 20:43:37 -0700, Andy Kim <[EMAIL PROTECTED]> said:
>Hi,
>
>I'm having trouble figuring out how to make the text system not break
>words that begin with a '/', such as paths, when wrapping. Let's say
>that we're laying out the following line of text:
>
>=
>Normally, you should never delete /Applications
>=
>
>I want '/Applications' to stay intact when wrapping. By default, the
>text system wraps it the following way:
>
>=
>Normally, you should never delete /
>Applications
>=
>
>I'd like it to look like this:
>
>=
>Normally, you should never delete
>/Applications
>=
>
>After much searching, the best solution I've come up with so far is a
>subclass of NSATSTypesetter with the following method implementation
>in it:
>
>- (BOOL)shouldBreakLineByWordBeforeCharacterAtIndex:
>(NSUInteger)charIndex
>{
> NSString *string = [[[self layoutManager] textStorage] string];
>
> if (charIndex >= 1) {
>  NSTextStorage *ts = [[self layoutManager] textStorage];
>  if ([ts attribute:PFPathAttributeName atIndex:charIndex
>effectiveRange:NULL]) {
>   // Only break if the previous character is not part of the path
>   return [ts attribute:PFPathAttributeName atIndex:charIndex-1
>effectiveRange:NULL] == nil;
>  }
> }
>
> return YES;
>}
>
>I am setting the attribute PFPathAttributeName to the text storage to
>mark the path. This works somewhat, but now the problem is that after
>wrapping, the text looks like this:
>
>=
>Normally, you should never
>delete /Applications
>=
>
>This happens because -shouldBreakLineByWordBeforeCharacterAtIndex:
>never gets called for the '/' and the next time it gets called is for
>the 'd' in 'delete'.
>
>This modified wrapping behavior makes it seem like 'delete /
>Applications' is one word. I think it's better than the default
>behavior but still not ideal.
>
>So how can I make it wrap exactly the way I want?


-- 
matt neuburg, phd = [EMAIL PROTECTED], 
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: 
AppleScript: the Definitive Guide - Second Edition!




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Does [NSApp setApplicationIconImage] leak memory?

2008-08-10 Thread Matt Neuburg
On Sat, 9 Aug 2008 15:19:08 -0700, "Shawn Erickson" <[EMAIL PROTECTED]>
said:
>On Sat, Aug 9, 2008 at 2:46 PM, Mark Allan <[EMAIL PROTECTED]> wrote:
>
>> I fail to see how [NSApp setApplicationIconImage:theNewImage]; is any
>> different to [NSApp setApplicationIconImage:[theNewImage objectAtIndex:1]]
>> but it obviously does function differently.
>
>Please post a complete code example that shows the original issue. I
>assure you the change that you stated that corrected the issue isn't
>the thing that corrected (of course you have only been posting partial
>code snippets and descriptions so we don't have the full context).

Also it might be useful to state how you "know" there is or is not a "leak"
in the first place. Is the phenomenon truly that an object remains
incorrectly in memory as revealed by Shark or MallocDebug or similar - and
if so, what object? - or is it merely intuition based on a high-level
virtual memory measurement like Activity Monitor? m.

-- 
matt neuburg, phd = [EMAIL PROTECTED], 
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: 
AppleScript: the Definitive Guide - Second Edition!




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: I don't understand why this is leaking...

2008-08-10 Thread Jean-Daniel Dupas


Le 10 août 08 à 00:48, Cate Tony a écrit :


This code is leaking:

- (void)saveItemExtensions:(id)sender
{
   NSMutableString* itemExtensionsFilePath = [NSMutableString  
stringWithString:@"~/Library/Preferences/MyApp/extensions.abc"];
   NSDictionary* extensions = [NSDictionary dictionaryWithDictionary: 
[itemDataSource itemExtensions]];


   [itemExtensionsFilePath setString:[itemExtensionsFilePath  
stringByExpandingTildeInPath]];
   [[NSArchiver archivedDataWithRootObject:extensions]  
itemExtensionsFilePath atomically: YES];

}

- (void)encodeWithCoder:(NSCoder *)coder
{
   [coder encodeObject: string1];
   [coder encodeObject: string2];
   [coder encodeObject: string3];
   [coder encodeObject: string4];
   [coder encodeObject: string5];
   [coder encodeObject: string6];
   [coder encodeObject: string7];
   [coder encodeObject: string8];
}
According to MallocDebug, the leak is in the encodeWithCoder method.


MallocDebug is not the best tool to debug Obj-C memory eaks. You  
should use ObjectAlloc instead (an Instrument probe).


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Custom URL Handling

2008-08-10 Thread Ken Thomases

On Aug 9, 2008, at 7:12 PM, Uli Kusterer wrote:


On 10.08.2008, at 01:50, Jacob Bandes-Storch wrote:
It doesn't seem to make sense to use the script suite stuff to  
receive the URL event.. shouldn't it be used for scripting only? Or  
am I mistaken?



Apple Events are simply a means for applications to communicate.  
Just like you can use AppleScript to tell an application to open a  
file (which sends an 'aevt'/'open' Apple Event), you can tell it to  
open a URL. So, using the scripting stuff not only implements the  
handler in a nice, object-oriented way, it also allows users to use  
scripting languages to achieve the same.


If you're not going to go to the trouble of making your application  
properly scriptable, which is a non-trivial task, I'd recommend that  
you just register a handler for the Apple Event.  It's quite  
straightforward.


Cheers,
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: Copying id

2008-08-10 Thread Ken Thomases

On Aug 10, 2008, at 2:05 AM, Mike wrote:

How does one go about copying an object specified by id when one  
doesn't know the object type and the object does not implement  
NSCopying protocol?


The short answer is: you don't.  If an object's class doesn't  
implement NSCopying, then there are no known semantics for what making  
a copy of it should mean.  Just to pick a random example, what might  
it mean to copy an NSTask object?  Or an NSThread?  I could keep  
going, of course.


However, I'm having a hard time imagining under what circumstances you  
would want to do this.  If you don't know what kind of object you  
have, and the object itself doesn't know how to make a copy, why do  
you want (or think you need) to make a copy?


Cheers,
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]


Copying id

2008-08-10 Thread Mike
How does one go about copying an object specified by id when one doesn't 
know the object type and the object does not implement NSCopying protocol?


Thanks,

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]