Re: NSComboBox and sorted list

2014-04-26 Thread Frédéric Testuz
Le 18 avr. 2014 à 13:32, Frédéric Testuz  a écrit :
> 
> I have a typical CoreData application which display my entities in an 
> NSTableView with an NSArrayController and a panel to edit the selected item.
> 
> I have an entity Book with a NSString attribute type displayed in an 
> NSComboBox. I want the drop down list of the combo box to display the 
> previously chosen types. I have an NSArrayController bind with the Book 
> entity and the managed object context.
> 
> I can make it works by binding the NSComboBox :
> Content (or Content Values) -> 
> bookarraycontroller.arrangedobjec...@distinctunionofobjects.type
> Value -> BookArrayController.selection.type
> 
> Until this point all is well, but I want the list to be sorted. So I think I 
> have to add a NSArrayController which will maintain the sorted list of types. 
> I try this :
> 
> TypeListArrayController :
> Content Array -> 
> bookarraycontroller.arrangedobjec...@distinctunionofobjects.type
> 
> NSComboBox :
> Content -> TypeListArrayController.arrangedObjects
> Value -> BookArrayController.selection.type
> 
> But with this setting, when I open my document (when the window is displayed) 
> it takes a long time. More than 10min when at first it takes 1s. I 
> check by stopping in the debugger, the stack frame is more than 38000 with 
> huge recursivity.
> 
> Is there a solution with NSArrayController and binding or I have to implement 
> a data source for the combo box manually ?

After trying some things I have it working by manually implementing the data 
source and observing my BookArrayController for change of the type property.

For information, in my second test, if dont bind the combo box to the array 
controller, there is no delay. So the recursive problem appears with the 
interaction of the bindings between NSComboBox<->TypeListArrayController and 
TypeListArrayController<->BookArrayController



___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

NSComboBox and sorted list

2014-04-18 Thread Frédéric Testuz
Hello,

I have a typical CoreData application which display my entities in an 
NSTableView with an NSArrayController and a panel to edit the selected item.

I have an entity Book with a NSString attribute type displayed in an 
NSComboBox. I want the drop down list of the combo box to display the 
previously chosen types. I have an NSArrayController bind with the Book entity 
and the managed object context.

I can make it works by binding the NSComboBox :
Content (or Content Values) -> 
bookarraycontroller.arrangedobjec...@distinctunionofobjects.type
Value -> BookArrayController.selection.type

Until this point all is well, but I want the list to be sorted. So I think I 
have to add a NSArrayController which will maintain the sorted list of types. I 
try this :

TypeListArrayController :
Content Array -> 
bookarraycontroller.arrangedobjec...@distinctunionofobjects.type

NSComboBox :
Content -> TypeListArrayController.arrangedObjects
Value -> BookArrayController.selection.type

But with this setting, when I open my document (when the window is displayed) 
it takes a long time. More than 10min when at first it takes 1s. I 
check by stopping in the debugger, the stack frame is more than 38000 with huge 
recursivity.

Is there a solution with NSArrayController and binding or I have to implement a 
data source for the combo box manually ?

Frédéric
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

@unionOfObjects and direct KVC in NSArray

2014-04-09 Thread Frédéric Testuz
Say I have an array of Person object with a name property. Is there a 
difference between :

namesArray = [personsArray valueForKeyPath:@"@unionOfObjects.name"];

and

namesArray = [personsArray valueForKeyPath:@"name"];


On a small test I can just see that the concrete NSArray class returned are not 
the same but is there something special ?

Frédéric



___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Two kinds of NSManagedObject fault?

2014-03-08 Thread Frédéric Testuz

Le 8 mars 2014 à 03:54, Jerry Krinock  a écrit :

> Sixten is correct about -isDeleted.  It is rarely useful.
> 
> Regarding these two kinds of managed object faults, your “second” kind is 
> similar to what I described in a message I posted earlier today [1].  In my 
> case,  
> 
> -isFault returns NO
> -isDeleted returns NO
> -retainCount returns +1 or greater
> -get works OK
> -get works OK
> -get makes EXC_BAD_ACCESS
> -get makes EXC_BAD_ACCESS
> -set makes EXC_BAD_ACCESS
> 
> I don’t know what to make of this either.  I was wondering if maybe the 
> object’s managed object context had been reset.

I suspect that in your test case, the number are tagged pointers, then they are 
never deallocated as they are not allocated in first place. And are you sure 
that the string tested are not static strings (NSCFConstantString) ? These ones 
are also never deallocated.

Frédéric


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Should copy + paste change characters?

2013-12-27 Thread Frédéric Testuz

Le 27 déc. 2013 à 21:01, Frédéric Testuz  a écrit :

> 
> Le 27 déc. 2013 à 18:09, Gerriet M. Denkmann  a écrit :
> 
>> 
>> Le 27 déc. 2013 à 21:42, Frédéric Testuz  a écrit :
>> 
>>> I have 10.9.1 (local:swiss-french) and did what you propose.
>>> First: when I copy-paste the text from your first mail to TE, I have 
>>> directly the good characters.
>> Did you check that 盧 = CJK COMPATIBILITY IDEOGRAPH-F933 and not (as I got by 
>> copying from Mail) U+76E7 ?
> 
> Your right, it’s U+76E7
> 
>> 
>>> Probably because by default, the font is Helvetica. For盧 and 雞, it became 
>>> Hiragino, for 鸡卵, 卢 and 鸡 it became Heiti SC.
>> I changed my language to Français suisse. Quit TextEdit, Mail. Started both 
>> and copied text.
>> All Chinese characters became Heiti, the rest Helvetica. No Hiragino at all 
>> - very strange.
> 
> I don’t know how there is a difference. Because I know a little japanese, I 
> put japanese in the list of my preferred language and Kotoeri as an input 
> method. So I test with these removed, I even restart. But it still Hiragino 
> for the same characters.

I did another test. I put chinese in the list of language, before japanese, 
with pinyin as input method. Then all ideogram have Heiti as font.

Regards.
Frédéric
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: sending html file to safari for printing

2012-06-06 Thread Frédéric Testuz
Le 6 juin 2012 à 18:08, Amy Gibbs a écrit :

> I've got an app I've written for myself, it's mac core data based.
> 
> I need to be able to output a printout of some data, it would basically be a 
> table with some images and data. I think the easiest thing to do may be to 
> create an HTML page that can then be opened in Safari.
> 
> I can manage creating and saving the HTML file, how do I automatically open 
> it up in Safari (or the default browser it doesn't matter) so I can print it 
> out?

Perhaps you have a reason to open it in a browser, but you can also directly 
print it from your application.

In short, create the html code, instantiate a WebView, make it render your html 
code and pass the web view to a NSPrintOperation.

Frédéric Testuz
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: New allowsExternalBinaryDataStorage in Core Data

2011-08-25 Thread Frédéric Testuz
Thanks,

Then for application where the user can choose the location of document, you 
can use it safely only if the store is in a package. If the document is 
moved/copied, the extern data are also moved/copied.

I had made some test with stores in the Desktop and after your reply I had 
found many hidden folder for each of my test.


And, in the video I talked about, they speak about a new example for Lion that 
will be available in some weeks. Some weeks have passed since the WWDC and I 
can't find this example. Is it available only for Xcode 4.2 ?

Frédéric


Le 25 août 2011 à 20:20, Steven Vandeweghe a écrit :

> It seems that when the image (or data in general) is larger than 1MB, it's 
> stored in a hidden folder in the same place as your main database. For 
> example, if the application is called MyLionApp and its persistent store is 
> located in the ~/Library/MyLionApp folder, the external files would be stored 
> in ~/Library/MyLionApp/.MyLionApp_SUPPORT/_EXTERNAL_DATA/.
> 
> The documentation is indeed very sparse, so I've investigated a bit myself 
> and posted the results here :
> 
> http://bluecrowbar.com/blog/2011/08/coredata-external.html
> 
> Steven
> 
> 
> On Aug 3, 2011, at 10:29 PM, Frédéric Testuz wrote:
> 
>> Hello,
>> 
>> I looked at the Core Data release notes of Lion, I also looked the "What's 
>> new in Core Data on Mac OS X" video of the WWDC 2011. And I have a question 
>> about the new allowsExternalBinaryDataStorage option for binary attribute.
>> 
>> I did some test with an attribute for images. I can see that when I put an 
>> big image in the data, the file did not grow.
>> 
>> But where the external file/data is put? If the file is moved or copied, 
>> what about theses external data? I tried to find info, but the documentation 
>> is very sparse.
>> 
>> Frédéric___
>> 
>> 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/steven%40bluecrowbar.com
>> 
>> This email sent to ste...@bluecrowbar.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


New allowsExternalBinaryDataStorage in Core Data

2011-08-03 Thread Frédéric Testuz
Hello,

I looked at the Core Data release notes of Lion, I also looked the "What's new 
in Core Data on Mac OS X" video of the WWDC 2011. And I have a question about 
the new allowsExternalBinaryDataStorage option for binary attribute.

I did some test with an attribute for images. I can see that when I put an big 
image in the data, the file did not grow.

But where the external file/data is put? If the file is moved or copied, what 
about theses external data? I tried to find info, but the documentation is very 
sparse.

Frédéric___

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: Automatic warnings for NSLocalizedString?

2011-07-20 Thread Frédéric Testuz
It's not at compile time, but you can have messages log at runtime. See the 
documentation for [NSBundle localizedStringForKey:value:table:]. This is the 
method called by NSLocalizedString.

F. Testuz


Le 20 juil. 2011 à 13:10, Oleg Krupnov a écrit :

> Hi,
> 
> Is there a way, at compile time, to automatically check that all
> strings referenced anywhere in my project via NSLocalizedString have
> their localized counterparts in *.strings files for all localizations
> I have included into the project? So that if a string is missing in a
> localization, I would receive some kind of warning.
> 
> Thanks
> ___
> 
> 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/ftestuz%40bluewin.ch
> 
> This email sent to ftes...@bluewin.ch

___

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


Bug with NSPredicateEditor in Xcode 4

2011-05-24 Thread Frédéric Testuz
In my project, I have a problem with editing NSPredicateEditor in a xib with 
Xcode 4.

If I add a row template for strings, when I run my application and try to add a 
row to the predicate editor, I have an exception saying that it's impossible to 
init a predicate with a nil expression. If I edit my xib with IB 3, the problem 
went away.

I just want to know if it's a known problem before reporting it.

Frédéric

PS : in my test case, the exception raise for all template, not only strings 
predicate template. I don't know why there is a difference in the test case and 
my application.___

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: Is a file open in another application?

2011-03-19 Thread Frédéric Testuz
Le 19 mars 2011 à 20:03, Kyle Sluder a écrit :

> On Sat, Mar 19, 2011 at 11:40 AM, Conrad Shultz
>  wrote:
>> Are you certain that is a general behavior?
> 
> 1. Open TextEdit.
> 2. Type some stuff.
> 3. Save As > /tmp/somefile.rtf
> 4. `lsof |grep somefile` prints nothing.
> 
>> For example, I have Preview open right now, and it very much lists all
>> its open files:
> 
> Preview probably mmaps the file contents. And that could even be done
> by PDFKit or NSImage, not explicitly by the application.
> 
>> But it does seem from the above that this can be handled in an
>> implementation-specific manner, no?  (Please forgive my ignorance, I
>> develop mostly with iOS.)
> 
> I don't think a general solution exists for Brad's problem.

I can't think of a general solution, but IIRC Brad is only interested about 
Word and Excel. These applications have AppleScript support.

I'm sure he can ask Word by AppleScript for the open documents. He had to check 
if Word can also return the path of the file for these documents.

-- 
Frédéric Testuz___

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: sending a message from an initializer method

2011-01-12 Thread Frédéric Testuz
Yes, you can, but... don't forget that in -computeVar3... self is not fully 
initialized. If you have all control on self it can be without problems, but 
Objective-C is an OO language. Consider this :

- Your class is ClassA with it's init method. 
- Then you have ClassB, subclass of ClassA. ClassB override -init cleanly (call 
super in the beginning etc.)
- Then ClassC, subclass of ClassB. ClassC override -computeVar3.
And then the problems can begin, in -[ClassC computeVar3] self is not fully 
initialize from the point of view of ClassA, but the initialization has not 
even began from the point of view of ClassB and ClassC. I think it's a break of 
encapsulation principle.

If you want to put the code outside -init only for code readability, just use a 
plain C function.

Frédéric

Le 12 janv. 2011 à 12:41, Luc Van Bogaert a écrit :

> Hi,
> 
> I have a question about how to design a initializer mehod. 
> 
> I have defined a class with three instance variables. Two of them are arrays 
> and their value can be initialized straightforward in the initializer method, 
> but the value of the third instance variable is the result of a complex 
> algorithm, based on the contents of the two arrays.
> 
> I would like to implement that algorithm in a seperate method, instead of 
> writing it directly in the initializer. Is that OK, and could I then message 
> "self" in the initializer like: 
> 
> - (id) init
> {
>   self = [super init];
>   if (self) {
>   var1 = ...;
>   var2 = ...;
>   var3 = [self computerVar3With:var1:var2];
>   }
>   return self;
> }
> 
> Or is it better to write the algorithm directly as part of the initializer?
> Thanks,
> 
> -- 
> Luc Van Bogaert
> luc.van.boga...@me.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/ftestuz%40bluewin.ch
> 
> This email sent to ftes...@bluewin.ch

___

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: Question about predicates and list properties.

2010-05-26 Thread Frédéric Testuz
Le 26 mai 2010 à 16:42, Graham Cox a écrit :

> 
> On 27/05/2010, at 12:35 AM, Keary Suska wrote:
> 
>> Not enough info: are you using Core Data, or a simple modeled relationship? 
>> I assume the issue is about traversing a relationship--otherwise the 
>> solution is trivial...
> 
> 
> No, it's a simple 'to many' property in my own model, not using Core Data. If 
> it's trivial I can't find the solution - I have tried many things hinted at 
> by the predicates guide. I am tired having worked a 14 hour day and counting, 
> so perhaps I just need a rest to see the wood for the trees...
> 
> I have a list of objects. Each object has a 'categories' property, which is 
> another 'to many' property, i.e. a list. Each category has a simple 'name' 
> property.
> 
> I desire to match a string I enter to any of the categories.name strings in 
> the list using equals, begins with, ends with, contains. I'm setting up the 
> predicate editor in IB, but I can't see any way to use the aggregating 
> predicate syntax anywhere there and when I attempt it I get a runtime error 
> (e.g. no value for key 'ANY categories').
> 
> Perhaps it's a limitation of IB that more complex predicate editor row 
> templates are not available?

I had a similar problem (perhaps not exactly the same).

I resolve it by subclassing NSPredicateEditorRowTemplate. Then in IB select the 
predicate row template and set its class to your subclass.

Here is my code :

@interface RBDAnyPredicateEditorRowTemplate : NSPredicateEditorRowTemplate {

}

@end

@implementation RBDAnyPredicateEditorRowTemplate

- (NSPredicate *)predicateWithSubpredicates:(NSArray *)subpredicates {
/* we only make NSComparisonPredicates */
NSComparisonPredicate *predicate = (NSComparisonPredicate *)[super 
predicateWithSubpredicates:subpredicates];

/* construct an identical predicate, but set the modifier to 
NSAnyPredicateModifier  flag */
return [NSComparisonPredicate predicateWithLeftExpression:[predicate 
leftExpression]

  rightExpression:[predicate rightExpression]

 modifier:NSAnyPredicateModifier

 type:[predicate predicateOperatorType]

  options:[predicate options]];
}

@end

I did something similar to have a boolean predicate.

Frédéric___

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: Why I can't see my localized nib?

2010-05-19 Thread Frédéric Testuz
Well, I'm not sure.

I only use AppleLanguages for debug. I'm setting the argument in the launch 
argument in Xcode. I think  that your method can work. Perhaps you can even set 
the defaults in the beginning of the application [NSUserDefaults 
registerDefaults:], but I think it must be very early in the launch process 
(before mainNib is loaded?).

But frankly, I don't see why you have to do this. If you want your application 
to run in sk (slovak?) then leave only this lproj in your app.

Frédéric

PS: sorry, I read one more time. If it's an option left to the user your method 
can be correct. registerDefaults would not be useful.

Le 18 mai 2010 à 22:37, Gustavo Pizano a écrit :

> So at app start up I can get the Application defaults objectforkey 
> "AppleLanguages", then set array with the first object to be "sk_SK" and then 
> push the array again back to the application defaults.. right?
> 
> And if the user selects for example English I must do the above, and restart 
> the application to load the proper language... correct me if Im wrong 
> please... 
> 
> thx
> 
> Gustavo
> 
> On 18.5.2010, at 21:13, Frédéric Testuz wrote:
> 
>> Le 18 mai 2010 à 18:28, Joanna Carter a écrit :
>> 
>>> Hi Gustavo
>>> 
>>>> In this case.. is tehre anyway to let teh user choose what lang to use?.. 
>>>> I mean if I localize my app, but the user has no localization either, how 
>>>> to make the app run in a given language (i.e sk)?
>>> 
>>> The only way I can think of is to delete the other localizations from the 
>>> bundle. Maybe someone else knows better :-)
>> 
>> You can launch the application with AppleLanguages in the arguments or in 
>> the app defaults.
>> 
>> See :
>> 
>> <http://www.cocoabuilder.com/archive/cocoa/3862-changing-language-at-runtime.html?q=applelanguages#3861>
>> 
>> and
>> 
>> <http://www.cocoabuilder.com/archive/search/1?q=applelanguages&l=cocoa>
>> 
>> Frédéric
> 

___

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: Why I can't see my localized nib?

2010-05-18 Thread Frédéric Testuz
Le 18 mai 2010 à 18:28, Joanna Carter a écrit :

> Hi Gustavo
> 
>> In this case.. is tehre anyway to let teh user choose what lang to use?.. I 
>> mean if I localize my app, but the user has no localization either, how to 
>> make the app run in a given language (i.e sk)?
> 
> The only way I can think of is to delete the other localizations from the 
> bundle. Maybe someone else knows better :-)

You can launch the application with AppleLanguages in the arguments or in the 
app defaults.

See :



and



Frédéric___

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


NSPopUpButton items disabled

2010-04-06 Thread Frédéric Testuz
Hi,

I have a pulldown button (NSPopUpButton) in an accessory view of a save panel. 
Before displaying the panel, I populate the popup with the name of the recent 
documents. My question is about the enable state of the pulldown menu items.

In IB, I connect the action of the popup to a controller. But the items stays 
disabled. If I set autoEnabled to NO, the items are enabled and the action 
method is called.

Is disabling autoEnabled is the only way to go? I thought that the automatic 
validation should enable the items because the action seems to work.

Frédéric___

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: Sheets, blocks and garbage collector

2010-02-06 Thread Frédéric Testuz
Le 6 févr. 2010 à 17:55, Michael Ash a écrit :

> 2010/2/6 Frédéric Testuz :
>> Hi all,
>> 
>> I'm beginning a new application targeting Snow Leopard only. So I want to 
>> use the new tools (blocks) and garbage collection (GC). It will be my first 
>> application using GC.
>> 
>> I read some sites on GC and blocks. In the blog of Mike Ash I found some 
>> very interesting propositions. My question concerns his code for using block 
>> with sheets 
>> (http://www.mikeash.com/?page=pyblog/friday-qa-2009-08-14-practical-blocks.html).
>>  Is this code works in GC ?
>> 
>> @implementation NSApplication (SheetAdditions)
>> 
>> - (void)beginSheet: (NSWindow *)sheet modalForWindow:(NSWindow *)docWindow 
>> didEndBlock: (void (^)(NSInteger returnCode))block
>> {
>> 
>> [self beginSheet: sheet
>>   modalForWindow: docWindow
>>   modalDelegate: self
>>   didEndSelector: @selector(my_blockSheetDidEnd:returnCode:contextInfo:)
>>   contextInfo: [block copy]];
>> }
>> 
>> - (void)my_blockSheetDidEnd: (NSWindow *)sheet returnCode: 
>> (NSInteger)returnCode contextInfo: (void *)contextInfo
>> {
>> void (^block)(NSInteger returnCode) = contextInfo;
>> block(returnCode);
>> [block release];
>> }
>> 
>> @end
>> 
>> I think, I have to replace [block copy] by CFRetain([block copy])
>> and [block release] by CFRelease(block).
> 
> I believe your GC modifications are correct. As you've presumably
> determined already, [block copy] alone isn't enough to keep the block
> alive through the void *.
> 
> If you happen to be writing dual-mode code, you can write code that
> works in both GC and refcounted environments by writing
> CFRetain([block copy]) in the first part and CFRelease(block); [block
> release]; in the second.

Thanks for your answer and for the completion. It will make the code reusable 
for another case without GC.

Frédéric___

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


Sheets, blocks and garbage collector

2010-02-06 Thread Frédéric Testuz
Hi all,

I'm beginning a new application targeting Snow Leopard only. So I want to use 
the new tools (blocks) and garbage collection (GC). It will be my first 
application using GC.

I read some sites on GC and blocks. In the blog of Mike Ash I found some very 
interesting propositions. My question concerns his code for using block with 
sheets 
(http://www.mikeash.com/?page=pyblog/friday-qa-2009-08-14-practical-blocks.html).
 Is this code works in GC ?

@implementation NSApplication (SheetAdditions)

- (void)beginSheet: (NSWindow *)sheet modalForWindow:(NSWindow *)docWindow 
didEndBlock: (void (^)(NSInteger returnCode))block
{

[self beginSheet: sheet
modalForWindow: docWindow
modalDelegate: self
didEndSelector: @selector(my_blockSheetDidEnd:returnCode:contextInfo:)
contextInfo: [block copy]];
}

- (void)my_blockSheetDidEnd: (NSWindow *)sheet returnCode: 
(NSInteger)returnCode contextInfo: (void *)contextInfo  
{
void (^block)(NSInteger returnCode) = contextInfo;
block(returnCode);
[block release];
}

@end

I think, I have to replace [block copy] by CFRetain([block copy])
and [block release] by CFRelease(block).

Frédéric

___

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: Making NSNumberFormatter empty-tolerant

2009-08-27 Thread Frédéric Testuz

Le 27 août 09 à 21:46, bryscomat a écrit :

Interesting. Is that documented anywhere? That's why I was confused  
as to exactly how I got mine to work. Seems like a fluke...


On Aug 27, 2009, at 2:39 PM, Frédéric Testuz wrote:


I had the same problem. For the 10.4 behaviour of  
NSNumberFormatter, you don't have to subclass it.


Just set the nil symbol with:

[myNumberFormatter setNilSymbol:@""];

Alternatively, you can set it in IB:

In the number formatter attribute palette, go down until you see  
Nil Symbol, enter a character and then delete it.



Note: if only the NSDateFormatter has the same attribute.

Frédéric___

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/bryscomat 
%40gmail.com


This email sent to brysco...@gmail.com


I don't think I saw it written explicitly. When I had the problem,  
before subclassing NSNumberFormatter, I check the docs, see  
setNilSymbol and try to use it.
For the IB trick I can't remember how I found it. It must be something  
like thinking about how IB is probably archiving objects and trying  
some solutions.


Frédéric___

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: Making NSNumberFormatter empty-tolerant

2009-08-27 Thread Frédéric Testuz

Le 27 août 09 à 20:45, Markus Spoettl a écrit :


Hello,

 before I get to the question this is my setup:

1) NSTextField ("field")
2) bound to an NSNumber property ("number") of an object.
3) "field" has an NSNumberFormatter attached with all default
  values (as set up by IB), except maximum fraction digits is set to  
1.

4) "number" can be nil - in fact it is when we start our app.

Starting this little app, one can tab into and out-of an the empty  
field, nothing happens. This as expected and what I want.


When you enter a value and tab out, "number" gets set to the new  
value. If you now attempt to remove the value by emptying the field  
you will get formatting error message. This is kind of unexpected as  
the empty field was fine with the formatter moments ago.


In other words, once the value is set to something non-nil it never  
can get nil again. I would like to be able to nil out a number by  
clear a field.


My solution for this is a sub-class of NSNumberFormatter which  
implements -getObjectValue:forString:range:error: as follows:


- (BOOL)getObjectValue:(out id *)anObject
forString:(NSString *)aString
range:(inout NSRange *)rangep
error:(out NSError **)error
{
   BOOL result = [super getObjectValue:anObject forString:aString  
range:rangep error:error];


   if (!result && ((aString == nil) || ([aString  
isEqualToString:@""]))) {

   *anObject = nil;
   result = YES;
   }

   return result;
}

The docs tell me that I have to feed a valid NSNumber into anObject  
when returning YES - nil is valid therefore this should be OK.


The question is: Is this safe? Do I overlook an aspect that I'd  
better not? Or even better, is there a simpler solution?


I had the same problem. For the 10.4 behaviour of NSNumberFormatter,  
you don't have to subclass it.


Just set the nil symbol with:

[myNumberFormatter setNilSymbol:@""];

Alternatively, you can set it in IB:

In the number formatter attribute palette, go down until you see Nil  
Symbol, enter a character and then delete it.



Note: if only the NSDateFormatter has the same attribute.

Frédéric___

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: Testing if a NSPipe has available data

2009-08-10 Thread Frédéric Testuz

Le 10 août 09 à 14:14, Alastair Houghton a écrit :


On 10 Aug 2009, at 12:28, Frédéric Testuz wrote:


Le 10 août 09 à 12:40, Alastair Houghton a écrit :

So what's wrong with waiting for -[NSFileHandle availableData] to  
return with zero bytes?


First : if you call availableData and there is no data and the end  
of file is not reached, you are blocking your thread.


Only if (a) there is no data available and (b) you are dealing with  
a communications link.


Yes. Sorry if it was implicite on my part because I was talking about  
a pipe communicating with a task.


If I understand correctly, gnuplot don't send the end of file  
because you can send new command to the same plot.


Ah, OK, I assume in that case that you want to keep gnuplot running  
so that you can plot something else afterwards?


Yes, I still can quit gnuplot after each plot, but I don't know if it  
will be very efficient (too early optimisation :-)


In that case, the cleanest approach is probably going to be to tell  
gnuplot to send the data somewhere other than stdout (using "set  
output").  The simplest thing would be to use a temporary file.


I will not have the similar problem ? When I can be sure that the file  
is written.


If you can live with invoking gnuplot separately every time, you  
could just tell it to quit after generating the data that you want.


See above.



So the only way I can see is to check if there still data waiting  
in the file handle buffer before calling readInBackgroundAndNotify  
or availableData.


That won't work in the general case; gnuplot might generate some  
data, then your app might run and take it all, in which case there  
would be no data waiting in the buffer... but gnuplot might not have  
finished and might subsequently generate more data.


Well thanks. Actually I'm doing it by coupling ioctl with checking the  
data for the presence of "%%Trailer", but I'm not sure it will be ok  
for future version of gnuplot.


Note : if there was an easy way to get a NSImage from svg I would have  
choose this format. Finding the end svg data is easy ()


Frédéric___

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: Testing if a NSPipe has available data

2009-08-10 Thread Frédéric Testuz

Le 10 août 09 à 12:40, Alastair Houghton a écrit :


On 10 Aug 2009, at 09:29, Frédéric Testuz wrote:

I'm using gnuplot to obtain graph of data. You can set gnuplot to  
send results in various formats and to stdout

I found the way to call it and get the data with NSTask and NSPipe.

Actually, I get the image as an eps. The whole pack of data come in  
several packs obtain by the pair of methods -[NSFileHandle  
readInBackgroundAndNotify] and -[NSFileHandle availableData].


But I have to know when there is no more data to wait for. I have  
found a solution in :
<http://www.cocoabuilder.com/archive/message/cocoa/ 
2000/11/21/31112> which use ioctl. This solution works, but it is a  
very low api and the message is a little old now.


I just want to know if there is, today, another solution with a  
higher api perhaps ?


From the documentation:

 availableData

 Returns the data available through the receiver.

 [snip]

 ... Returns an empty data object if the end of file is reached. ...

So what's wrong with waiting for -[NSFileHandle availableData] to  
return with zero bytes?


First : if you call availableData and there is no data and the end of  
file is not reached, you are blocking your thread.


If I understand correctly, gnuplot don't send the end of file because  
you can send new command to the same plot. And if an end of file was  
sent, stdout would not be closed ? But if it's not the case I don't  
think it makes a difference :


I observe the file handle for the data available notification
I call readInBackgroundAndNotify
My notification method is then called, inside it I call availableData  
to read the data


It will be enough if all the data can be read in 1 time, because of  
buffer, I think, the data come in several chunks. So in my  
notification method I call readInBackgroundAndNotify again.


Now if I call readInBackgroundAndNotify and I have collected all the  
data, I'm waiting for nothing. I can't inspect the data because there  
is nothing in the EPS format to tell you that you are at the end of  
the plot data (other than the end of the file). So the only way I can  
see is to check if there still data waiting in the file handle buffer  
before calling readInBackgroundAndNotify or availableData.


Frédéric

___

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


Testing if a NSPipe has available data

2009-08-10 Thread Frédéric Testuz

Hi,


I'm using gnuplot to obtain graph of data. You can set gnuplot to send  
results in various formats and to stdout

I found the way to call it and get the data with NSTask and NSPipe.

Actually, I get the image as an eps. The whole pack of data come in  
several packs obtain by the pair of methods -[NSFileHandle  
readInBackgroundAndNotify] and -[NSFileHandle availableData].


But I have to know when there is no more data to wait for. I have  
found a solution in :
  
which use ioctl. This solution works, but it is a very low api and the  
message is a little old now.


I just want to know if there is, today, another solution with a higher  
api perhaps ?


Thank you

Frédéric___

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: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2009-02-25 Thread Frédéric Testuz

Le 25 févr. 09 à 18:37, mmalc Crawford a écrit :




mmalc


OK, thank you

Frédéric

___

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: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2009-02-25 Thread Frédéric Testuz

Le 25 févr. 09 à 00:44, Jonathan Hess a écrit :



On Feb 20, 2009, at 1:05 AM, Alexander Spohr wrote:



Am 20.02.2009 um 04:18 schrieb mmalc Crawford:



On Feb 19, 2009, at 12:34 PM, mmalc Crawford wrote:

See also updated: 




The Doc states:
You should therefore also set outlet variables to nil in dealloc:

- (void)dealloc {
// release outlets and set outlet variables to nil
[anOutlet release], anOutlet = nil;
[super dealloc];
}

why not just use

[self setAnOutlet = nil];
or
self.anOutlet = nil;

Any danger in this? (except a bad implementation of setAnOutlet:)



Any of the standard arguments about not calling setters in dealloc  
and init would apply. For example, if you were subclassed, and your  
subclass had an override of one of your setters, and you called it  
from dealloc you'd be calling one of their methods after they'd  
called [super dealloc]. Or, you might later implement side-effects  
for one of your setters not thinking about the called-from-dealloc- 
case and introduce a subtle bug into your own code.


One question about this.

If I understand correctly the 64bit runtime, for property we don't  
have to declare ivar.

Then, if I want to init a property and clear it in dealloc I must do :

self.myProperty = anObject;  // in init

and

self.myProperty = nil;  // in dealloc

Does it mean I must always declare ivars even for 64bit only  
architecture ?


Frédéric___

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: Populating a new SQLite Core Data store with default data

2009-02-23 Thread Frédéric Testuz


Le 23 févr. 09 à 21:50, Jon C. Munson II a écrit :



 I meant:

[(MyClassyClass *)obj doSomethingSpecificToMyClassyClass]

 The cast needs to be applied to the pointer - obj - and not to the
returned value (outside the [ ] square brackets).

--
I.S.


[Jon C. Munson II] That made a difference.  I took your literal word
originally.  :)

After adding @class anEntity; to the .h file (may not be necessary,  
but did

it anyway), and adding #import "anEntity.h" to the .m file, using:

[(anEntity *)someObject setAttribute:@"somevalue"];

everything worked just peachy.  This uses the dynamic setter for the
anEntity class.

So, I'll switch from using the KVC calls to the casted calls to take
advantage of better efficiency.

Thank you, Quincey Morris, for your insight, I appreciate it.

I could not, however get this to work (and it may not be possible)  
with the

appropriate @class & #import:

(anEntity *)someObject.attribute = @"somevalue";

Is there a way to implement that methodology as well?  Correct me if  
I'm
wrong, however, the dot syntax is the same as the dynamic setter,  
right?  To
use this methodology, does one then need to use the explicit  
someObject

instead of the generic version:

// generic
NSManagedObject someObject = [NSEntityDescription insert...];
(anEntity *)someObject.attribute = @"somevalue";


Same here, I don't know if this must be seen as a bug or not. This  
works for me :


((anEntity *)someObject).attribute = @"somevalue";

Frédéric___

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: NSNotificationCenter : multiple messages sent to the same observer?

2009-02-22 Thread Frédéric Testuz


Le 22 févr. 09 à 10:52, Frédéric Testuz a écrit :


Le 22 févr. 09 à 00:06, Iceberg-Dev a écrit :

I just discovered something recently. If you register an observer  
with the same name/object/selector twice, you get the notification  
twice when you post it.


Isn't the NSNotificationCenter supposed to prevent this?


Notifications post via a NSNotificationQueue can have this  
behaviour. The documentation said nothing about coalescing  
notifications sent directly to a NSNotificationCenter.


Sorry, after reflection, I made a confusion between sending two time a  
notification and registering two times for a notification.


Frédéric___

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: NSNotificationCenter : multiple messages sent to the same observer?

2009-02-22 Thread Frédéric Testuz

Le 22 févr. 09 à 00:06, Iceberg-Dev a écrit :

I just discovered something recently. If you register an observer  
with the same name/object/selector twice, you get the notification  
twice when you post it.


Isn't the NSNotificationCenter supposed to prevent this?


Notifications post via a NSNotificationQueue can have this behaviour.  
The documentation said nothing about coalescing notifications sent  
directly to a NSNotificationCenter.


Frédéric___

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: Simple memory problem

2009-02-06 Thread Frédéric Testuz

Le 6 févr. 09 à 07:32, Martin Wierschin a écrit :


On Feb 5, 2009, at 4:42 PM, Steve Sisak wrote:

	NSString * newString = [inputString  
stringByReplacingCharactersInRange:range withString:@""];

[inputString release]; // release old inputString
inputString = [newString retain]; // retain new inputString


This sequence is not safe. As an optimization there is nothing  
preventing "inputString" from returning self if "range" is of zero  
length. If that ever happened, you could end up deallocating the  
string before the following retain occurs. As has been suggested,  
using a single mutable string is probably the best way to go.


I don't think so. If I understand memory management correctly want you  
describe is a bug.


By the rule stringByReplacingCharactersInRange:withString: return an  
instance that the caller dont have ownership. And NSString know  
nothing about the ownership of self and the code outside of itself, he  
can't make this sort of optimization.


If there is an optimization in  
stringByReplacingCharactersInRange:withString: then return will have  
the form of :


return [[self retain] autoreleased];

With this sequence, the precedent code is safe.

Frédéric___

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: CoreData relationship/KVC question

2009-01-30 Thread Frédéric Testuz

Le 30 janv. 09 à 20:14, Jean-Nicolas Jolivet a écrit :

I've been working on my first CoreData project and I have a question  
regarding dynamically generated accessors for to-many relationships  
and KVC...


I'll keep it as simple as possible, let's assume I have a Department  
entity which contains many Employees entities
from what I understand in the doc, CoreData should automatically  
generate those methods for Department:


-addEmployees:(NSSet *)values
-addEmployeesObject:(NSManagedObject *)value

My question is, how would I access these  2 methods using KVC  
accessors?


For example, if I want to set the employee's name attribute I can  
use:  [anEmployee setValue:@"John Doe" forKey:@"name"];


Following this pattern, could I use
[aDeparment setValue:anEmployee forKey@"employees];  // Assuming  
anEmployee is an NSManagedObject*


or

[aDeparment setValue:someEmployees forKey@"employees]; // Assuming  
someEmployees is an NSSet*



In other words, are relationship also KVC and, will CoreData  
aumatically call the correct method depending on the type of the  
"value" I'm setting (either an NSSet or an NSManagedObject) ?


No. I never tried, but I'm pretty sure you will obtain garbage, at  
least for you first proposition. The second will simply replace the  
old employees set with someEmployees.


I know I can declare an NSManagedObject category with a bunch of  
accessors etc.. to suppress compiler warning but I was wondering  
about the KVC get/set as I am using them too


If you want to use the KVC method use -mutableSetValueForKey or - 
mutableSetValueForKeyPath: . In return you have a proxy object for the  
key (keypath). Send to this proxy usual mutable set methods, the KVO  
notifications will be send for you. EX :


[[aDepartment mutableSetForKey:@"employees"] addObject:someEmployees];
[[aDepartment mutableSetForKey:@"employees"] unionSet:someEmployees];

Frédéric


___

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: Sublclassing NSThread

2008-12-17 Thread Frédéric Testuz


Le 17 déc. 08 à 17:14, Keith Duncan a écrit :



On 17 Dec 2008, at 15:41, Jean-Daniel Dupas wrote:

because there's absolutely no way to guarantee that only a single  
NSOperationQueue

exists in your process


Couldn't you swizzle +[NSOperationQueue alloc] to return a  
singleton? Sure it's a hack, but a simple one that can be #ifdefed  
out for post Leopard builds. And would fix the problem for now if  
you've already architected a project around operation queues.


And -waitUntilAllOperationsAreFinished became useless : one of your  
thread create an operation queue and add some operations then wait for  
them to finish. But meanwhile another thread, perhaps in a frameeork  
you dont control, create also an operation queue and add some  
operations. Because of the singleton, your thread can wait a long time  
to continue.


Frédéric___

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: Programatically Triggering an NSSearchField Search

2008-11-26 Thread Frédéric Testuz

Le 26 nov. 08 à 04:57, Steve Steinitz a écrit :


Hello,

I use NSSearchFields bound to NSArrayControllers to allow my client  
to search their Core Data database.  Pretty standard.  My search  
predicate bindings are lengthy, giving my client lots of options to  
find what they want.


Occasionally I would like to programmatically specify a search for  
them.  For example, I was able to programmatically clear their  
search fields like this:


   [searchfield setStringValue: @""];
   [arrayController setFilterPredicate: nil];

However I can't work out how to set the correct non-nil predicate.   
Actually, I don't want to set the  predicate -- that's already done  
nicely in the bindings and I don't want to duplicate it in the code,  
for maintenance reasons.  ** I just want to put something in the  
search field and make it 'do it' **


I've tried increasingly desperate ideas to 'do' the search string.   
Here is my most recent defeat - sad, perhaps comical:


   [searchfield setStringValue: @"10471"];
   [arrayController setFilterPredicate: [arrayController  
filterPredicate]]; // :)


(How) can I just trigger the search after setting the  
NSSearchField's value?


I'm not sure but did you try :

[searchfield validateEditing];

- (void)validateEditing

Discussion
Validation sets the object value of the cell to the current contents  
of the cell’s editor (the NSTextobject used for editing), storing it  
as a simple NSString or an attributed string object based on the  
attributes of the editor.


Frédéric___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Call getElementById in Cocoa

2008-11-24 Thread Frédéric Testuz

Le 24 nov. 08 à 18:34, Mike Abdullah a écrit :



On 24 Nov 2008, at 17:28, Jean-Daniel Dupas wrote:



Le 24 nov. 08 à 18:03, Mike Abdullah a écrit :



On 24 Nov 2008, at 16:45, John Terranova wrote:



On Nov 24, 2008, at 8:11 AM, Jean-Daniel Dupas wrote:

You call -mainFrameDocument on your WebView to get a DOMDocument  
instance, and have access to the DOM functions from here (there  
is no up-to-date doc of the Cocoa DOM API, you will have to  
check headers files directly to see what function is available,  
for example the DOMDocument.h file show you that there is a - 
[DomDocument getElementById:] method.


Is it possible to use the DOM functions without first creating  
the WebView?


I want to download a webpage and parse its contents without ever  
displaying the page. I currently parse the html text directly,  
but it is somewhat cumbersome.  If I could just walk the DOM  
structure, then that would likely be much cleaner.


No, this is not possible. But there is no reason why you have to  
present the WebView to the user. Just stick it in an offscreen  
window and wait for it to load.


Mike.


I don't think you have to create an offscreen window at all.  
Creating the WebView and loading the URL programmatically is enough  
to access the dom tree.



That would be ideal, but I could swear I've run across WebKit  
documentation stating that a WebView must be placed within a window  
for it to operate properly.


I'm using a WebView for printing without a window and it works  
perfectly (but perhaps the PrintOperation is doing what the window is  
doing in the normal situation).


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Localization...

2008-11-03 Thread Frédéric Testuz


Le 3 nov. 08 à 05:04, Chris Idou a écrit :

I don't seem to be having much luck getting localization to work.  
I've got a utf16 strings file in my project called MetaData.strings  
that contains:


"kMDItemFSLabel" = "color label";


Then in my code...

[[NSBundle bundleForClass:[self class]]  
localizedStringForKey:@"kMDItemFSLabel" value:@"nothing here"  
table:@"MetaData"]


MetaData.strings ends up in my English.lproj and get info says it is  
an English localization. But the code returns "nothing here".


I've also tried:

NSLocalizedStringFromTable(@"kMDItemFSLabel", @"MetaData",  
@"kMDItemFSLabel")


But that doesn't work either. Am I missing something?


You can also tried to launch your application with  
NSShowNonLocalizedStrings argument. With this argument  
localizedString... method logs error in the console. See the low part  
of >



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Problem with Info.plist in 10.5 [RESOLVED]

2008-09-01 Thread Frédéric Testuz

Le 27 août 08 à 21:14, Frédéric Testuz a écrit :


Hi,

I'm writing a Leopard-target application. Therefore I'm willing to  
use UTI and the new-style for the Info.plist. I red the AppKit  
release notes and I thought I didn't forget something. But when I'm  
calling the save panel I get this error message on the console:


2008-08-27 14:12:52.522 MyApp[23412:813] An NSDocumentController  
returned nil when sent -displayNameForType:@"ch.ftestuz.MyApp.rgbd".  
See the info about new support for UTIs in the Leopard AppKit  
release notes.
2008-08-27 14:12:52.523 MyApp[23412:813] An NSDocumentController  
returned nil when sent - 
displayNameForType:@"ch.ftestuz.MyApp.rgbdx". See the info about new  
support for UTIs in the Leopard AppKit release notes.


I resolved the problem. I'm not exactly sure about what cause the  
resolution. I took the Info.plist of the Sketch exemple, changed it's  
data with mine. Rebuild and launched the app. At this time, the  
problem was not resolved.


Then I deleted all the keys which are obsolete in 10.5, rebuild and  
launched the app. And the problem was resolved.


I don't know if the Info.plist parser is too sensible with mix of 10.4  
and 10.5 infos. It can also be that the new infos was not immediately  
take into account by the system (LaunchService I think?).


Frédéric___

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

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

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

This email sent to [EMAIL PROTECTED]


Problem with Info.plist in 10.5

2008-08-27 Thread Frédéric Testuz

Hi,

I'm writing a Leopard-target application. Therefore I'm willing to use  
UTI and the new-style for the Info.plist. I red the AppKit release  
notes and I thought I didn't forget something. But when I'm calling  
the save panel I get this error message on the console:


2008-08-27 14:12:52.522 MyApp[23412:813] An NSDocumentController  
returned nil when sent -displayNameForType:@"ch.ftestuz.MyApp.rgbd".  
See the info about new support for UTIs in the Leopard AppKit release  
notes.
2008-08-27 14:12:52.523 MyApp[23412:813] An NSDocumentController  
returned nil when sent -displayNameForType:@"ch.ftestuz.MyApp.rgbdx".  
See the info about new support for UTIs in the Leopard AppKit release  
notes.


My Info.plist is below. I know I can delete some keys, may this be the  
source of the problems?



http://www.apple.com/DTDs/PropertyList-1.0.dtd 
">



CFBundleDevelopmentRegion
fr_CH
CFBundleDisplayName

CFBundleDocumentTypes


CFBundleTypeExtensions

rgbd

CFBundleTypeMIMETypes

application/octet-stream

CFBundleTypeName
MyApp SQLite
CFBundleTypeOSTypes

RgBD

CFBundleTypeRole
Editor
LSItemContentTypes

ch.ftestuz.MyApp.rgbd

LSTypeIsPackage

NSDocumentClass
RBDDocument
NSPersistentStoreTypeKey
SQLite


CFBundleTypeExtensions

rgbdx

CFBundleTypeMIMETypes

text/xml

CFBundleTypeName
XML
CFBundleTypeOSTypes

RgBX

CFBundleTypeRole
Editor
LSItemContentTypes

ch.ftestuz.MyApp.rgbdx

LSTypeIsPackage

NSDocumentClass
RBDDocument
NSPersistentStoreTypeKey
XML


CFBundleExecutable
MyApp
CFBundleIdentifier
ch.ftestuz.MyApp
CFBundleInfoDictionaryVersion
6.0
CFBundleName
MyApp
CFBundlePackageType
APPL
CFBundleShortVersionString
0.1
CFBundleSignature
RgBD
CFBundleVersion
0.1
NSMainNibFile
MainMenu
NSPrincipalClass
NSApplication
UTExportedTypeDeclarations


UTTypeConformsTo

public.content
public.data

UTTypeDescription
MyApp document
UTTypeIdentifier
ch.ftestuz.MyApp.rgbd
UTTypeTagSpecification

com.apple.ostype
RgBD
public.filename-extension
rgbd
public.mime-type
application/octet-stream



UTTypeConformsTo

public.xml-file

UTTypeDescription
MyApp XML document
UTTypeIdentifier
ch.ftestuz.MyApp.rgbdx
UTTypeTagSpecification

com.apple.ostype
RgBX
public.filename-extension
rgbdx
public.mime-type
text/xml






Anyone can give me a little help? Or show me an example with just the  
keys required by Leopard?


Thank you.

Frédéri

NSPredicateEditorRowTemplate and ANY predicate

2008-07-22 Thread Frédéric Testuz

Hello,

Is it possible to prepare a row template for a NSPredicateEditor in IB  
for a predicate like "ANY keyPath == 'aValue'" ?


Otherwise I found this : 

If I can't do it in IB, I think it will be the simplest solution :

- (NSPredicate *)predicateWithSubpredicates:(NSArray *)subpredicates
{ /* we only make NSComparisonPredicates */
	NSComparisonPredicate *predicate = (NSComparisonPredicate *)[super  
predicateWithSubpredicates:subpredicates];
 /* construct an identical predicate, but add the  
NSCaseInsensitivePredicateOption flag */
	return [NSComparisonPredicate predicateWithLeftExpression:[predicate  
leftExpression] rightExpression:[predicate rightExpression]  
modifier:NSAnyPredicateModifier type:[predicate predicateOperatorType]  
options:[predicate options]];

}

Thanks
Frédéric___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: CALayer transform, setting the Y value of rotation causes side-effects

2008-07-14 Thread Frédéric Testuz

Le 14 juil. 08 à 18:57, John Clayton a écrit :


Hi All,

I'm setting the rotation values of a CALayer, and notice that when  
setting the Y component of rotation of a CATransform3D structure via  
the :

[layer setValue:someValue forKeyPath:@"transform.rotation.y"]

call, that in certain cases of 'someValue' (the y rotation), the X  
and Z rotation values are modified as well.


I set the value of the transform.rotation.Y using the standard  
setValue:forKeyPath: method, and logged the resulting X, Y and Z  
rotation values.  Here's the code and logging results:


- (void) awakeFromNib {
CALayer* testLayer = [CALayer new];
NSLog(@"before: x, y, x = %@ / %@ / %@",
  [testLayer valueForKeyPath:@"transform.rotation.x"],
  [testLayer valueForKeyPath:@"transform.rotation.y"],
  [testLayer valueForKeyPath:@"transform.rotation.z"]);

// but this breaks the X and Z, how come?
	[testLayer setValue:[NSNumber numberWithDouble:2.12041]  
forKeyPath:@"transform.rotation.y"];

NSLog(@"after: x, y, x = %@ / %@ / %@",
  [testLayer valueForKeyPath:@"transform.rotation.x"],
  [testLayer valueForKeyPath:@"transform.rotation.y"],
  [testLayer valueForKeyPath:@"transform.rotation.z"]);

[testLayer release];
}

2008-07-14 17:48:23.555 Annotate[42997:10b] before: x, y, x = 0 /  
-0 / 0
2008-07-14 17:48:23.562 Annotate[42997:10b] after: x, y, x =  
3.141593 / 1.021183 / 3.141593


Huh?

Question 1: Why do X and Z get very close to PI?
Question 2: Why does Y end up being 1.02 when I set it to 2.12041?

Does anyone know what's going on here?  I'm a little stumped by this  
one.


Hello,

I never used CALayer but if I understand correctly the rotation, there  
is no difference between


rotation (A) : x, y, x = 0 / 2.12041 / 0

and

rotation (B) : x, y, x = 3.141593 / 1.021183 / 3.141593

It's because a rotation of pi is a half-circle rotation and 1.021183  
is equal to pi-2.12041. So the two transformation are equals. But why  
the layer transform the rotation like this. It has to be a internal  
check like in 2D when you want the angle of rotation to stay between - 
pi and pi.


You can check the equality by doing the transformation for an  
arbitrary point, or calculating the transformation matrix.


rot(A) : x,y,z = 0 , a , 0

(cos a  0  -sin a  0)
R(A) =  (0  1   0  0)
(sin a  0   cos a  0)
(0  0   0  1)

rot(B) : x,y,z = pi, pi-a, pi

(10   0  0) (cos pi-a  0  -sin pi-a  0) ( cos pi   
sin pi  0  0)
R(B) =  (0   cos pi  sin pi  0) (0 1  0  0) (-sin pi   
cos pi  0  0)
(0  -sin pi  cos pi  0) (sin pi-a  0   cos pi-a  0)  
(  0   0  1  0)
(00   0  1) (0 0  0  1)  
(  0   0  0  1)


(1   0   0  0) (-cos a  0  -sin a  0) (-1   0  0  0)
R(B) =  (0  -1   0  0) ( 0  1   0  0) ( 0  -1  0  0)
(0   0  -1  0) ( sin a  0  -cos a  0) ( 0   0  1  0)
(0   0   0  1) ( 0  0   0  1) ( 0   0  0  1)

(-cos a   0  -sin a  0) (-1   0  0  0)
R(B) =  ( 0  -1   0  0) ( 0  -1  0  0)
(-sin a   0   cos a  0) ( 0   0  1  0)
( 0   0   0  1) ( 0   0  0  1)

(cos a  0  -sin a  0)
R(B) =  (0  1   0  0)
(sin a  0   cos a  0)
(0  0   0  1)

And you have R(A) = R(B)

Frédéric Testuz___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Printing a Webview

2008-07-10 Thread Frédéric Testuz

Hello,

If your have :

WebView *myView;

Don't print myView, but print [[[myView mainFrame] frameView]  
documentView].


Consider WebView and frameView like NSScrolView. You don't want to  
print the scroll view but its content.


Frédéric Testuz

Le 10 juil. 08 à 17:44, Western Botanicals a écrit :

I am trying to print a whole page in a webview, but it is only  
printing the portion that I can see in the window (there is more if  
I scroll down), how can I print the whole thing. I think the problem  
may be that the page setup is not the right size.


What can I do?

Thank you

Justin Giboney
___

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/ftestuz%40bluewin.ch

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSNumberFormatter behavior

2008-05-07 Thread Frédéric Testuz

Le 6 mai 08 à 03:29, Chataka a écrit :


Hello,

My app has a NSTextField on a UI window to accept user input and to  
display a NSNumber
in a model object. The NSTextField and the NSNumber are bound using  
Cocoa Bindings,
and the NSTextField is set a NSNumberFormatter. It is a very simple  
UI but I have two
problems regarding this NSTextField (NSNumberFormatter) which I  
don't know how to fix.


One is that the NSTextField can't be blank. When I enter a number in  
the NSTextField then
delete the number, an alert panel appears to show "Format error" and  
require to fill a number
in the NSTextField. I would like to leave the NSTextField blank when  
the number is deleted,
would like to set nil to the NSNumber bound in the model object, and  
would like to disable

the alert panel but I don't know how.

The other problem may be the same problem as the first one. I have a  
method which
handles the NSNumber in the model object and after all computations  
using the NSNumber
finishes, the NSNumber is set nil at the end of the method. But the  
NSTextField bound to this
NSNumber isn't cleared and continue to have the same number before  
the computation, while
the NSNumber in the model object becomes nil. This breaks a  
synchronization between
the UI and the model object and I would like to know how to fix this  
too.


In the 10.4 behaviour of NSNumberFormatter use

[myNumberFormatter setNilSymbol:@""];

You can also fix it in IB. Select the formatter, in the attribute  
palette go to the nil symbole, type a letter then delete it.


If you have the same problem with NSDateFormatter, the only solution I  
found is to subclass NSDateFormatter.


It must fix the problem for the first part, I'm not sure for the  
second part.


F. Testuz___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSString format parameter order

2008-04-08 Thread Frédéric Testuz
I think using the capacity of Cocoa would be simplier. Look at the doc  
on the localization :





This line :

NSLog(@"%3$u : %2$@ : %1$@", @"le 1", @"le 2", 3);

result in :

2008-04-08 12:37:50.036 Test[483:10b] 3 : le 2 : le 1

F. Testuz



Le 8 avr. 08 à 12:01, Jere Gmail a écrit :

Well, I have found a "good" solution using
stringByReplacingOccurrencesOfString:withString:options:range:
The only problem is that one of the parameters is a float, and if I
want to display it with more or less precision I would have to make a
preprocess of the parameter format into the string.

Now it works with:
[str stringByReplacingOccurrencesOfString:@"%1" withString:string1]

On Tue, Apr 8, 2008 at 11:55 AM, Michael Vannorsdel <[EMAIL PROTECTED] 
> wrote:
You could load the strings into an NSArray and then use the proper  
indexes

to print out the string you want.



On Apr 8, 2008, at 3:48 AM, Jere Gmail wrote:


Well, it's not a language thing at this moment but it started this  
way.
Right now I have a txt file with one string with the places where  
the
fields should be. I use it as a template to generate an HTML from  
some

fields obtained from and XML.
This way I can change the page displayed without having to recompile
the application.




___

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/zon7mail%40gmail.com

This email sent to [EMAIL PROTECTED]





--
http://zon7blog.wordpress.com/
And again we fall.
___

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/ftestuz%40mac.com

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]