How to use Authenticator example to a remote machine?

2009-09-24 Thread Arthur C.
Hi,

I've been looking at the Authenticator example code as a starting point
for a (very simple) Cocoa client/server message-passing program. 

Now in the 'client' section there is a line

// Lookup the server connection

NSConnection *conn = [NSConnection
connectionWithRegisteredName:CONNECTION_NAME host: nil];


 

However when I fill in @127.0.0.1 or @localhost for 'host', it cannot
find the server (which is in fact running).
Why is this? Are my ports closed? 

The example is for inter-application communication on one machine; I'd
like to have that between two machines...


Thanks for your time,
Arthur C.



___

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

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


NSUserDefaults and valueForKeyPath ?

2008-12-09 Thread Arthur C.
I've been busy adding some structure to the NSUserDefaults in my app. So I
would have a dictionary like 'generalPrefs' with some key/value pairs,
separate from 'otherPrefs' etc.

Now I wonder why the following doesn't work:

[[NSUserDefaultsController sharedUserDefaultsController] valueForKeyPath:
@values.generalPrefs.numberOfPoints]

while this does work:

[[NSUserDefaultsController sharedUserDefaultsController] valueForKeyPath:
@values.generalPrefs],

after which generalPrefs can be referenced.

Am I missing some elementary KVC or is there something special about the
user defaults?


Thanks for your time,
Arthur

___

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

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


Binding to managedObjectContexts using dictionary hangs

2008-11-19 Thread Arthur C.
I have a Core Data application with a double Core Data implementation,
that is, there are two managedObjectModels, persistentStoreCoordinators
and managedObjectContexts.
These are referenced by the following methods:

// appDelegate.h
- (NSPersistentStoreCoordinator *)
persistentStoreCoordinatorForConfiguration: (NSString *) configuration;
- (NSManagedObjectModel *) managedObjectModelForConfiguration: (NSString
*) configuration;
- (NSManagedObjectContext *) managedObjectContextForConfiguration:
(NSString *) configuration;

- (NSManagedObjectContext *) managedObjectContextIpAddresses; // used for
bindings
- (NSManagedObjectContext *) managedObjectContextRecipes; // used
for bindings

To make the code cleaner and generic for N objectContexts, I'd like to
have them all in an NSDictionary, and bind to the dictionary instead.

So, I'd have

- (NSMutableDictionary *) managedObjectContextDictionary;

which I fill in the appDelegate's init (to do it as early as possible) as
follows:

- (id) init
{
self = [super init];
if (self != nil)
{
managedObjectContextDictionary  = [[NSMutableDictionary 
alloc] init];
persistentStoreCoordinatorDictionary= [[NSMutableDictionary 
alloc] init];
managedObjectModelDictionary= [[NSMutableDictionary 
alloc] init];

NSArray * keys   = [NSArray arrayWithObjects: 
recipesConfigurationKey,
ipAddressesConfigurationKey, nil];

for(unsigned int i = 0; i  [keys count]; i++)
{ // we do this because of the bindings
NSString * key = [keys objectAtIndex: i];
[managedObjectContextDictionary setObject: [self
managedObjectContextForConfiguration: key] forKey: key];
}
}
return self;
}

Problem: when I use this, and bind to
managedObjectContextDictionary.recipes and
managedObjectContextDictionary.ipAddresses, the application *sometimes*
hangs after startup. That is, the interface does not work, and there is no
spinning ball either; it is just dead.
When using the debugger, it does work OK.
I checked that the whole Core Data implementation is set up, as well as
the dictionary.

Questions:

1. What could be the difference with binding to

- (NSManagedObjectContext *) managedObjectContextRecipes
{
return [self managedObjectContextForConfiguration: 
recipesConfigurationKey];
} ?

2. Is it correct to set up the dictionary in - init?
3. Could there be a timing problem?


Thanks in advance,
Arthur C.






___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 save error with multiple persistent stores [SOLVED]

2008-11-19 Thread Arthur C.
A solution is to have 2 persistentStoreCoordinators and 2
managedObjectContexts, with the Coordinators each having one single
persistent store.
It is clear that there can be no reassignment problems anymore.

However, I don't understand why this seems to be required; that is, why
can't I have two managedObjectContexts with one persistentStoreCoordinator
having two persistent stores?


Thanks,
Arthur C.



___

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

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

2008-11-17 Thread Arthur C .

It might also be worth putting a test in awakeFromInsert -- first  
check if the object has been assigned to a persistent store, and only  
assign if it has not.Done that; it doesn't get called more than once, and it 
doesn't help to do the assignObject: toPersistentStore: outside the 
awakeFromInsert.
Note that on systems with OS 10.5 (Leopard) it works fine, while on 10.4 
(Tiger)it always gives the error... We'll try to set it up using 
configurations in the data model. Any other suggestions?Okay, I've made a 
minimal test project using configurations in the data model, so we no longer 
need the assignObject: toPersistentStore: calls.The exception 'can't reassign 
object to a different store once it has been saved' occurs on quitting the 
application in the following case:- we have two managedObjectContexts, to be 
able to have separate save actions.- in one store we have two entities having 
a one-to-many relationship (say Person and Hobby).- in the second store we 
have just a single entity.- there are object instances of all entities present 
when we start the program.- we have added a new Person *and* we set the 
relationship of two Hobbys to one Person.- we are running on Tiger (10.4), not 
on 10.5 (this seems to matter).We are using standard interface for 'many 
objects'; array controllers bound to the correspondingmanaged object 
context.It turns out that the relationship is critical; with the relationship 
set to 'No Value' there is no error; when it is set in a newly added object, 
things go wrong. When running on Leopard, no problems...It seems that problems 
only come when there is one object having a relation to two or more other 
objects.So, the problem is now more accurately defined. I hope someone has an 
idea how to tackle this one, as it prevents us in a nasty way from having 
multiple separately savable stores.Thanks,Arthur C.
_
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/___

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

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

2008-11-16 Thread Arthur C .

In my application I have two managed object contexts, as I need to be able to 
save two subsets of my Core Data setup separately. 
These are both using one and the same persistent store coordinator; the 
coordinator has two stores. 
 
I take care that every object instance gets inserted into the right 
managedObjectContext, by using [NSEntityDescription 
insertNewObjectForEntityForName: ...]. And it gets assigned to the right 
persistent store by using
 
- (void) awakeFromInsert
{
   ...
   [managedObjectContext assignObject:self toPersistentStore: 
[persistentStoreCoordinator persistentStoreForURL: url]];
}.
There are no relationships between objects in different persistent stores, as 
it should be.
 
This seems to work OK on one system, but leads to a strange error on two other 
systems (for the same program).
 
When a change has been made to the Core Data objects (e.g. adding an instance), 
the 'save' action of the managedObjectContext gives an exception (no error 
screen) saying 'can't reassign object to a different store once it has been 
saved'. 
This means the Core Data stack cannot be saved anymore, which is of course a 
serious problem. 
 
Do you know what causes this error? Do I need to use a different setup for the 
managedObjectContext - persistentStoreCoordinator - persistentStores system?
 
 
Thanks for your time,
Arthur C.
 
 
_
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/___

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

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

2008-11-16 Thread Arthur C .





From: [EMAIL PROTECTED]: [EMAIL PROTECTED]: Core data save error with multiple 
persistent storesDate: Sun, 16 Nov 2008 21:02:37 +0100

In my application I have two managed object contexts, as I need to be able to 
save two subsets of my Core Data setup separately. These are both using one and 
the same persistent store coordinator; the coordinator has two stores.  I take 
care that every object instance gets inserted into the right 
managedObjectContext, by using [NSEntityDescription 
insertNewObjectForEntityForName: ...]. And it gets assigned to the right 
persistent store by using - (void) awakeFromInsert{   ...   
[managedObjectContext assignObject:self toPersistentStore: 
[persistentStoreCoordinator persistentStoreForURL: url]];}.There are no 
relationships between objects in different persistent stores, as it should be. 
This seems to work OK on one system, but leads to a strange error on two other 
systems (for the same program). When a change has been made to the Core Data 
objects (e.g. adding an instance), the 'save' action of the 
managedObjectContext gives an exception (no error screen) saying 'can't 
reassign object to a different store once it has been saved'. This means the 
Core Data stack cannot be saved anymore, which is of course a serious problem.  
Do you know what causes this error? Do I need to use a different setup for the 
managedObjectContext - persistentStoreCoordinator - persistentStores system?  
Thanks for your time,Arthur C.  
 
 The example in the documentation:   
 http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdCreateMOs.html#/
  /apple_ref/doc/uid/TP40001654-SW2does the assignment immediately after 
 the  insertNewObjectForEntityForName call, not in awakeFromInsert.
All right, but that does not cover the case of an object being added using the 
'add' button linked to the array controller (which btw is bound to the correct 
managedObjectContext). Then you end up directly in awakeFromInsert, which at 
least should be OK if it is executed only once.
I'm wondering if undo is what's causing your problem. If not undo,  then some 
other circumstances that leads to awakeFromInsert being  called when the 
object is not really brand-new.
I'll check that. Undo is probably not the problem, we can trigger the error 
without doing an undo operation.
 
Have you tried doing it the way Apple's example shows? 
 
I'll do that, but as said, it's incomplete and the awakeFromInsert will still 
be needed...
 
 
Thanks so far,
Arthur C.
_
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Validating a non-optional transient Core Data property - it can be erased?!

2008-11-13 Thread Arthur C .





From: [EMAIL PROTECTED]To: cocoa-dev@lists.apple.comSubject: Validating a 
non-optional transient Core Data property - it can be erased?!Date: Wed, 12 
Nov 2008 22:31:02 +0100

In my Core Data database I have a property called 'target' (double), which is 
transient and required (i.e. 'non-optional' in the model). It is dependent on 
another variable 'color'; so for each color there is a 'target'. As I want to 
show only the target for the selected color, I use this transient variable. It 
is used as well to set a new target (from the table view) for the selected 
color. In the model I have imposed a minimum, maximum and default value for 
'target', and the table column is set to validate immediately. This works 
correctly. However, the feedback in the validation sheet is rather minimal. 
So, first question: how can I change the validation message, to include e.g. 
required range etc.? Another thing is, I have found that I can erase the 
value in the table view, without a validation error getting triggered! A 
nil-value is not acceptable. The easiest solution I've found is just to make 
it persistent (non-transient). But I think 'non-optional' should mean 
'required', meaning the value should never be nil... especially since I gave 
a min, max and default value.Is there a better way to do this while keeping 
the variable transient? 
 (Pay careful attention to what   it says about validation *instead of* 
 versus validation *as well as*   Core Data's other validation mechanisms.)
Yes, I have found that I should not do it both. That is, if I check also in 
code on maximum/minimum, an error message 'multiple validation errors' will 
come up. 
 
There's also a way of localizing the built-in error messages, which  may be 
another solution to your first question if you just want to  vary the wording 
a bit:   
http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdUsingMOM.html#/
 /apple_ref/doc/uid/TP40005190-SW13 
 
Well, that turns out to be complicated... I have to retrieve the validation 
predicates for max, min from the model:
 
 NSEntityDescription * recipeEntity = [NSEntityDescription entityForName: 
@Recipe inManagedObjectContext: [[NSApp delegate] managedObjectContext]];  
NSAttributeDescription * targetDescription = [[recipeEntity propertiesByName] 
valueForKey: @target]; NSArray * validationPredicates = [targetDescription 
validationPredicates];
after which the predicates need to be parsed in order to find which is the max 
/ min predicate. Then, the custom error message has to be fed to the managed 
object model's localizationDictionary, which I don't fully understand... The 
following code does not work:
 
 NSManagedObjectModel * model = [[NSApp delegate] managedObjectModel]; 
NSMutableDictionary * localizedDict = [NSMutableDictionary dictionary];
 for (unsigned int i = 0; i  [validationPredicates count]; i++) {  
NSComparisonPredicate * predicate = [validationPredicates objectAtIndex: i];  
NSString * description = [predicate description];  double value = [[[predicate 
rightExpression] constantValue] doubleValue];if ( [description hasPrefix: 
@SELF ] )  {   minimumTarget = value;   id validationWarning = 
[[targetDescription validationWarnings] objectAtIndex: i];   [localizedDict 
setValue: @Test string 123 forKey: [NSString stringWithFormat: 
@ErrorString/%@, validationWarning]];   [model setLocalizationDictionary: 
localizedDict]; } 
 }
 
Any ideas on how this can be done in a *simpler* way?
 
 
Thanks so far,
Arthur
 
 
 
 Thanks in advance,Arthur



Express yourself instantly with MSN Messenger! MSN Messenger
_
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 search box: how to preserve selection while searching?

2008-11-12 Thread Arthur C .

Hello,
 
I have a Core Data database, of which always one item is selected. The values 
of the selected item are used in another (non-Core Data) part of the 
application.
Now this leads to problems with the use of the search box. When the user 
searches for some item, the selection in the table is not preserved, which 
causes the rest of the application to behave unexpectedly. 
How can I preserve this selection, and make the user select a new item 
explicitly also when using the search box? 
 
 
Thanks for your time,
Arthur C.
 
 

_
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/___

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

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


Validating a non-optional transient Core Data property - it can be erased?!

2008-11-12 Thread Arthur C .

In my Core Data database I have a property called 'target' (double), which is 
transient and required (i.e. 'non-optional' in the model). It is dependent on 
another variable 'color'; so for each color there is a 'target'. As I want to 
show only the target for the selected color, I use this transient variable. It 
is used as well to set a new target (from the table view) for the selected 
color.
 
In the model I have imposed a minimum, maximum and default value for 'target', 
and the table column is set to validate immediately. This works correctly. 
However, the feedback in the validation sheet is rather minimal. 
So, first question: how can I change the validation message, to include e.g. 
required range etc.?
 
Another thing is, I have found that I can erase the value in the table view, 
without a validation error getting triggered! A nil-value is not acceptable. 
The easiest solution I've found is just to make it persistent (non-transient). 
But I think 'non-optional' should mean 'required', meaning the value should 
never be nil... especially since I gave a min, max and default value.
Is there a better way to do this while keeping the variable transient?
 
 
Thanks in advance,
Arthur
 
 
 
 

_
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 one-to-many: how to set relationship for newly added 'many' objects?

2008-10-22 Thread Arthur C .
A basic question:
I have a Core Data model which has a one-to-many relationship, say one 
Department and several Employees.
When an Employee is added using the 'add' button of the standard interface, how 
can I set the relationship to the (one) instance of Department? It means you 
need access to theDepartment from Employee - awakeFromInsert. But I'm not 
allowed to do a fetchRequest from here, right?
What is a clean way to do this? At this moment I have the department 
pre-fetched somewhere (like in AppDelegate), but that's probably not the right 
approach.
 
 
Thanks for your time,
Arthur C.
_
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 uniquely determine MD5-sum of a dict?

2008-09-16 Thread Arthur C .
I have an NSDictionary that has to be written to disk, distributed and read in 
again. 
I would like to add an MD5 sum to the dictionary to make sure it has not been 
modified/corrupted on the way. That can be done by making NSData using 
NSArchiver and then passing it to MD5() from openssl/md5.h. 
 
But, the order in which keys/values are stored in the dict is not fixed. I 
would like to know if there is a simple way to get a unique (reproducable) 
MD5-sum.
 
 
Thanks in advance,
Arthur
_
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/___

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

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


Saving some managed objects separately

2008-09-09 Thread Arthur C .
In my application I have a status log which is kept in Core Data. This gives a 
nice interface and persistence for the log. 
However, I would like to be able to save the log to disk independent from other 
parts of my Core Data model. This is needed to prevent the log from getting 
lost in the event of a power failure or program crash. The uptime is supposed 
to be several months, at least, so things should be saved at some point. 
 
It is possible to assign the log objects to a second persistent store, but that 
gives no second 'save action' to save it independently. The only save action I 
found is in the managedObjectContext but that saves everything, destroying the 
undo stack. So should I have two managed object contexts? And then, also with 
another persistent store coordinator? Or is there a simpler way?
 
 
Thanks for your time,
Arthur 
_
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/___

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

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