Re: NSMutableDictionary crash on PPC

2010-09-29 Thread Trygve Inda
> On Sep 28, 2010, at 22:48, Trygve Inda wrote:
> 
>>[myObject removeObjectForKey:myDict];
> 
> Shouldn't that be:
> 
> [myObject removeObjectForKey:myOldKey];
> 
> ?

Yes. Sorry - typing in Mail.

Correct code (still crashes on PPC)

myDict = [myObject objectForKey:myOldKey];
if (myDict)
{
[myObject removeObjectForKey: myOldKey];
[myObject setValue:myDict forKey:myNewKey];

[[NSUserDefaults standardUserDefaults] synchronize];
}

It works on Intel, but crashes on PPC. Any idea why?

Trygve


___

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

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

2010-09-29 Thread Roland King
Did you read my post about retaining things before you remove them from 
dictionaries?



On Sep 29, 2010, at 15:29, Trygve Inda  wrote:

>> On Sep 28, 2010, at 22:48, Trygve Inda wrote:
>> 
>>>   [myObject removeObjectForKey:myDict];
>> 
>> Shouldn't that be:
>> 
>> [myObject removeObjectForKey:myOldKey];
>> 
>> ?
> 
> Yes. Sorry - typing in Mail.
> 
> Correct code (still crashes on PPC)
> 
> myDict = [myObject objectForKey:myOldKey];
> if (myDict)
> {
>[myObject removeObjectForKey: myOldKey];
>[myObject setValue:myDict forKey:myNewKey];
> 
>[[NSUserDefaults standardUserDefaults] synchronize];
> }
> 
> It works on Intel, but crashes on PPC. Any idea why?
> 
> Trygve
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org
> 
> This email sent to r...@rols.org
___

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

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

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

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


Re: NSMutableDictionary crash on PPC

2010-09-29 Thread Trygve Inda
> Did you read my post about retaining things before you remove them from
> dictionaries?
> 


> myDict = [myObject objectForKey:myOldKey];
> if (myDict)
> {
>[myObject removeObjectForKey: myOldKey];
>[myObject setValue:myDict forKey:myNewKey];
> 
>[[NSUserDefaults standardUserDefaults] synchronize];
> }


I don't have a PPC here, but I assume that must be it. Odd though that it
doesn't wait until the autorelease pool is flushed.

There is example code here (2nd example) that removes before setting too.

http://stackoverflow.com/questions/1024938/renaming-keys-in-nsmutablediction
ary

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 arch...@mail-archive.com


Re: NSMutableDictionary crash on PPC

2010-09-29 Thread Roland King
There's nothing odd about it. It's simple memory management rules. The moment 
you remove the object from the dictionary the dictionary is no longer an owner 
and since you've not retained it, neither are you. If nobody else is, it's 
subject to dealloc as soon as the dictionary releases it If it so happens it is 
on an outer autorelease pool on PPC that's just lucky. 

I think there is a warning about this in the documentation too. 



On Sep 29, 2010, at 16:02, Trygve Inda  wrote:

>> Did you read my post about retaining things before you remove them from
>> dictionaries?
>> 
> 
> 
>> myDict = [myObject objectForKey:myOldKey];
>> if (myDict)
>> {
>>   [myObject removeObjectForKey: myOldKey];
>>   [myObject setValue:myDict forKey:myNewKey];
>> 
>>   [[NSUserDefaults standardUserDefaults] synchronize];
>> }
> 
> 
> I don't have a PPC here, but I assume that must be it. Odd though that it
> doesn't wait until the autorelease pool is flushed.
> 
> There is example code here (2nd example) that removes before setting too.
> 
> http://stackoverflow.com/questions/1024938/renaming-keys-in-nsmutablediction
> ary
> 
> 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 arch...@mail-archive.com


Re: I want a window's file owner that's not a NSWindowController

2010-09-29 Thread Jonny Taylor
> Quincey Morris wrote:
>> You're kind of mixing up two different tasks here. The Camera object is 
>> (likely) part of your data model (in the MVC paradigm). A window controller 
>> is a ... controller. For your settings window, you'll have least heartache 
>> if you make the NIB's File's Owner a window controller. Window controllers 
>> are *designed* to be the owners of NIB files.
>> 
>> So, subclass NSWindowController, and add a "camera" property. (Your Camera 
>> object can pass its 'self' pointer as a parameter to the window controller 
>> subclass's init... method.)
>> 
>> Then, to get at Camera properties, objects in the NIB can bind to File's 
>> Owner.camera.whateverProperty -- instead of File's Owner.whateverProperty as 
>> you have now.
> Ah, that is quite a neat solution - thanks for that. I hadn't twigged that I 
> could do that sort of "property of a property" binding. It still seems a bit 
> of a faff to create a controller subclass that isn't really doing anything 
> other than passing through property requests, but at least I don't have do 
> write accessors for every property I want to get at in the Camera object!

OK, while that's a very handy thing to know, I think I have worked out a 
simpler way that does not require an intermediate class - I'll state it here 
for the archives (and any comments welcome...)

I show the window using the following code:
@implementation Camera
-(void)showSettingsWindow
{
if (settingsWindowController == NULL)
[NSBundle loadNibNamed:@"Camera Settings" owner:self];
[settingsWindowController showWindow:self];
}
@end

... and the NIB file (File's Owner = Camera) contains the window and a 
controller object (linked together), with the window controller linked to the 
outlet "settingsWindowController" in File's Owner placeholder.

Jonny___

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

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


Background-Task (Timer)

2010-09-29 Thread Lukas Tenbrink
Hey there, Cocoa List!

I've got a question about background tasking, and I couldn't really answer 
myself it by searching in the documentation (or even in the internet).
I want to make a background task with an application. Firstly, I used the code 
they gave as a sample, which looks like this:

- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIApplication*app = [UIApplication sharedApplication];

bgTask = [app beginBackgroundTaskWithExpirationHandler:
^{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 
0), ^{

[self showALocalNotification];

[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
});
}


It actually shows my local notification, but I want the application to check 
for some conditions (like "Is the Device charging?" or "In what way does the 
user hold the device?"), and if certain conditions are complied with, I want to 
show the local notification. So I only want that the Device sends me a message 
from time to time (like every 10 seconds), then I execute a little bit of code, 
and maybe show this notification.

Does somebody know if this is possible? Thanks in before,

Lukas___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Acquiring an NSConnection otherwise than by registered name?

2010-09-29 Thread Oleg Krupnov
Hi Ken,

Now I see. I hardly find words to thank you for your patience! :)

There's been indeed a misunderstanding. I imagined mistakenly that
there could be many "connection points" on the server, one connection
point per thread, and each such connection point could vend a
different object of different type. So I was looking for a way to pass
"address" of this new connection point (like the registered name for
the main one) to the client thread, so that it could call a method
similar to rootProxyForConnectionWithRegisteredName on it.

Now I see that the correct picture is the following. There is only one
connection point, and there is only one root vended object in the
server. I need only to make sure that each client thread uses a
different connection object, though all connections use the same
connection point and send port on server (addressed by its single
registered name). In other words, this new connection is like a
parallel channel to the same root vended object. So when I call
rootProxy on the new connection on client, I obtain the same root
proxy (not the per-thread proxy that I initially thought of). Then I
ask this root proxy to take the current connection and detach it to a
new thread. Objects and threads are fully orthogonal.

Of course, I've read all docs, but I found them quite scarce and even
confusing at times. Only with your help, and with some knowledge of
sockets I have, I went down to the basics and became able to
understand how it works under the hood. For example, the docs say
nothing about the notion of connection points as opposed to child
connections. It calls everything a "NSConnection" and this was my
source of confusion.

There is only one problem left: logs show that although I obtain the
root proxy for the new connection and call a worker method on it in
client, the server still uses the main thread to respond, instead of
the newly created connection's thread. More experiment shows that when
there is already a busy server thread, then the server uses the new
thread, but when there are no other threads, the main thread is used.
Is it a kind of optimization the framework does, or is it my bug? I'd
like that each client thread only worked with its dedicated server
thread and did not mess with the server's main thread.

Thank you again,

Oleg.

On Wed, Sep 29, 2010 at 3:26 AM, Ken Thomases  wrote:
> On Sep 28, 2010, at 1:23 PM, Oleg Krupnov wrote:
>
>> So, let's assume I create the connection in this way:
>>
>> NSConnection* connection = [NSConnection connectionWithReceivePort:nil
>> sendPort:[[NSMachBootstrapServer sharedInstance] portForName:@"foo"]];
>>
>> or even
>>
>> NSConnection* connection = [NSConnection
>> connectionWithReceivePort:[NSMachPort port] sendPort:[NSMachPort
>> port]];
>>
>> Then I vend the object:
>>
>> [connection setRootObject:serverObject];
>>
>> And finally launch it in a separate thread:
>>
>> [connection runInNewThread];
>>
>> But how do I pass this connection back to client so that I could call
>> -rootProxy on it?
>
> You don't.  Please reread what I wrote.  My last email was largely about how 
> the client creates its connection.  You've misunderstood it to be about how 
> the server creates it.  (The above approaches wouldn't even work for a 
> server.)
>
> Servers don't create connections to clients.  Clients create connections to 
> servers.
>
> A server only explicitly creates a single NSConnection instance.  This isn't 
> a connection so much as a "connection point" -- a place where clients can 
> connect to.
>
> Then, clients create connections to the server.  In response, in the server, 
> the frameworks implicitly create new NSConnection instances for each client 
> connection.  Once again, this is clearly illustrated in the documentation on 
> Distributed Objects.  Have you read it?
> 
>
> We've already discussed how and when the server tells the newly-created 
> connections to run in a separate thread.
>
> The only complication is that, because your clients are attempting to make 
> multiple connections from the same process, and because the frameworks try to 
> reuse connections within a process, you have to take some minor extra 
> precautions to make sure you are getting separate, independent connections to 
> the server.  I have told you how to do that.
>
>> That was actually the original question in the
>> subject of this mail :)
>
> Not as I understood it.  And if it was, then you have a fundamental 
> misunderstanding about how connections work.  Again: servers don't create 
> connections to clients; clients create connections to servers.
>
>> The other question I've got is how do I exit the newly created thread
>> when its job is done?
>
> It should exit when the connection from the client closes.  It's possible 
> that the server will have to explicitly -invalidate the connection in 
> response to a sign-off message fr

Re: Acquiring an NSConnection otherwise than by registered name?

2010-09-29 Thread Ken Thomases
Hi Oleg,

On Sep 29, 2010, at 5:16 AM, Oleg Krupnov wrote:

> Now I see. I hardly find words to thank you for your patience! :)

You're welcome.  I'm glad I could help.


> Now I see that the correct picture is the following. There is only one
> connection point, and there is only one root vended object in the
> server. I need only to make sure that each client thread uses a
> different connection object, though all connections use the same
> connection point and send port on server (addressed by its single
> registered name).

In the server, it is the receive port which is registered under a name.  The 
server "receives" connections from clients on that port.  (Actually, reading 
the docs for -initWithReceivePort:sendPort:, the server's connection point 
typically uses the same port for receive and send.)

> In other words, this new connection is like a
> parallel channel to the same root vended object. So when I call
> rootProxy on the new connection on client, I obtain the same root
> proxy (not the per-thread proxy that I initially thought of).

You should receive a different proxy to the same root object.  (The root proxy 
is an NSDistantObject that is specific to the connection.  So, a different 
connection implies a different proxy object.)

But you are correct that the design has a single root object in the server, not 
multiple root objects, one for each client connection.

> Then I
> ask this root proxy to take the current connection and detach it to a
> new thread. Objects and threads are fully orthogonal.

Well, the client shouldn't be aware that its check-in message has the result of 
spawning a new thread in the server.  The check-in message should just be a way 
for the client to make the server aware of it, and to initiate service for it 
(whatever "service" means in your application).  The server could be designed 
either way, with a separate thread per client connection or all handled by one 
thread.

If having a single root object feels cumbersome, the root object could be 
turned into just a factory for per-client service objects.  So, the client 
checks in and asks the single root object for a new object which will serve 
just it (that specific client; I consider each thread within the client process 
to be a separate "client" in your design).  The server creates a new object to 
satisfy that request, and that new object would be initialized with whatever 
state is specific to that client.  It would also happen to spin off a separate 
thread to handle communications with that client, but that's an implementation 
detail.


> Of course, I've read all docs, but I found them quite scarce and even
> confusing at times. Only with your help, and with some knowledge of
> sockets I have, I went down to the basics and became able to
> understand how it works under the hood.

OK.  I can definitely see how the docs can be confusing or less than thorough.  
I recommend that you file requests for enhancements to anything you didn't 
understand.

> For example, the docs say
> nothing about the notion of connection points as opposed to child
> connections. It calls everything a "NSConnection" and this was my
> source of confusion.

They do say "the connection labeled s is used to form new connections" and "A 
named connection rarely has a channel to any other NSConnection object (in 
Figure 1 and Figure 2 the named NSConnection objects are the circles labeled 
s). When a client contacts the server, a new pair of NSConnection objects is 
created specifically to handle communication between the two."


> There is only one problem left: logs show that although I obtain the
> root proxy for the new connection and call a worker method on it in
> client, the server still uses the main thread to respond, instead of
> the newly created connection's thread. More experiment shows that when
> there is already a busy server thread, then the server uses the new
> thread, but when there are no other threads, the main thread is used.
> Is it a kind of optimization the framework does, or is it my bug? I'd
> like that each client thread only worked with its dedicated server
> thread and did not mess with the server's main thread.

I'm not sure exactly what's happening.  It sounds like the connection's ports 
are still scheduled in the main thread's run loop as well as the new thread's 
run loop.  When a request arrives and both run loops are idle, it's effectively 
arbitrary which one will handle the request.  I would have thought that 
-runInNewThread would do this implicitly, but you may have to use 
-[NSConnection removeRunLoop:[NSRunLoop currentRunLoop]] to remove the 
connection's ports from the run loop of the main thread (or whichever thread 
the check-in message is handled by).

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

Button performs action and then stores result to a binding?

2010-09-29 Thread Jonny Taylor
I have a modal dialog which, among other things, contains a number of file 
paths. There are "set..." buttons to set which files these are pointing to. I 
feel that with bindings I should be able to set things up automatically in 
InterfaceBuilder so that when that button is clicked a nav dialog is presented 
[ok, I'll probably need a subclass and/or custom action for that part...], and 
the appropriate bound parameter in my model is updated with the new path as 
chosen by the user.

Unfortunately I cannot work out how I would do this. Apple's BoundButton 
example shows how to use bindings to pass *input* parameters to a method that 
is invoked when a button is clicked. What I want to do is effectively to 
specify what happens to the *return parameter* of the method that is invoked. 
I'm pretty sure that this is not possible per se, but there must be some sort 
of relationship I can construct that will enable me to achieve what I want.

(I suspect I could achieve what I want by passing a pointer to the NSString* 
instance variable, thus enabling the action method to modify it, but that seems 
very wrong indeed. Similarly, if I could work out how, I might be able to pass 
the "setPathString:" selector on the model object as a parameter to the action 
method(!), but this again is so convoluted that it's probably telling me I'm 
not doing it right!)

I think what I'm trying to achieve is quite a tidy pattern - so what is the 
simple implementation that I am missing?
Thanks in advance
Jonny___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: I want a window's file owner that's not a NSWindowController

2010-09-29 Thread Ken Thomases
On Sep 29, 2010, at 3:21 AM, Jonny Taylor wrote:

> OK, while that's a very handy thing to know, I think I have worked out a 
> simpler way that does not require an intermediate class - I'll state it here 
> for the archives (and any comments welcome...)
> 
> I show the window using the following code:
> @implementation Camera
> -(void)showSettingsWindow
> {
>   if (settingsWindowController == NULL)
>   [NSBundle loadNibNamed:@"Camera Settings" owner:self];
>   [settingsWindowController showWindow:self];
> }
> @end
> 
> ... and the NIB file (File's Owner = Camera) contains the window and a 
> controller object (linked together), with the window controller linked to the 
> outlet "settingsWindowController" in File's Owner placeholder.

You should be using an NSWindowController, anyway.  NSWindowController performs 
important services for you, like memory management of the top-level objects in 
the NIB and breaking retain cycles for bindings through File's Owner.  You 
could take care of these yourself, but it's tedious and error-prone.

http://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/MemoryMgmt/Articles/mmNibObjects.html

See the class reference for NSViewController for an oblique reference to the 
binding retain cycle fix in NSWindowController.

Regards,
Ken

___

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

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

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

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


Re: Button performs action and then stores result to a binding?

2010-09-29 Thread Ken Thomases
On Sep 29, 2010, at 6:31 AM, Jonny Taylor wrote:

> I have a modal dialog which, among other things, contains a number of file 
> paths. There are "set..." buttons to set which files these are pointing to.

You should probably by using NSPathControl instead of displaying paths and 
having "set" buttons.

> I feel that with bindings I should be able to set things up automatically in 
> InterfaceBuilder so that when that button is clicked a nav dialog is 
> presented [ok, I'll probably need a subclass and/or custom action for that 
> part...], and the appropriate bound parameter in my model is updated with the 
> new path as chosen by the user.

Bindings aren't magic and they aren't the right solution to every problem.

Buttons should typically use the target-action mechanism to perform their 
purpose.  Just have each button deliver an appropriate message to the 
controller and have the controller update the model.  It's the simplest and 
cleanest approach.

Remember that today you just have a button to perform this action.  Tomorrow or 
in some other context, you may have a toolbar button or a menu item or want to 
invoke the functionality programmatically.  Etc.  Rigging everything up so the 
details of what gets done are stored in the button and its connections is the 
less general solution.  Put the smarts in the controller where they belong and 
they can be reused later.

Just about the only properties of a button (or other control) that are safe to 
use for a purpose such as this are the action, the target, and the tag.  If you 
really want, you can have multiple buttons all invoke the same action method on 
the same target and then have that method operate slightly differently based on 
the sender's tag.  I think you'll find that, in most cases, it's not an 
improvement over just using a separate action method per button.

Regards,
Ken

___

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

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

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

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


Core data: Inverse relationships with subclasses

2010-09-29 Thread Gideon King
Hi, I have a bidirectional one to one relationship between two entities like 
this:

Foo <-> Bar, and Foo has a subclass FooSub. All entities are concrete. 

Sometimes when I set the inverse relationship it's like this aBar.toFoo = aFoo, 
and this works fine, but when it's linking back to the subclass, aBar.toFoo = 
aFooSub, it fails with a validation error: toFoo is not valid, dangling 
reference to an invalid object = null.

I would have thought it would be OK for the relationship to point to an 
instance of FooSub shouldn't it? After all, it is a subclass of Foo. Or do 
things work differently for subclasses in Core Data? If so, how should I work 
around this problem?

TIA

Gideon






___

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

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

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

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


Re: My NSSwappedDouble decoding crashes on iPhone 4

2010-09-29 Thread Markus Spoettl
On Sep 29, 2010, at 2:41 AM, Markus Spoettl wrote:
> The the Mac code is 32bit and runs on Leopard and Snow Leopard.
> 
> - (void)encodeDouble:(double)value forKey:(NSString *)key withCoder:(NSCoder 
> *)encoder
> {
>NSSwappedDouble sd = NSSwapHostDoubleToLittle(value);
>[encoder encodeBytes:(const uint8_t *)&sd length:sizeof(NSSwappedDouble) 
> forKey:key];
> }
> 
> - (double)decodeDoubleForKey:(NSString *)key withCoder:(NSCoder *)decoder
> {
>double result = 0.0;
>NSUInteger retsize;
>NSSwappedDouble *sd = (NSSwappedDouble *)[decoder decodeBytesForKey:key 
> returnedLength:&retsize];
>if (retsize == sizeof(NSSwappedDouble)) {  // <=== crash
>result = NSSwapLittleDoubleToHost(*sd);
>}
>return result;
> }


I just noticed the unfamiliar exception code EXC_ARM_DA_ALIGN. Googling it 
turns up that I'm not the only one experiencing the issue. I'll post a solution 
when I have it ready. Sorry for the noise.

Regards
Markus

--
__
Markus Spoettl

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Acquiring an NSConnection otherwise than by registered name?

2010-09-29 Thread Oleg Krupnov
Hi Ken,

> I'm not sure exactly what's happening.  It sounds like the connection's ports 
> are still scheduled in the main thread's run loop as well as the new thread's 
> run loop.  When a request arrives and both run loops are idle, it's 
> effectively arbitrary which one will handle the request.  I would have 
> thought that -runInNewThread would do this implicitly, but you may have to 
> use -[NSConnection removeRunLoop:[NSRunLoop currentRunLoop]] to remove the 
> connection's ports from the run loop of the main thread (or whichever thread 
> the check-in message is handled by).

I tried -[NSConnection removeRunLoop:[NSRunLoop currentRunLoop]], but
it doesn't seem to change anything.

Well, I could live with it, because the server already works as
multi-threaded, but the problem is that the new thread that is
spawned, is not released if the request is handled in the main thread,
when I call -invalidate on the connection. And there does not seem a
way to get the thread created by runInNewThread to exit it manually,
or is there?

Thanks,

Oleg.

On Wed, Sep 29, 2010 at 2:22 PM, Ken Thomases  wrote:
> Hi Oleg,
>
> On Sep 29, 2010, at 5:16 AM, Oleg Krupnov wrote:
>
>> Now I see. I hardly find words to thank you for your patience! :)
>
> You're welcome.  I'm glad I could help.
>
>
>> Now I see that the correct picture is the following. There is only one
>> connection point, and there is only one root vended object in the
>> server. I need only to make sure that each client thread uses a
>> different connection object, though all connections use the same
>> connection point and send port on server (addressed by its single
>> registered name).
>
> In the server, it is the receive port which is registered under a name.  The 
> server "receives" connections from clients on that port.  (Actually, reading 
> the docs for -initWithReceivePort:sendPort:, the server's connection point 
> typically uses the same port for receive and send.)
>
>> In other words, this new connection is like a
>> parallel channel to the same root vended object. So when I call
>> rootProxy on the new connection on client, I obtain the same root
>> proxy (not the per-thread proxy that I initially thought of).
>
> You should receive a different proxy to the same root object.  (The root 
> proxy is an NSDistantObject that is specific to the connection.  So, a 
> different connection implies a different proxy object.)
>
> But you are correct that the design has a single root object in the server, 
> not multiple root objects, one for each client connection.
>
>> Then I
>> ask this root proxy to take the current connection and detach it to a
>> new thread. Objects and threads are fully orthogonal.
>
> Well, the client shouldn't be aware that its check-in message has the result 
> of spawning a new thread in the server.  The check-in message should just be 
> a way for the client to make the server aware of it, and to initiate service 
> for it (whatever "service" means in your application).  The server could be 
> designed either way, with a separate thread per client connection or all 
> handled by one thread.
>
> If having a single root object feels cumbersome, the root object could be 
> turned into just a factory for per-client service objects.  So, the client 
> checks in and asks the single root object for a new object which will serve 
> just it (that specific client; I consider each thread within the client 
> process to be a separate "client" in your design).  The server creates a new 
> object to satisfy that request, and that new object would be initialized with 
> whatever state is specific to that client.  It would also happen to spin off 
> a separate thread to handle communications with that client, but that's an 
> implementation detail.
>
>
>> Of course, I've read all docs, but I found them quite scarce and even
>> confusing at times. Only with your help, and with some knowledge of
>> sockets I have, I went down to the basics and became able to
>> understand how it works under the hood.
>
> OK.  I can definitely see how the docs can be confusing or less than 
> thorough.  I recommend that you file requests for enhancements to anything 
> you didn't understand.
>
>> For example, the docs say
>> nothing about the notion of connection points as opposed to child
>> connections. It calls everything a "NSConnection" and this was my
>> source of confusion.
>
> They do say "the connection labeled s is used to form new connections" and "A 
> named connection rarely has a channel to any other NSConnection object (in 
> Figure 1 and Figure 2 the named NSConnection objects are the circles labeled 
> s). When a client contacts the server, a new pair of NSConnection objects is 
> created specifically to handle communication between the two."
>
>
>> There is only one problem left: logs show that although I obtain the
>> root proxy for the new connection and call a worker method on it in
>> client, the server still uses the main thread to re

Text "ghosting" or "doubling" problem

2010-09-29 Thread Andrew Hughes

Hello all,

I am working on a word processing problem. I have a paginated view  
that has multiple text containers and text views laid out to form pages.


I have an intermittent bug where one line of text from another text  
view/text container gets overlaid onto a line from the "current" text  
view/text container. I think this always happens with the first lines,  
such that one line is drawn on the top of the other line. The "ghosted  
line" is still visible in the second container, and both lines change  
if I edit that line. I can click on the text view or scroll and the  
"ghost" line of text will often disappear or flicker and reappear  
(perhaps as the text view is displayed?).


I think I've narrowed the problem down to calling NSLayoutManager's  
method "rectArrayForGlyphRange". Basically I think that if I call this  
and ask for a glyph range that is longer than what is contained in the  
current text container, this is somehow causing other text to bleed  
over. The doc's state that these arrays are reused by the layout  
manager.


Has anyone else run into this? Is this the expected behavior?

Thanks - Andrew Hughes
___

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

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

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

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


Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread jeremy
If your data store is SQLite, I believe the problem is the subclass FooSub.

Since FooSub is a subclass of Foo, CoreData combines both Foo and FooSub into a 
single table whose columns include all properties from Foo AND FooSub.

Consequently, when you create a new instance of Foo, columns from FooSub may 
contain invalid data. 

You can easily verify this by opening your SQLite database store with SQLite 
Database Browser, found at:

http://sqlitebrowser.sourceforge.net

For a solution, rework your schema to subclass FooSub directly from 
NSManagedObject.


On Sep 29, 2010, at 9:28 AM, Gideon King wrote:

> Hi, I have a bidirectional one to one relationship between two entities like 
> this:
> 
> Foo <-> Bar, and Foo has a subclass FooSub. All entities are concrete. 
> 
> Sometimes when I set the inverse relationship it's like this aBar.toFoo = 
> aFoo, and this works fine, but when it's linking back to the subclass, 
> aBar.toFoo = aFooSub, it fails with a validation error: toFoo is not valid, 
> dangling reference to an invalid object = null.
> 
> I would have thought it would be OK for the relationship to point to an 
> instance of FooSub shouldn't it? After all, it is a subclass of Foo. Or do 
> things work differently for subclasses in Core Data? If so, how should I work 
> around this problem?

___

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

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

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

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


portable app

2010-09-29 Thread Amy Heavey

I'm writing an app for personal use, using core data.

At the moment it's set up to save the data file in the library/ 
application support/myapp folder on the machine. I also want to store  
a growing number of images to use with the app, so they are set to  
store in this folder as well.


However, I'd like to be able to use this app on my laptop as well as  
the desktop. I don't really fancy managaing some kind of sync, and  
thought the best solution would be to store the app and all the data/ 
images on a thumb drive. There's only me using the app, and having to  
walk and get the drive from the office isn't a huge headache, and I  
can easily take it with me if I want to work elsewhere (not on my home  
network).


How would I set the data store to a mobile drive? can anyone point me  
at a tutorial? Is it as simple as naming the thumbdrive and referring  
to it by name in the code? The Code I've currently got is the auto/ 
default type set up, following the Hillegass book as well,


Thanks,
Amy

___

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

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

2010-09-29 Thread Martin Wierschin

On Sep 29, 2010, at 16:02, Trygve Inda  wrote:

There is example code here (2nd example) that removes before setting  
too.


http://stackoverflow.com/questions/1024938/renaming-keys-in-nsmutabledictionary


That 2nd example shouldn't be followed. Either retain the value  
obtained from the dictionary before removing the key, or store the  
value using the new key before removing the old key.



On 2010.09.29, at 1:07 AM, Roland King wrote:

There's nothing odd about it. It's simple memory management rules.  
The moment you remove the object from the dictionary the dictionary  
is no longer an owner and since you've not retained it, neither are  
you. If nobody else is, it's subject to dealloc as soon as the  
dictionary releases it If it so happens it is on an outer  
autorelease pool on PPC that's just lucky.


I think there is a warning about this in the documentation too.


Yes, see:

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ 
MemoryMgmt/Articles/mmObjectOwnership.html%23//apple_ref/doc/uid/ 
2043-1000922


When an object is removed from one of the fundamental collection  
classes, it is sent a release (rather thanautorelease) message. If  
the collection was the only owner of the removed object, the removed  
object (heisenObjectin the example ) is then immediately deallocated.



~Martin

___

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

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

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

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


Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Quincey Morris
On Sep 29, 2010, at 06:28, Gideon King wrote:

> I would have thought it would be OK for the relationship to point to an 
> instance of FooSub shouldn't it? After all, it is a subclass of Foo. Or do 
> things work differently for subclasses in Core Data? If so, how should I work 
> around this problem?

You repeatedly say "subclass". Do you mean "sub-entity", or do you really mean 
a subclass with no corresponding Core Data entity?

Core Data needs to know, from your data model, the custom class (if any) for 
every entity. It can't use NSManagedObject subclasses that aren't modeled, even 
if they're sub-subclasses of a modeled subclass.


___

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

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

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

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


Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Jerry Krinock

On 2010 Sep 29, at 09:19, jeremy wrote:

> For a solution, rework your schema to subclass FooSub directly from 
> NSManagedObject.

That might work.  If it doesn't,

On Sep 29, 2010, at 9:28 AM, Gideon King wrote:

> All entities are concrete … I would have thought it would be OK for the 
> relationship to point to an instance of FooSub shouldn't it? After all, it is 
> a subclass of Foo.

Not sure about that.  I'd have made it be a subentity.  Core Data knows more 
about entities than classes.

(But if you do make a subentity, and do a migration someday, remember that you 
need to work around a bug if you allow operation in Mac OS 10.5.)

___

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

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

2010-09-29 Thread Matt Neuburg

On Sep 29, 2010, at 12:02 PM, cocoa-dev-requ...@lists.apple.com wrote:

> Message: 6
> Date: Wed, 29 Sep 2010 17:48:43 +0100
> From: Amy Heavey 
> Subject: portable app
> To: cocoa-dev@lists.apple.com
> Message-ID:
>   <5bd34c42-c5df-42a4-a054-9f6f9376d...@willowtreecrafts.co.uk>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
> 
> I'm writing an app for personal use, using core data.
> 
> At the moment it's set up to save the data file in the library/ 
> application support/myapp folder on the machine. I also want to store  
> a growing number of images to use with the app, so they are set to  
> store in this folder as well.
> 
> However, I'd like to be able to use this app on my laptop as well as  
> the desktop. I don't really fancy managaing some kind of sync, and  
> thought the best solution would be to store the app and all the data/ 
> images on a thumb drive. There's only me using the app, and having to  
> walk and get the drive from the office isn't a huge headache, and I  
> can easily take it with me if I want to work elsewhere (not on my home  
> network).
> 
> How would I set the data store to a mobile drive?

I believe it would be sufficient to make the myapp folder a symlink to a folder 
on the mobile drive. 

m. 

___

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

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

2010-09-29 Thread Keary Suska
On Sep 29, 2010, at 2:54 AM, Lukas Tenbrink wrote:

> I've got a question about background tasking, and I couldn't really answer 
> myself it by searching in the documentation (or even in the internet).
> I want to make a background task with an application. Firstly, I used the 
> code they gave as a sample, which looks like this:

> It actually shows my local notification, but I want the application to check 
> for some conditions (like "Is the Device charging?" or "In what way does the 
> user hold the device?"), and if certain conditions are complied with, I want 
> to show the local notification. So I only want that the Device sends me a 
> message from time to time (like every 10 seconds), then I execute a little 
> bit of code, and maybe show this notification.
> 
> Does somebody know if this is possible? Thanks in before,

Long running (and especially perpetual) background tasks are not permitted. If 
your app isn't rejected by Apple outright, your app will be force terminated by 
the OS anyway after the max time is reached. You can read more about this in 
the IOS Human Interface Guidelines.

HTH,

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

___

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

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

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

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


Open Multiple Files

2010-09-29 Thread Richard Somers

I need to know how many files the user is attempting to open.

The NSApplicationDelegate Protocol has this method.

- (void)application:(NSApplication *)sender openFiles:(NSArray  
*)filenames


Just count the number of items in the array and then re-route the call  
for continued processing. But re-routing the call using super will not  
work because this is a delegate method. You can't send it back to  
NSApp because it has no methods for opening files.


Does anyone know how this could be easily done?

--Richard Somers

___

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

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

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

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


Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Gideon King
Thanks but no, it's an atomic store which gets written to XML.

Regards

Gideon

On 30/09/2010, at 2:19 AM, jeremy wrote:

> If your data store is SQLite, I believe the problem is the subclass FooSub.
> 
> Since FooSub is a subclass of Foo, CoreData combines both Foo and FooSub into 
> a single table whose columns include all properties from Foo AND FooSub.
> 
> Consequently, when you create a new instance of Foo, columns from FooSub may 
> contain invalid data. 
> 
> You can easily verify this by opening your SQLite database store with SQLite 
> Database Browser, found at:
> 
> http://sqlitebrowser.sourceforge.net
> 
> For a solution, rework your schema to subclass FooSub directly from 
> NSManagedObject.
> 
> 
> On Sep 29, 2010, at 9:28 AM, Gideon King wrote:
> 
>> Hi, I have a bidirectional one to one relationship between two entities like 
>> this:
>> 
>> Foo <-> Bar, and Foo has a subclass FooSub. All entities are concrete. 
>> 
>> Sometimes when I set the inverse relationship it's like this aBar.toFoo = 
>> aFoo, and this works fine, but when it's linking back to the subclass, 
>> aBar.toFoo = aFooSub, it fails with a validation error: toFoo is not valid, 
>> dangling reference to an invalid object = null.
>> 
>> I would have thought it would be OK for the relationship to point to an 
>> instance of FooSub shouldn't it? After all, it is a subclass of Foo. Or do 
>> things work differently for subclasses in Core Data? If so, how should I 
>> work around this problem?
> 

___

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

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

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

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


Core Data inheritance across models?

2010-09-29 Thread Rick Mann
Is it possible for an Entity defined in one .xcdatamodel file to inherit from 
an Entity in a separate .xcdatamodel file?

TIA,
Rick

___

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

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

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

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


Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Gideon King
Sorry, I should have been clearer. It is a sub-entity which is implemented as a 
subclass.

Regards

Gideon

On 30/09/2010, at 3:39 AM, Quincey Morris wrote:

> On Sep 29, 2010, at 06:28, Gideon King wrote:
> 
>> I would have thought it would be OK for the relationship to point to an 
>> instance of FooSub shouldn't it? After all, it is a subclass of Foo. Or do 
>> things work differently for subclasses in Core Data? If so, how should I 
>> work around this problem?
> 
> You repeatedly say "subclass". Do you mean "sub-entity", or do you really 
> mean a subclass with no corresponding Core Data entity?
> 
> Core Data needs to know, from your data model, the custom class (if any) for 
> every entity. It can't use NSManagedObject subclasses that aren't modeled, 
> even if they're sub-subclasses of a modeled subclass.

___

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

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

2010-09-29 Thread Sean McBride
On Wed, 29 Sep 2010 16:21:41 -0600, Richard Somers said:

>I need to know how many files the user is attempting to open.
>
>The NSApplicationDelegate Protocol has this method.
>
>- (void)application:(NSApplication *)sender openFiles:(NSArray
>*)filenames
>
>Just count the number of items in the array and then re-route the call
>for continued processing. But re-routing the call using super will not
>work because this is a delegate method. You can't send it back to
>NSApp because it has no methods for opening files.
>
>Does anyone know how this could be easily done?

Are you a document-based app?  Have you seen this:?


--

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


___

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

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

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

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


Re: Core Data inheritance across models?

2010-09-29 Thread Sean McBride
On Wed, 29 Sep 2010 15:29:39 -0700, Rick Mann said:

>Is it possible for an Entity defined in one .xcdatamodel file to inherit
>from an Entity in a separate .xcdatamodel file?

No (AFAIK).  But .xcdatamodels are not magic, you could build everything
programatically I suppose.  See: NSEntityDescription,
NSManagedObjectModel, etc.

--

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


___

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

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

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

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


Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Gideon King
Hi Jerry,

Can I just clarify what you mean about working around a bug on 10.5? I do need 
this to work on 10.5. 

FooSub is a subentity of Foo, and both have their classes defined, with 
FooSub's class being a subclass of Foo's class.

Thanks

Gideon

On 30/09/2010, at 3:49 AM, Jerry Krinock wrote:

> 
> On 2010 Sep 29, at 09:19, jeremy wrote:
> 
>> For a solution, rework your schema to subclass FooSub directly from 
>> NSManagedObject.
> 
> That might work.  If it doesn't,
> 
> On Sep 29, 2010, at 9:28 AM, Gideon King wrote:
> 
>> All entities are concrete … I would have thought it would be OK for the 
>> relationship to point to an instance of FooSub shouldn't it? After all, it 
>> is a subclass of Foo.
> 
> Not sure about that.  I'd have made it be a subentity.  Core Data knows more 
> about entities than classes.
> 
> (But if you do make a subentity, and do a migration someday, remember that 
> you need to work around a bug if you allow operation in Mac OS 10.5.)
> 
> 
___

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

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

2010-09-29 Thread Richard Somers

On Sep 29, 2010, at 4:32 PM, Sean McBride wrote:


Are you a document-based app?  Have you seen this:?



Yes it is document-based app. I have seen this, but not recently.  
Looks like it would require subclassing NSDocumentController and  
overriding the 'openDocument:' method.


I put a breakpoint on 'openDocument:' and it is triggered with  
file>open from the main menu but it is not called when directly  
opening files from the Finder.


--Richard Somers

___

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

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

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

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


Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Quincey Morris
On Sep 29, 2010, at 15:30, Gideon King wrote:

> Sorry, I should have been clearer. It is a sub-entity which is implemented as 
> a subclass.

Hmm. I'd suspect a limitation of delete cascading rules, but that doesn't 
really fit with the error message your reported. Was that error text exactly 
what was displayed? It appeared when *saving*, yes (as opposed to setting the 
relationship)?

If the inverse is in fact being set to an invalid object, I'd take a look at 
the way the subclass object is being created. If that's not fruitful, ...

It's also possible to override some validation methods (see 
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdValidation.html%23//apple_ref/doc/uid/TP40004807-SW3).
 In your override, you could call the super implementation first and break if 
that fails. That would let you inspect the objects and relationships involved.


___

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

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

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

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


Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Gideon King
That's actually how I eventually managed to work out that it appeared to be a 
subclass/subentity thing. It got picked up on validateForInsert when I was 
doing a Save As, and I checked the objects, and they all seemed fine.

But this actually gives me an idea for a bit more testing that I can do - I'll 
get the inserted, updated and deleted objects from the managed object context 
and run the validation on them at some different points in my program to see if 
there is something else going on that could be affecting it.

Regards

Gideon

On 30/09/2010, at 9:22 AM, Quincey Morris wrote:

> On Sep 29, 2010, at 15:30, Gideon King wrote:
> 
>> Sorry, I should have been clearer. It is a sub-entity which is implemented 
>> as a subclass.
> 
> Hmm. I'd suspect a limitation of delete cascading rules, but that doesn't 
> really fit with the error message your reported. Was that error text exactly 
> what was displayed? It appeared when *saving*, yes (as opposed to setting the 
> relationship)?
> 
> If the inverse is in fact being set to an invalid object, I'd take a look at 
> the way the subclass object is being created. If that's not fruitful, ...
> 
> It's also possible to override some validation methods (see 
> http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdValidation.html%23//apple_ref/doc/uid/TP40004807-SW3).
>  In your override, you could call the super implementation first and break if 
> that fails. That would let you inspect the objects and relationships involved.
> 

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Acquiring an NSConnection otherwise than by registered name?

2010-09-29 Thread Ken Thomases
Hi Oleg,

On Sep 29, 2010, at 9:57 AM, Oleg Krupnov wrote:

> I tried -[NSConnection removeRunLoop:[NSRunLoop currentRunLoop]], but
> it doesn't seem to change anything.

Huh.  I don't know what's going on there.  You might consider opening a 
developer technical support incident with Apple to ask them for advice on how 
to achieve what you want.  Those cost money, but probably not as much as your 
time.


> Well, I could live with it, because the server already works as
> multi-threaded, but the problem is that the new thread that is
> spawned, is not released if the request is handled in the main thread,
> when I call -invalidate on the connection. And there does not seem a
> way to get the thread created by runInNewThread to exit it manually,
> or is there?

Probably not, but you could re-implement -runInNewThread and make arrangements 
to terminate the thread on other occasions.

I think that an alternative implementation should just remove the connection 
from the current run loop and spawn a new thread.  The method of the new thread 
would add the connection to its run loop and run the run loop indefinitely.  
You could change that to add your own signaling mechanism so that, when 
signaled, the thread would exit instead of looping through the run loop again.

Regards,
Ken

___

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

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

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

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


Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Jerry Krinock

On 2010 Sep 29, at 15:57, Gideon King wrote:

> Can I just clarify what you mean about working around a bug on 10.5? I do 
> need this to work on 10.5.

It was Quincey who tipped me off to this a few weeks ago:

http://developer.apple.com/mac/library/releasenotes/Cocoa/MigrationCrashBuild106Run105/index.html

It's all true.___

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

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

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

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


Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Gideon King
Thanks Jerry, I'll need to keep that in mind. 

In the meantime, I've done more research this morning, and it appears that the 
underlying issue is that my one to one relationships that have an inverse are 
not being maintained properly during a Save As operation, even though at the 
managed object level the relationships are definitely still showing up as being 
correct. 

I think it must have something to do with my atomic store or my atomic store 
cache nodes, but am really not sure what to look for at this stage. 

Am continuing to investigate this afternoon...


Regards

Gideon



On 30/09/2010, at 1:30 PM, Jerry Krinock wrote:

> 
> On 2010 Sep 29, at 15:57, Gideon King wrote:
> 
>> Can I just clarify what you mean about working around a bug on 10.5? I do 
>> need this to work on 10.5.
> 
> It was Quincey who tipped me off to this a few weeks ago:
> 
> http://developer.apple.com/mac/library/releasenotes/Cocoa/MigrationCrashBuild106Run105/index.html
> 
> It's all true.___
> 

___

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

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


CGEventTap Not Receiving Events after some time

2010-09-29 Thread Erik Aigner
When I create an event tap with  CGEventTapCreate(..) and add it to the runloop 
everything works as expected.
However, after some time (I don't know what triggers this) the event tap 
doesn't receive events anymore, until
I manually call CGEventTapEnable(..) again.

Any clues what could cause this? Are there any notifications for status changes 
that i should know about?

Regards, Erik

PS:

I checked if kCGEventTapDisabledByTimeout or kCGEventTapDisabledByUserInput are 
sent to my callback,
but that doesn't seem to be the case 
either.___

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

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


Accessing Scrollers in NSBrowser ?

2010-09-29 Thread Naresh Kongara
Hi,

I want to add an icon over scrollers of Each column in NSBrowser.

How can I access the scrollview of each column and how to add action icon to 
the scroller in each column.

Can anybody help me out ?


Thanks.
kongara___

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

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


Interface showing wrong values

2010-09-29 Thread Evan Coleman
I'm having a very strange problem. I can't provide any code because I don't
know which part of my code is causing the problem. I have an NSMenuExtra,
and for some reason some labels and image views in an NSView inside of an
NSMenuItem are displaying their default values (the values that are set in
interface builder). But when I do [textField stringValue] it returns the
value it should be displaying, not what is actually displayed. Anyone know
what's causing this?

Thanks,
Evan
___

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

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


Creating and associating my own file extension based on plist

2010-09-29 Thread Ignacio Enriquez
Hi
This is basically a duplicate of this thread:
but the more eyes the better I thought so here is my question:

My iPad application handles with files of type *.mndl which is not
more than a customized *.plist. Up until now I've been using *.plist
files but now I want to associate the extension and be able to open
*.mndl files from any other app I have realized that renaming
file.plist to file.mndl does not work. (Hence, I don't even know if I
did correctly the extension association and exportation thing)

I sent to myself a file file.mndl from the computer and when received
in mail.app I got file.mndl.plist (It was automatically renamed and my
guess is because of its header)

How can I create my own *.mndl files while being able to read its
content using +dictionaryWithContentsOfFile: of NSDictionary class?

Even I am working with iOS I believe this kind of things were ported
from MacOS and Cocoa. So Cocoa developers could also know about this.

Thanks in advance

Ignacio.
___

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

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

2010-09-29 Thread Kyle Sluder
On Sep 29, 2010, at 7:02 PM, Evan Coleman  wrote:

> I'm having a very strange problem. I can't provide any code because I don't
> know which part of my code is causing the problem. I have an NSMenuExtra,
> and for some reason some labels and image views in an NSView inside of an
> NSMenuItem are displaying their default values (the values that are set in
> interface builder). But when I do [textField stringValue] it returns the
> value it should be displaying, not what is actually displayed. Anyone know
> what's causing this?

Are you sure you're talking to the objects you think you're talking to? Most 
often this happens because two copies of the views are created, and the code 
only interacts with the offscreen one.

--Kyle Sluder___

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

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

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

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


Re: Table column alignment

2010-09-29 Thread Reinhard Segeler

No.

-- Reinhard 

Am 26.09.2010 um 18:04 schrieb k...@highrolls.net:

In IB I have set the properties of a table text field cell to be  
right justified but do not see this result when displaying data;  
i.e. the data remains left justified. Is there some other setting  
that must be made for the IB alignment setting to be used?



-koko
___

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

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

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

This email sent to macmeid...@googlemail.com


___

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

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

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

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