Re: NSPipe (NSFileHandle) writedata limit?

2010-04-12 Thread McLaughlin, Michael P.
This is turning out to be a lot trickier than I had expected.  [I note that
there is currently another thread in this list with a similar concern but
I'm not sure if our problems are identical.]

In my case, I have a main app with an NSArray of subtasks (inheriting from
NSObject), initialized then set up as follows:

-(void)setName:(NSString*)name ID:(int)ident
{
   myID = [NSString stringWithFormat:@"%d ", ident];
   inPipe = [NSPipe pipe]; // i.e., input for subtask
   outPipe = [NSPipe pipe];
   sendEnd = [inPipe fileHandleForWriting]; // send TO subtask
   readEnd = [outPipe fileHandleForReading];

   aTask = [NSTask new];
   [aTask setLaunchPath: theExecutable];// known by now
   [aTask setArguments:[NSArray arrayWithObject:myID]];
   [aTask setStandardInput:inPipe];
   [aTask setStandardOutput:outPipe];
   [aTask launch];
}

Thereafter, the main task and subtasks are *supposed to* communicate as
follows:

main --> subtask (main send data)

-(void)sendData:(void*)data numBytes:(NSUInteger)sz taskTag:(NSString*)tag
{
   NSData *dataset = [NSData dataWithBytes:data length:sz];
   NSNumber *num = [NSNumber numberWithUnsignedInteger:sz]; // NSUInteger
   NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: num,
@"size", nil];
   [sendEnd writeData:dataset];// Do NOT close the fileHandle!
   [[NSDistributedNotificationCenter defaultCenter] postNotificationName:tag
object:myID userInfo:dict];
}

That is, main
1) sends (via FileHandle and pipe) a known quantity of data to the subtask
and
2) tells it what sort of data are coming and how much.

The subtask, when it gets the CPU, reads in the data using the following
code.  [Granted, it might not get the CPU long enough to read all the data
but I hoped that the OS would handle that problem.]

-(NSData*)getDataSz:(NSUInteger)sz
{   
   return [input readDataOfLength:sz];
}

The returned NSData is parsed in accordance with the aforementioned tag.

My intent was to do the reverse from subtask to main.

*** All of the above works perfectly PROVIDED that the data sent from main
is at most 65336 bytes. ***

[If I use availableData instead of readDataOfLength, then the limit is 4096
bytes.]  All this is under Leopard but SL shows the same problem.

Notes:
1) GC is supported and compiler is gcc 4.2.
2) sz is everywhere NSUInteger and should go up to about 4 Gb -- and NSData
should know this as well.  According to NSLog, sizeof(sz) is always 4 bytes.
3) I need to know when all subtasks have read and processed their data so
that I can proceed to the next phase of a large SIMD computation which MUST
be done in a fixed sequence with additional data known only to main.
4) FWIW, these subtasks must be persistent (not one-shot) since they will be
called repeatedly.  The main() portion of the subtask executable calls
[[NSRunLoop currentRunLoop] run];
5) There are only subtasks here, no threads.

*

Clearly, there is some internal blockage, due to some hidden buffer of
limited size, that I am ignoring.

Is there a recommended (better) way of sending and receiving a known (large)
amount of data to and from a subtask?  Is there any sample code anywhere
similar to what I need?  I couldn't find anything close enough to work.

I could also not find anything like (BOOL)dataStillAvailable in NSFileHandle
or else I would have tried a while loop.

Thanks.

-- 
Mike McLaughlin

___

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


Data managment

2010-04-12 Thread Billy Flatman
Hi all,

I'm trying to find the best approach to data storage with a cocoa application.
I've got my application working and saving document specific data to a file, 
but I also need a larger data file of persistent data, that shouldn't be 
duplicated. I'm considering imbedding an SQLite database into my application, 
but wasn't sure if I could use core data some how.

Thanks

Billy Flatman
b.flat...@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


Re: Problem with reading an NSPipe->NSFileHandle to end

2010-04-12 Thread Rasmus Skaarup

> Try simplifying your app by eliminating the use of background threads.  Or, 
> if you feel you must use background threads for long-running computation, use 
> them only for handling the data after receiving it.  Do everything involving 
> launching the task and initiating background reads of its output from the 
> main thread (without that bizarre bit about launching a background thread 
> just to have it shunt some work back to the main thread).

I thought that when I added the observers from the main init, and started the 
tasks by doing performSelectorOnMainThread: from the background thread, it 
would also start the task on the same thread as the observers - the main 
thread. But to my suprice, if I add specific observers from startMyTask: 
(instead of from the main init) everything works perfectly, even though I still 
initate the task launch from a background thread. 

Thanks for your help Ken!

Br
Rasmus Skaarup___

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: Data managment

2010-04-12 Thread Joanna Carter
> I'm trying to find the best approach to data storage with a cocoa application.
> I've got my application working and saving document specific data to a file, 
> but I also need a larger data file of persistent data, that shouldn't be 
> duplicated. I'm considering imbedding an SQLite database into my application, 
> but wasn't sure if I could use core data some how.

Since Core Data uses SQLite, why not go that route?

Joanna

--
Joanna Carter
Carter Consulting

___

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: Data managment

2010-04-12 Thread Samuel Williams
Dear Billy,

It might depend on whether you want to remain cross platform or not.

Also, if your requirements are very limited, CoreData might be considered 
overkill.

On the other hand, CoreData has great integration with NSDocument type 
applications and Cocoa UIs.

Kind regards,
Samuel

On 13/04/2010, at 2:04 AM, Joanna Carter wrote:

>> I'm trying to find the best approach to data storage with a cocoa 
>> application.
>> I've got my application working and saving document specific data to a file, 
>> but I also need a larger data file of persistent data, that shouldn't be 
>> duplicated. I'm considering imbedding an SQLite database into my 
>> application, but wasn't sure if I could use core data some how.
> 
> Since Core Data uses SQLite, why not go that route?
> 
> Joanna
> 
> --
> Joanna Carter
> Carter Consulting
> 
> ___
> 
> 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/space.ship.traveller%40gmail.com
> 
> This email sent to space.ship.travel...@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: Data managment

2010-04-12 Thread Dru Satori
So long as the application is single user, core data or sqlite are both 
excellent options.  I personally prefer sqlite, as I find it easier to work 
with than core data.   The problem I have with core data is that it's usage is 
so tightly wound to the managed object interface, that is can be difficult to 
come to grips with after years of working directly with SQL in other worlds.

Andy 'Dru' Satori

On Apr 12, 2010, at 9:38 AM, Billy Flatman  wrote:

> Hi all,
> 
> I'm trying to find the best approach to data storage with a cocoa application.
> I've got my application working and saving document specific data to a file, 
> but I also need a larger data file of persistent data, that shouldn't be 
> duplicated. I'm considering imbedding an SQLite database into my application, 
> but wasn't sure if I could use core data some how.
> 
> Thanks
> 
> Billy Flatman
> b.flat...@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/dru%40druware.com
> 
> This email sent to d...@druware.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: Data managment

2010-04-12 Thread Billy Flatman
Hi Samuel,

Is it possible to get core data data models to save differently, one for a 
document save which for example might be an XML format, and one into the 
applications bundle as an SQLite file?

That way when a document is saved the main database won't be duplicated, just 
the document specific data.

Cheers,

Billy.

On 12 Apr 2010, at 15:14, Samuel Williams wrote:

> Dear Billy,
> 
> It might depend on whether you want to remain cross platform or not.
> 
> Also, if your requirements are very limited, CoreData might be considered 
> overkill.
> 
> On the other hand, CoreData has great integration with NSDocument type 
> applications and Cocoa UIs.
> 
> Kind regards,
> Samuel
> 
> On 13/04/2010, at 2:04 AM, Joanna Carter wrote:
> 
>>> I'm trying to find the best approach to data storage with a cocoa 
>>> application.
>>> I've got my application working and saving document specific data to a 
>>> file, but I also need a larger data file of persistent data, that shouldn't 
>>> be duplicated. I'm considering imbedding an SQLite database into my 
>>> application, but wasn't sure if I could use core data some how.
>> 
>> Since Core Data uses SQLite, why not go that route?
>> 
>> Joanna
>> 
>> --
>> Joanna Carter
>> Carter Consulting
>> 
>> ___
>> 
>> 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/space.ship.traveller%40gmail.com
>> 
>> This email sent to space.ship.travel...@gmail.com
> 

Billy Flatman
b.flat...@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


Re: IKImageView delegate

2010-04-12 Thread Brian Postow

On Apr 10, 2010, at 2:13 AM, Gerriet M. Denkmann wrote:

> The documentation (updated this morning) says: "An IKImageView object’s 
> delegate [...] is informed of various actions by the image view through 
> delegation messages."
> 

Why do you say that the documentation has been edited? When I look at it, it 
says it was edited in February... 

The answer to most of your questions seems to be "The IKImageView documentation 
is lousy and buggy" (they mention that you can but an NSImage into an 
IKImageView, but there is no documented method for this for example...)

> This begs the question: What are these "delegation messages" and where are 
> they documented?
> 
> Also: IKImageView seems to understand the cut:, copy:, paste: etc. messages. 
> But I can't find any documentation about this (neither in IKImageView nor in 
> it's superclasses).

I wrote my own using the get the region method described below. It's not 
elegant, but it seems to work... I also just used the code from IKImageViewDemo 
and trusted that it would work... Note that it uses undocumented methods!

> According to the documentation cut: seems to be implemented only by NSText 
> and WebView.
> 

I'm not sure what you want cut to do in an IKImageView, make the area grey?

> Another thing: IKImageView can mark a region (IKToolModeSelect). How to get 
> this region from IKImageView? (Clumsy workaround: send it a copy: message and 
> look at the pasteboard).

There is an *UNDOCUMENTED* method (CGRect)selectionRect which returns the 
selection rectangle in view coordinates. I use a separate version of the image 
and do: (full is the CGImageref of the whole image) 

CGRect selection;
selection = flipCGRect( CGImageGetHeight(full), [imageView 
selectionRect]);

CGImageRef selectedImage;

if (selection.size.width == 0 || selection.size.height == 0)
selectedImage =full;
else
selectedImage = CGImageCreateWithImageInRect( full, selection);

it's not elegant, but it seems to work.

Again, selectionRect is UNDOCUMENTED so use it at your own risk!


Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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


CIContext in 10.6

2010-04-12 Thread Gerriet M. Denkmann

This works (but is deprecated in 10.6):

NSOpenGLPixelFormat *pixelFomat = 
CGLPixelFormatObj b = [ pixelFomat CGLPixelFormatObj ];
CGLContextObj a = CGLGetCurrentContext();
ciContext = [ CIContext contextWithCGLContext:  a
pixelFormat:
b 
options:
nil
];

But this does NOT:

NSGraphicsContext *currentContext = [NSGraphicsContext 
currentContext];
CGContextRef ctx = [ currentContext graphicsPort];  
ciContext = [ CIContext contextWithCGContext:   ctx 
options:
nil
];

What is wrong?


Kind regards,

Gerriet.

___

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: CIContext in 10.6

2010-04-12 Thread Jean-Daniel Dupas

Le 12 avr. 2010 à 16:39, Gerriet M. Denkmann a écrit :

> 
> This works (but is deprecated in 10.6):
> 
>   NSOpenGLPixelFormat *pixelFomat = 
>   CGLPixelFormatObj b = [ pixelFomat CGLPixelFormatObj ];
>   CGLContextObj a = CGLGetCurrentContext();
>   ciContext = [ CIContext contextWithCGLContext:  a
>   pixelFormat:
> b 
>   options:
> nil
>   ];
> 

Why not using the 10.6 function (and filling a documentation bug report because 
it does not contains the new version) ? 

+ (CIContext *)contextWithCGLContext:(CGLContextObj)ctx
   pixelFormat:(CGLPixelFormatObj)pf colorSpace:(CGColorSpaceRef)cs 
options:(NSDictionary *)dict;


> But this does NOT:
> 
>   NSGraphicsContext *currentContext = [NSGraphicsContext 
> currentContext];
>   CGContextRef ctx = [ currentContext graphicsPort];  
>   ciContext = [ CIContext contextWithCGContext:   ctx 
>   options:
> nil
>   ];
> 
> What is wrong?

Without defining "does not works", we cannot help you.

-- 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: Data managment

2010-04-12 Thread Joanna Carter
Hi Billy

> Is it possible to get core data data models to save differently, one for a 
> document save which for example might be an XML format, and one into the 
> applications bundle as an SQLite file?
> 
> That way when a document is saved the main database won't be duplicated, just 
> the document specific data.

You can have multiple Core Data stores, each with a different storage mechanism.

Joanna

--
Joanna Carter
Carter Consulting

___

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


NSArrayController in entity mode and permutations (CoreData question)

2010-04-12 Thread vincent habchi
Hi again!

I'd like to change the place of a NSManagedObject stored in a NSArrayController 
in entity mode (after a drag'n drop operation). I didn't find any suitable 
primitive, so I decided to go something like "removeAtSomeIndex" and then 
immediately after "insertAtSomeOtherIndex".

However, it does not work: it seems as soon as an object is removed from the 
array, core data is told to unlink it, so, at the end of the permutation, I end 
up with an array full of object that get removed in core data at a later point, 
and after a while I get faults with non-existent objects.

Is there any trick to solve this knot?

Thanks a lot,
Vincent___

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

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

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

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


Re: Problem with reading an NSPipe->NSFileHandle to end

2010-04-12 Thread Ken Thomases
On Apr 12, 2010, at 8:46 AM, Rasmus Skaarup wrote:

>> Try simplifying your app by eliminating the use of background threads.  Or, 
>> if you feel you must use background threads for long-running computation, 
>> use them only for handling the data after receiving it.  Do everything 
>> involving launching the task and initiating background reads of its output 
>> from the main thread (without that bizarre bit about launching a background 
>> thread just to have it shunt some work back to the main thread).
> 
> I thought that when I added the observers from the main init, and started the 
> tasks by doing performSelectorOnMainThread: from the background thread, it 
> would also start the task on the same thread as the observers - the main 
> thread. But to my suprice, if I add specific observers from startMyTask: 
> (instead of from the main init) everything works perfectly, even though I 
> still initate the task launch from a background thread. 
> 
> Thanks for your help Ken!

You're welcome, but the above still demonstrates quite  a bit of confusion 
about threads.  The reason I told you to remove the (apparently unnecessary) 
threading from your app was because, no offense, I don't have confidence that 
you're getting it right.  And getting the threading wrong is very likely to 
produce symptoms like you described.

For example, the phrase "on the same thread as the observers" makes no sense.  
Observers don't have or live on a specific thread.  Whatever thread a 
notification is posted on, that's the thread where the observers' methods are 
invoked.  Notification delivery is just a one-step-indirect method invocation.  
Posting the notification is exactly the same as looping through a list of the 
observers and just directly invoking their registered selector.

Second, the "main" init (whatever that means) may be, but is not necessarily, 
invoked on the main thread.  It depends on how you wrote things.  But it 
shouldn't matter, in terms of where you register observers of notifications.  
Registering observers with the default notification center means they are 
registered with the notification center, period.  That's true across all 
threads.  The notification center and registrations with it are not 
thread-specific.

The fact that neither of us understands why the change you made has "fixed" the 
problem means I have no confidence in it, and neither should you. You need to 
actually understand what's going on and why.

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: NSImageView Will Not Alias Images

2010-04-12 Thread Chris Tracewell


On Apr 6, 2010, at 8:16 PM, Ken Ferry wrote:

This was once true, but is out of date.  I'd like to see a test  
app.  For example, how do you know you aren't getting  
antialiasing?  It may be that you just don't like the output. :-)


Well - NSImageInterpolationHigh and NSImageInterpolationNone produce  
the same exact result - screen shot copy (control-command-shift-4)  
the imageView built once using NSImageInterpolationHigh  and once  
using NSImageInterpolationNone then paste each into a Photoshop  
layer, align them perfectly and then turn the top layer off and on  
at 800% and there is not a single pixel that moves or changes color.


The dropped image is roughly 1000 x 1000 (a screen shot PNG) and the  
imageView size is 200x200


To make sure the currentContext was correct - I log  
[[NSGraphicsContext currentContext] imageInterpolation] for each  
build and it shows the correct values 3 and 1 respectively. And then  
just to be super sure I I log [[NSGraphicsContext currentContext]  
isDrawingToScreen] inside drawRect of my NSImageView subclass and  
get YES.


I did implement my own image sizing in drawRect and then used [self  
setImage] and it works great. Not sure what could be the issue.




It would also be good to know what OS you are working on.

-Ken



I'm using 10.5.8. - XCode   3.1.2 - iMac Core 2 Duo and the app is GC.

What Jens is saying is probably true in 10.5, not in 10.6.   
Nevertheless, I would be interested to see a test app.


-Ken
Cocoa Frameworks



Thought I'd add some closure to this, even though it's a week later. I  
believe Ken's original assessment to be accurate - that I am just not  
happy with the resampling that NSImageView is doing. Using larger  
images with lots of detail, like a screenshot, the problem is more  
pronounced, the same is true for images with thin diagonal lines. More  
organic images that aren't too big produce acceptable results.


Of note, I tested an image in Photoshop that was struggling in the  
ImageView and found that by sizing to the same size as the ImageView  
using, "Nearest Neighbor" as the sampling method, resulted in  
identical "distortion" or lack of smoothness per se. Nearest Neighbor  
has been a resampling method in PS for as long as I can remember, but  
I isn't really an anti-alias resampling method - it chooses the pixel  
values by proximity and duplicates it - thus no new color values get  
produced. I have used it in the past when needing to take, for  
example, a small bit icon or type element that I want to enlarge  
without aliasing, to keep a pixel accurate representation at a larger  
scale. Using this method to downsize will give mediocre results at best.


All of that to say, it seems that an NSImageView in <= 10.5 you'll be  
getting that method for resampling - so yes it resamples, but the  
method is not optimal.

___

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: NSPipe (NSFileHandle) writedata limit?

2010-04-12 Thread Greg Guerin

McLaughlin, Michael P wrote:

Is there a recommended (better) way of sending and receiving a  
known (large)
amount of data to and from a subtask?  Is there any sample code  
anywhere
similar to what I need?  I couldn't find anything close enough to  
work.


Reading your description, my first thought was sockets.  And more  
specifically, CocoaAsyncSocket:


http://code.google.com/p/cocoaasyncsocket/

However, you still haven't completely described how your subtasks  
consume input and produce output, and how the parent collects output  
or other results.  So sockets may not work any better.


I am assuming that subtask output or results are written to the  
subtask's stdout stream, which is a pipe back to the parent process.


If all the subtasks read *all* the input data before producing any  
output data, then I don't know why the parent would be blocking in  
pipe-writing.  The only reasons that come to mind are bugs:  
misinterpretation of protocol bytes, reading the wrong sizes, etc.


If the subtasks read *some* input, then produce *any* output on  
stdout, then that is an opportunity for deadlock, as I previously  
described.  Here's how deadlock happens: after reading some but not  
all input, the subtask writes to its stdout.  This is a pipe back to  
its parent.  The parent is NOT reading its end of the pipe.  When the  
pipe fills up (16 KB), the subtask is then blocked in its writing to  
stdout.  Since it's blocked, it no longer reads its stdin (another  
pipe to parent).  So if parent continues to write bytes to its end of  
the pipe, and does not read from the subtask's output pipe, then the  
parent will eventually block when writing to the pipe that is the  
subtask's stdin.  The parent is now waiting for the child to read its  
input, freeing up space in the pipe, and the child is waiting for the  
parent to read its input, and neither one can proceed until the other  
does.  Classic deadlock.


The fundamental design is "send all data before looking for any  
results".  This is inherently synchronous, even though two or more  
processes are involved.  If the subtask is designed to "read all data  
before producting any results", then it shouldn't deadlock.  However,  
if the subtask is designed to "read some data, produce some results",  
then it is prone to deadlock.


Note that sockets WILL NOT prevent deadlock in this situation.  If  
the requester (the parent) sends enough data to the responder (the  
subtask), but does not read pending responses, then TCP/IP will  
eventually block, just as surely as pipes do.  The size may be larger  
than with pipes, but it can still happen.  Neither pipes nor sockets  
are infinitely buffered streams.  If you treat them as such in your  
software design, then that is a grave error.


I can't tell if this is the cause of the blocking or not, because you  
haven't described how the subtasks produce output.  You also haven't  
described how the parent reads the output from the subtasks.


If the reading is fully asynchronous and infinitely buffered, then it  
shouldn't deadlock.  However, if it's synchronous or has a finite  
buffer length, then it will deadlock under some conditions.  The  
exact conditions depend on the length of the buffers and the amounts  
of data produced for a given input.  Each pipe will hold 16 KB before  
it blocks on write.  Two pipes, so that account for 32 KB.  The other  
32 KB could be in-memory buffering in any of the processes.


If nothing else works, then I think you need to make a well-isolated  
test case that exhibits the problem.  The subtask can be something  
simple, like the 'wc' (word-count) command-line tool.  It reads all  
input before producing any output, so it should never exhibit  
deadlock even if your parent doesn't read any responses until all  
data is sent.


  -- GG

___

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: NSPipe (NSFileHandle) writedata limit?

2010-04-12 Thread Greg Guerin

McLaughlin, Michael P. wrote:


main --> subtask (main send data)

-(void)sendData:(void*)data numBytes:(NSUInteger)sz taskTag: 
(NSString*)tag

{
   NSData *dataset = [NSData dataWithBytes:data length:sz];
   NSNumber *num = [NSNumber numberWithUnsignedInteger:sz]; //  
NSUInteger
   NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:  
num,

@"size", nil];
   [sendEnd writeData:dataset];// Do NOT close the fileHandle!
   [[NSDistributedNotificationCenter defaultCenter]  
postNotificationName:tag

object:myID userInfo:dict];
}

That is, main
1) sends (via FileHandle and pipe) a known quantity of data to the  
subtask

and
2) tells it what sort of data are coming and how much.



All that stuff I just wrote?  Uh, never mind.

There's your deadlock right there.

You must send the notification with size and such BEFORE writing to  
the pipe.  Otherwise the sender can become blocked, because the  
receiver doesn't know it should be reading anything.


If you'd been sending the size over the pipe, it would have been  
obvious.  You have to tell the receiver how many bytes follow.


  -- GG

___

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: IKImageView delegate

2010-04-12 Thread Gerriet M. Denkmann

On 12 Apr 2010, at 21:39, Brian Postow wrote:

> 
> On Apr 10, 2010, at 2:13 AM, Gerriet M. Denkmann wrote:
> 
>> The documentation (updated this morning) says: "An IKImageView object’s 
>> delegate [...] is informed of various actions by the image view through 
>> delegation messages."
>> 
> Why do you say that the documentation has been edited? When I look at it, it 
> says it was edited in February... 
No. I just wanted to say that I am using the current documentation.
> 
> I'm not sure what you want cut to do in an IKImageView, make the area grey?
[ myIkImageView cut: nil] seems to replace the image with the stuff in the 
selected range.


> 
>> Another thing: IKImageView can mark a region (IKToolModeSelect). How to get 
>> this region from IKImageView? (Clumsy workaround: send it a copy: message 
>> and look at the pasteboard).
> 
> There is an *UNDOCUMENTED* method (CGRect)selectionRect which returns the 
> selection rectangle in view coordinates.
> 
Thanks a lot. This works perfectly. 
How did you find this undocumented method? Maybe there is more useful stuff to 
be found?


Kind regards,

Gerriet.

___

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: NSPipe (NSFileHandle) writedata limit?

2010-04-12 Thread Jens Alfke

On Apr 12, 2010, at 9:09 AM, Greg Guerin wrote:

> You must send the notification with size and such BEFORE writing to the pipe. 
>  Otherwise the sender can become blocked, because the receiver doesn't know 
> it should be reading anything.

And it seems strange to use a second mechanism (a distributed notification) to 
tell the receiver that data is available. You don’t really need this — the 
reader can just wait for the NSStreamEventHasBytesAvailable event and then read 
the data. Then you can send everything over a single stream.

—Jens___

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: Data managment

2010-04-12 Thread Jens Alfke

On Apr 12, 2010, at 7:36 AM, Billy Flatman wrote:

> Is it possible to get core data data models to save differently, one for a 
> document save which for example might be an XML format, and one into the 
> applications bundle as an SQLite file?
> That way when a document is saved the main database won't be duplicated, just 
> the document specific data.

You can have different documents with different data models, without needing to 
use different on-disk data formats. In other words, you can have two different 
document types both of which use SQLite.

CoreData is very powerful, but it’s going to take over your app — you’ll end up 
writing everything using managed objects and bindings. Which can be good, but 
there’s a whole ‘nother learning curve for that. It can be easier to just use a 
data storage API directly even if it doesn’t get you all the bells and whistles.

If you want to go with SQLite, you might consider using one of the Cocoa 
adapter libraries so you can use an Objective-C API and not have to deal with 
translating between char* and NSString all the time. The two I know of are FMDB 
and QuickLite.

There are also other data storage libraries that have a simpler data model than 
sqlite (they’re like on-disk NSDictionaries) so they’re a bit simpler to use 
and can potentially run faster. Tokyo Cabinet seems like the main contender in 
that area right now. It comes with C and C++ APIs; I don’t know if anyone’s 
adapted it to Objective-C yet.

—Jens___

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: How do I compare two NSDates using NSPredicate & Core Data

2010-04-12 Thread Jeffrey Oleander
A date-time is a date-time, regardless of how it is 
displayed or entered or obtained from the system.

The whole purpose of the NSDate object is to allow easy
comparison, and determination of intervals by subtraction...
well, a couple of the main purposes... and be able to
display dates and intervals as appropriate to the context.

Calendar systems and date display formats don't lend 
themselves to such calculations, and change-overs from
one calendar to another have made it more difficult.

> On Fri, 2010/04/09, Ashley Clark  wrote:
> From: Ashley Clark 
> Subject: Re: How do I compare two NSDates using NSPredicate & Core Data
> To: "Sean McBride" 
> Cc: Cocoa-dev@lists.apple.com
> Date: Friday, 2010 April 9, 12:52
>> On 2010 Apr 5, at 19:02, Sean McBride wrote:
>>> On Sun, 2010 Apr 04 23:15:16 -0400, Michael A. Crawford said:
>>> Thus far I've gotten away with using
>>> -predicateWithFormat and scalar
>>> values.  I now need to compare a couple of
>>> NSDate instances but am not
>>> sure how to code it up with NSPredicate. 
>>> Consider me a 'visual' learner.
>>
>> I'm pretty sure you can use just <, >, ==, etc.
>> with NSDates in NSPredicates.
>
> One thing that many people overlook is that NSDates
> *always* include a time component. And if that time
> wasn't specified explicitly it typically defaults
> to a preset value set in the editing control (if
> one was used) or the current time at the time the
> date string was parsed.
> 
> So, if you were expecting to compare a set of NSDate
> objects to be on a particular date irrespective of
> their time value... you have a bit of work to do.
> A simple way to approximate the test is to look at
> a time range from midnight to midnight-1 second
> of the following day.
>
> That of course leaves another issue aside though,
> that of differing timezones. All NSDate objects are
> converted to the local timezone by default and the
> original timezone information is not stored in the
> object, so an NSDate created as {2010/01/01 23:59 EDT}
> when read back at some later point when the computer
> is now on the west coast (PDT) would show as
> {2009/12/31 20:59 PDT}.
> 
> All of that to say, comparing dates with predicates
> (or at all) is hard.



___

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: NSPipe (NSFileHandle) writedata limit?

2010-04-12 Thread Marcel Weiher

On Apr 9, 2010, at 10:35 , McLaughlin, Michael P. wrote:

> My main thread has an NSArray of Subtasks and sends data to each via
> 
>  Npending = numProcessors;
>   for (k = 0;k < numProcessors;k++) {
>  Subtask  *aTask = [myTask objectAtIndex:k];
>  [aTask sendData:&theData numBytes:sz taskTag:@"aTag"];
>   }

Just a quick note that the   "&data"  looks fishy to me.  Unless theData is 
declared as   theData[]  this will send the pointer + random data 
behind it down the pipe, and if it is declared that way the & is redundant.

Marcel

___

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: NSArrayController in entity mode and permutations (CoreData question)

2010-04-12 Thread Quincey Morris
On Apr 12, 2010, at 08:15, vincent habchi wrote:

> I'd like to change the place of a NSManagedObject stored in a 
> NSArrayController in entity mode (after a drag'n drop operation). I didn't 
> find any suitable primitive, so I decided to go something like 
> "removeAtSomeIndex" and then immediately after "insertAtSomeOtherIndex".
> 
> However, it does not work: it seems as soon as an object is removed from the 
> array, core data is told to unlink it, so, at the end of the permutation, I 
> end up with an array full of object that get removed in core data at a later 
> point, and after a while I get faults with non-existent objects.

This is likely NOT a Core Data question. Most likely you're not doing your 
memory management quite correctly. Look here under the heading "Mutable Arrays":


http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Collections/Articles/Arrays.html#//apple_ref/doc/uid/2132-BBCCJBIF

In particular, it says:

"In a managed memory environment, when an object is removed from a mutable 
array it receives a release message. This means that if an array is the only 
owner of an object, then the object is deallocated when it is removed. If you 
want to use the object after its removal, you should therefore typically send 
it a retain message before it’s removed from the array."


___

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: CIContext in 10.6

2010-04-12 Thread Gerriet M. Denkmann

On 12 Apr 2010, at 21:55, Jean-Daniel Dupas wrote:

> 
> Le 12 avr. 2010 à 16:39, Gerriet M. Denkmann a écrit :
> 
>> 
>> This works (but is deprecated in 10.6):
>> 
>>  NSOpenGLPixelFormat *pixelFomat = 
>>  CGLPixelFormatObj b = [ pixelFomat CGLPixelFormatObj ];
>>  CGLContextObj a = CGLGetCurrentContext();
>>  ciContext = [ CIContext contextWithCGLContext:  a
>>  pixelFormat:
>> b 
>>  options:
>> nil
>>  ];
>> 
> 
> Why not using the 10.6 function 
Because I relied on the documentation and did not look into CIContext.h.

> 
> 
>> But this does NOT:
>> 
>>  NSGraphicsContext *currentContext = [NSGraphicsContext 
>> currentContext];
>>  CGContextRef ctx = [ currentContext graphicsPort];  
>>  ciContext = [ CIContext contextWithCGContext:   ctx 
>>  options:
>> nil
>>  ];
>> 
>> What is wrong?
> 
> Without defining "does not works", we cannot help you.

Sorry about my sloppy post. Here is the complete story:

The next step:
[ ciContext drawImage: image atPoint: io fromRect: rr ];
does not do anything. No log messages, no picture.
All things involved are non-nil.

But the 10.6 method you mentioned works perfectly. Merci beaucoup.


Kind regards,

Gerriet.

___

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: Data managment

2010-04-12 Thread Chris Ridd
On 12 Apr 2010, at 17:33, Jens Alfke wrote:

> There are also other data storage libraries that have a simpler data model 
> than sqlite (they’re like on-disk NSDictionaries) so they’re a bit simpler to 
> use and can potentially run faster. Tokyo Cabinet seems like the main 
> contender in that area right now. It comes with C and C++ APIs; I don’t know 
> if anyone’s adapted it to Objective-C yet.

Aaron Hillegass's BNRPersistence framework uses it: 


Cheers,

Chris___

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

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

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

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


Re: How do I compare two NSDates using NSPredicate & Core Data

2010-04-12 Thread Jens Alfke


On Apr 12, 2010, at 9:35 AM, Jeffrey Oleander wrote:


A date-time is a date-time, regardless of how it is
displayed or entered or obtained from the system.
The whole purpose of the NSDate object is to allow easy
comparison, and determination of intervals by subtraction...


Yup. An NSDate is really just a fancy wrapper around a floating-point  
number (a CFAbsoluteTime) representing the number of seconds since  
1/1/2001.


(OK, an NSDate also remembers a time zone, but that's just for  
converting to human-readable form, it doesn't affect the actual time  
stored.)


—Jens___

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


Disappearing prefs

2010-04-12 Thread Eric Long
This a Hail Mary pass...

I have a bizarre bug.  Perhaps someone has a hunch about what's going on.

My application prefs file, which is managed with NSUserDefaults, is getting
reset to default values, but so far only on a PPC running 10.5.8 and only
during the wee hours of Monday mornings. (Go figure)

The story is this:

My app runs scheduled tasks, such as checking for damaged files and
reporting the results.  (Note: That particular task will also run plutil on
plist files to check their format validity.)  QA created a number of tasks
that run nightly.  These all work just fine except on Mondays on PPC running
10.5.8.  

The tasks execute at their appointed times, all is well, then suddenly a
task attempts to execute and discovers that the application preferences have
been reset to default values.  It can't find config data it expected to
find, so it bails.

The failure always occurs on the next execution after the task that performs
file validity checks.  That task does not remove or modify damaged files.
It simply creates a report of what it finds.  That task always completes
successfully.

The scheduled task jobs are lengthy to perform. QA was able to reproduce the
bug by manipulating the date/time.  Interestingly enough, this morning's
test executed without reproducing the bug.

(sigh).

Eric





___

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: NSImageView Will Not Alias Images

2010-04-12 Thread Ken Ferry
On Mon, Apr 12, 2010 at 8:59 AM, Chris Tracewell  wrote:

>
> On Apr 6, 2010, at 8:16 PM, Ken Ferry wrote:
>
>  This was once true, but is out of date.  I'd like to see a test app.  For
>>> example, how do you know you aren't getting antialiasing?  It may be that
>>> you just don't like the output. :-)
>>>
>>
>> Well - NSImageInterpolationHigh and NSImageInterpolationNone produce the
>> same exact result - screen shot copy (control-command-shift-4) the imageView
>> built once using NSImageInterpolationHigh  and once using
>> NSImageInterpolationNone then paste each into a Photoshop layer, align them
>> perfectly and then turn the top layer off and on at 800% and there is not a
>> single pixel that moves or changes color.
>>
>> The dropped image is roughly 1000 x 1000 (a screen shot PNG) and the
>> imageView size is 200x200
>>
>> To make sure the currentContext was correct - I log [[NSGraphicsContext
>> currentContext] imageInterpolation] for each build and it shows the correct
>> values 3 and 1 respectively. And then just to be super sure I I log
>> [[NSGraphicsContext currentContext] isDrawingToScreen] inside drawRect of my
>> NSImageView subclass and get YES.
>>
>> I did implement my own image sizing in drawRect and then used [self
>> setImage] and it works great. Not sure what could be the issue.
>>
>>
>>  It would also be good to know what OS you are working on.
>>>
>>> -Ken
>>>
>>
>>
>> I'm using 10.5.8. - XCode   3.1.2 - iMac Core 2 Duo and the app is GC.
>>
>> What Jens is saying is probably true in 10.5, not in 10.6.  Nevertheless,
>> I would be interested to see a test app.
>>
>> -Ken
>> Cocoa Frameworks
>>
>
>
> Thought I'd add some closure to this, even though it's a week later. I
> believe Ken's original assessment to be accurate - that I am just not happy
> with the resampling that NSImageView is doing. Using larger images with lots
> of detail, like a screenshot, the problem is more pronounced, the same is
> true for images with thin diagonal lines. More organic images that aren't
> too big produce acceptable results.
>
> Of note, I tested an image in Photoshop that was struggling in the
> ImageView and found that by sizing to the same size as the ImageView using,
> "Nearest Neighbor" as the sampling method, resulted in identical
> "distortion" or lack of smoothness per se. Nearest Neighbor has been a
> resampling method in PS for as long as I can remember, but I isn't really an
> anti-alias resampling method - it chooses the pixel values by proximity and
> duplicates it - thus no new color values get produced. I have used it in the
> past when needing to take, for example, a small bit icon or type element
> that I want to enlarge without aliasing, to keep a pixel accurate
> representation at a larger scale. Using this method to downsize will give
> mediocre results at best.
>
> All of that to say, it seems that an NSImageView in <= 10.5 you'll be
> getting that method for resampling - so yes it resamples, but the method is
> not optimal.
>

You may be getting nearest neighbor resampling, but if the conclusion is
that this is all NSImage is capable of doing then that part isn't accurate.
 Quart'z high quality interpolation is currently Lanczos, medium quality
is Fant.  I don't recall right now what low corresponds to right now, but I
would think that no interpolation would be nearest neighbor.  NSImage
drawing is Quartz drawing.

-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: Disappearing prefs

2010-04-12 Thread Jens Alfke
One possibility, since it sounds like you can reproduce the problem  
fairly often by manipulating the clock, is to use fs_usage to log all  
filesystem activity while your tasks are running. Actually you  
probably want to do something like. Then you can sort through the  
output to see what process is removing/resetting the plist file and  
when. That might give you a clue.


—Jens___

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: NSArrayController in entity mode and permutations (CoreData question)

2010-04-12 Thread vincent habchi
Quincy,
(sorry for the double answer)

> This is likely NOT a Core Data question. Most likely you're not doing your 
> memory management quite correctly. Look here under the heading "Mutable 
> Arrays":
> 
>   
> http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Collections/Articles/Arrays.html#//apple_ref/doc/uid/2132-BBCCJBIF
> 
> In particular, it says:
> 
> "In a managed memory environment, when an object is removed from a mutable 
> array it receives a release message. This means that if an array is the only 
> owner of an object, then the object is deallocated when it is removed. If you 
> want to use the object after its removal, you should therefore typically send 
> it a retain message before it’s removed from the array."

Right. So I inserted the object into another mutable array (that store the 
permuted objects) *before* actually deleting and reinserting it. Same behavior. 
To be more specific, everything works right, up to the point where I saved the 
context and bing, all the objects disappear. That leads me, on the contrary, to 
believe that memory management is okay, but core data references go away.

Anyhow, I'm trying to solve this using proxy objets that I manipulate instead 
of the managed objects.

Vincent

 ___

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

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

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

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


Re: Data managment

2010-04-12 Thread Dru Satori
Another consideration is:

Is this a project that could ever need a multi-user or networked data engine?  

If the above answer is yes, then CoreData is probably a bad option (though 
Marko's excellent BaseTen for PostgreSQL might be an option in that case), as 
the options for migrating Managed Objects to network databases are limited.  

That is part of the problem, 'Data' is such a relative term, and without 
knowing the goal of the application, it is tough to provide a good scalable 
alternative.

From first hand experience, one of the projects I am working on is in some of 
this box.

One application that can be used standalone, or always on multi-user or with 
multiple disconnected users synchronizing data when peered.  Complex?  You have 
no idea.  But in the design process, many decisions had to be made, that meant 
architecture and implementation.  The end result for me?  a client server 
design that uses a multi-user capable database engine even when in stand-alone 
single user mode. When you start the application, it starts the embedded 
database engine.  While this is massive overkill for most implementations, it 
is still a very real design, IF your project demands it.

Andy 'Dru' Satori

On Apr 12, 2010, at 12:33 PM, Jens Alfke  wrote:

> 
> On Apr 12, 2010, at 7:36 AM, Billy Flatman wrote:
> 
>> Is it possible to get core data data models to save differently, one for a 
>> document save which for example might be an XML format, and one into the 
>> applications bundle as an SQLite file?
>> That way when a document is saved the main database won't be duplicated, 
>> just the document specific data.
> 
> You can have different documents with different data models, without needing 
> to use different on-disk data formats. In other words, you can have two 
> different document types both of which use SQLite.
> 
> CoreData is very powerful, but it’s going to take over your app — you’ll end 
> up writing everything using managed objects and bindings. Which can be good, 
> but there’s a whole ‘nother learning curve for that. It can be easier to just 
> use a data storage API directly even if it doesn’t get you all the bells and 
> whistles.
> 
> If you want to go with SQLite, you might consider using one of the Cocoa 
> adapter libraries so you can use an Objective-C API and not have to deal with 
> translating between char* and NSString all the time. The two I know of are 
> FMDB and QuickLite.
> 
> There are also other data storage libraries that have a simpler data model 
> than sqlite (they’re like on-disk NSDictionaries) so they’re a bit simpler to 
> use and can potentially run faster. Tokyo Cabinet seems like the main 
> contender in that area right now. It comes with C and C++ APIs; I don’t know 
> if anyone’s adapted it to Objective-C yet.
> 
> —Jens___
> 
> 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/dru%40druware.com
> 
> This email sent to d...@druware.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: NSPipe (NSFileHandle) writedata limit?

2010-04-12 Thread McLaughlin, Michael P.
>Greg Guerin wrote

>The fundamental design is "send all data before looking for any
>results".  This is inherently synchronous, even though two or more
>processes are involved.  If the subtask is designed to "read all data
>before producting any results", then it shouldn't deadlock.  However,
>if the subtask is designed to "read some data, produce some results",
>then it is prone to deadlock.

In my app so far, I have not even gotten to the point where the subtask
produces any output.  I am sending all data from main but main blocks iff
the number of bytes sent > 65536.

As noted in my previous posting, the subtask consumes this stream via

-(NSData*)getDataSz:(NSUInteger)sz
{   
   return [input readDataOfLength:sz];  // where input = stdin
}

The only allusion to the number 65536 that I found was via sysctl which
reveals the following buffer size:

net.inet.tcp.sendspace = net.inet.tcp.recvspace = 65536

but I am not certain that this is relevant.

-- 
Mike McLaughlin

___

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: Data managment

2010-04-12 Thread Jens Alfke


On Apr 12, 2010, at 10:54 AM, Dru Satori wrote:

One application that can be used standalone, or always on multi-user  
or with multiple disconnected users synchronizing data when peered.   
Complex?  You have no idea.  But in the design process, many  
decisions had to be made, that meant architecture and  
implementation.  The end result for me?  a client server design that  
uses a multi-user capable database engine even when in stand-alone  
single user mode. When you start the application, it starts the  
embedded database engine.  While this is massive overkill for most  
implementations, it is still a very real design, IF your project  
demands it.


Veering a little off-topic, but have you looked at CouchDB? It's a  
very cool persistent data store that works either single-user, multi- 
user, or replicated. It's kind of a fancy JSON-based key-value store  
with MapReduce based querying, and a fancy sync engine for connecting  
multiple instances.


I haven't seen any usage of CouchDB by Mac apps yet, but it's already  
been integrated into Ubuntu Linux's desktop as the underlying shared  
data store for contacts and calendars and so on — like a combination  
of the AddressBook and Calendar frameworks and iSync. This is one of  
the few times I've been jealous of Linux's UI. :)


The CouchDB protocol is pretty easy to work with because it's all HTTP/ 
REST/JSON. You'd mostly just need NSURLRequest and one of the Cocoa  
JSON parsers.


—Jens___

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: NSArrayController in entity mode and permutations (CoreData question)

2010-04-12 Thread Quincey Morris
On Apr 12, 2010, at 10:14, vincent wrote:

> I did try to insert the moved object in another array *before* deleting and 
> reinserting it (and then deleting it from the other array). AFAIK, inserting 
> an object in a NSArray retains it. TO no avail.

Ah, ok, sorry -- trying the easiest answer first was worth a try. :)

> I am trying to solve this issue using proxy objects.

So we move on to possible answer B. From the description of -[NSArrayController 
removeObject:]

"If you are using Core Data, the exact semantics of this method differ 
depending on the settings for the array controller. If the receiver’s content 
is fetched automatically, removed objects are marked for deletion by the 
managed object context (and hence removal from the object graph). If, however, 
the receiver’s contentSet is bound to a relationship, removeObject: by default 
only removes the object from the relationship (not from the object graph). You 
can, though, set the “Deletes Object on Remove” option for the contentSet 
binding, in which case objects are marked for deletion as well as being removed 
from the relationship."

I think the real problem is that you're not seeing the implication of 
NSArrayController's being a proxy object -- you cannot "remove" objects from 
*just* the array controller (and re-insert them later), because the array 
controller doesn't contain any objects -- it's merely a proxy for the actual 
container, and removing objects from the actual container has side-effects in 
the Core Data case (at least the way NSArrayController does it, some of the 
time).

Answer C:

Also, because the content set has no order, the order of the objects in the 
array controller's arrangedObjects (if you could manipulate it the way you 
want) would have no way of persisting, and you'd have to be certain that 
nothing ever caused the controller's arrangeObjects method to be called, 
directly or indirectly.

Surely it would be more robust to make the order explicit in your data model 
(with a transient property if the order really is transient) and let the array 
controller keep the displayed content sorted according to that order?

Answer D:

You seem to be getting awfully close to trying to program your data model by 
"remote control" via NSArrayController -- which may seem attractive because 
they superficially seem a bit easier to program. (You want an ordering on your 
otherwise-unordered Core Data objects, and you're taking a short cut by 
implementing the ordering via NSArrayController, instead of enhancing your data 
model to support the desired order.) This isn't really the purpose of array 
controllers, and torturing them in this way often (as we see on this list) ends 
up torturing the developer even more.

Again, I think you'd be much better off finding a solution properly within your 
data model.

Of course, answer D is largely a matter of opinion -- and answer C to some 
degree. FWIW.


___

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: Data managment

2010-04-12 Thread Jens Alfke
The @*$& listserv is stripping the HTML from messages, so the links in  
my previous post got lost. (I guess hyperlinking is too newfangled a  
concept for Mailman?)


CouchDB: http://couchdb.apache.org
Ubuntu DesktopCouch: http://www.freedesktop.org/wiki/Specifications/desktopcouch

—Jens___

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: Disappearing prefs

2010-04-12 Thread Quincey Morris
On Apr 12, 2010, at 10:21, Eric Long wrote:

> This a Hail Mary pass...
> 
> I have a bizarre bug.  Perhaps someone has a hunch about what's going on.
> 
> My application prefs file, which is managed with NSUserDefaults, is getting
> reset to default values, but so far only on a PPC running 10.5.8 and only
> during the wee hours of Monday mornings. (Go figure)

I can't resist trying a Hail Mary answer. If I'm right can I have a million 
dollars, please?

One possibility to consider is messaging a nil object. That's normally safe 
(you get a reliable return value of 0/nil/NULL). But if the method return value 
is a *structure*, the return value is unpredictable. (And, yes, I learned this 
the hard way. Even though I already knew it.)

One thing that I *think* is different about PPC is the set of rules for how 
structures are returned (depending on how big they are, and whatever other 
factors).

So, sending a structure-returning message to a nil object may fail differently 
on PPC, but differently in a repeatable way, perhaps.

Or not.

Message me off-list about where to send the million dollars, ok?


___

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: NSInvocation error when closing a dirty document

2010-04-12 Thread Brad Stone
The view that has the combo box, for example, has a Object Controller (called 
"NoteObjectController) binded to my file's owner (MyDocument : NSDocument) with 
the Model Key Path to the MOC and the object controller is an entity of my 
model I created in Core Data.  The combo box is binded to the attribute 
"category" (which is in the entity Note).  All of it is just like you said and 
pretty plain vanilla.  Remember, all this binding works fine with a normal 
save.  Just not when I close a dirty document.  When I do, the first time I get 
the invocation error.  I don't know **why** I just know it's because the cursor 
is still in the text fields (any one of them).  When I close again it works 
because the editing ended when the error came up.  I'm using 
"saveDocumentWithDelegate" to check to see if the user is closing a document 
that needs to be saved so I can end editing before the save begins to head off 
the error.

I agree with you 100%.  I'm learning in Cocoa that if you're doing too much 
coding you're doing something wrong but I don't know how else to fix it.  I'm 
an experience programmer but only 6-months with Cocoa.



On Apr 12, 2010, at 1:04 AM, Jerry Krinock wrote:

> Brad, you're overriding a method for a strange purpose, and it looks like 
> you're examining an argument to see if it is a certain Apple private 
> selector, and all this is done to achieve something which is quite ordinary, 
> namely binding your data model to a combo box and a text view.
> 
> When you find yourself doing something extraordinary to achieve a result 
> which is ordinary, it means that you took a wrong turn somewhere.  Anyone 
> else with a similar problem should instead try the object controller I 
> suggested.
> 
> 
> On 2010 Apr 11, at 14:42, Brad Stone wrote:
> 
>> - (void)saveDocumentWithDelegate:(id)delegate 
>> didSaveSelector:(SEL)didSaveSelector contextInfo:(void *)contextInfo {
>>  
>>  if (didSaveSelector == @selector(_document:shouldClose:contextInfo:)) { 
> 
> 
> ___
> 
> 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/cocoa-dev%40softraph.com
> 
> This email sent to cocoa-...@softraph.com
On Apr 12, 2010, at 1:04 AM, Jerry Krinock wrote:

> Brad, you're overriding a method for a strange purpose, and it looks like 
> you're examining an argument to see if it is a certain Apple private 
> selector, and all this is done to achieve something which is quite ordinary, 
> namely binding your data model to a combo box and a text view.
> 
> When you find yourself doing something extraordinary to achieve a result 
> which is ordinary, it means that you took a wrong turn somewhere.  Anyone 
> else with a similar problem should instead try the object controller I 
> suggested.
> 
> 
> On 2010 Apr 11, at 14:42, Brad Stone wrote:
> 
>> - (void)saveDocumentWithDelegate:(id)delegate 
>> didSaveSelector:(SEL)didSaveSelector contextInfo:(void *)contextInfo {
>>  
>>if (didSaveSelector == @selector(_document:shouldClose:contextInfo:)) {   
> 
> 
> ___
> 
> 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/cocoa-dev%40softraph.com
> 
> This email sent to cocoa-...@softraph.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: Data managment

2010-04-12 Thread Kyle Sluder

On Apr 12, 2010, at 11:08 AM, Jens Alfke  wrote:

The @*$& listserv is stripping the HTML from messages, so the links  
in my previous post got lost. (I guess hyperlinking is too  
newfangled a concept for Mailman?)


I think you meant to say "The listserv is sparing us from the %...@ing  
atrocity that is HTML mail. ;-)


Just put your URLs inline or as footnotes; I'm sure we can manage.

--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: NSArrayController in entity mode and permutations (CoreData question)

2010-04-12 Thread vincent habchi
Quincey,

thanks a lot

> Surely it would be more robust to make the order explicit in your data model 
> (with a transient property if the order really is transient) and let the 
> array controller keep the displayed content sorted according to that order?

Sure, I could do that. In fact I have done it: This order is not a property of 
the inserted object, but of one liked therewith. But tell me, would 
drag-and-drop work by just rearranging an object ID?

Besides, the proxy solution has one advantage: since the object in the 
NSArrayController reacts to actions performed on buttons linked to it, I think 
it is better to have code in the proxy object rather than on the NSManaged one, 
that gets overwritten every time I alter it, even slightly. What do you think?

Thanks again,
Vincent


___

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

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

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

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


Re: Data managment

2010-04-12 Thread Dru Satori
I looked at it pretty hard, but in the end I went with a traditional RDBMS, 
largely for the eventual need to expose the interface to external reporting 
tools, that as a rule don't talk custom interfaces.  Admittedly, I borrowed 
some concepts though.

Design wise the 'server' in my configuration is PostgreSQL->Cocoa Business 
Objects exposed via web services ( custom fastcgi interface running in an 
embedded instance of lighttpd using SOAP for compatability with a possible .NET 
client ) that even in single user mode passes all data requests via http.

It is a solution.  It has quirks, but the long term, I think it is a design 
that we will see more and more of.  CouchDB is very very slick, but it has some 
issues behind the scenes particularly in terms of performance.

Andy 'Dru' Satori

On Apr 12, 2010, at 2:05 PM, Jens Alfke  wrote:

> 
> On Apr 12, 2010, at 10:54 AM, Dru Satori wrote:
> 
>> One application that can be used standalone, or always on multi-user or with 
>> multiple disconnected users synchronizing data when peered.  Complex?  You 
>> have no idea.  But in the design process, many decisions had to be made, 
>> that meant architecture and implementation.  The end result for me?  a 
>> client server design that uses a multi-user capable database engine even 
>> when in stand-alone single user mode. When you start the application, it 
>> starts the embedded database engine.  While this is massive overkill for 
>> most implementations, it is still a very real design, IF your project 
>> demands it.
> 
> Veering a little off-topic, but have you looked at CouchDB? It's a very cool 
> persistent data store that works either single-user, multi-user, or 
> replicated. It's kind of a fancy JSON-based key-value store with MapReduce 
> based querying, and a fancy sync engine for connecting multiple instances.
> 
> I haven't seen any usage of CouchDB by Mac apps yet, but it's already been 
> integrated into Ubuntu Linux's desktop as the underlying shared data store 
> for contacts and calendars and so on — like a combination of the AddressBook 
> and Calendar frameworks and iSync. This is one of the few times I've been 
> jealous of Linux's UI. :)
> 
> The CouchDB protocol is pretty easy to work with because it's all 
> HTTP/REST/JSON. You'd mostly just need NSURLRequest and one of the Cocoa JSON 
> parsers.
> 
> —Jens
___

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: Data managment

2010-04-12 Thread Dru Satori
Honestly I am surprised that apple has not adopted one of the OSS database 
engines as a standard db in osx and implemented core data on top of it for 
multi user implementations.

If for no other reason than to shoot at Microsoft over the mssql as part of the 
file system debacle

Andy 'Dru' Satori

On Apr 12, 2010, at 2:08 PM, Jens Alfke  wrote:

> The @*$& listserv is stripping the HTML from messages, so the links in my 
> previous post got lost. (I guess hyperlinking is too newfangled a concept for 
> Mailman?)
> 
> CouchDB: http://couchdb.apache.org
> Ubuntu DesktopCouch: 
> http://www.freedesktop.org/wiki/Specifications/desktopcouch
> 
> —Jens
___

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


Updating parameters of a CI filter on a CA layer

2010-04-12 Thread James Walker
The documentation for the filters property of the CALayer class says: 
"Filter properties should be modified by calling setValue:forKeyPath: on 
each layer that the filter is attached to."  But I don't understand 
exactly how to write the key path, since the filters property is an 
array rather than a single CIFilter.  I looked through the KVC guide, 
and though I saw array operators like @count, I couldn't find any way to 
just ask for item number 0 in an array.

--
  James W. Walker, Innoventive Software LLC
  
___

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: NSPipe (NSFileHandle) writedata limit?

2010-04-12 Thread Dave Keck
> In my app so far, I have not even gotten to the point where the subtask
> produces any output.  I am sending all data from main but main blocks iff
> the number of bytes sent > 65536.

There's nothing inherent about that number, as shown in the following test case:

http://themha.com/ipctest

... which viciously consumes 268435456 bytes no problem.

If I were you I would take that test case and gradually transform it
into your project until it breaks, or vice versa. Unless you can share
all the relevant producer/consumer code, all we can do is take wild
stabs in the dark about what your code might be doing wrong.
___

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 parameters of a CI filter on a CA layer

2010-04-12 Thread David Duncan
On Apr 12, 2010, at 1:15 PM, James Walker wrote:

> The documentation for the filters property of the CALayer class says: "Filter 
> properties should be modified by calling setValue:forKeyPath: on each layer 
> that the filter is attached to."  But I don't understand exactly how to write 
> the key path, since the filters property is an array rather than a single 
> CIFilter.  I looked through the KVC guide, and though I saw array operators 
> like @count, I couldn't find any way to just ask for item number 0 in an 
> array.


You need to assign a name to each filter, then you can create keypaths like 
@"filters.myfiltername.property".
--
David Duncan
Apple DTS Animation and Printing

___

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: NSArrayController in entity mode and permutations (CoreData question)

2010-04-12 Thread Kyle Sluder
On Mon, Apr 12, 2010 at 12:12 PM, vincent habchi  wrote:
> Besides, the proxy solution has one advantage: since the object in the 
> NSArrayController reacts to actions performed on buttons linked to it, I 
> think it is better to have code in the proxy object rather than on the 
> NSManaged one, that gets overwritten every time I alter it, even slightly. 
> What do you think?

You're advocating an explicit violation of MVC. Why not instead move
the code into the model where it belongs and have the controller ask
the model to perform the operation?

--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: Updating parameters of a CI filter on a CA layer

2010-04-12 Thread Kyle Sluder
On Mon, Apr 12, 2010 at 1:22 PM, David Duncan  wrote:
> You need to assign a name to each filter, then you can create keypaths like 
> @"filters.myfiltername.property".

Can we get some explanation of the magic involved in CALayer KVC
support? Why is -setValue:forKeyPath: necessary here, rather than just
changing the filter directly? Why does CALayer treat an array property
as if it were a dictionary when it's part of a keypath?

Some rationale would be very helpful. All we know now is "CALayer
extends KVC for some super-secret reason."

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


Font Style Names for iPhone/iPad

2010-04-12 Thread Gordon Apple
How do I get a list of style names for a particular font family for
iPhone/iPad?  I can get the full font names and have my own font picker
which shows those.  However, that is not what I really want.  I want the
secondary list to show the common names, i.e., "Bold", "Italic", etc., like
is shown in the iPad Pages app, not the full font names.  In MacOS,
NSFileManager has a means to do that.  I can't find any equivalent in iPhone
OS.  I thought of using the full name to create a CGFont, but that still
doesn't lead me to the short names that I want.  Any ideas?


___

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: Font Style Names for iPhone/iPad

2010-04-12 Thread Eric E. Dolecki
http://www.alexcurylo.com/blog/2008/10/05/snippet-available-uifonts/

On Mon, Apr 12, 2010 at 5:03 PM, Gordon Apple  wrote:

> How do I get a list of style names for a particular font family for
> iPhone/iPad?  I can get the full font names and have my own font picker
> which shows those.  However, that is not what I really want.  I want the
> secondary list to show the common names, i.e., "Bold", "Italic", etc., like
> is shown in the iPad Pages app, not the full font names.  In MacOS,
> NSFileManager has a means to do that.  I can't find any equivalent in
> iPhone
> OS.  I thought of using the full name to create a CGFont, but that still
> doesn't lead me to the short names that I want.  Any ideas?
>
>
> ___
>
> 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/edolecki%40gmail.com
>
> This email sent to edole...@gmail.com
>



-- 
http://ericd.net
Interactive design and development
___

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: NSArrayController in entity mode and permutations (CoreData question)

2010-04-12 Thread Quincey Morris
On Apr 12, 2010, at 12:12, vincent habchi wrote:

> Sure, I could do that. In fact I have done it: This order is not a property 
> of the inserted object, but of one liked therewith. But tell me, would 
> drag-and-drop work by just rearranging an object ID?
> 
> Besides, the proxy solution has one advantage: since the object in the 
> NSArrayController reacts to actions performed on buttons linked to it, I 
> think it is better to have code in the proxy object rather than on the 
> NSManaged one, that gets overwritten every time I alter it, even slightly. 
> What do you think?

I think I'm confused now about what scenario we are talking about. Are you 
saying that the object you insert with [NSArrayController insertObject...] is 
*not* a NSManagedObject, but is a proxy object that is linked to the 
NSManagedObject? Or are you referring to the NSArrayController itself as a 
proxy object?

I also don't understand what "the object in the NSArrayController reacts to 
actions performed on buttons linked to it" means. There aren't any objects "in" 
a NSArrayController. Or do you mean the NSArrayController instance itself has 
buttons linked to it?

And I also don't understand what's being "overwritten". Do you mean the Core 
Data persistent store?

I've got a feeling that what you're trying to do is put an "ordered containment 
layer" (a sorted NSArray, basically) between the Core Data NSSet in your data 
model and the NSArrayController. If so, I think that's perfectly fine, but it 
should be part of your data model, and you can't just use the NSArrayController 
for the purpose.


___

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: Font Style Names for iPhone/iPad

2010-04-12 Thread Fritz Anderson
On 12 Apr 2010, at 4:08 PM, Eric E. Dolecki wrote:

> http://www.alexcurylo.com/blog/2008/10/05/snippet-available-uifonts/

That gets you things like "CourierNewPS-BoldItalicMT," which the OP made clear 
he doesn't want. He wants to know how to get the two strings "Courier New" and 
"Bold Italic." The first can come from [UIFont familyNames], as shown in the 
sample you link to, but it doesn't show how to get the style name.

I don't have ready access to the documentation (AppKiDo iPhone isn't speaking 
to me just now), which may have an easier answer, but I fear the answer is one 
of these:

1. Apple can do it because it already knows the names of its fonts and can keep 
the translations in a table. They can afford to do this because the iWork 
developers get privileged access to that information, and can coordinate with 
updates that might add more fonts in the future. 

You could do the same, but would be subject to bit rot as the OS changes.

2. Fake the variant names:
a. If there is only one variant, use the family name and call it 
"Regular." Or don't offer a variant, as your need may be.
b. Otherwise, take the portion of the variant name that follows the 
"-", strip off trailing capital letters, and insert spaces in front of embedded 
caps.

Again, an OS update could break this.

It surprises me that font variants seem not to be accessible in the abstract in 
iPhone OS as of the versions we are permitted to discuss here. On the Mac side, 
NSFont and NSFontDescriptor provide a mechanism that you can put a font or font 
name into, and get strings or masks back.

— F

___

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


set up a hotkey UI

2010-04-12 Thread Martin Batholdy
Hi,


I would like to implement a "set-hotkey" option,
where the user presses a hotkey, the app registers the key-combination and 
makes a global key-shortcut.

Does someone here know a good tutorial or has some hints where to start?


thanks for any help.

___

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: Font Style Names for iPhone/iPad

2010-04-12 Thread Kyle Sluder
On Mon, Apr 12, 2010 at 2:47 PM, Fritz Anderson  wrote:
> That gets you things like "CourierNewPS-BoldItalicMT," which the OP made 
> clear he doesn't want. He wants to know how to get the two strings "Courier 
> New" and "Bold Italic." The first can come from [UIFont familyNames], as 
> shown in the sample you link to, but it doesn't show how to get the style 
> name.

See CTFontCopyDisplayName and file a bug that this should be
accessible from UIFont.

--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: set up a hotkey UI

2010-04-12 Thread Dave DeLong
The Shortcut Recorder works pretty darn well:

http://code.google.com/p/shortcutrecorder/

The test project uses the PTHotKey library to demonstrate hotkey functionality, 
but I've found PTHotKey to be somewhat cumbersome, so I wrote my own wrapper:  
http://github.com/davedelong/DDHotKey

Cheers,

Dave

On Apr 12, 2010, at 3:52 PM, Martin Batholdy wrote:

> Hi,
> 
> 
> I would like to implement a "set-hotkey" option,
> where the user presses a hotkey, the app registers the key-combination and 
> makes a global key-shortcut.
> 
> Does someone here know a good tutorial or has some hints where to start?


smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Updating parameters of a CI filter on a CA layer

2010-04-12 Thread David Duncan
On Apr 12, 2010, at 1:30 PM, Kyle Sluder wrote:

> On Mon, Apr 12, 2010 at 1:22 PM, David Duncan  wrote:
>> You need to assign a name to each filter, then you can create keypaths like 
>> @"filters.myfiltername.property".
> 
> Can we get some explanation of the magic involved in CALayer KVC
> support? Why is -setValue:forKeyPath: necessary here, rather than just
> changing the filter directly? Why does CALayer treat an array property
> as if it were a dictionary when it's part of a keypath?
> 
> Some rationale would be very helpful. All we know now is "CALayer
> extends KVC for some super-secret reason."


In order to properly animate values, Core Animation needs to be notified of 
value changes, hence why you need to go through Core Animation to change the 
values of a filter if you want it to animate properly. In addition to that, we 
make no guarantee that the instances of the filters that you provide are the 
same ones used to render, so by going directly to the filter you would be 
changing the wrong instance (with the correct one being private to Core 
Animation).

A filter chain requires an order to make sense, hence the filter list needs to 
be an array or some more complex structure that can specify rendering order. In 
the end it was chosen to use an array while extending CIFilter to allow for a 
name property (whose usefulness in Core Animation is similar to a layer's own 
name property) and to extend array notation to allow you to use that name to 
lookup an object in the array.

For a why, the best I can come up with is to try to make the API easier to use.
--
David Duncan
Apple DTS Animation and Printing

___

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: Font Style Names for iPhone/iPad

2010-04-12 Thread Gordon Apple
Thanks for the response, but that is what I have now and am trying to get
away from.  I want ³normal², ³bold² and ³Italic²,  not ³Veranda²,
³Veranda-Bold² and ³Veranda-Italic² for the secondary list.  In many cases
it might be possible to strip the font Family name, but the font naming
convention is not consistent.  Some even use contractions.  If you look at
the font list in Pages on the iPad, it does what I want.


On 4/12/10 4:08 PM, "Eric E. Dolecki"  wrote:

> http://www.alexcurylo.com/blog/2008/10/05/snippet-available-uifonts/
> 
> On Mon, Apr 12, 2010 at 5:03 PM, Gordon Apple  wrote:
>> How do I get a list of style names for a particular font family for
>> iPhone/iPad?  I can get the full font names and have my own font picker
>> which shows those.  However, that is not what I really want.  I want the
>> secondary list to show the common names, i.e., "Bold", "Italic", etc., like
>> is shown in the iPad Pages app, not the full font names.  In MacOS,
>> NSFileManager has a means to do that.  I can't find any equivalent in iPhone
>> OS.  I thought of using the full name to create a CGFont, but that still
>> doesn't lead me to the short names that I want.  Any ideas?
>> 
>> 
>> ___
>> 
>> 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/edolecki%40gmail.com
>> 
>> This email sent to edole...@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: Font Style Names for iPhone/iPad

2010-04-12 Thread Kyle Sluder
On Mon, Apr 12, 2010 at 3:08 PM, Gordon Apple  wrote:
> Thanks for the response, but that is what I have now and am trying to get
> away from.  I want ³normal², ³bold² and ³Italic²,  not ³Veranda²,
> ³Veranda-Bold² and ³Veranda-Italic² for the secondary list.  In many cases
> it might be possible to strip the font Family name, but the font naming
> convention is not consistent.  Some even use contractions.  If you look at
> the font list in Pages on the iPad, it does what I want.

Ah, in that case you're going to need to do a little bit more work.
But CTFont does everything you need. Take a look at
kCTFontStyleNameKey and friends.

--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: Font Style Names for iPhone/iPad

2010-04-12 Thread Gordon Apple
Thanks.  That did it.  I just needed a display name.  I used the following
when loading the picker view:

- (NSString*)styleNameForIndex:(NSUInteger)index
inFontFamily:(NSString*)famName {
NSString* fontName = [[UIFont fontNamesForFamilyName:famName]
objectAtIndex:index];
CTFontRef fontRef = CTFontCreateWithName((CFStringRef)fontName, 0.0,
NULL);
CFStringRef style = CTFontCopyName(fontRef, kCTFontStyleNameKey);
CFRelease(fontRef);
return [(NSString*)style autorelease];
}

My first shot at a FontPicker subclass of UIPickerView was almost as wide as
the iPad.  After moving to a two-line UILabel and using the short style
names, I've got it slimmed down to being usable on an iPhone.

BTW, general info in case anybody is interested -- If you are going to use
dependent columns in a UIPickerView, the only way I could figure out to do
it is to use a timer to poll it for changes in the primary column so you can
reload the dependent column.


On 4/12/10 5:15 PM, "Kyle Sluder"  wrote:

> On Mon, Apr 12, 2010 at 3:08 PM, Gordon Apple  wrote:
>> Thanks for the response, but that is what I have now and am trying to get
>> away from.  I want ³normal², ³bold² and ³Italic²,  not ³Veranda²,
>> ³Veranda-Bold² and ³Veranda-Italic² for the secondary list.  In many cases
>> it might be possible to strip the font Family name, but the font naming
>> convention is not consistent.  Some even use contractions.  If you look at
>> the font list in Pages on the iPad, it does what I want.
> 
> Ah, in that case you're going to need to do a little bit more work.
> But CTFont does everything you need. Take a look at
> kCTFontStyleNameKey and friends.
> 
> --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: NSPipe (NSFileHandle) writedata limit?

2010-04-12 Thread Andrew Farmer
On 12 Apr 2010, at 10:56, McLaughlin, Michael P. wrote:
> Greg Guerin wrote
>> The fundamental design is "send all data before looking for any
>> results".  This is inherently synchronous, even though two or more
>> processes are involved.  If the subtask is designed to "read all data
>> before producting any results", then it shouldn't deadlock.  However,
>> if the subtask is designed to "read some data, produce some results",
>> then it is prone to deadlock.
> 
> In my app so far, I have not even gotten to the point where the subtask
> produces any output.  I am sending all data from main but main blocks iff
> the number of bytes sent > 65536.

What I think you're missing here is that pipes have a finite capacity -- this 
is 64K in current releases of OS X, as you've discovered, but POSIX guarantees 
only that it will be at least 512 bytes. As such, writing data to a pipe and 
then beginning to read bytes from the other end WILL cause deadlocks; you will 
need to start reading data from the pipe at the same time as data is being 
written to it. In practical terms, this means either ordering the reading end 
to start reading before beginning to write data to the other end, or adding the 
pipe fd as a runloop source.___

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


Drawing a path and making an object follow that path IPHONE

2010-04-12 Thread charisse napeÿfffff1as
Hello,

I'm a newbie at iphone development and I was wondering if somebody can point 
out how to create a simple app where I can draw a simple path with loops or 
curves from point a to b and then make an object follow that path from a to b. 
Anybody can give me a sample code or something so I can study it? 
Thanks,
Charisse


  Get your preferred Email name!
Now you can @ymail.com and @rocketmail.com. 
http://mail.promotions.yahoo.com/newdomains/aa/
___

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