Re: Core Data Manual Migration

2009-09-14 Thread Yvan BARTHÉLEMY
After further research I determined that this problem occured because
I didn't set the source type and destination type. I will fill a bug
report about the message not containing enough information (by the
way, I'm running 10.5.6 as this is my target platform, this might have
been solved since that).

However, the reference for 'NSMigrationManager' indicated that
possible values for "type:" are specified
'NSPersistentStoreCoordinator' Reference. Based on that I assumed (as
it was not indicated), that the accepted values would be the same as
in "addPersistentStoreWithType:" which nil is a valid value (though
not documented as valid).

I'm wondering if I should also file a documentation bug about the fact
that nil is not valid in this context or never valid (this works, but
I should not rely on this behavior). Or if this should be supported,
and then I should file a behavior bug.

Thanks,
Yvan

2009/9/11 Ben Trumbull :
>> The process fails here and the log then contains the following:
>> An error occured while manually migrating document: Error
>> Domain=NSCocoaErrorDomain Code=134110 UserInfo=0xf336960 "An error
>> occured during persistent store migration."
>> [6871:813] Error: {
>>   reason = "Can't add source store";
>> }
>
> There should be more in the userInfo dictionary explaining what's going on.
>  If you can reproduce it in a new test project with your models & mapping
> models, then please file a bug with the project source zipped up at
> bugreport.apple.com and we'll look at it.
>
> - Ben
>
>
___

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

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

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

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


Core Data Manual Migration

2009-09-11 Thread Yvan BARTHÉLEMY
Hello,
I need to implement manual migration in order to chain migrations. I
have compiled every mapping model from a version to the next one. All
my models are included in my resources (in a .momd bundle). My code
determines the model version used to create the document
metadataForPersistentStoreOfType:URL:error: and
isConfiguration:compatibleWithStoreMetadata:. with success.
Once the version is determined, I determine the migration path using
the model name (if I have found that the document is using model A,
and that current is C, I now I should use AtoB and then BtoC mapping
models).
Once I have manually got my file to be migrated, source model,
destination model, mapping model. I cannot successfully migrate using
NSMigrationManager.

I have configured NSMigrationManager following the steps described in
Core Data Migration Programming Guide - Customizing the Migration
Process:

NSMigrationManager *mManager = [[NSMigrationManager alloc]
initWithSourceModel:srcModel destinationModel:destModel];
NSString *storePath = [NSTemporaryDirectory()
stringByAppendingPathComponent:@"(A document being migrated)"];

if ([[NSFileManager defaultManager] fileExistsAtPath:storePath]) {
// Removing previous item because unless, core data will try to
append data rather overwriting
[[NSFileManager defaultManager] removeItemAtPath:storePath 
error:&error];
}

NSURL *storeURL = [NSURL fileURLWithPath:storePath];
NSURL *backupURL = [NSURL fileURLWithPath:[[[storePath
stringByDeletingPathExtension]  stringByAppendingString:@"~"]
 
stringByAppendingPathExtension:[storePath pathExtension]]];

[mManager migrateStoreFromURL:URL type:nil options:0
withMappingModel:mModel toDestinationURL:storeURL destinationType:nil
destinationOptions:0 error:&error];

if (error) {
  NSLog(@"An error occured while manually migrating document: %@", error);
  NSLog(@"UserInfo: %@",[error userInfo]);
}

The process fails here and the log then contains the following:
An error occured while manually migrating document: Error
Domain=NSCocoaErrorDomain Code=134110 UserInfo=0xf336960 "An error
occured during persistent store migration."
[6871:813] Error: {
reason = "Can't add source store";
}

I don't understand what does mean Can't add source store, and how
should I configure my Migration Manager to perform my migration
successfully.

Does anyone can explain to me what is happening ?

Thanks in advance
Yvan BARTHELEMY
___

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

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

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

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


NSPersistentDocument Save As failure

2009-07-29 Thread Yvan BARTHÉLEMY
Hi,
I have some misunderestanding with Core Data documents. I'm creating an
empty Core Data document and then adding some content in it. I then saved it
successfully. The problem comes only when I'm using Save As. In one
document, I can add items (using my array controllers bound to my context),
then choose Save As without any hurt. In the other document, this fails.
This time the object is added programmatically the following way :

NSManagedObjectContext *context = [[self graphicsContainer]
managedObjectContext];

 DSCanvasImage *image = [NSEntityDescription insertNewObjectForEntityForName
:@"Image" inManagedObjectContext:context];

 [image setImage:[[NSImage alloc] initWithPasteboard:[sender
draggingPasteboard]]];

[[self graphicsContainer] addObject:image];

graphicsContainer is the arrayController bound to my view in which I call
the code.

On Saving I got the following error message, but it doesn't help me to find
the cause of my problem:

*Error: Error Domain=NSCocoaErrorDomain Code=134030 UserInfo=0xef20190 "An
error occurred while saving."*

*
*

Querying userInfo on this error gives me (got by overriding *
writeToURL:ofType:forSaveOperation:originalContentsURL:error:*):

*{*

*NSAffectedObjectsErrorKey = (*

* (entity: Image; id: 0x10ea4400

; data: )*

*);*

*NSUnderlyingException = Cannot update object that was never inserted.;*

*}*


Any information is welcome.

Thanks for helping.

Regards,
Yvan
___

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

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

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

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


IB Plugin - optionDescriptionsForBinding: not called

2009-05-27 Thread Yvan BARTHÉLEMY

Hello,

I have tried to create a custom IB Plugin to support custom bindings/ 
reimplement existing bindings on NSImageView. My final goal is to have  
read/write access to path and url bindings, I intend to reimplement  
drag & drop and create files on the fly to achieve this.


For this I tried to create a simple binding by calling exposeBinding:  
in initialize and implementing valueClassForBinding:. This works, but  
optionDescriptionsForBinding: is not called by IB (tested by adding a  
NSLog on the top of the method). I cannot then add custom checkboxes,  
etc. for the binding.


Should I file a bug about this behavior ? I am using IB 3.1.2 (677).  
Should I switch to an other version of IB ?


Thanks for any help,
Yvan
___

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

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

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

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


Core Data: [Fixed] NSPredicate failing when using NSSQLiteStoreType

2009-05-05 Thread Yvan BARTHÉLEMY

Hello,

In an entity A, I have a toMany relationship to an entity B named  
relB. relB has a inverse toOne relationship relA.


NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
	[request setEntity:[NSEntityDescription entityForName:@"A"  
inManagedObjectContext:moc]];
	[request setPredicate:[NSPredicate predicateWithFormat:@"(relB ==  
NIL) || (relB[SIZE] == 0)"]];

NSArray *objects = [moc executeFetchRequest:request error:&error];

Using NSSQLiteStoreType, this raises the following exception on  
executeFetchRequest :
	*** Terminating app due to uncaught exception  
'NSInvalidArgumentException', reason: 'to-many key not allowed here'


Changing predicates raises other exceptions, but I couldn't make this  
work. I need to switch from XML to SQLite because my model needs to  
scale.


Here is the other variants I tried and their associated exceptions :
	[request setPredicate:[NSPredicate  
predicateWithFormat:@"self.relB[SIZE] = 0"]];
		*** Terminating app due to uncaught exception  
'NSInvalidArgumentException', reason: '*** -constantValue only defined  
for abstract class.  Define -[NSFunctionExpression constantValue]!'


	[request setPredicate:[NSPredicate predicateWithFormat:@"relB[SIZE] =  
0"]];
	*** Terminating app due to uncaught exception  
'NSInvalidArgumentException', reason: 'Unsupported function expression  
displays[SIZE]'


	[request setPredicate:[NSPredicate predicateWithFormat:@"displays ==  
NIL"]];
	*** Terminating app due to uncaught exception  
'NSInvalidArgumentException', reason: 'to-many key not allowed here'


	[request setPredicate:[NSPredicate  
predicateWithFormat:@"self.displays == NIL"]];
	*** Terminating app due to uncaught exception  
'NSInvalidArgumentException', reason: 'to-many key not allowed here'


I don't really understand what can happen here. Any information would  
be welcome.


For now, I am using -[NSArray filteredArrayUsingPredicate:] which  
solves my problem. But I'm still wondering why I cannot do this using - 
[NSFetchRequest setPredicate:].


Thanks,
Yvan BARTHÉLEMY___

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

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

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

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


Re: isEqual, isEqualToString, compare behaviors

2009-03-27 Thread Yvan BARTHÉLEMY
isEqualXXX methods returns a boolean and not a NSComaprisonResult like  
compare:. So, for these 0 == NO, and 1 == YES. No problem then.


Le 27 mars 09 à 19:30, Ameen a écrit :

am not being able to explain the output of the following code; code  
and output pasted below.


#import 

int main (int argc, const char * argv[]) {
  NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
  NSComparisonResult compareResult = 0;
  id fileAttributes = nil;
if(fileAttributes = [[NSFileManager defaultManager]  
fileAttributesAtPath:@"/Applications"
  
traverseLink:FALSE]) {
  NSLog(@"[fileAttributes objectForKey:NSFileType] = %@;  
NSDirectoryFileType = %@",[fileAttributes  
objectForKey:NSFileType],NSDirectoryFileType);
compareResult = [(NSString *) [fileAttributes  
objectForKey:NSFileType] isEqualToString:NSDirectoryFileType];
  NSLog(@"[(NSString *) [fileAttributes objectForKey:NSFileType]  
isEqualToString:NSDirectoryFileType] = %d",compareResult);
compareResult = [(NSString *) [fileAttributes  
objectForKey:NSFileType] compare:NSDirectoryFileType];
  NSLog(@"[(NSString *) [fileAttributes objectForKey:NSFileType]  
compare:NSDirectoryFileType] = %d",compareResult);
compareResult = [[fileAttributes  
objectForKey:NSFileType] isEqual:NSDirectoryFileType];
  NSLog(@"[[fileAttributes objectForKey:NSFileType]  
isEqual:NSDirectoryFileType] = %d",compareResult);
compareResult = [[fileAttributes  
objectForKey:NSFileType] isEqual:[fileAttributes  
objectForKey:NSFileType]];
  NSLog(@"[[fileAttributes objectForKey:NSFileType] isEqual: 
[fileAttributes objectForKey:NSFileType]] = %d",compareResult);
compareResult = [NSDirectoryFileType  
isEqual:NSDirectoryFileType];
  NSLog(@"[NSDirectoryFileType isEqual:NSDirectoryFileType] =  
%d",compareResult);

  }
[pool drain];
  return 0;
}

/** output (target system OS X 10.5.6, using XCode  
3.0)*/
[fileAttributes objectForKey:NSFileType] = NSFileTypeDirectory;  
NSDirectoryFileType = NXDirectoryFileType
[(NSString *) [fileAttributes objectForKey:NSFileType]  
isEqualToString:NSDirectoryFileType] = 0  //This shouldn't have been  
true. because both strings are different.
[(NSString *) [fileAttributes objectForKey:NSFileType]  
compare:NSDirectoryFileType] = -1 //OK they are not same. fine.
[[fileAttributes objectForKey:NSFileType]  
isEqual:NSDirectoryFileType] = 0 //How come ?
[[fileAttributes objectForKey:NSFileType] isEqual:[fileAttributes  
objectForKey:NSFileType]] = 1 //This cannot be true. An object  
should be equal to itself.
[NSDirectoryFileType isEqual:NSDirectoryFileType] = 1 //This cannot  
be true. An object should be equal to itself.


any body knows why this behavior.

___

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

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

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

This email sent to ybarthel...@free.fr


___

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

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

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

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


NSButton manual drawing

2009-03-13 Thread Yvan BARTHÉLEMY

Hi,

I am drawing controls into view to use as feedback during Drag & Drop  
operation.


I've tried to draw manually a NSButton (with NSRoundedBezelStyle)  
using [[button cell] drawWithFrame:frame inView:[NSView focusView]];


I obtain a button image with the correct background, but the button  
text is at the bottom. When I add the button to the view it is  
correctly displayed.


Am I doing something wrong, since this method seems to work for popup  
buttons ?


Thanks,
Yvan
___

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

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

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

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


Memory Management - Best practices

2009-01-22 Thread Yvan BARTHÉLEMY

Hello,

I am implementing mouse support in Core Animation. For this I have a  
CAButton : CALayer and adds button-related behavior : highlighting on  
mouseDown, stopping highlighting on mouseExit, etc. and actions.


The actions are associated using:
 -[CAButton setAction:(SEL) withTarget:(SEL)]

These are performed on mouseUp if the mouse is still within the  
button's rect.


The problem that occurred is that the action might cause the button to  
be removed by a side-effect of performSelector (ex. a view switch) and  
I might still need to perform additional actions that needs button's  
ivars after performSelector has been called (which might cause  
unexpected behavior).


When I encounter the problem, I changed mouseUp so it does not need to  
perform any action after the performSelector. But I am wondering if  
there are special practices to prevent this problem : should we assume  
that the button will not be released by the performAction, retain it  
before the performSelector and release it after, or do not use self  
after performSelector ?


Thanks for your advice,
Yvan
___

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

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

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

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


Core Animation NSTrackingArea

2008-12-16 Thread Yvan BARTHÉLEMY

Hi,

For my project, I want to add mouse support in Core Animation views.  
For this, when I create a Core Animation button, I associate to the  
view a NSTrackingArea with the frame of my button. This way I can get  
mouse Up, Down, Entered and Exited events and implement the behavior  
of my button and visual feedback. Until here, this works perfectly.


The problem is that I need to remove the tracking rects when the  
button disappear from the view. That is that event that is painful to  
detect.


For now, I have a working solution, but it looks like dirty code and  
I'm not sure if this is really safe. I remove the tracking rect when  
the bound are updated by subclassing [CALayer setNeedsLayout], which  
is fine, when the view is removed by subclassing [CALayer  
removeFromSublayer] (which is not fine because it's not called when  
you directly remove the superlayer), in the dealloc method (this one  
causes me a problem, as, this is not just memory management and I have  
no guarantee dealloc is called), and the worst one : I registered for  
the notification applicationWillTerminate (I need this, because if  
dealloc is called after the windows's contentView has been  
deallocated, this simply crashes as contentView is not nil).


What do you think I should do with this ?

Best Regards,
Yvan BARTHÉLEMY___

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

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

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

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


KVO and CALayers

2008-12-12 Thread Yvan BARTHÉLEMY

Hi,

I had a problem this morning, and I am wondering if the behavior I've  
observed was normal or not.


I needed to use KVO on some object and wasn't able to figure why this  
didn't work. I spent some time figuring out what was happening (since  
it was the first time I used KVO, I started to blame my code).  
Reducing the problem, I finally found that my code didn't work because  
my observer was a subclass CALayer.


I attached the code that doesn't work (the observer method is not  
called).


If I make it a subclass of NSObject, it works. Is this a correct  
behavior or a bug ?


@interface Application : CALayer {
NSString *manager;
}

@property (retain) NSString *manager;

@end

@implementation Application

@synthesize manager;

- (id) init
{
self = [super init];
if (self != nil) {
[self addObserver:self forKeyPath:@"manager" options:0 
context:NULL];
		[NSTimer scheduledTimerWithTimeInterval:1 target:self  
selector:@selector(fired:) userInfo:nil repeats:NO];

}
return self;
}

-(void)fired:(id)sender
{
[self setManager:@"foo"];
[self setManager:nil];
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object  
change:(NSDictionary *)change

   context:(void *)context
{
NSLog(@"Observed: %@ = %@", keyPath, [self manager]);
}   

@end

___

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

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

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

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


Re: ASL & Unicode in Xcode's Console

2008-10-29 Thread Yvan BARTHÉLEMY
In fact I am very interested about this undocumented call as it is  
painful for me to dig into darwin sources.


Thanks,
Yvan

Le 29 oct. 08 à 14:41, Jason Coco a écrit :



On Oct 29, 2008, at 09:06 , Yvan BARTHÉLEMY wrote:

A solution for this is to not use directly asl_log, but wrap it to  
a function that will then use asl_log for console, and fprintf for  
logging to stderr (instead of asl_open(stderr)), of course you will  
have to regenerate yourself date, host name, process name, process  
id information if needed when using fprintf.


Yeah, that's basically the solution I used, but didn't really bother  
with re-generating the log information. I also used an undocumented  
call that I found on the asl source code that let me specify the  
encoding that I wanted instead of defaulting to that stupid "visual"  
encoding for the console. But I wrapped the ASL stuff in an  
Objective-C class so I just added code that if the level was  
ASL_LEVEL_DEBUG and NDEBUG wasn't defined, the data went to stderr  
as well as the logging system.


J


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: ASL & Unicode in Xcode's Console

2008-10-29 Thread Yvan BARTHÉLEMY

Hi,

A solution for this is to not use directly asl_log, but wrap it to a  
function that will then use asl_log for console, and fprintf for  
logging to stderr (instead of asl_open(stderr)), of course you will  
have to regenerate yourself date, host name, process name, process id  
information if needed when using fprintf.


Regards,
Yvan

Le 28 oct. 08 à 19:01, Karl Moskowski a écrit :

I've been experimenting with replacing my app's logging with Apple  
System Logger. When it comes to multi-byte characters, every thing  
looks OK in Console.app. However, Xcode's console shows things  
incorrectly. It probably won't come up often, but I'm wondering if  
it's fixable.


For example, this bit of code:
NSLog(@"あ");
	aslclient client = asl_open(NULL, NULL, ASL_OPT_STDERR); // add  
STDERR's fd to the connection's set of fds so things show up in  
Xcode's console

asl_log(client, NULL, ASL_LEVEL_ERR, "あ");
asl_close(client);

Results in this output in Xcode:
2008-10-28 13:49:19.767 ASL[3484:10b] あ
Tue Oct 28 13:49:19 iMac.local ASL[3484] : \M-c\M^A\M^B

The call to NSLog displays correctly, but asl_log doesn't.

(In case it doesn't survive email, the character in quotes is  
Hiragana Letter A, from Leopard's Character Palette > East Asian  
Scripts > Hiragana > first character.)


___

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

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


Remote Contol Wrapper

2008-05-13 Thread Yvan BARTHÉLEMY

Hi,

I am a Cocoa developer currently coding a user interface using a  
custom IR Remote extending the functionalities of Apple one.


My company have a partnership with a remote maker, and we asked them  
to make a remote using Apple Remote IR codes, plus some custom ones.


Unfortunately, we have not been able to get the events back using the  
Remote Control Wrapper. Do you know the reason why IO HID API is not  
providing the customized events sent by the remote, and eventually how  
can I access them.


I saw in Remote Control Wrapper code that you have been able to add  
support for Keyspan remote. Should I use a similar path to add support  
for my Remote ?


Regards,
Yvan BARTHÉLEMY___

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

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


Is this a bug in Cocoa 'isLike' ?

2008-04-07 Thread Yvan BARTHÉLEMY
On my machine (quite recent 20 inches iMac x86), following (reduced)  
code seems to go in a infinite loop...
Checkpoint 2 is never reached. The number of 'x' characters is  
important.


Should I send it in reporter ?

#import 

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

NSLog(@"Checkpoint 1");
[@"lxxlaxxl" isLike:@"*la"];
NSLog(@"Checkpoint 2");

[pool drain];
return 0;
}

___

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

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

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

This email sent to [EMAIL PROTECTED]