NSMatrix bindings

2011-03-18 Thread Christian Ziegler
Hi all!

I'm having hard times figuring out how to bind an NSMatrix properly. I got an 
NSMatrix with NSButtonCells (checkboxes) and I want to somehow bind to my model 
which of these checkboxes are selected. What should work is binding the content 
objects of the NSMatrix to an ArrayController and fill the arrayController's 
content with NSButtonCells programmatically. By assigning tags I can then 
determine which checkboxes are selected. Unfortunately I have to add the 
checkbox cells programmatically this way and can not use the IB. I don't fully 
understand the NSMatrix bindings and frankly the documentation is not really 
helpful, so I am wondering whether there is a better/easier way to do it.

I would appreciate if anyone can shed some light into this.

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: NSTask is intermittently failing to return results.

2011-03-18 Thread jonat...@mugginsoft.com
Hi Jason

I haven't attempted to debug your code but I use NSTask extensively and have 
experienced some of the problems you describe.

In each case I was not correctly handling the asynchronous availability of data 
in the pipe ie: there is nothing wrong with the approach but implementation is 
all.

In my case I found that the implementation detailed in the following sample 
worked with great reliability on GC apps (search the xcode docs):

CommandLineToolPlugin.m 

This sample uses NSFileHandle - waitForDataInBackgroundAndNotify.
This generates a single notification with all the available data - which may or 
may not be suitable for your needs.

The sample above calls NSTask - waitUntilExit but that is only a detail I think.

If this was my project I would instigate a branch that implemented the approach 
detailed in CommandLineToolPlugin.m and see where that got me.
It should have fewer moving parts at least.

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.com







On 17 Mar 2011, at 09:01, Jason Harris wrote:

> General Problem:
> 
> NSTask is most of the time working for me, but intermittently it's failing to 
> return results. Either the result is silently dropped, or more infrequently I 
> am getting exceptions in:
> 
> [NSConcreteData initWithBytes:length:copy:freeWhenDone:bytesAreVM:] or
> [NSConcreteFileHandle availableData] or
> [NSConcreteFileHandle readDataOfLength:]
> 
> depending on the tweaks / experiments I am attempting to play with.
> 
> If MacHg issues the *exact* same command a little later it will work.
> 
> 
> 
> Background:
> 
> I write MacHg an open source OSX multithreaded GUI client for Mercurial. I 
> have wanted to move to showing progress bars in MacHg as Mercurial progresses 
> in doing its long running operations.
> 
> In all my released versions of MacHg so far I have used only the 
> readDataToEndOfFileIgnoringErrors approach to NSTask (since once I launch a 
> task I am only ever reading data from it, and not actually ever sending data 
> to its stdin). Ie something like:
> 
>   NSData* outData = [[outPipe fileHandleForReading] 
> readDataToEndOfFileIgnoringErrors]
>   NSData* errData = [[errPipe fileHandleForReading] 
> readDataToEndOfFileIgnoringErrors];
> 
> However, I have previously had problems with intermittent exceptions of 
> [NSConcreteFileHandle readDataOfLength:] which bugged me. I spent some time 
> trying to fix these but in the end couldn't figure out what was going wrong / 
> how to fix them properly. In the end I used the bandaided approach of: 
> http://www.cocoabuilder.com/archive/cocoa/173348-nstask-stealth-bug-in-readdataoflength.html#173647
> 
> (Of note I have Garbage collection turned on in the MacHg project.)
> 
> 
> 
> Moving to Notification based NSTask:
> 
> But it has nagged me as to why this was occurring using 
> readDataToEndOfFileIgnoringErrors.  In any case I had thought moving to a 
> "Moriarity" style NSTask usage was going to solve my problems. I have now 
> coded a "Moriarity" style NSTask usage up in MacHg. Ie using 
> NSFileHandleReadCompletionNotification and NSTaskDidTerminateNotification. 
> However, I discovered that the frequency of odd behavior has actually 
> increased not decreased in moving to this approach.
> 
> I have looked at (in fact studied in detail) the source code for Moriarity, 
> AMShellWrapper, MyTask, and OpenFileKiller. 
> (http://cocoadev.com/index.pl?NSTask ) (I have not really covered looking at 
> MFTask, or trying to use Pseudo-TTYs or fork(), exec(), popen(), pipe() sorts 
> of low level unix / posix things.)
> 
> The hart of the code is the following (Note there are currently things in the 
> code which won't be in the production code since they are used for debugging. 
> Eg, the member theShellTask_ of ExecutionResult will be ripped out for 
> production.)
> 
> 
> 
> The Relevant Code:
> 
> 
> - (void) setPendingTermination
> {
>pendingTermination_ = YES;
>[NSObject cancelPreviousPerformRequestsWithTarget:self  
> selector:@selector(finishUp)  object:nil];
>[self performSelector:@selector(finishUp)  withObject:nil  
> afterDelay:10.0];
> }
> 
> - (void) resetPendingTermination
> {
>[NSObject cancelPreviousPerformRequestsWithTarget:self  
> selector:@selector(finishUp)  object:nil];
>pendingTermination_ = NO;
> }
> 
> - (id) initWithCommand:(NSString*)cmd andArgs:(NSArray*)args 
> onTask:(NSTask*)task
> {
>generatingCmd_ = cmd;
>generatingArgs_ = args;
>task_ = task ? task : [[NSTask alloc] init];
> 
>outPipe_= [[NSPipe alloc] init]; // Create the pipe to write 
> standard out to
>errPipe_= [[NSPipe alloc] init]; // Create the pipe to write 
> standard error to
>outHandle_  = [outPipe_ fileHandleForReading];
>errHandle_  = [errPipe_ fileHandleForReading];
>outp

Re: Remove characters from string

2011-03-18 Thread Heizer, Charles
I'm looking to clean up some system profiler data before sending it to a
database to have it displayed on a web page. Wile I can insert the data in
to the MySQL database just fine. The copyright and registered symbols do
not display properly on a web page. I was just thinking to make life easy
I could just remove them before posting to my database so that I don¹t
have to deal with it on the web end.

Charles






On 3/17/11 12:12 PM, "Gary L. Wade"  wrote:

>Is it possible you're assuming text being given to you is in ASCII format
>but is actually in UTF-8 or some other encoding?  Try looking at the text
>you have in other encodings before trying to remove characters.
>
>On 03/17/2011 6:03 AM, "Heizer, Charles"  wrote:
>
>>Hello,
>>I would like to know how to remove certain characters from a NSString.
>>The
>>characters are "©". I thought I could just use encodings and convert the
>>string using NSASCIIStringEncoding but that did not work and I'm not sure
>>what the car codes are for these as well.
>>
>>Thanks,
>>Charles
>
>
>___
>
>Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
>Please do not post admin requests or moderator comments to the list.
>Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
>Help/Unsubscribe/Update your Subscription:
>http://lists.apple.com/mailman/options/cocoa-dev/heizer1%40llnl.gov
>
>This email sent to heiz...@llnl.gov

___

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: Help: XCode 3.2 breaks XCode 3.1 projects

2011-03-18 Thread Artemiy Pavlov
Just to make clear what I did:

- Downloaded XCode 3.2.6 and did a standard install
- Downloaded the latest/fixed AU with Cocoa template
- Started a new project
- It has AU base file groups in red
- Raises a ton of errors and doesn't build


On 18 Mar 2011, at 16:46, tahome izwah wrote:

> Works for me. Make sure you're using the standard paths for Xcode.
> 
> --th

___

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


newbie question

2011-03-18 Thread Luca Ciciriello
Hi All. Im' new in Cocoa and Cocoa touch programming.
My question is: How can I make the keyboard disappear when I use a UITextView 
conroller?

In my class I've a Text field and a Text view controller and in my declaration 
I'v added the delegates: 
now In the case of UITextField I've used the method : 

- (BOOL)textFieldShouldReturn:(UITextField *)textField

but there isn't nothing of similar for resign the first responder in the case 
of UITextView.

Thanks in advance.

Luca.___

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: Remove characters from string

2011-03-18 Thread Gary L. Wade
In that case, you should determine what encoding your web page is being 
displayed in and convert your NSString to that encoding. If it's in UTF8, you 
can use UTF8String; otherwise, consider dataUsingEncoding: or related messages 
to see if that will do what you need.

- Gary L. Wade (Sent from my iPad)

On Mar 18, 2011, at 8:03 AM, "Heizer, Charles"  wrote:

> I'm looking to clean up some system profiler data before sending it to a
> database to have it displayed on a web page. Wile I can insert the data in
> to the MySQL database just fine. The copyright and registered symbols do
> not display properly on a web page. I was just thinking to make life easy
> I could just remove them before posting to my database so that I don¹t
> have to deal with it on the web end.
> 
> Charles
> 
> 
> 
> 
> 
> 
> On 3/17/11 12:12 PM, "Gary L. Wade"  wrote:
> 
>> Is it possible you're assuming text being given to you is in ASCII format
>> but is actually in UTF-8 or some other encoding?  Try looking at the text
>> you have in other encodings before trying to remove characters.
>> 
>> On 03/17/2011 6:03 AM, "Heizer, Charles"  wrote:
>> 
>>> Hello,
>>> I would like to know how to remove certain characters from a NSString.
>>> The
>>> characters are "©". I thought I could just use encodings and convert the
>>> string using NSASCIIStringEncoding but that did not work and I'm not sure
>>> what the car codes are for these as well.
>>> 
>>> Thanks,
>>> Charles
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/heizer1%40llnl.gov
>> 
>> This email sent to heiz...@llnl.gov
> 
___

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: Remove characters from string

2011-03-18 Thread John Joyce
You might also consider using HTML entities for those, as you never know what 
the browser/user-agent has set for encoding...

On Mar 18, 2011, at 11:24 PM, Gary L. Wade wrote:

> In that case, you should determine what encoding your web page is being 
> displayed in and convert your NSString to that encoding. If it's in UTF8, you 
> can use UTF8String; otherwise, consider dataUsingEncoding: or related 
> messages to see if that will do what you need.
> 
> - Gary L. Wade (Sent from my iPad)
> 
> On Mar 18, 2011, at 8:03 AM, "Heizer, Charles"  wrote:
> 
>> I'm looking to clean up some system profiler data before sending it to a
>> database to have it displayed on a web page. Wile I can insert the data in
>> to the MySQL database just fine. The copyright and registered symbols do
>> not display properly on a web page. I was just thinking to make life easy
>> I could just remove them before posting to my database so that I don¹t
>> have to deal with it on the web end.
>> 
>> Charles
>> 
>> 
>> 
>> 
>> 
>> 
>> On 3/17/11 12:12 PM, "Gary L. Wade"  wrote:
>> 
>>> Is it possible you're assuming text being given to you is in ASCII format
>>> but is actually in UTF-8 or some other encoding?  Try looking at the text
>>> you have in other encodings before trying to remove characters.
>>> 
>>> On 03/17/2011 6:03 AM, "Heizer, Charles"  wrote:
>>> 
 Hello,
 I would like to know how to remove certain characters from a NSString.
 The
 characters are "©". I thought I could just use encodings and convert the
 string using NSASCIIStringEncoding but that did not work and I'm not sure
 what the car codes are for these as well.
 
 Thanks,
 Charles
>>> 
>>> 
>>> ___
>>> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>> 
>>> Please do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>> 
>>> Help/Unsubscribe/Update your Subscription:
>>> http://lists.apple.com/mailman/options/cocoa-dev/heizer1%40llnl.gov
>>> 
>>> This email sent to heiz...@llnl.gov
>> 
> ___
> 
> 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/jjoyce%40apple.com
> 
> This email sent to jjo...@apple.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: Remove characters from string

2011-03-18 Thread Kyle Sluder
On Fri, Mar 18, 2011 at 8:28 AM, John Joyce
 wrote:
> You might also consider using HTML entities for those, as you never know what 
> the browser/user-agent has set for encoding...

You do if you generate correct HTML and your web server emits the
correct Content-type header.

Charles, since it sounds like you're in control of the entire
pipeline, the correct solution is to store the UTF-8 data in the MySQL
database, and fix your web frontend to correctly output UTF-8 with the
proper Content-type header.

--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: newbie question (SOLVED)

2011-03-18 Thread Luca Ciciriello
Sorry for this question. I've find out how to solve my problem in apple 
documentation. At my first reading I'd missed it.

Luca.

On Mar 18, 2011, at 4:17 PM, Luca Ciciriello wrote:

> Hi All. Im' new in Cocoa and Cocoa touch programming.
> My question is: How can I make the keyboard disappear when I use a UITextView 
> conroller?
> 
> In my class I've a Text field and a Text view controller and in my 
> declaration I'v added the delegates: 
> now In the case of UITextField I've used the method : 
> 
> - (BOOL)textFieldShouldReturn:(UITextField *)textField
> 
> but there isn't nothing of similar for resign the first responder in the case 
> of UITextView.
> 
> Thanks in advance.
> 
> Luca.___
> 
> 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/luca_ciciriello%40hotmail.com
> 
> This email sent to luca_cicirie...@hotmail.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: iOS Core Data complex predicate.

2011-03-18 Thread Sandro Noël
Andreas

First off, thank you for taking the time to read my essay.

I did not know the setReturnDistinctResults: was dependant on 
setPropertiesToFetch:
your explanation is outstanding.

That did the trick, and I thank you very much.

Sandro.

On 2011-03-17, at 6:49 PM, Andreas Grosam wrote:

> 
> On Mar 17, 2011, at 8:15 PM, Sandro Noël wrote:
> 
>> Greetings!
>> 
>> I am facing a problem with a complicated predicate I'm building.
>> 
> ...
> 
>> then this predicate is fed to a fetch Request which in turn is fed to a 
>> fetched Result Controller.
>> the fetch is configured to   [fetchRequest setReturnsDistinctResults:YES];
>> 
>> The problem as stated in the introduction this complete predicate returns 
>> multiple instances of the same record and it should not.
> 
> About setReturnsDistinctResults:
> "If YES, the request returns only distinct values for the *fields specified 
> by propertiesToFetch*."
> 
> That is, setReturnDistinctResults: makes only sense IFF you also specified 
> the set of properties you want to fetch (via -setPropertiesToFetch). And this 
> requires that you specify NSDictionaryResultType for the resultType property 
> of the fetch request. As a result, with setReturnDistinctResults:YES you get 
> a set of dictionaries whose values are distinct.
> 
> In other words, you cannot use -setReturnsDistinctResults:YES to make your 
> result set distinct if this array contains *managed objects*.
> 
> 
> You might use a NSSet which you initialize from your original array of 
> managed objects in order to get a unique set.
> 
> Alternatively, you might fetch just objectID properties using a 
> NSDictionaryResultType. This, however, is a bit elaborated:
> 
> When you return (unique) dictionaries as objects in your result array, and if 
> you want these dictionaries having a key "objectID" which value corresponds 
> the actual managed object of this dictionary instance, you need to create an 
> appropriate NSExpressionDescription: and include this property description in 
> the array which you pass to -setPropertiesToFetch:
> 
> NSExpressionDescription* objectIdDescription = [[NSExpressionDescription 
> alloc] init];
> [objectIdDescription setExpression:[NSExpression 
> expressionForEvaluatedObject]];
> [objectIdDescription setExpressionResultType:NSObjectIDAttributeType];
> 
> Note: NSExpressionDescription is subclassed from NSPropertyDescription.
> 
> Then you use objectIdDescription as one of the properties 
> (NSPropertyDescription) you want to fetch:
> [myFetchRequest setPropertiesToFetch:[NSArray arrayWithObject: 
> objectIdDescription]];
> 
> Don't forget to set the result type (after you set the entity):
> [myFetchRequest setResultType: NSDictionaryResultType];
> [myFetchRequest setReturnsDistinctResults:YES];
> ...
> 
> 
> The next step would be to extract the objectIDs from the array of 
> dictionaries and store them in an array for convenience.
> 
> 
> Regards
> Andreas
> 
> 
>> if any of you see a flaw in the logic or anything, please comment, I'm 
>> currently so deep into it, I cant see it anymore. :)
>> 
>> I hope I have not missed nay details.
>> Thank you!!!
>> Sandro.
> ___
> 
> 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/apple.lists%40gestosoft.com
> 
> This email sent to apple.li...@gestosoft.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: LSUIElement making custom windows non-visible.

2011-03-18 Thread Seth Willits
On Mar 16, 2011, at 11:15 AM, Kevin Muldoon wrote:

> My understanding is turning on LSUIElement in the pList is the method to make 
> this happen. Unfortunately, this makes the NSPanel non-visible as well.


Perhaps because panels are not visible when the application is not active by 
default (hidesOnDeactivate is YES). You can use a normal window for this. I 
don't think a panel offers any benefit.


--
Seth Willits



___

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

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

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

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


framework and dylib dependency

2011-03-18 Thread Macdev

___

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: NSTask is intermittently failing to return results.

2011-03-18 Thread Jason Harris
> 
> Hi Jason
> 
> I haven't attempted to debug your code but I use NSTask extensively and have 
> experienced some of the problems you describe.
> 
> In each case I was not correctly handling the asynchronous availability of 
> data in the pipe ie: there is nothing wrong with the approach but 
> implementation is all.
> 
> In my case I found that the implementation detailed in the following sample 
> worked with great reliability on GC apps (search the xcode docs):
> 
> 
> This sample uses NSFileHandle - waitForDataInBackgroundAndNotify.
> This generates a single notification with all the available data - which may 
> or may not be suitable for your needs.
> 
> The sample above calls NSTask - waitUntilExit but that is only a detail I 
> think.
> 
> If this was my project I would instigate a branch that implemented the 
> approach detailed in CommandLineToolPlugin.m and see where that got me.
> It should have fewer moving parts at least.
> 
> Regards
> 
> Jonathan Mitchell
> 
> Developer
> Mugginsoft LLP
> http://www.mugginsoft.com


Hi Jonathan,

Thanks for looking at this! It's good to know I am not going crazy and there is 
some subtle thing I am doing wrong here...

Just to clarify you mean this example here:

http://developer.apple.com/library/mac/#samplecode/CommandLineTool/Listings/CommandLineToolPlugIn_m.html

for the CommandLineToolPlugin.m?

I hadn't  seen this approach at the end of using [task waitUntilExit] after you 
have set up the observers and notifications. I had seen in eg OpenFileKiller: 
http://cocoawithlove.com/2009/05/invoking-other-processes-in-cocoa.html and in 
https://bitbucket.org/snej/myutilities/src/tip/MYTask.m where a run loop is 
used. Ie something like:

- (void)launchTaskAndRunSynchronous
{
[task launch];

BOOL isRunning = YES;
while (isRunning && (!taskComplete || !outputClosed || !errorClosed))
{
isRunning =
[[NSRunLoop currentRunLoop]
runMode:NSDefaultRunLoopMode
beforeDate:[NSDate distantFuture]];
}
}

(Also just glancing at the code, I noticed a couple of really small things... 
the date at the top of CommandLineToolPlugin.m lists 2009 yet its using old 
style NS_DURING, NS_HANDLER, NS_ENDHANDLER which seems a little strange... but 
its not wrong or anything, just a little well strange. Also it looks like 
CommandLineToolPlugin.m sets [task setStandardInput:inPipe] whereas I have no 
input.. Again just small differences. I will have a play and get back to the 
group.)

Thanks!
   Jas

___

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: NSMatrix bindings

2011-03-18 Thread Ken Thomases
On Mar 18, 2011, at 3:45 AM, Christian Ziegler wrote:

> I'm having hard times figuring out how to bind an NSMatrix properly. I got an 
> NSMatrix with NSButtonCells (checkboxes) and I want to somehow bind to my 
> model which of these checkboxes are selected. What should work is binding the 
> content objects of the NSMatrix to an ArrayController and fill the 
> arrayController's content with NSButtonCells programmatically.

Huh?  An NSMatrix is a view (in the Model-View-Controller design pattern), an 
array controller is a controller, and it provides access to model data.  
NSButtonCells are not model data, they are elements of the view.  You don't 
"fill the arrayController's content with NSButtonCells".

You should have a model property somewhere which is an array of objects to be 
presented in the matrix.  This might be as simple as strings for the names of 
the checkboxes, or it might be objects each of which has a property which will 
be the name of a checkbox.  You bind the array controller's contentArray to 
this model property (the array of objects).

You then bind the matrix's content to the array controller's arrangedObjects.  
If the objects are not themselves the values for the checkboxes, you also bind 
the matrix's contentValues to the array controller's arrangedObjects with a 
model key path which obtains the values for the checkboxes.

You can bind the matrix's selectedObjects or selectedValues to another 
controller's property, which is a to-many property with the appropriate 
mutation accessors.  You bind selectedObjects if you want to track the objects 
which correspond to each checkbox.  You bind selectedValues if you want to 
track the values, if there's a distinction (see previous paragraph).

It should also work to bind the matrix's selectedObjects to the array 
controller's selection.  Then you can bind the array controller's 
selectionIndexes to a property of your coordinating controller (e.g. File's 
Owner).  That way, your property which tracks the selection can be related back 
to the property which provided the array controller's content, instead of 
merely being another array which shares some elements.

I hope that helps.

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: NSTask is intermittently failing to return results.

2011-03-18 Thread jonat...@mugginsoft.com

On 18 Mar 2011, at 21:04, Jason Harris wrote:
> 
> 
> Hi Jonathan,
> 
> Thanks for looking at this! It's good to know I am not going crazy and there 
> is some subtle thing I am doing wrong here...
> 
> Just to clarify you mean this example here:
> 
> http://developer.apple.com/library/mac/#samplecode/CommandLineTool/Listings/CommandLineToolPlugIn_m.html
> 
> for the CommandLineToolPlugin.m?
Yep.

> 
> I hadn't  seen this approach at the end of using [task waitUntilExit] after 
> you have set up the observers and notifications. I had seen in eg 
> OpenFileKiller: 
> http://cocoawithlove.com/2009/05/invoking-other-processes-in-cocoa.html and 
> in https://bitbucket.org/snej/myutilities/src/tip/MYTask.m where a run loop 
> is used. Ie something like:
> 
> - (void)launchTaskAndRunSynchronous
> {
>   [task launch];
>   
>   BOOL isRunning = YES;
>   while (isRunning && (!taskComplete || !outputClosed || !errorClosed))
>   {
>   isRunning =
>   [[NSRunLoop currentRunLoop]
>   runMode:NSDefaultRunLoopMode
>   beforeDate:[NSDate distantFuture]];
>   }
> }
> 
I don't see any reason not to use the NSTask implementation unless you 
encounter any particular issues.

> (Also just glancing at the code, I noticed a couple of really small things... 
> the date at the top of CommandLineToolPlugin.m lists 2009 yet its using old 
> style NS_DURING, NS_HANDLER, NS_ENDHANDLER which seems a little strange... 
> but its not wrong or anything, just a little well strange.
Yes, a bit curious. Maybe its a rehash of something more archaic though the 
revision notes don't specify this.

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.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: NSTask is intermittently failing to return results.

2011-03-18 Thread Jason Harris

On Mar 18, 2011, at 10:36 PM, jonat...@mugginsoft.com wrote:

> 
> On 18 Mar 2011, at 21:04, Jason Harris wrote:
>> 
>> 
>> Hi Jonathan,
>> 
>> Thanks for looking at this! It's good to know I am not going crazy and there 
>> is some subtle thing I am doing wrong here...
>> 
>> Just to clarify you mean this example here:
>> 
>> http://developer.apple.com/library/mac/#samplecode/CommandLineTool/Listings/CommandLineToolPlugIn_m.html
>> 
>> for the CommandLineToolPlugin.m?
> Yep.
> 
>> 
>> I hadn't  seen this approach at the end of using [task waitUntilExit] after 
>> you have set up the observers and notifications. I had seen in eg 
>> OpenFileKiller: 
>> http://cocoawithlove.com/2009/05/invoking-other-processes-in-cocoa.html and 
>> in https://bitbucket.org/snej/myutilities/src/tip/MYTask.m where a run loop 
>> is used. Ie something like:
>> 
>> - (void)launchTaskAndRunSynchronous
>> {
>>  [task launch];
>>  
>>  BOOL isRunning = YES;
>>  while (isRunning && (!taskComplete || !outputClosed || !errorClosed))
>>  {
>>  isRunning =
>>  [[NSRunLoop currentRunLoop]
>>  runMode:NSDefaultRunLoopMode
>>  beforeDate:[NSDate distantFuture]];
>>  }
>> }
>> 
> I don't see any reason not to use the NSTask implementation unless you 
> encounter any particular issues.
> 
>> (Also just glancing at the code, I noticed a couple of really small 
>> things... the date at the top of CommandLineToolPlugin.m lists 2009 yet its 
>> using old style NS_DURING, NS_HANDLER, NS_ENDHANDLER which seems a little 
>> strange... but its not wrong or anything, just a little well strange.
> Yes, a bit curious. Maybe its a rehash of something more archaic though the 
> revision notes don't specify this.

Well just to give some quick feedback... Surprisingly to me your suggested 
approach here seems to be working straight off the bat!!

Ie if in my code I just replace 

- (BOOL) waitTillFinished
{
// wait for task to exit:
while (![self shouldFinishUp])
{
// If the task is terminated we should set up a pending 
termination which will terminate in a bit. This catches some
// zombie NSTasks where either the outputData or errorData of 0 
were never posted..
BOOL terminated = ![task_ isRunning];
if (terminated && !pendingTermination_)
{
DebugLog(@"...Found terminated for %@ ...", [self 
commandLineString]);
[self setPendingTermination];
}

BOOL runLoopRan = [[NSRunLoop currentRunLoop] 
runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
if (!runLoopRan)
break;
if (!isFinished_)
DebugLog(@"...waitTillFinished still waiting for %@ 
...", [self commandLineString]);
}

[self finishUp];
DebugLog(@"...Exiting waitTillFinished for %@ ...", [self 
commandLineString]);
return (result_ == 0);
}


with 

- (BOOL) waitTillFinished
{
// wait for task to exit:
[task_ waitUntilExit];
DebugLog(@"...Exiting waitTillFinished for %@ ...", [self 
commandLineString]);
return (result_ == 0);
}

Along with some other tweaks (No longer call [self finishUp] in any form) then 
it works.

Thank you! Thank you! At least I have something to explore now. I don't know 
*why* this works since it seems to use a different approach to that of eg 
OpenFileKiller and MyTask but:
(i) The exceptions seem to be gone
(ii) There seems to be no dropped results.
(iii) The tasks seem to be exiting (ie no stuck processes...) (A stuck process 
is a sort of zombie process which just doesn't finish (but it turns out a 
zombie process has a defined meaning in unix and my stuck processes where not 
zombies...))

I'll investigate a bit more and try and boil down what was going on and post my 
findings back. If anyone else can shed some light on the reasons why this is 
happening I would be most grateful.

But in any case *Thank You Jonathan*!!!

Cheers,
  Jas___

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: NSTask is intermittently failing to return results.

2011-03-18 Thread Ken Thomases
I would say that your "...IgnoringErrors" methods are masking a real problem, 
and you shouldn't have written them let alone used them.  (By the way, you 
didn't post them except incidentally in your screenshot.)

The exception is saying that the file descriptor backing the 
NSPipe/NSFileHandle has been closed.  Retrying after some time can only result 
in the frameworks co-opting a new, unrelated file object that happened to get 
the same file descriptor.  That would explain why your reads sometimes never 
get any data -- you're reading from a completely different file object.

I'm not sure why the file descriptor is being closed.  It may be a framework 
bug having to do with garbage collection.

I'd try creating the file descriptors manually with the pipe(2) system call.  
Then, construct NSFileHandles from them with -initWithFileDescriptor:theReadFD 
closeOnDealloc:NO.  (Pass [NSFileHandle fileHandleWithNullDevice] to 
-setStandardInput:, while you're at it.)  After you launch the task, be sure to 
close the write ends of your pipes.  And, of course, when everything is 
finished up, close the read ends, too.

By the way, there's nothing incorrect about getting the task-terminated 
notification before the end-of-file for the task output or error file handles.  
There's no guarantee about the order of those events.

On Mar 17, 2011, at 4:01 AM, Jason Harris wrote:

> - (BOOL) waitTillFinished
> {
>// wait for task to exit:
>while (![self shouldFinishUp])
>{
>// If the task is terminated we should set up a pending termination 
> which will terminate in a bit. This catches some
>// zombie NSTasks where either the outputData or errorData of 0 were 
> never posted..
>BOOL terminated = ![task_ isRunning];
>if (terminated && !pendingTermination_)
>{
>DebugLog(@"...Found terminated for %@ ...", [self 
> commandLineString]);
>[self setPendingTermination];
>}
> 
>BOOL runLoopRan = [[NSRunLoop currentRunLoop] 
> runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
>if (!runLoopRan)
>break;
>if (!isFinished_)
>DebugLog(@"...waitTillFinished still waiting for %@ ...", [self 
> commandLineString]);
>}
> 
>[self finishUp];
>DebugLog(@"...Exiting waitTillFinished for %@ ...", [self 
> commandLineString]);
>return (result_ == 0);
> }
> 
> 
> + (ExecutionResult*) execute:(NSString*)cmd withArgs:(NSArray*)args 
> onTask:(NSTask*)task
> {
>ShellTask* shellTask = [[ShellTask alloc] initWithCommand:cmd andArgs:args 
> onTask:task];
> 
>[shellTask->task_ launch];// Start the process
>DebugLog(@"launched %@", [shellTask commandLineString]);
> 
>[shellTask waitTillFinished];
> 
>DebugLog(@"Finished execute cmd for %@", [shellTask commandLineString]);
> 
>NSString* outStr = [[NSString alloc] initWithData:shellTask->outputData_ 
> encoding:NSUTF8StringEncoding];
>NSString* errStr = [[NSString alloc] initWithData:shellTask->errorData_  
> encoding:NSUTF8StringEncoding];
>ExecutionResult* result = [ExecutionResult resultWithCmd:cmd args:args 
> result:shellTask->result_ outStr:outStr errStr:errStr];
>result->theShellTask_ = shellTask;
>return result;
> }

> BAD:
> 
> 0x1014810/-[MacHgDocument initializeRepositoryData] Initializing log entry 
> collection
> 0x1250100/+[ShellTask execute:withArgs:onTask:]launched localhg 
> combinedinfo --cwd /Volumes/QuickSilver/Development/sandbox/RhodeCode
> 0x1250100/-[ShellTask gotExit:]...got Exit for localhg 
> combinedinfo --cwd /Volumes/QuickSilver/Development/sandbox/RhodeCode ...
> 0x1250100/-[ShellTask gotError:]   ...got NULL Error Output 
> for localhg combinedinfo --cwd 
> /Volumes/QuickSilver/Development/sandbox/RhodeCode ...
> 0x1250100/-[ShellTask waitTillFinished]...waitTillFinished still 
> waiting for localhg combinedinfo --cwd 
> /Volumes/QuickSilver/Development/sandbox/RhodeCode ...
> 0x1250100/-[ShellTask finishUp]...Finishing up for 
> localhg combinedinfo --cwd /Volumes/QuickSilver/Development/sandbox/RhodeCode 
> ...

> Now a couple things to note is that if the   [self 
> performSelector:@selector(finishUp)  withObject:nil  afterDelay:10.0]
> fires in the BAD case then the outer call to waitTillFinished just sort of 
> vanishes, since there is always a DebugLog call which prints "...Exiting 
> waitTillFinished for ..." but is can be seen in the BAD transcript this just 
> isn't present.

I see no evidence that it has "vanished".  It seems to me that 
-waitTillFinished is still executing, presumably blocked in the run loop.  Note 
that, not only is the DebugLog at the end of -waitTillFinished not hit, but 
neither is the one immediately after the call to it in 
+execute:withArgs:onTask:.  In other words, it just hasn't returned.

Good luck,
Ken

___

Releasing memory allocated by CoreData's _PFAllocateObjects function?

2011-03-18 Thread Nick Zitzmann
Okay, I have a problem that has been driving me nuts all day now. I have an 
application that loads tens of thousands of CoreData managed objects across 
several threads, where each thread has its own unique managed object context.

When I run the allocations instrument in Instruments, I can see that an eight 
digit amount of bytes is being gobbled up & not freed by thousands of 320 byte 
mallocs, each of which has the following stack trace:

   0 CoreData _PFAllocateObjects
   1 CoreData +[NSSQLRow 
newBatchRowAllocation:count:forSQLEntity:withOwnedObjectIDs:andTimestamp:]
   2 CoreData -[NSSQLCore 
_prepareResultsFromResultSet:usingFetchPlan:withMatchingRows:]
   3 CoreData -[NSSQLCore _newRowsForFetchPlan:selectedBy:withArgument:]
   4 CoreData -[NSSQLCore newRowsForFetchPlan:]
   5 CoreData -[NSSQLCore 
_prefetchRelationshipKey:sourceEntityDescription:sourceObjectIDs:prefetchRelationshipKeys:inContext:]
   6 CoreData -[NSSQLCore _prefetchWithFetchRequest:withObjectIDs:inContext:]
   7 CoreData -[NSSQLCore _newRowsForFetchPlan:selectedBy:withArgument:]
   8 CoreData -[NSSQLCore newRowsForFetchPlan:]
   9 CoreData -[NSSQLCore objectsForFetchRequest:inContext:]
  10 CoreData -[NSSQLCore executeRequest:withContext:]
  11 CoreData -[NSPersistentStoreCoordinator(_NSInternalMethods) 
executeRequest:withContext:]
  12 CoreData -[NSManagedObjectContext executeFetchRequest:error:]

Question: What does my program have to do to release all of that memory? I've 
already tried resetting and releasing the managed object contexts, and 
Instruments confirms that they're gone, but that doesn't clean up this memory. 
And without the CoreData source code, I can't tell what action is supposed to 
free up the memory.

Nick Zitzmann


___

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: NSTask is intermittently failing to return results.

2011-03-18 Thread Jason Harris

On Mar 18, 2011, at 11:07 PM, Ken Thomases wrote:

> I would say that your "...IgnoringErrors" methods are masking a real problem, 
> and you shouldn't have written them let alone used them.  (By the way, you 
> didn't post them except incidentally in your screenshot.)

(Ahh yep. I didn't want to spam the group with lots and lots of code and 
headers and other bits. I tried to pick the "relevant" code and then provided 
the link to the sourcefiles on bitbucket...)  

And in answer to this I was grasping at straws and I didn't really write this 
code, I was trying this since it was recommended in some previous posts by 
others (I can post the references if you are interested).  In the end I think 
this @try @catch just served to not crash the app and return nil for the 
result... But you are right I am keenly interested in what is going wrong and 
how to remedy it. (As I said previously the error would manifest itself every 
so often which was of course very annoying, but now moving to the Moriarty 
style of things, the errors suddenly became quite noticeable.)


> The exception is saying that the file descriptor backing the 
> NSPipe/NSFileHandle has been closed.  Retrying after some time can only 
> result in the frameworks co-opting a new, unrelated file object that happened 
> to get the same file descriptor.  That would explain why your reads sometimes 
> never get any data -- you're reading from a completely different file object.

I am sorry, but can you explain the paragraph in more detail? (Just to be clear 
sometimes I never get the exception and yet it still drops data... So the ugly 
bit of the @catch is never hit but it still was dropping the data...)


> I'm not sure why the file descriptor is being closed.  It may be a framework 
> bug having to do with garbage collection.
> 
> I'd try creating the file descriptors manually with the pipe(2) system call.  
> Then, construct NSFileHandles from them with 
> -initWithFileDescriptor:theReadFD closeOnDealloc:NO.

Sorry just so I don't stuff this up can I ask you to give me the exact code 
here... or point me to an example of this?


> (Pass [NSFileHandle fileHandleWithNullDevice] to -setStandardInput:, while 
> you're at it.)  After you launch the task, be sure to close the write ends of 
> your pipes.  And, of course, when everything is finished up, close the read 
> ends, too.

I'd like to try this thanks!


> By the way, there's nothing incorrect about getting the task-terminated 
> notification before the end-of-file for the task output or error file 
> handles.  There's no guarantee about the order of those events.

Yes, I gathered that. I also gathered that you should always get all three 
things right? ie
(i) The NSTaskDidTerminateNotification
(ii) and the NULL for the NSFileHandleReadCompletionNotification for stdOut
(iii) and the NULL for the NSFileHandleReadCompletionNotification for stdErr

Well when it was dropping the data I was missing one of these notifications and 
my empirical observation was that more commonly I was receiving the 
NSTaskDidTerminateNotification first and then either of the other notifications.

Whereas when things were working it was uncommon or I didn't get the 
NSTaskDidTerminateNotification first It was just a data point I was trying 
to give everyone so it might shed some light on the problem.


> On Mar 17, 2011, at 4:01 AM, Jason Harris wrote:
> 
>> - (BOOL) waitTillFinished
>> {
>>   // wait for task to exit:
>>   while (![self shouldFinishUp])
>>   {
>>   // If the task is terminated we should set up a pending termination 
>> which will terminate in a bit. This catches some
>>   // zombie NSTasks where either the outputData or errorData of 0 were 
>> never posted..
>>   BOOL terminated = ![task_ isRunning];
>>   if (terminated && !pendingTermination_)
>>   {
>>   DebugLog(@"...Found terminated for %@ ...", [self 
>> commandLineString]);
>>   [self setPendingTermination];
>>   }
>> 
>>   BOOL runLoopRan = [[NSRunLoop currentRunLoop] 
>> runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
>>   if (!runLoopRan)
>>   break;
>>   if (!isFinished_)
>>   DebugLog(@"...waitTillFinished still waiting for %@ ...", [self 
>> commandLineString]);
>>   }
>> 
>>   [self finishUp];
>>   DebugLog(@"...Exiting waitTillFinished for %@ ...", [self 
>> commandLineString]);
>>   return (result_ == 0);
>> }
>> 
>> 
>> + (ExecutionResult*) execute:(NSString*)cmd withArgs:(NSArray*)args 
>> onTask:(NSTask*)task
>> {
>>   ShellTask* shellTask = [[ShellTask alloc] initWithCommand:cmd andArgs:args 
>> onTask:task];
>> 
>>   [shellTask->task_ launch];// Start the process
>>   DebugLog(@"launched %@", [shellTask commandLineString]);
>> 
>>   [shellTask waitTillFinished];
>> 
>>   DebugLog(@"Finished execute cmd for %@", [shellTask commandLineString]);
>> 
>>   NSString* outStr = [[NSString alloc] initWithData:shellTask->outputData_ 
>> en

Re: NSTask is intermittently failing to return results.

2011-03-18 Thread jonat...@mugginsoft.com

On 18 Mar 2011, at 22:03, Jason Harris wrote:
> 
> Well just to give some quick feedback... Surprisingly to me your suggested 
> approach here seems to be working straight off the bat!!
> 
> Along with some other tweaks (No longer call [self finishUp] in any form) 
> then it works.
> 
> Thank you! Thank you! At least I have something to explore now. I don't know 
> *why* this works since it seems to use a different approach to that of eg 
> OpenFileKiller and MyTask but:
> (i) The exceptions seem to be gone
> (ii) There seems to be no dropped results.
> (iii) The tasks seem to be exiting (ie no stuck processes...) (A stuck 
> process is a sort of zombie process which just doesn't finish (but it turns 
> out a zombie process has a defined meaning in unix and my stuck processes 
> where not zombies...))
> 


I would be surprised if the whole matter was resolved so adroitly but if it 
proves to be the case then good.
The reason why it works is that the asynchronous file handle access is now 
implemented correctly - no mystery.
Other approaches will work too but the implementation will need to be spot on.

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.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


Quick way to find is a path is contained in another path?

2011-03-18 Thread Laurent Daudelin
I have a couple of ideas using "pathComponents" but does anybody have a quick 
way to find if a given path is contained in another path, e.g. if 
"/Library/Users/laurent/Library" is contained in "/Library/Users/laurent" (in 
this case, it is)?

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.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


Splitting a single Core Data model between several files

2011-03-18 Thread WT
Hello,

in searching the web and the archives for help on splitting a single CD model 
into several files, I found that the most recent exchanges on this subject date 
back to July 2009 and September 2008:

Core Data, migrate a model split into two files
http://www.cocoabuilder.com/archive/cocoa/240263-core-data-migrate-model-split-into-two-files.html

Let's merge managed object models!
http://chanson.livejournal.com/187540.html

My question is not how to do it (Chris' article above explains how) but whether 
anything has changed since, in regards to official support in XCode for merging 
separate model files. Note that this is not specifically about migration but 
merely about breaking down a complex model into more manageable parts.

Is the technique suggested by Chris still the way to go? Should I have posted 
this in the XCode list instead?

Thanks.
WT___

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: Quick way to find is a path is contained in another path?

2011-03-18 Thread Mike Abdullah
- (BOOL)ks_isSubpathOfPath:(NSString *)aPath
https://github.com/karelia/KSFileUtilities/blob/master/KSPathUtilities.h
Standard BSD license.

On 18 Mar 2011, at 22:59, Laurent Daudelin wrote:

> I have a couple of ideas using "pathComponents" but does anybody have a quick 
> way to find if a given path is contained in another path, e.g. if 
> "/Library/Users/laurent/Library" is contained in "/Library/Users/laurent" (in 
> this case, it is)?
> 
> -Laurent.
> -- 
> Laurent Daudelin
> AIM/iChat/Skype:LaurentDaudelin   
> http://www.nemesys-soft.com/
> Logiciels Nemesys Software
> laur...@nemesys-soft.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/cocoadev%40mikeabdullah.net
> 
> This email sent to cocoa...@mikeabdullah.net

___

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

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

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

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


Re: Quick way to find is a path is contained in another path?

2011-03-18 Thread Laurent Daudelin
On Mar 18, 2011, at 16:43, Mike Abdullah wrote:

> - (BOOL)ks_isSubpathOfPath:(NSString *)aPath
> https://github.com/karelia/KSFileUtilities/blob/master/KSPathUtilities.h
> Standard BSD license.
> 
> On 18 Mar 2011, at 22:59, Laurent Daudelin wrote:
> 
>> I have a couple of ideas using "pathComponents" but does anybody have a 
>> quick way to find if a given path is contained in another path, e.g. if 
>> "/Library/Users/laurent/Library" is contained in "/Library/Users/laurent" 
>> (in this case, it is)?
>> 
>> -Laurent.

Thanks, Mike!

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.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: Quick way to find is a path is contained in another path?

2011-03-18 Thread Gary L. Wade
If you're not concerned about mount-path inclusion, where Library may be
on another volume but mounted at that point, use
rangeOfString:options:range: with an anchored search option and range
consisting of the full length of the laurent-ending string.  You have
three possible results: not found (no), lengths are equal (yes), or length
to search is larger than the length found (maybe).  In that last case, see
if the next character after the found range is a path separator.  If it
is, (yes); if not, (no).  The method hasPrefix: is pretty much a
convenience for this call but does not differentiate in the last case and
would always return yes.

On 03/18/2011 2:59 PM, "Laurent Daudelin"  wrote:

>I have a couple of ideas using "pathComponents" but does anybody have a
>quick way to find if a given path is contained in another path, e.g. if
>"/Library/Users/laurent/Library" is contained in "/Library/Users/laurent"
>(in this case, it is)?
>
>-Laurent.
>-- 
>Laurent Daudelin
>AIM/iChat/Skype:LaurentDaudelin
>http://www.nemesys-soft.com/
>Logiciels Nemesys Software
>laur...@nemesys-soft.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: Quick way to find is a path is contained in another path?

2011-03-18 Thread Laurent Daudelin
Yeah, I found out that hasPrefix: was not really a good one...

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.com

On Mar 18, 2011, at 17:58, Gary L. Wade wrote:

> If you're not concerned about mount-path inclusion, where Library may be
> on another volume but mounted at that point, use
> rangeOfString:options:range: with an anchored search option and range
> consisting of the full length of the laurent-ending string.  You have
> three possible results: not found (no), lengths are equal (yes), or length
> to search is larger than the length found (maybe).  In that last case, see
> if the next character after the found range is a path separator.  If it
> is, (yes); if not, (no).  The method hasPrefix: is pretty much a
> convenience for this call but does not differentiate in the last case and
> would always return yes.
> 
> On 03/18/2011 2:59 PM, "Laurent Daudelin"  wrote:
> 
>> I have a couple of ideas using "pathComponents" but does anybody have a
>> quick way to find if a given path is contained in another path, e.g. if
>> "/Library/Users/laurent/Library" is contained in "/Library/Users/laurent"
>> (in this case, it is)?

___

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: Releasing memory allocated by CoreData's _PFAllocateObjects function?

2011-03-18 Thread Quincey Morris
On Mar 18, 2011, at 15:25, Nick Zitzmann wrote:

>  I have an application that loads tens of thousands of CoreData managed 
> objects across several threads, where each thread has its own unique managed 
> object context.
> 
> When I run the allocations instrument in Instruments, I can see that an eight 
> digit amount of bytes is being gobbled up & not freed by thousands of 320 
> byte mallocs, each of which has the following stack trace:
> 
>   0 CoreData _PFAllocateObjects
>   1 CoreData +[NSSQLRow 
> newBatchRowAllocation:count:forSQLEntity:withOwnedObjectIDs:andTimestamp:]
>   2 CoreData -[NSSQLCore 
> _prepareResultsFromResultSet:usingFetchPlan:withMatchingRows:]
>   3 CoreData -[NSSQLCore _newRowsForFetchPlan:selectedBy:withArgument:]
>   4 CoreData -[NSSQLCore newRowsForFetchPlan:]
>   5 CoreData -[NSSQLCore 
> _prefetchRelationshipKey:sourceEntityDescription:sourceObjectIDs:prefetchRelationshipKeys:inContext:]
>   6 CoreData -[NSSQLCore _prefetchWithFetchRequest:withObjectIDs:inContext:]
>   7 CoreData -[NSSQLCore _newRowsForFetchPlan:selectedBy:withArgument:]
>   8 CoreData -[NSSQLCore newRowsForFetchPlan:]
>   9 CoreData -[NSSQLCore objectsForFetchRequest:inContext:]
>  10 CoreData -[NSSQLCore executeRequest:withContext:]
>  11 CoreData -[NSPersistentStoreCoordinator(_NSInternalMethods) 
> executeRequest:withContext:]
>  12 CoreData -[NSManagedObjectContext executeFetchRequest:error:]
> 
> Question: What does my program have to do to release all of that memory? I've 
> already tried resetting and releasing the managed object contexts, and 
> Instruments confirms that they're gone, but that doesn't clean up this memory.

NSSQLRow is apparently part of Core Data's internal store cache, which is 
mentioned somewhere in the documentation. I suspect it doesn't contain any Core 
Data managed objects, but rather raw property data fetched from SQL. There's no 
API for managing it, and the only way I ever found of clearing it at all was to 
reset (or perhaps it was destroy, can't quite remember now) the managed object 
context. I spent, literally, weeks trying other approaches, all useless.

It's possible that you didn't close *all* of the contexts, and that's keeping 
the cache contents alive. IIRC I wasn't dealing with multiple contexts.

It's also possible that closing the contexts works lazily -- the cache contents 
aren't really dumped until other data needs to be loaded into it. That would 
mar your view of things in Instruments, if you weren't expecting it.

Also, in my case, I had a small number of very large objects.


___

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


iPhone: animating UILabel width results in pre-stretched text

2011-03-18 Thread Rick Mann
I have a table view that allows swipe-to-delete. When the delete button comes 
up, I want to shrink the UILabels in the custom cell to make room for the 
button.

So I implement -[tableView:willBeginEditingRowAtIndexPath:] and set up an 
animation that shrinks a view that contains my labels. All the subviews have 
frame bindings set up, and they shrink correctly.

The problem is that the text within the UILabels is pre-rendered at the new 
(narrower) size. The resulting image is then scaled to match the current 
(wider) size, and as everything animates, it shrinks to be the correct size.

The result is visually very unappealing: the text snaps to a larger (often 
truncated) look, then animates into place.

The reverse happens when widening if the delete operation is canceled.

Here's a movie showing what I'm talking about:

http://roderickmann.org/stuff/TextResize.mov

I tried setting the text content mode to "redraw," but that had no effect.

Any way to get it to re-render the text throughout the animation?

Looking closely at what Mail does, I see it replaces the wider view with the 
narrower version with a crossfade animation.

-- 
Rick

___

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

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

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

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


Re: iPhone: animating UILabel width results in pre-stretched text

2011-03-18 Thread David Duncan

On Mar 18, 2011, at 5:20 PM, Rick Mann wrote:

> Any way to get it to re-render the text throughout the animation?

Not really. This would also possibly introduce a performance issue.

> Looking closely at what Mail does, I see it replaces the wider view with the 
> narrower version with a crossfade animation.


This is probably a better alternative.
--
David Duncan

___

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: iPhone: animating UILabel width results in pre-stretched text

2011-03-18 Thread Rick Mann

On Mar 18, 2011, at 5:30 PM, David Duncan wrote:

> 
> On Mar 18, 2011, at 5:20 PM, Rick Mann wrote:
> 
>> Any way to get it to re-render the text throughout the animation?
> 
> Not really. This would also possibly introduce a performance issue.

Thanks for the reply, David.

I'd argue that in a scenario like this, performance is probably not going to be 
an issue.

>> Looking closely at what Mail does, I see it replaces the wider view with the 
>> narrower version with a crossfade animation.
> 
> 
> This is probably a better alternative.

Nearly finished implementing it now.

-- 
Rick


___

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

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

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

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


Re: Quick way to find is a path is contained in another path?

2011-03-18 Thread koko
BOOL isDirectory;
BOOL exists = [[NSFileManager defaultManager]  
fileExistsAtPath:@"/Library/Users/laurent/Library" isDirectory:&isDirectory]
if(exists && isDirectory)
NSLog(@"EUREKA I have found it!");




On Mar 18, 2011, at 5:58 PM, Laurent Daudelin wrote:

> On Mar 18, 2011, at 16:43, Mike Abdullah wrote:
> 
>> - (BOOL)ks_isSubpathOfPath:(NSString *)aPath
>> https://github.com/karelia/KSFileUtilities/blob/master/KSPathUtilities.h
>> Standard BSD license.
>> 
>> On 18 Mar 2011, at 22:59, Laurent Daudelin wrote:
>> 
>>> I have a couple of ideas using "pathComponents" but does anybody have a 
>>> quick way to find if a given path is contained in another path, e.g. if 
>>> "/Library/Users/laurent/Library" is contained in "/Library/Users/laurent" 
>>> (in this case, it is)?
>>> 
>>> -Laurent.
> 
> Thanks, Mike!
> 
> -Laurent.
> -- 
> Laurent Daudelin
> AIM/iChat/Skype:LaurentDaudelin   
> http://www.nemesys-soft.com/
> Logiciels Nemesys Software
> laur...@nemesys-soft.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/koko%40highrolls.net
> 
> This email sent to k...@highrolls.net
> 

___

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

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

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

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


Re: Quick way to find is a path is contained in another path?

2011-03-18 Thread Graham Cox

On 19/03/2011, at 12:15 PM, koko wrote:

> BOOL isDirectory;
> BOOL exists = [[NSFileManager defaultManager]  
> fileExistsAtPath:@"/Library/Users/laurent/Library" isDirectory:&isDirectory]
> if(exists && isDirectory)
>   NSLog(@"EUREKA I have found it!");
>   
>   


This does not solve the OP's problem.

Yes, it tells you that a file exists at that path, it does not tell you whether 
it's a child (or parent) of some other path, which may or may not refer to an 
actual file or directory that exists at the moment. The string comparison 
approach suggested is what I've used, and works fine.

--Graham




___

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

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

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

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