Re: Rotated and scaled CALayer

2010-12-07 Thread Rimas M.
Hello Andreas,

Thank you for detailed explanation.

However, I am not able to do what I want. Almost.

I have discovered, that if I use only CA layers transformations (via
setTransform:), I am getting the same rotated pixels when zooming in.
The only way, which does what I want is:
a) use core image filter to rotate layer (simple CIAffineTransform)
b) use second CI filter to tell renderer to use nearest interpolation
instead of linear.
c) use CA transformation to scale layer

Filter mentioned in b) does nothing. It only sets
kCISamplerFilterNearest for kCISamplerFilterMode of the input sampler.
And for c) I am using CATransform3DMakeScale.

Result is OK - when zooming in pixels remains unrotated. But new
problem occurs - when scrolling (even slowly) zoomed in layer, the
"pixels" flickers. And that causes filter of b). If I am not using it,
o its kCISamplerFilterMode setting to the kCISamplerFilterLinear,
flickering is gone. But zoomed pixels becomes rotated.

Rotated pixels:
http://dl.dropbox.com/u/2030721/ForAppleList/Rotated%20Pixels.png
Expected result:
http://dl.dropbox.com/u/2030721/ForAppleList/Non-rotated_pixels_when_zooming_in.png

Best Regards,

Rimas M.

p.s. I could provide sample application to demonstrate problem.

> - You should add your new layer as a sublayer to the layer of the 
> view-controller's view - or as a sublayer to any other layer than the 
> controller view's layer.
>
> - Usually, you "draw" the contents only once. However, when you set an 
> *image* via the layers's contents property, you don't need to explicitly draw 
> the layer - the layer draws the image for you, when it is required. So, just 
> set the image as the layer's contents.
>
> - You can scale/zoom the layers's contents by setting the layer's transform 
> property accordingly. This uses Core Animation, which executes - if possible 
> - on the GPU, and is therefore the fastest method. Note, this doesn't require 
> the image to be "drawn" again (it requires "rendering").
> You can create a suitable transform which scales AND zooms at once.
>
> - A CALayer's properties are "animatable" (see Core Animation). In fact, 
> changes in properties are animated by default. But you can define any 
> animation, and CA nicely performs them for you.
>
> - Using Core Graphics functions is *usually* not as fast as Core Animation 
> (if a CA alternative exists). But certainly, CG has its use. So, if you want 
> to scale and zoom interactively, use CA.
>
> Regarding transforms, see also:
> CATransform3DMakeRotation, CATransform3DMakeScale, CATransform3DConcat
>
>
> Regards,
>
> Andreas
___

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

Please do not post admin requests or moderator comments to the list.
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: Updating progress of UIProgressView. And Getting Better Saving Performance

2010-12-07 Thread Gustavo Pizano
Hello Guys..

I see, I have been using GCD and blocks but on somme OSX app I did before, not 
on iPhone, I tough tit wasn't there... :P. 

SO, I from within the method( block) that makes all the saving process, I do 
something like 

>>  dispatch_async(dispatch_get_main_queue(), ^{
>> // code executed on main thread goes here (i.e., updating the 
>> progress indicator in your case
>> 
>>  });


and update the progress indicator bar,  great im gonna try that..

also I have the option to call from within the same method a  [ performSelectorinMainThread: withObject: waitUntilDone:NO];  

right?


What about the saving operation improving its saving time?,  I will check today 
what takes longer, if creating the thumbnial, or encoding the views,  maybe I 
shouldn't encode the whole view, but s just the image reference and the 
transform matrix...  ?/ I will try that one also.

Thanks for the replies.. 


Gustavo


On Dec 7, 2010, at 4:22 AM, davel...@mac.com wrote:

> 
> On Dec 6, 2010, at 9:21 PM, Laurent Daudelin wrote:
> 
>> On Dec 6, 2010, at 17:16, davel...@mac.com wrote:
>> 
>>> On Dec 6, 2010, at 5:37 PM, Gustavo Pizano wrote:
>>> 
 Hello.
 
 My application is saving some data, and it takes a while to do it, it can 
 be 1 second to 10 sec around.. Im doing some image processing,  The thing 
 is..
 
 I send the saving operation in another thread using the NSThread + 
 detachNewThreadSelector:toTarget:withObject: method,  and in the main 
 thread I update a UIActivityIndicator, and stop it when I receive the 
 NSThreadWillExitNotification.  The problem is that when it takes long to 
 save, it may seem the app is somehow stuck, even the spinning indicator is 
 running. I wanted to change the ActivityIndicator to a progressview, but 
 then I can't make it work because the saving process not on the main 
 thread, i think.. correct me if Im wrong, Im not so much familiar with 
 multithreaded apps.
 
 As for the saving process, what I do is the following.
 
 I have a Parent view which contains subviews, these subviews are drawing 
 images. The user can modify this images, (scale and rotate), so when I 
 save i encode these views so it will save the view's transform,  and then  
 I archive the data I encoded for all these subviews.
>>> 
>>> 
>>> 
>>> 
>>> You are correct that you cannot call GUI methods from other threads, but 
>>> NSObject (which all your UI objects inherit from) has the method.
>>> 
>>> - (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg
>>> 
>>> So from your other thread, you can update the progress indicator by using 
>>> it to call a method that updates the progress. 
>>> 
>>> 
>>> This is even easier if you are targeting iOS 4.0 and higher using Blocks 
>>> and GrandCentral Dispatch.
>>> 
>>> Code typed in email (i.e., not tested):
>>> 
>>> dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 
>>> 0), ^{
>>>  // code you want implemented on another thread goes here:
>>> 
>>>  dispatch_async(dispatch_get_main_queue(), ^{
>>> // code executed on main thread goes here (i.e., updating the 
>>> progress indicator in your case
>>> 
>>>  });
>>>  });
>>> 
>>> HTH,
>>> Dave
>> 
>> Maybe I'm missing something but aren't the UI actions supposed to happen in 
>> the main thread, in this case, he should really call 
>> "performSelectorOnMainThread:withObject:waitUntilDone:"?
>> 
>> -Laurent.
> 
> 
> I copied and pasted the wrong method. Yes, the onMainThread version is the 
> one to use for this.
> 
> The Grand Central Dispatch code is ok though as Conrad pointed out.
> 
> Dave
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/gustavxcodepicora%40gmail.com
> 
> This email sent to gustavxcodepic...@gmail.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


Re: Problem instantiating an array

2010-12-07 Thread Graham Cox

On 07/12/2010, at 5:35 PM, Ken Thomases wrote:

>> gameColumns = [NSArray arrayWithObjects:allColumns count: boardDimension];


Another issue with this line is that, assuming 'gameColumns' is an instance 
variable of the object, the array will be autoreleased, leaving the variable 
pointing at deallocated memory, which will surely crash later.

--Graham


___

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

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

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

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


QT streaming with initWithAttributes

2010-12-07 Thread Leonardo
Ok, I have found, in order to use QTMovieDataSizeAttribute I must set
QTMovieOpenForPlaybackAttribute to YES. But, when
QTMovieOpenForPlaybackAttribute is YES I can't access the Movie variable, as

mMovie = (Movie)[mQTMovie quickTimeMovie];

and I need the mMovie variable, e.g. for
SetMovieVisualContext(mMovie, visualContext->context);

How to deal with this restriction? I am puzzled.


Regards
-- Leonardo


___

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

Please do not post admin requests or moderator comments to the list.
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: Problem instantiating an array

2010-12-07 Thread Ken Thomases
On Dec 7, 2010, at 2:40 AM, Graham Cox wrote:

> On 07/12/2010, at 5:35 PM, Ken Thomases wrote:
> 
>>> gameColumns = [NSArray arrayWithObjects:allColumns count: boardDimension];
> 
> Another issue with this line is that, assuming 'gameColumns' is an instance 
> variable of the object, the array will be autoreleased, leaving the variable 
> pointing at deallocated memory, which will surely crash later.

Yeah.  I got sidetracked by the other issues enough that I didn't even get 
around to considering the memory management problems.  Conrad Shultz addressed 
another, with the TileColumn instances in the allColumns array.

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: problem with core data and uno

2010-12-07 Thread Mike Abdullah
This is the correct behaviour (at least from Core Data's perspective). Undoing 
registration effectively amends changes onto the previous change. It doesn't 
remove the changes entirely from Core Data's notice.

On 6 Dec 2010, at 19:40, kvic...@pobox.com wrote:

> i'm having a problem with core data and undo. here is the simplified 
> situation. i've got subclasses of NSManagedObject: object A and object B. 
> object A has a to-one relationship to object B. the reciprocal relationship 
> in object B is a to many relationship. i.e., object B can refer to multiple 
> object A s, but object A can only reference one object B. i then edit object 
> A (using a sheet to enable editing multiple properties simultaneously) to 
> refer to a different object B. this is an undoable user action. later on i 
> programmatically change one of the properties of object B. this is NOT 
> undoable, and the change is done as follows:
> 
>   [moc processPendingChanges];
>   [[moc undoManager] disableUndoRegistration];
> 
>   b.propertyB = blah;
>   ...
> 
>   [moc processPendingChanges];
>   [[moc undoManager] enableUndoRegistration];
> 
> now if i subsequently undo the first set of edits to object A, propertyB of 
> object B gets reverted back to the value it had prior to this entire 
> sequence. this strikes me as wrong! while the first set of edits (to object 
> A) did change the to many relationship that object B had, they did not touch 
> the propertyB property and should not have reverted it.
> 
> it seems to me that core data is saving the entire state of object B, instead 
> of simply the state of the to many relationship.
> 
> can anyone confirm my suspicions? or suggest that possibly this is a bug in 
> my app -- i have spent about 12 hours trying to track this down in my app, 
> and haven't found anything? or if my suspicions are correct, can anyone 
> suggest a work-around? or is there some other way to do this?
> 
> thanx,
> 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/cocoadev%40mikeabdullah.net
> 
> This email sent to cocoa...@mikeabdullah.net

___

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

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

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

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


Re: Updating progress of UIProgressView. And Getting Better Saving Performance

2010-12-07 Thread David Reed

On Dec 7, 2010, at 3:16 AM, Gustavo Pizano wrote:

> Hello Guys..
> 
> I see, I have been using GCD and blocks but on somme OSX app I did before, 
> not on iPhone, I tough tit wasn't there... :P. 


Blocks/GCD are in iOS 4.0 and higher. Assuming you have a paid developer 
account, you may want to watch the relevant WWDC videos from last year.

> 
> SO, I from within the method( block) that makes all the saving process, I do 
> something like 
> 
>>> dispatch_async(dispatch_get_main_queue(), ^{
>>>// code executed on main thread goes here (i.e., updating the 
>>> progress indicator in your case
>>> 
>>> });
> 
> 
> and update the progress indicator bar,  great im gonna try that..


Yes.


> 
> also I have the option to call from within the same method a  [ With the Progress indicator> performSelectorinMainThread: 
> withObject: waitUntilDone:NO];  
> 
> right?


Yes, ssuming the selector you pass (you left it out) takes the NSNumber and 
updates the progress bar.


> 
> 
> What about the saving operation improving its saving time?,  I will check 
> today what takes longer, if creating the thumbnial, or encoding the views,  
> maybe I shouldn't encode the whole view, but s just the image reference and 
> the transform matrix...  ?/ I will try that one also.


I didn't look at your code closely and don't have the other code around it to 
profile which part is taking so long. 

Dave


___

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

Please do not post admin requests or moderator comments to the list.
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


SearchBar doesn't display at all

2010-12-07 Thread Jonathan Schmidt
I have an app that has a TabBar as the rot controller, a NavigationController 
in the first tab, and a TableView NIB as the first view in the 
NavigationController (I'll call that the Primary TableView).  That TableView 
provides a list with multiple sections for the user to choose from.  When 
selected, a second NIB with a TableView is pushed onto the screen (I'll call 
that the Secondary TableView).

I only want the SearchBar to show up on the Secondary TableView as that is the 
real meat of the data.  If I add a SearchDisplayController with a UISearchBar 
to the Primary TableView, it shows up just fine at runtime.  However, if I add 
the SearchDisplayController to the Secondary TableView, it doesn't show up at 
all at runtime when that view is pushed.  Instead, it just shows the TableView. 
 The view looks correct other than that the SearchBar is absent.

Any help is appreciated!

Jonathan Schmidt




___

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

Please do not post admin requests or moderator comments to the list.
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


Problem with NSInputStream

2010-12-07 Thread Remco Poelstra
Hi all,

I've a problem with NSInputStream:
In my object I create (only once) an input and output stream like:

CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, 
(CFStringRef)IPString, 2101, &readStream, &writeStream);
if (readStream==NULL || writeStream==NULL ) {
return NO;
}

CFReadStreamSetProperty(readStream, 
kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
CFWriteStreamSetProperty(writeStream, 
kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);

serialInput=(NSInputStream *)readStream;
serialOutput=(NSOutputStream *)writeStream;

[serialInput setDelegate:self];
[serialOutput setDelegate:self];
[serialInput scheduleInRunLoop:[NSRunLoop currentRunLoop] 
forMode:NSDefaultRunLoopMode];
[serialOutput scheduleInRunLoop:[NSRunLoop currentRunLoop] 
forMode:NSDefaultRunLoopMode];
[serialOutput open];
[serialInput open];

When I'm done with my object, I clean it up (in dealloc) like:
[serialInput  close];
[serialInput release];
[serialOutput  close];
[serialOutput release];

The problem is now that the stream event handler is still called after dealloc 
has finished, resulting in a crash. How can I make sure that the event handler 
is not called anymore? It seems the socket does not get properly closed. Maybe 
a problem with slow handshaking over Wi-Fi?

Any help is appreciated.

Kind regards,

Remco Poelstra

___

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

Please do not post admin requests or moderator comments to the list.
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


NSDocument app where the document is a SQLite file

2010-12-07 Thread davelist
I've written a few small personal Mac apps and one iOS app and now am 
attempting to write my first NSDocument-based Mac application. I would like the 
document itself to be a SQLite file (with specific tables for my app - not a 
generic SQLite file). I've been reading through the NSDocument documentation 
and it appears this can be done, but I'm not 100% certain of the steps and 
wanted to make certain I wasn't going down a path I shouldn't before getting 
too far into it. Here is what I think I need to do:

Here's what I think I need to do in my NSDocument subclass.

When the user chooses a File->New, the method - (id)initWithType:(NSString 
*)typeName error:(NSError **)outError is called so in it I would create a 
SQLite database file in a temporary location and call setFileURL: to store the 
location of that SQLite file (and store a connection to the SQLite database 
file).

In the - (BOOL)writeToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName 
error:(NSError **)outError, if the passed absoluteURL matches the return value 
of fileURL:  I would do something like commit the SQLite transactions. If the 
absoluteURL did not match the returned value of fileURL: I need to copy the 
current SQLite file to this location. Will this work ok?

In the - (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName 
error:(NSError **)outError  I would just open the SQLite file and store my 
connection to it for use in the other methods for updating the file.

Am I missing something? Is attempting to use a SQLite file as the document file 
a bad idea?

I'm also considering an iOS application that uses the same SQLite database 
files so that's why I'd like to use SQLite on the Mac if possible. I'm also not 
ready to tackle using Core Data although that may be the better option if there 
are reasons that SQLite doesn't map well to a NSDocument based application. My 
other option is to not use the NSDocument architecture, and just open one file 
at a time in my GUI but I thought I'd try to learn about the NSDocument 
architecture while writing it.

Thanks,
Dave



___

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

Please do not post admin requests or moderator comments to the list.
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: Updating progress of UIProgressView. And Getting Better Saving Performance

2010-12-07 Thread Gustavo Pizano
David hello.

I didn't use blocks, in order to support 3.2, just in case, you never know who 
is out there still using it.  so I sue normal [NSObject performSelectorOnThread 
methods,..

Now I divided the Saving operation and the thumbnail creation in 2 separate 
threads, the thumbnail is inside the thread of saving, now its much faster,  
encoding and saving takes little time, I believe that the thumbnail creation is 
the responsible for slowing the process.

Basically and I think Im very wrong in whatIm doing is create a screenshot of 
the View with all its subviews, following Apple docs to do so, so each view's 
layer renderInContext is called. Of course I previously create a 
UIImageCOntext,  then after I get that image,  I scaled it down
to the thumb dimensions,  but here is where it get's messy:

The thumb must have a rounded corner mask + the border stroke, if I do that in 
the same UIImageContext I created to resize the screenShot I got, then I get no 
rounded corners for the image but the stroke of the path is rounded.  So I was 
reading a little and to add a clip to a context I must have a BItMapContext, in 
this case the image gets rounded corners but if I try to stroke the path the 
clip I add goes away.

So what I did was, create the thumb with a UIImageContext, then clip it using a 
UIBitMapContext, then create a final Image using once again a UIImageContext 
which in this case I draw the rounded corner image and then stroke the path.

So I believe I can do better in this process.


Thx

Gustavo




On Dec 7, 2010, at 1:59 PM, David Reed wrote:

> 
> On Dec 7, 2010, at 3:16 AM, Gustavo Pizano wrote:
> 
>> Hello Guys..
>> 
>> I see, I have been using GCD and blocks but on somme OSX app I did before, 
>> not on iPhone, I tough tit wasn't there... :P. 
> 
> 
> Blocks/GCD are in iOS 4.0 and higher. Assuming you have a paid developer 
> account, you may want to watch the relevant WWDC videos from last year.
> 
>> 
>> SO, I from within the method( block) that makes all the saving process, I do 
>> something like 
>> 
dispatch_async(dispatch_get_main_queue(), ^{
   // code executed on main thread goes here (i.e., updating the 
 progress indicator in your case
 
});
>> 
>> 
>> and update the progress indicator bar,  great im gonna try that..
> 
> 
> Yes.
> 
> 
>> 
>> also I have the option to call from within the same method a  
>> [ performSelectorinMainThread: 
>> withObject: waitUntilDone:NO];  
>> 
>> right?
> 
> 
> Yes, ssuming the selector you pass (you left it out) takes the NSNumber and 
> updates the progress bar.
> 
> 
>> 
>> 
>> What about the saving operation improving its saving time?,  I will check 
>> today what takes longer, if creating the thumbnial, or encoding the views,  
>> maybe I shouldn't encode the whole view, but s just the image reference and 
>> the transform matrix...  ?/ I will try that one also.
> 
> 
> I didn't look at your code closely and don't have the other code around it to 
> profile which part is taking so long. 
> 
> Dave
> 
> 

___

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

Please do not post admin requests or moderator comments to the list.
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


Interprocess Communication (IPC) : Which "technology" to use?

2010-12-07 Thread Jerry Krinock
My application needs to communicate with my associated Internet Plugin (a 
bundle that runs in web browsers).  For example, here is one sequence:

• App sends a "hello" to the plugin.
• Plugin processes "hello", responds to app, indicating that it is installed 
and alive.
• App sends up to a few hundred KB to the plugin.
• Plugin sends a few tens of KB back to the app.

This may happen several times a day.

Apple documentation seems to be steering me into Distributed Objects (DO) for 
this.  But DO are so complicated!  There are vended objects, proxies, 
connection configurations, etc.  Looks like I'd have to study it for a week or 
more.  Since the web browser talks in JSON-encoded strings anyhow, I don't need 
to send any Cocoa objects; just bytes are fine.

Trying to use what I know, I've been using NSDistributedNotificationCenter to 
send little messages, and when there is significant data, the sender writes the 
data to a temporary file and sends the temporary file's path as userInfo in the 
notification.  Upon receiving the notification, the receiver reads the file; 
end of story.

This seems to work OK, except for the minor annoyance of distributed 
notifications always arriving on the main thread and needing to be forwarded.  
I was thinking that maybe I should use NSPort since I've had some experience 
with it, but NSPort documentation advises that "You should implement 
interapplication communication using distributed objects whenever possible and 
use NSPort objects only when necessary."  Why is that?

How should I be doing this?

___

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

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

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

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


Re: Interprocess Communication (IPC) : Which "technology" to use?

2010-12-07 Thread Keary Suska
On Dec 7, 2010, at 9:28 AM, Jerry Krinock wrote:

> My application needs to communicate with my associated Internet Plugin (a 
> bundle that runs in web browsers).  For example, here is one sequence:
> 
> • App sends a "hello" to the plugin.
> • Plugin processes "hello", responds to app, indicating that it is installed 
> and alive.
> • App sends up to a few hundred KB to the plugin.
> • Plugin sends a few tens of KB back to the app.
> 
> This may happen several times a day.
> 
> Apple documentation seems to be steering me into Distributed Objects (DO) for 
> this.  But DO are so complicated!  There are vended objects, proxies, 
> connection configurations, etc.  Looks like I'd have to study it for a week 
> or more.  Since the web browser talks in JSON-encoded strings anyhow, I don't 
> need to send any Cocoa objects; just bytes are fine.
> 
> Trying to use what I know, I've been using NSDistributedNotificationCenter to 
> send little messages, and when there is significant data, the sender writes 
> the data to a temporary file and sends the temporary file's path as userInfo 
> in the notification.  Upon receiving the notification, the receiver reads the 
> file; end of story.
> 
> This seems to work OK, except for the minor annoyance of distributed 
> notifications always arriving on the main thread and needing to be forwarded. 
>  I was thinking that maybe I should use NSPort since I've had some experience 
> with it, but NSPort documentation advises that "You should implement 
> interapplication communication using distributed objects whenever possible 
> and use NSPort objects only when necessary."  Why is that?
> 
> How should I be doing this?

If the data you are exchanging is fairly lightweight I can recommend shared 
memory segments. Decidedly un-Cocoa-like but very fast and reliable. DO is 
heavy and distributed notification are unreliable (per the documentation). In 
both cases you may need code to ensure reliability.

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


Re: Interprocess Communication (IPC) : Which "technology" to use?

2010-12-07 Thread Jean-Daniel Dupas

Le 7 déc. 2010 à 17:56, Keary Suska a écrit :

> On Dec 7, 2010, at 9:28 AM, Jerry Krinock wrote:
> 
>> My application needs to communicate with my associated Internet Plugin (a 
>> bundle that runs in web browsers).  For example, here is one sequence:
>> 
>> • App sends a "hello" to the plugin.
>> • Plugin processes "hello", responds to app, indicating that it is installed 
>> and alive.
>> • App sends up to a few hundred KB to the plugin.
>> • Plugin sends a few tens of KB back to the app.
>> 
>> This may happen several times a day.
>> 
>> Apple documentation seems to be steering me into Distributed Objects (DO) 
>> for this.  But DO are so complicated!  There are vended objects, proxies, 
>> connection configurations, etc.  Looks like I'd have to study it for a week 
>> or more.  Since the web browser talks in JSON-encoded strings anyhow, I 
>> don't need to send any Cocoa objects; just bytes are fine.
>> 
>> Trying to use what I know, I've been using NSDistributedNotificationCenter 
>> to send little messages, and when there is significant data, the sender 
>> writes the data to a temporary file and sends the temporary file's path as 
>> userInfo in the notification.  Upon receiving the notification, the receiver 
>> reads the file; end of story.
>> 
>> This seems to work OK, except for the minor annoyance of distributed 
>> notifications always arriving on the main thread and needing to be 
>> forwarded.  I was thinking that maybe I should use NSPort since I've had 
>> some experience with it, but NSPort documentation advises that "You should 
>> implement interapplication communication using distributed objects whenever 
>> possible and use NSPort objects only when necessary."  Why is that?
>> 
>> How should I be doing this?
> 
> If the data you are exchanging is fairly lightweight I can recommend shared 
> memory segments. Decidedly un-Cocoa-like but very fast and reliable. DO is 
> heavy and distributed notification are unreliable (per the documentation). In 
> both cases you may need code to ensure reliability.
> 

CFMessagePort is fine too to simply pass data from one process to an other. And 
it is far more cocoa-like as it is CF based.
And as it is a CFRunLoop source, it's easy to decide which thread send and 
receive messages.

-- Jean-Daniel




___

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

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

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

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


Re: Problem instantiating an array

2010-12-07 Thread Dennis
Hi Ken,

Thanks for taking a look at my code.

On Dec 6, 2010, at 10:35 PM, Ken Thomases wrote:

> If you step after the line "TileColumn *allColumns[boardDimension - 1]", 
> nothing has happened, yet.  That's just a declaration.

But if for example I declare int test[16], the debugger shows the array "test" 
with 16 members. That's not happening in the case of my code with allColumns. 
It's displaying an array of -1 members.

> Or am I misunderstanding, and you mean you have stepped repeatedly after that 
> line, through the loop?

Yes, exactly.

> Also, what you mean "array remains with a member count of -1"?  Which array?  
> How are you assessing the member count?

I'm talking about allColumns. When I inspect allColumns in the debugger after 
stepping over the line "TileColumn *allColumns[boardDimension - 1]", the 
debugger shows -1 for the array member count. That's how I'm assessing it.

>  The allColumns array is a C array, which doesn't know its element count.  

That doesn't make any sense to me. As mentioned above, if I declare an int 
array with a member count, it displays as such in the debugger.

> The gameColumns array, which I assume is an instance variable of type 
> NSArray*, is nil until you assign to it in the last statement before the 
> return.  After that assignment, it will be a pointer to an NSArray with 
> boardDimension elements (or it will have failed with an exception if 
> something is very wrong, like some element of allColumns is still nil).

I understand that the NSArray gameColumns is nil until I assign to it. 
Unfortunately I am assigning a C array with -1 elements to it because the 
declaration TileColumn *allColumns[boardDimension - 1] allocates an array with 
-1 members as displayed in the debugger.

>> In the for loop, the line "allColumns[i] = column;" doesn't produce any 
>> errors but doesn't change the array.
> 
> Doesn't change which array?  allColumns?  That's basically impossible.  How 
> are you determining this?

By looking at allColumns in the debugger. When I look at other code in the 
debugger that works properly to create and populate an array, I can see objects 
being added to the array. So why do you say it's impossible to determine this?

> Is there any chance that you're trying to debug a release build (or any build 
> that has optimizations enabled)?  An optimized build will be very confusing 
> to debug.

No. It's a debug build.
 
> Finally, something to consider: there's nothing wrong with the technique 
> you've used of populating a C array and then building an NSArray from that C 
> array.  However, you might consider creating an NSMutableArray that starts 
> empty and then, during the for loop, each TileColumn is added to it.  If you 
> create the NSMutableArray with +arrayWithCapacity: or -initWithCapacity:, 
> you'll even avoid reallocation as you add elements to the array.

I experimented with doing that unsuccessfully.

I am beginning to think that the problem is with having declared boardDimension 
at the top of my file. I did another experiment and added: int 
test[boardDimension]; to the file. After stepping over that in the debugger, it 
showed an array with -1 members. I changed it to int test[16], stepped over 
that and the debugger showed an array with 16 members. Am I misunderstanding 
how the debugger works? If not, why is it now working to declare boardDimension 
at the top of the file?___

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

Please do not post admin requests or moderator comments to the list.
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: Problem instantiating an array

2010-12-07 Thread Wim Lewis

On 7 Dec 2010, at 10:11 AM, Dennis wrote:
> But if for example I declare int test[16], the debugger shows the array 
> "test" with 16 members. That's not happening in the case of my code with 
> allColumns. It's displaying an array of -1 members.

It's possible that the debugger simply doesn't know how to discover the length 
of a variable-length C array (it's a relatively recent addition to the 
language). Have you tried changing the array size to a literal 15? The array 
should have the declared size anyway (and asking the debugger to shoe element 
3, etc., should still work) even if the debugger doesn't know its size.



___

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

Please do not post admin requests or moderator comments to the list.
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: Problem instantiating an array

2010-12-07 Thread Dave Carrigan
On Dec 7, 2010, at 10:11 AM, Dennis wrote:

> On Dec 6, 2010, at 10:35 PM, Ken Thomases wrote:
> 
>> If you step after the line "TileColumn *allColumns[boardDimension - 1]", 
>> nothing has happened, yet.  That's just a declaration.
> 
> But if for example I declare int test[16], the debugger shows the array 
> "test" with 16 members. That's not happening in the case of my code with 
> allColumns. It's displaying an array of -1 members.

There is a big difference in declaring an array with an integer literal and 
declaring one with an integer variable. In the former, the compiler knows at 
compile time what is the size of the array. This is not so in the case of the 
latter, which means that the debugger also doesn't know the size of the array. 
A smarter debugger might be able to know this, but gdb is not a smarter 
debugger. This is not a Cocoa thing; it's just part of the C language. In fact, 
variable-length arrays weren't even supported in C until relatively recently 
(C99?).

>> Finally, something to consider: there's nothing wrong with the technique 
>> you've used of populating a C array and then building an NSArray from that C 
>> array.  However, you might consider creating an NSMutableArray that starts 
>> empty and then, during the for loop, each TileColumn is added to it.  If you 
>> create the NSMutableArray with +arrayWithCapacity: or -initWithCapacity:, 
>> you'll even avoid reallocation as you add elements to the array.
> 
> I experimented with doing that unsuccessfully.

You should keep experimenting; using Foundation arrays is usually preferable to 
using C arrays for most circumstances, unless speed is really important, and 
you won't know if that's the case until you start profiling.

Anyway, this should get you going:

gameColumns = [[NSMutableArray alloc] initWithCapacity:boardDimension];
for (.) {
   [gameColumns addObject:[[[TileColumn alloc] init] autorelease];
}

Note the autorelease of the tilecolumn. You need this because NSMutableArrays 
will claim ownership of their objects, so you need to relinquish your own 
ownership or else you'll have a memory leak. 

-- 
Dave Carrigan
d...@rudedog.org
Seattle, WA, USA

___

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

Please do not post admin requests or moderator comments to the list.
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: OS X Desktop

2010-12-07 Thread Seth Willits
On Dec 7, 2010, at 8:39 AM, Charlie Dickman wrote:

> Thanks Seth. I'll look into AppleScript. Can't you write to the .DS_Store 
> file with root privilege?

You don't need root, you need to force Finder to re-read the file, which you 
can't do unless you were to quit it, rewrite the file, and relaunch Finder. 
Either way, it's more likely to break and is more disruptive to the user than 
AppleScript.


--
Seth Willits





___

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

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

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

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


performSelectorOnMainThread fails second time through

2010-12-07 Thread Gideon King
Hi, I'm trying to debug a really odd issue. I have a method that I run in a 
separate thread, and right at the end of the method, I call 

[anObject performSelectorOnMainThread:@selector(myMethod:) 
withObject:someData waitUntilDone:YES];

This works fine the first time I run it. The second and subsequent times I try 
it, the message never arrives at its destination. I have checked and the 
destination object is exactly the same, it still has a retain count of 1, and 
if I ask respondsToSelector: it says yes.

Any ideas what else I should look at to try to track down the cause of this?

Thanks

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: performSelectorOnMainThread fails second time through

2010-12-07 Thread Gideon King
Another data point on this: if I use waitUntilDone:NO, it doesn't even work the 
first time through.

Responds to selector still returns YES. There are no error messages.

On 08/12/2010, at 6:05 AM, Gideon King wrote:

> Hi, I'm trying to debug a really odd issue. I have a method that I run in a 
> separate thread, and right at the end of the method, I call 
> 
>   [anObject performSelectorOnMainThread:@selector(myMethod:) 
> withObject:someData waitUntilDone:YES];
> 
> This works fine the first time I run it. The second and subsequent times I 
> try it, the message never arrives at its destination. I have checked and the 
> destination object is exactly the same, it still has a retain count of 1, and 
> if I ask respondsToSelector: it says yes.
> 
> Any ideas what else I should look at to try to track down the cause of this?

___

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

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

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

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


Re: performSelectorOnMainThread fails second time through

2010-12-07 Thread Charles Srstka
On Dec 7, 2010, at 2:19 PM, Gideon King wrote:

> Another data point on this: if I use waitUntilDone:NO, it doesn't even work 
> the first time through.
> 
> Responds to selector still returns YES. There are no error messages.

Is something tying up the main thread? It won’t execute your request if it 
doesn’t get to the end of its run loop.

Charles___

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

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

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

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


Re: Interprocess Communication (IPC) : Which "technology" to use?

2010-12-07 Thread Jerry Krinock
Thank you.  I found an example of shared memory segments here:

http://software.itags.org/software-mac-os/235083/
(Looks like the original server of this page is down.)

And an example of CFMessagePort here:

http://www.omnigroup.com/mailman/archive/macosx-dev/2001-June/028795.html

Given what I know, the CFMessagePort looks like a faster solution for me.  Very 
lean and just what you'd expect.  The server names the port and defines a 
callback which returns a response.  The client names the same port when sending 
a request and the response is returned by reference.  I updated Douglas 
Davidsons' year-2001 code given in there, to remove compiler warnings.  

So it looks like I get to go another year without tackling Distributed Objects. 
 Whew!

To view the demo, compile and run the Server, then compile and run the Client.


/*** CFMessagePortDemoServer.c ***/

#include 

CFStringRef kPortName = CFSTR("MyCFMessagePortDemo") ;

CFDataRef myCallBack(
 CFMessagePortRef local,
 SInt32 msgid,
 CFDataRef data,
 void *info) {
char *message = "I'm at your service!";
UInt8 *bytes = (UInt8*)message ;
int dataLength  = strlen(message) + 1;
CFDataRef returnData = CFDataCreate(
NULL,
bytes,
dataLength);
printf(
   "Received data from a client: %s\n",
   CFDataGetBytePtr(data));

// From CFMessagePortCallBack documentation, we return the
// "data to send back to the sender of the message.  The system
// releases the returned CFData object."
return returnData; 
}

int main() {
CFMessagePortRef local = CFMessagePortCreateLocal(
  NULL, 
  kPortName,
  myCallBack,
  NULL,
  false);
CFRunLoopSourceRef source = CFMessagePortCreateRunLoopSource(
 NULL, 
 local,
 0);
CFRunLoopAddSource(
   CFRunLoopGetCurrent(),
   source, 
   kCFRunLoopDefaultMode);
// The following will block as long as message port is still valid
// and source remains on the run loop
CFRunLoopRun();

CFRelease(local);
}

Also, quoting from Douglas' original comments, 

"As for using it within a Cocoa run loop--by which I assume you mean the main 
run loop in an AppKit-based application--that is even easier.  In that case, 
the server doesn't run the run loop itself, it just adds the source to the 
current run loop and lets the AppKit run it…"


/*** CFMessagePortDemoClient.c ***/

#include 

CFStringRef kPortName = CFSTR("MyCFMessagePortDemo") ;

int main() {
CFMessagePortRef remote = CFMessagePortCreateRemote(
NULL, 
kPortName
);
char *message = "Hello, I'm a client!";
UInt8 *bytes = (UInt8*)message ;
int dataLength = strlen(message) + 1;
CFDataRef data, returnData = NULL;
data = CFDataCreate(NULL,
bytes,
dataLength);
SInt32 result = CFMessagePortSendRequest(remote,
 0, 
 data,
 1,
 1,
 kCFRunLoopDefaultMode,
 &returnData) ;
if (
(result == kCFMessagePortSuccess)
&&
(returnData != NULL)
) {
printf(
   "Received data from the server: %s\n", 
   CFDataGetBytePtr(returnData));

CFRelease(returnData);
}
CFRelease(data);
CFRelease(remote);
}


___

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

Please do not post admin requests or moderator comments to the list.
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: performSelectorOnMainThread fails second time through

2010-12-07 Thread Gideon King
Good thought thanks Charles, but everything else seems to be responding as 
usual. No spinning wheel, still able to do other things in the UI. Main thread 
trace says:

#0  0x9546b0fa in mach_msg_trap ()
#1  0x9546b867 in mach_msg ()
#2  0x9212d37f in __CFRunLoopRun ()
#3  0x9212c464 in CFRunLoopRunSpecific ()
#4  0x9212c291 in CFRunLoopRunInMode ()
#5  0x92442f58 in RunCurrentEventLoopInMode ()
#6  0x92442d0f in ReceiveNextEventCommon ()
#7  0x92442b94 in BlockUntilNextEventMatchingListInMode ()
#8  0x96aa578d in _DPSNextEvent ()
#9  0x96aa4fce in -[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#10 0x96a67247 in -[NSApplication run] ()
#11 0x96a5f2d9 in NSApplicationMain ()
#12 0x2d98 in main (argc=1, argv=0xb7d0) at 
/Users/gideon/Development/CADisplay/main.m:13

which I believe just means that it's idling, waiting for the next event.


I tried running the whole thing without using a separate thread for that 
method, and it worked fine both the first and second time.

Gideon

On 08/12/2010, at 6:33 AM, Charles Srstka wrote:

> On Dec 7, 2010, at 2:19 PM, Gideon King wrote:
> 
>> Another data point on this: if I use waitUntilDone:NO, it doesn't even work 
>> the first time through.
>> 
>> Responds to selector still returns YES. There are no error messages.
> 
> Is something tying up the main thread? It won’t execute your request if it 
> doesn’t get to the end of its run loop.
> 
> Charles

___

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

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

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

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


Re: Problem instantiating an array

2010-12-07 Thread Ken Thomases
On Dec 7, 2010, at 12:11 PM, Dennis wrote:

> Thanks for taking a look at my code.

Sure.

> On Dec 6, 2010, at 10:35 PM, Ken Thomases wrote:
> 
>> If you step after the line "TileColumn *allColumns[boardDimension - 1]", 
>> nothing has happened, yet.  That's just a declaration.
> 
> But if for example I declare int test[16], the debugger shows the array 
> "test" with 16 members. That's not happening in the case of my code with 
> allColumns. It's displaying an array of -1 members.

As others have pointed out, that doesn't say anything about the code, it says 
something about the debugger.

>> The allColumns array is a C array, which doesn't know its element count.  
> 
> That doesn't make any sense to me. As mentioned above, if I declare an int 
> array with a member count, it displays as such in the debugger.

The debugger may know the element count of a fixed-size C array, but the array 
itself is a "dumb" data structure.  You can't query a C array for its element 
count in code.  Also, the number of elements in the array is (potentially) a 
different question than the capacity of the array.  You seemed to be saying 
that you were expecting the array to know or express how many elements you had 
assigned into it.  It doesn't know that.

That is, even if the debugger knew the size of allColumns, that wouldn't change 
as you assigned things into it.  It would be a fixed size and only the contents 
of each position in it might change.  So, stepping through your loop expecting 
the debugger to say "now there's 1 element in the array, now there are 2 
elements, etc.", which is what it seemed your were saying, is unreasonable.

>> The gameColumns array, which I assume is an instance variable of type 
>> NSArray*, is nil until you assign to it in the last statement before the 
>> return.  After that assignment, it will be a pointer to an NSArray with 
>> boardDimension elements (or it will have failed with an exception if 
>> something is very wrong, like some element of allColumns is still nil).
> 
> I understand that the NSArray gameColumns is nil until I assign to it. 
> Unfortunately I am assigning a C array with -1 elements to it because the 
> declaration TileColumn *allColumns[boardDimension - 1] allocates an array 
> with -1 members as displayed in the debugger.

The expression you used to assign to gameColumns read boardDimension elements 
from the C array.  So, it's simply not true that you were "array with -1 
elements to it".  There's no such thing as a C array with negative elements.

>>> In the for loop, the line "allColumns[i] = column;" doesn't produce any 
>>> errors but doesn't change the array.
>> 
>> Doesn't change which array?  allColumns?  That's basically impossible.  How 
>> are you determining this?
> 
> By looking at allColumns in the debugger. When I look at other code in the 
> debugger that works properly to create and populate an array, I can see 
> objects being added to the array.

Well, you see object pointers being assigned into the positions within the 
array.  You can't "add" to a C array.

> So why do you say it's impossible to determine this?

I was saying that it's impossible for the statement "allColumns[i] = column;" 
to not affect the array, assuming 'i' is within the array's bounds.

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


iOS when is my app launched

2010-12-07 Thread Jason Bobier
How do I find the date and time when my application launched? I've done this 
before on OS X, but it was a while ago and I've forgotten how. :)

Thanks so much!

Jason

___

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

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

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

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


Re: label color

2010-12-07 Thread Sean McBride
On Sun, 5 Dec 2010 15:47:32 -0700, Nick Zitzmann said:

>No. The only parts of Carbon that have gone away are the obsolete APIs
>(FSSpec, Internet Config, QuickDraw, etc.) as well as HIView. The rest
>of Carbon isn't going anywhere. There are still a number of OS features
>that can only be accessed by using Carbon.

Funny that you mention Internet Config.  Oddly, none of it is even
marked deprecated.

--

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: performSelectorOnMainThread fails second time through

2010-12-07 Thread Gideon King
I have completely commented out all the actions of the method that is executing 
in the thread. The only things it does are to create an autorelease pool, call 
a simple performSelectorOnMainThread, and release the pool. There is nothing 
else going on that I can see, and yet it still fails as per my previous post. 
If I have multiple performSelectorOnMainThread calls with wait until completed 
set to YES, they all work the first time the thread is run, and if set to NO, 
none of them work.

I have taken the threading part of the application and created a little test 
application with the same flow, and it always works correctly in the test 
application. 

Therefore I would conclude that there is nothing I am doing specifically in the 
threading portion (which is pretty simple anyway), but something else in the 
program is upsetting it. I have absolutely no idea where else to look.  As far 
as I can tell, the application is just sitting there idle in the main loop 
waiting for input, so it should execute straight away. I'm not sure what to 
read into the fact that the first time I call the performSelectorOnMainThread 
it works if I say for it to wait for completion, but doesn't work if I say not 
to.

I tried running the application in Instruments using the thread states tool, 
and although I couldn't find any documentation on how to interpret the results, 
what I believe to be the main thread on both my original application and my 
mini test application seem to have very similar thread state changes, and what 
I believe to be the main thread is in "On run queue" state in both cases.

I really am at a loss as to where to look next, so would appreciate any 
suggestions.

To restate the issue, when I run a method in a thread and call 
performSelectorOnMainThread, it works the first time only if I say to wait for 
completion, and never works if I  say not to wait for completion.

Any ideas?

Thanks

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: performSelectorOnMainThread fails second time through

2010-12-07 Thread Dave Keck
> Any ideas?

Post your code!
___

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

Please do not post admin requests or moderator comments to the list.
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: performSelectorOnMainThread fails second time through

2010-12-07 Thread Gideon King
Umm, as I mentioned, I have stripped back the multithreading part to virtually 
nothing and taken that code to a test application and it works there, and the 
rest of the application is 23,000 lines of code, which I can't post. 

In my main application, the following still fails (workerThread is an instance 
variable):

- (void)execute:(AADataForLayoutProcess *)data {
[self cancel];

self.currentDataForLayout = data;

workerThread = [[NSThread alloc] initWithTarget:self 
selector:@selector(doLayout:) object:self.currentDataForLayout];
[workerThread start];
}

- (void)cancel {
[workerThread cancel];
[workerThread release];
workerThread = nil; 
}

- (void)doLayout:(id)data {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[self innerExecute:(AADataForLayoutProcess *)data];
[pool release];
}

- (void)innerExecute:(AADataForLayoutProcess *)data {
[self performSelectorOnMainThread:@selector(callback) withObject:nil 
waitUntilDone:NO];
}

- (void)callback {
NSLog(@"Called back from thread");
}


At this stage, I'm pretty sure that something other than this code is causing 
the issue, but have no clue where to look.

Regards

Gideon


On 08/12/2010, at 11:29 AM, Dave Keck wrote:

>> Any ideas?
> 
> Post your code!

___

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

Please do not post admin requests or moderator comments to the list.
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: performSelectorOnMainThread fails second time through

2010-12-07 Thread Dave Keck
Some thoughts:

1. What happens if you specify a different object to receive the
message? For example, try [NSApp performSelectorOnMainThread:
@selector(terminate:) ... waitUntilDone: YES]. Does your app
terminate?

2. Specify waitUntilDone: NO, and after the call to
-performSelectorOnMainThread:, call:

CFRunLoopStop(CFRunLoopGetMain());

Does that make it work?
___

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

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

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

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


Re: performSelectorOnMainThread fails second time through

2010-12-07 Thread Dave Keck
Also: a quick peek at the assembly of -performSelectorOnMainThread:
reveals that it calls _CFExecutableLinkedOnOrAfter(). Presumably this
is to modify its behavior based on what SDK your app links against;
perhaps changing your Base SDK has an effect?
___

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

Please do not post admin requests or moderator comments to the list.
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: performSelectorOnMainThread fails second time through

2010-12-07 Thread Gideon King
Interesting:

1. No.
2. No.

Weird...

Now I thought it would be interesting to try those calls before the thread was 
dispatched, and the terminate one worked, but the run loop stop didn't. I also 
tried the runloop stop one in my mini test application, and it didn't work 
there either, so am a bit suspicious of that. Should that kill any application? 
If so, then maybe there is something wrong on my machine which is showing up in 
different ways with different apps. I have recently installed the latest XCode. 
Might try this on another computer and see if that makes any difference.

I also checked my build settings, and it was set to use the current MacOS as 
the base SDK (i.e. 10.6), and the architecture was set to be 32 bit universal, 
so I changed that to native architecture of build machine. That made no 
difference.

So, no luck so far ... thanks for the suggestions though...

Gideon

On 08/12/2010, at 2:36 PM, Dave Keck wrote:

> Some thoughts:
> 
> 1. What happens if you specify a different object to receive the
> message? For example, try [NSApp performSelectorOnMainThread:
> @selector(terminate:) ... waitUntilDone: YES]. Does your app
> terminate?
> 
> 2. Specify waitUntilDone: NO, and after the call to
> -performSelectorOnMainThread:, call:
> 
>CFRunLoopStop(CFRunLoopGetMain());
> 
> Does that make it work?

___

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

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

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

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


Re: performSelectorOnMainThread fails second time through

2010-12-07 Thread Gideon King
I have copied the source code to a different computer, and can confirm that it 
made no difference - the behaviour is the same.

Regards

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: OS X Desktop

2010-12-07 Thread Charlie Dickman
Thanks Seth. I'll look into AppleScript. Can't you write to the .DS_Store file 
with root privilege?

On Dec 7, 2010, at 1:10 AM, Seth Willits wrote:

> On Dec 6, 2010, at 3:11 PM, Charlie Dickman wrote:
> 
>> In the days of System 9 there was a thing known as the desktop database and 
>> a number of applications/utilities that "remembered" the location of things 
>> on the desktop and would restore a saved configuration on command.
> 
> Heh. I made one. Clean Desk was the first program I ever sold. I made like 
> $1200 off of that thing. Pretty nice chunk of change when you're 14. :-)
> 
> 
> 
>> For some time now I have been trying to find a similar OS X implementation 
>> that actually works. All of the ones I have tried mess up when trying to 
>> restore a saved desktop state; some put icons on top of other icons and some 
>> place the icons off the screen.
>> 
>> I've tried searching the web for a description of where OS X keeps desktop 
>> icon placement information, how to read it and how to save it with no luck.
> 
> It really hasn't changed. On OS 9 you had to get the position via 
> AppleScript. It's the same now unless you dig into the private file format of 
> .DS_Store (which I spent a lng time doing for DMG Canvas), but then you 
> can only read the file, not write to it, so you still need to use AppleScript 
> to get/set the file position reliably, unless you're going to force the user 
> to quit Finder, rewrite the private file, and relaunch Finder.
> 
> 
> --
> Seth Willits
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/3tothe4th%40comcast.net
> 
> This email sent to 3tothe...@comcast.net

Charlie Dickman
3tothe...@comcast.net



___

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

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

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

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


another Core Data and Undo Question

2010-12-07 Thread kvic...@pobox.com
i have a core data app that supports both real time events and user 
interaction. some of the user interactions can generate an undo stack 
similar to the following:


beginUndoGroup
beginUndoGroup
core data action
core data action
endUndoGroup
myAction
endUndoGroup

now some of the real time events can cause the target of myAction to 
be deleted and i can easily remove this from the undo stack. but that 
leaves a nested group which is no longer meaningful and it leaves the 
undo menu action name referring to the deleted myAction


is there anyway to delete the entire group (including the nested core 
data actions)? if so, how? alternatively, can anyone suggest an 
approach to deal with this situation?


thanx,
ken

p.s. i don't know if its relevant or not, but i have setGroupsByEvent 
set to NO and i begin an undo group when i'm ready to execute a user 
action.


___

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

Please do not post admin requests or moderator comments to the list.
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


Cocoaheads Lake Forest meets tomorrow, 12/8 at 7pm

2010-12-07 Thread Scott Ellsworth
CocoaHeads Lake Forest will be meeting on the second Wednesday of the month.
 We will be meeting at the Orange County Public Library (El Toro) community
room, 24672 Raymond Way, Lake Forest, CA 92630

Please join us from 7pm to 9pm on Wednesday, 12/8.

Peter Hosey will walk through the code for an application that uses some of
the lesser-known APIs available in Mac OS X.

As always, details and the upcoming meeting calendar can be found at the
cocoaheads web site, www.cocoaheads.org.

(Personal note: Google Irvine is hiring again.  Ping me or drop by for
details.)
___

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

Please do not post admin requests or moderator comments to the list.
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: performSelectorOnMainThread fails second time through

2010-12-07 Thread Dave Keck
> Now I thought it would be interesting to try those calls before the thread 
> was dispatched, and the terminate one worked, but the run loop stop didn't. I 
> also tried the runloop stop one in my mini test application, and it didn't 
> work there either, so am a bit suspicious of that. Should that kill any 
> application?

No, it shouldn't make your app terminate - it'll just cause
CFRunLoopRunInMode() to return (see the stack trace you posted
earlier.) I was thinking this would cause the
-performSelectorOnMainThread machinery to notice that there was an
enqueued invocation. (Not that this should be necessary, of course.)

On my system, -performSelectorOnMainThread works using a
CFRunLoopSource attached to the main thread's run loop, which is
signaled after -performSelectorOnMainThread has enqueued an object
representing the invocation. I'm thinking -performSelectorOnMainThread
isn't working because either the main thread isn't running in a common
mode, or something's failing with the CFRunLoopSource. Here are some
things to try:

1. Place a breakpoint on the line after the call to
-performSelectorOnMainThread. After this is hit, at the GDB prompt,
enter the following command:

po (void*)CFRunLoopGetMain()

This should print a lot of information. One of the first lines printed
will mention "current mode =". What mode does it say?

2. In the information printed in the last step, do you see a run loop
source mentioned with a callout of "__NSThreadPerformPerform"? (This
is the run loop source mentioned previously.)

3. Stop your program, and set a breakpoint on the
-performSelectorOnMainThread line. Run your program again. When this
breakpoint is hit, before continuing your program, set a breakpoint at
CFRunLoopSourceSignal(). Continue your program. The
CFRunLoopSourceSignal breakpoint should be hit (directly or
indirectly) from within the stack frame of
-performSelectorOnMainThread; is this 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: performSelectorOnMainThread fails second time through

2010-12-07 Thread Dave Keck
> 3. Stop your program, and set a breakpoint on the
> -performSelectorOnMainThread line. Run your program again. When this
> breakpoint is hit, before continuing your program, set a breakpoint at
> CFRunLoopSourceSignal(). Continue your program. The
> CFRunLoopSourceSignal breakpoint should be hit (directly or
> indirectly) from within the stack frame of
> -performSelectorOnMainThread; is this true?

Oh - CFRunLoopWakeUp() should also be called after
CFRunLoopSourceSignal(). Set a breakpoint on CFRunLoopWakeUp() too,
and make sure it's called from within the
-performSelectorOnMainThread: stack frame.

Furthermore, printing the first argument to both of these functions
when/if their breakpoints are hit would also useful:

i386:

po *(id*)($ebp+8)

x86_64:

po $rdi
___

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

Please do not post admin requests or moderator comments to the list.
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: performSelectorOnMainThread fails second time through

2010-12-07 Thread Gideon King
Thanks for those excellent suggestions Dave (way above my head, but it's good 
to have the instructions to execute).

1. Current mode is kCFRunLoopDefaultMode
2. Nothing beginning with NSThread (same was true of my mini test app)
3. Yes, it broke at both those points, and there was something odd going on 
with the wake up - it says current mode is (none). It tried this on the mini 
test application, and it gave a mode of kCFRunLoopDefaultMode. So it looks as 
if we're getting somewhere in tracking down that there seems to be something 
wrong with the program at that point, but I really don't fully understand what 
it means or where to go next.

#0  0x92154965 in CFRunLoopSourceSignal ()
#1  0x996c27c1 in -[NSThread _nq:] ()
#2  0x996c243d in -[NSObject(NSThreadPerformAdditions) 
performSelector:onThread:withObject:waitUntilDone:modes:] ()
#3  0x996d4adf in -[NSObject(NSThreadPerformAdditions) 
performSelectorOnMainThread:withObject:waitUntilDone:] ()
#4  0x00057a6c in -[AALayoutExecutor innerExecute:] (self=0x1a15ee0, 
_cmd=0x7fe3f, data=0x1e03c30) at 
/Users/gideon/Development/Restored/CADisplay/AALayoutExecutor.m:133
#5  0x000572ca in -[AALayoutExecutor doLayout:] (self=0x1a15ee0, _cmd=0x7fe50, 
data=0x1e03c30) at 
/Users/gideon/Development/Restored/CADisplay/AALayoutExecutor.m:50
#6  0x996acbf0 in -[NSThread main] ()
#7  0x996acba0 in __NSThread__main__ ()
#8  0x9549885d in _pthread_start ()
#9  0x954986e2 in thread_start ()

{locked = No, signalled = No, valid = 
Yes, order = 0, context = {version = 0, info = 
0x180c150, callout = __NSThreadPerformPerform (0x996c2bbf)}}

#0  0x92154a5d in CFRunLoopWakeUp ()
#1  0x996c2826 in -[NSThread _nq:] ()
#2  0x996c243d in -[NSObject(NSThreadPerformAdditions) 
performSelector:onThread:withObject:waitUntilDone:modes:] ()
#3  0x996d4adf in -[NSObject(NSThreadPerformAdditions) 
performSelectorOnMainThread:withObject:waitUntilDone:] ()
#4  0x00057a6c in -[AALayoutExecutor innerExecute:] (self=0x1a15ee0, 
_cmd=0x7fe3f, data=0x1e03c30) at 
/Users/gideon/Development/Restored/CADisplay/AALayoutExecutor.m:133
#5  0x000572ca in -[AALayoutExecutor doLayout:] (self=0x1a15ee0, _cmd=0x7fe50, 
data=0x1e03c30) at 
/Users/gideon/Development/Restored/CADisplay/AALayoutExecutor.m:50
#6  0x996acbf0 in -[NSThread main] ()
#7  0x996acba0 in __NSThread__main__ ()
#8  0x9549885d in _pthread_start ()
#9  0x954986e2 in thread_start ()

{locked = false, wakeup port = 0x5a03, 
stopped = false,
current mode = (none),
common modes = {type = mutable set, count = 
1,
entries =>
1 : {contents = 
"kCFRunLoopDefaultMode"}
}
,
common mode items = {type = mutable set, 
count = 1,
entries =>
25 : {locked = No, signalled = 
Yes, valid = Yes, order = 0, context = {version = 0, 
info = 0x180c150, callout = __NSThreadPerformPerform (0x996c2bbf)}}
}
,
modes = {type = mutable set, count = 1,
entries =>
10 : {name = 
kCFRunLoopDefaultMode, locked = false, port set = 0x5b03,
sources = {type = mutable set, 
count = 1,
entries =>
5 : {locked = No, signalled = 
Yes, valid = Yes, order = 0, context = {version = 0, 
info = 0x180c150, callout = __NSThreadPerformPerform (0x996c2bbf)}}
}
,
observers = (null),
timers = (null)
},

}
}

Thanks again


Gideon


On 08/12/2010, at 4:19 PM, Dave Keck wrote:

> 
> 1. Place a breakpoint on the line after the call to
> -performSelectorOnMainThread. After this is hit, at the GDB prompt,
> enter the following command:
> 
>po (void*)CFRunLoopGetMain()
> 
> This should print a lot of information. One of the first lines printed
> will mention "current mode =". What mode does it say?
> 
> 2. In the information printed in the last step, do you see a run loop
> source mentioned with a callout of "__NSThreadPerformPerform"? (This
> is the run loop source mentioned previously.)
> 
> 3. Stop your program, and set a breakpoint on the
> -performSelectorOnMainThread line. Run your program again. When this
> breakpoint is hit, before continuing your program, set a breakpoint at
> CFRunLoopSourceSignal(). Continue your program. The
> CFRunLoopSourceSignal breakpoint should be hit (directly or
> indirectly) from within the stack frame of
> -performSelectorOnMainThread; is this 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: another Core Data and Undo Question

2010-12-07 Thread Kyle Sluder
On Tue, Dec 7, 2010 at 5:14 PM, kvic...@pobox.com  wrote:
> i have a core data app that supports both real time events and user
> interaction. some of the user interactions can generate an undo stack
> similar to the following:
>
> beginUndoGroup
>        beginUndoGroup
>        core data action
>        core data action
>        endUndoGroup
> myAction
> endUndoGroup
>
> now some of the real time events can cause the target of myAction to be
> deleted and i can easily remove this from the undo stack. but that leaves a
> nested group which is no longer meaningful and it leaves the undo menu
> action name referring to the deleted myAction
>
> is there anyway to delete the entire group (including the nested core data
> actions)? if so, how? alternatively, can anyone suggest an approach to deal
> with this situation?

Nope. Welcome to the wonderful world of undo! Where despite the
promise of the API, the framework **really** doesn't like it when you
call -[NSUndoManager removeAllActionsForTarget:].

Your delete should be undoable, right? So undoing the delete will make
your undo group meaningful again. I hope.

That's how it works for us in our non-Core Data apps, anyway.
Hopefully Core Data is smart enough to be able to associate undo
groups with resurrected managed objects.

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