Re: How do I extract the int value from an xml node/element?

2009-07-26 Thread Roland King

-(NSInteger)integerValue

is a method of NSString 


On Jul 26, 2009, at 2:05 PM, Rick Schmidt wrote:

Hi I am trying to extract the value in an XML node/element as an  
int.  Here

is a snip of what the xml looks like.

   
 1
 
   
 1
 gi|229264291|gb|CP001598.1|
 Bacillus anthracis str. A0248, complete genomeHit_def>

 CP001598
 5227419

What I need to get at is the number for  and others in the  
file.  I
know this must be an easy thing to do I just cannot find a simple  
way to do

it.  Any ides...? Thanks

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/rols%40rols.org

This email sent to r...@rols.org


___

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

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

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

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


Rotating image

2009-07-26 Thread Agha Khan

HI:
I have an image which works fine.
UIImage *img = [UIImage imageNamed:@"background.png"];
[img drawAtPoint:CGPointMake(0,0)];
[img release];

Now suppose I want to rotate that image at 90 degree. Is there an easy  
way to accomplish this task?


Best regards
Agha

___

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

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

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

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


Re: How do I extract the int value from an xml node/element?

2009-07-26 Thread Quincey Morris

On Jul 25, 2009, at 23:05, Rick Schmidt wrote:

Hi I am trying to extract the value in an XML node/element as an  
int.  Here

is a snip of what the xml looks like.

   
 1
 
   
 1
 gi|229264291|gb|CP001598.1|
 Bacillus anthracis str. A0248, complete genomeHit_def>

 CP001598
 5227419

What I need to get at is the number for  and others in the  
file.  I
know this must be an easy thing to do I just cannot find a simple  
way to do

it.  Any ides...? Thanks


If it really looks this, like you should be able to feed your XML to  
NSXMLElement's 'initWithXMLString:error:'. Then use 'elementsForName:'  
to descend though the hierarchy and use 'attributeForName:' to get the  
attribute you want.


(If you have an entire XML document, you might need to parse it with a  
NSXMLDocument and descend from its 'rootElement' instead.)



___

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] Why can't a UITextField be its own delegate?

2009-07-26 Thread Peter Blazejewicz
Hi WT,
have you tried - to avoid everything discussed in thread - to use
implementation like below one? For what you want it could be more
proper avoiding discussed issues and at the same time it hides
everything into your subclass (wrapped delegate class details are
hidden into module):

#import 

@class CustomTextFieldDelegate;

@interface CustomTextField : UITextField

{

    @private

    CustomTextFieldDelegate * _customDelegate;

}

@end

#import "CustomTextField.h"

@interface CustomTextFieldDelegate:NSObject

@end

@implementation CustomTextFieldDelegate

-(BOOL)textField:(UITextField*)text_field
shouldChangeCharactersInRange: (NSRange) range replacementString:
(NSString*) string

{

    NSLog(@"-textField: shouldChangeCharactersInRange: replacementString:");

    return YES;

}

-(BOOL)textFieldShouldBeginEditing:(UITextField*)text_field

{

    NSLog(@"-textFieldShouldBeginEditing:");

    return YES;

}

- (void)textFieldDidBeginEditing:(UITextField*)text_field

{

    NSLog(@"-textFieldDidBeginEditing:");

}

- (BOOL) textFieldShouldEndEditing: (UITextField*) text_field

{

    NSLog(@"-textFieldShouldEndEditing:");

    return YES;

}

- (void) textFieldDidEndEditing: (UITextField*) text_field

{

    NSLog(@"-textFieldDidEndEditing:");

}

- (BOOL) textFieldShouldClear: (UITextField*) text_field

{

    NSLog(@"-textFieldShouldClear:");

    return YES;

}

- (BOOL) textFieldShouldReturn: (UITextField*) text_field

{

    NSLog(@"-textFieldShouldReturn:");

    [text_field resignFirstResponder];

    return YES;

}



@end

@implementation CustomTextField

-(void)awakeFromNib

{

    _customDelegate = [[CustomTextFieldDelegate alloc] init];

    self.delegate = _customDelegate;

    self.text = @"Hello World";

    [super awakeFromNib];

}

-(void)dealloc

{

    [_customDelegate release]; _customDelegate = nil;

    [super dealloc];

}

@end

On Sat, Jul 25, 2009 at 9:06 PM, WT  wrote:
>
> Hello all,
>
> I need to create a subclass of UITextField for a text field that performs 
> some control over its own editing. The obvious idea is to make the subclass 
> instance set itself up as its own delegate, but that freezes the app as soon 
> as the delegate method -textFieldDidBeginEditing returns.
>
> Looking at Activity Monitor, the CPU usage of the app goes up to nearly 100%. 
> I've since created the most trivial app with a UITextField subclass that 
> conforms to the UITextFieldDelegate protocol and which sets itself up as its 
> own delegate and, sure enough, the app freezes.
>
> Here's the subclass. Set up a project then add a text field to a view and 
> make its class be CustomTextField. Compile and run, and watch it freeze when 
> you attempt to edit the text in the field.
>
> So... why can't the field be its own delegate?
>
> Thanks in advance.
> Wagner
>
>
> // CustomTextField.h:
>
> #import 
>
> @interface CustomTextField: UITextField 
> {
> }
>
> @end
>
> // CustomTextField.m:
>
> #import "CustomTextField.h"
>
> @implementation CustomTextField
>
> - (void) awakeFromNib
> {
>    super.delegate = self;
>    super.text = @"Hello world";
>
>    NSLog(@"awakeFromNib called - delegate set to self");
> }
>
> // = 
> //
>
> - (BOOL) textField: (UITextField*) text_field
>         shouldChangeCharactersInRange: (NSRange) range
>         replacementString: (NSString*) string
> {
>    NSLog(@"-textField: shouldChangeCharactersInRange: replacementString:");
>    return YES;
> }
>
> // = 
> //
>
> - (BOOL) textFieldShouldBeginEditing: (UITextField*) text_field
> {
>    NSLog(@"-textFieldShouldBeginEditing:");
>    return YES;
> }
>
> // = 
> //
>
> - (void) textFieldDidBeginEditing: (UITextField*) text_field
> {
>    NSLog(@"-textFieldDidBeginEditing:");
> }
>
> // = 
> //
>
> - (BOOL) textFieldShouldEndEditing: (UITextField*) text_field
> {
>    NSLog(@"-textFieldShouldEndEditing:");
>    return YES;
> }
>
> // = 
> //
>
> - (void) textFieldDidEndEditing: (UITextField*) text_field
> {
>    NSLog(@"-textFieldDidEndEditing:");
> }
>
> // = 
> //
>
> - (BOOL) textFieldShouldClear: (UITextField*) text_field
> {
>    NSLog(@"-textFieldShouldClear:");
>    return YES;
> }
>
> // = 
> //
>
> - (BOOL) textFieldShouldReturn: (UITextField*) text_field
> {
>    NSLog(@"-textFieldShouldReturn:");
>    [self resignFirstResponder];
>    return YES;
> }
>
> // = 
> //
>
> @end
>
> ___
>
> Cocoa-dev maili

NSButton setImage in runtime : where is template image?

2009-07-26 Thread Alexander Bokovikov

Hi, All,

I'm trying to create a simple switch button, showing something like  
"Show blablabla >" / "< Hide blablabla" depending on the state of  
"blablabla". I've found that it would be most suitable to use rounded  
textrured button and change its title, image and image position in the  
onClick: handler. Everything is OK, but I can't find how to set an  
image from template, which we can see in the IB. We can choose several  
images there, in particular, I've chosen NSCoLeftTemplate and  
NSCoRightTemplate for button states. But how to change them in  
runtime? As far as I can understand, I should write something like this:


[myButton setImage:[NSImage .]]

but the question is what messages to use here and how to reach those  
templates, as we can see in the IB?


I tried imageNamed, but it does not find an image. I tried to search  
in Google for NSCoLeftTemplate / NSCoRightTemplate, but they're not  
found.


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/archive%40mail-archive.com

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


Re: NSButton setImage in runtime : where is template image?

2009-07-26 Thread Brandon Walkin
There's a typo in your image names. Use NSGoLeftTemplate and  
NSGoRightTemplate ("Go" instead of "Co").


On 2009-07-26, at 6:08 AM, Alexander Bokovikov wrote:


Hi, All,

I'm trying to create a simple switch button, showing something like  
"Show blablabla >" / "< Hide blablabla" depending on the state of  
"blablabla". I've found that it would be most suitable to use  
rounded textrured button and change its title, image and image  
position in the onClick: handler. Everything is OK, but I can't find  
how to set an image from template, which we can see in the IB. We  
can choose several images there, in particular, I've chosen  
NSCoLeftTemplate and NSCoRightTemplate for button states. But how to  
change them in runtime? As far as I can understand, I should write  
something like this:


[myButton setImage:[NSImage .]]

but the question is what messages to use here and how to reach those  
templates, as we can see in the IB?


I tried imageNamed, but it does not find an image. I tried to search  
in Google for NSCoLeftTemplate / NSCoRightTemplate, but they're not  
found.


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/archive%40mail-archive.com

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


Re: Display csv in a tableView with bindings

2009-07-26 Thread Aaron Burghardt


On Jul 24, 2009, at 8:11 PM, gumbo...@mac.com wrote:


I need some direction please.

I would like to load a csv file and display the contents in an  
NSTableView. What is the best way to achieve this with bindings?


Should the model store the data in an array of arrays (rows and  
columns) or a dictionary of arrays (keyed columns and rows)?




Neither, you want an array of dictionaries where each row of CSV is a  
dictionary in which the values keyed to column names and each row of  
CSV is one dictionary object in the array.


Aaron



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Passing data between NSOperation and main thread

2009-07-26 Thread Meik Schuetz

Dear all,
  I am just starting to test my little application for leaks using  
Instruments. I have got a NSOperation which is doing some JSON  
communication stuff with my server. The NSOperation is sending an  
NSDictionary object back to the main thread (using a delegate and  
performSelectorOnMainThread) when the thread is about to complete.
  It happens that the Leaks instrument is finding leaks just right  
there. To analyse the problem, I created a test app having the same  
communication method in the main thread. Curiously, the Leaks  
instrument is not finding any leak in this test application.
  I believe that the NSOperation's main method is encapsulated in  
some autorelease pool. Is there anything that I need to worry about  
when passing an NSDictionary between threads?


Thanks a lot.
Best regards
Meik
___

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: NSButton setImage in runtime : where is template image?

2009-07-26 Thread Alexander Bokovikov


On 26.07.2009, at 16:31, Brandon Walkin wrote:

There's a typo in your image names. Use NSGoLeftTemplate and  
NSGoRightTemplate ("Go" instead of "Co").


I'm so sorry! I was just blind and used Cmd+C too often... sorry.

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/archive%40mail-archive.com

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


Re: Rotating image

2009-07-26 Thread Jerry Krinock


On 2009 Jul 26, at 01:00, Agha Khan wrote:

Now suppose I want to rotate that image at 90 degree. Is there an  
easy way to accomplish this task?


Easy, yes.  (Just copy Steve Christensen's code ... it works)
   http://www.cocoabuilder.com/archive/message/cocoa/2009/3/1/231362

Here's the header file for that category:
#import 

@interface NSImage (Transform)

/*!
 @briefRotates an image around its center by a given
 angle in degrees and returns the new image.

 @details  The width and height of the returned image are,
 respectively, the height and width of the receiver.

 I have not yet tested this with a non-square image.
*/
- (NSImage*)imageRotatedByDegrees:(CGFloat)degrees ;

@end


Two more solutions from Douglas Welton:
   http://www.cocoabuilder.com/archive/message/cocoa/2009/3/2/231366
___

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


My app controller knows it orientation view but sub-views don't

2009-07-26 Thread Agha Khan

HI
My app controller knows it orientation view but sub-views don't  and  
even in sub-views I will not hit the code at
- (void)willAnimateSecondHalfOfRotationFromInterfaceOrientation: 
(UIInterfaceOrientation)fromInterfaceOrientation duration: 
(NSTimeInterval)duration



But how I know about orientation where [[UIScreen mainScreen] bounds];  
will not help. Always 320 x 480


-Best regards
Agha
___

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

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

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

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


Re: My app controller knows it orientation view but sub-views don't

2009-07-26 Thread Luke the Hiesterman

To everyone this time

Are you defining this method in your views or your UIViewControllers?  
That method is defined in UIViewController and will only work with its  
subclasses.


Luke

On Jul 26, 2009, at 5:30 AM, Agha Khan wrote:


HI
My app controller knows it orientation view but sub-views don't  and  
even in sub-views I will not hit the code at
- (void)willAnimateSecondHalfOfRotationFromInterfaceOrientation: 
(UIInterfaceOrientation)fromInterfaceOrientation duration: 
(NSTimeInterval)duration



But how I know about orientation where [[UIScreen mainScreen]  
bounds]; will not help. Always 320 x 480


-Best regards
Agha
___

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/luketheh%40apple.com

This email sent to luket...@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: Display csv in a tableView with bindings

2009-07-26 Thread I. Savant

On Jul 26, 2009, at 6:32 AM, Aaron Burghardt wrote:

Neither, you want an array of dictionaries where each row of CSV is  
a dictionary in which the values keyed to column names and each row  
of CSV is one dictionary object in the array.


  This is a bit more complicated than that, actually.

  There's a bit of a catch-22 here. On the one hand, you have a  
performance consideration. On the other, you have an ease-of- 
programming consideration. Using NSDictionary is easier, but for  
moderately-sized files it is noticeably slow, for large files, it's  
unusably so.


  If you go the dictionary route, using the keys to identify the  
"fields" in each row, you're storing *way* more than just the  
individual field contents. You're storing a copy of your field  
identifier keys for every field, for every row. Best-case scenario,  
you're storing a pointer to some object that represents the "column"  
to which the fields belong, but this defeats the ease-of-use with  
bindings as you need string keys. As I mentioned above, with  
increasingly large files, this dramatically increases your reading/ 
writing time and uses a lot of memory. But at least you get the  
ability to easily use bindings and to sort, all for free, performance  
be damned.


  If you go another route (an array of arrays of strings), it's far  
more efficient, but adds a few programming complexities:


1 - How do you sort by a column? There's no key for sort descriptors  
and sorting via selector provides no way to pass additional  
information (such as column index or identifier).


2 - To what do you bind? The same limitation that causes concern in  
problem #1 makes #2 difficult ... and there is little by way of over- 
the-counter laxative to make #2 less difficult.


3 - If you intend to allow reordering of columns (built-in NSTableView  
feature) or even adding/removing columns, how do you handle keeping  
the columns mapped to the correct fields in the row array in the  
absence of an associative array (dictionary)?


  The easiest solution to all three of these problems (in my opinion)  
is to make a "row" a custom class and a helper class (we'll call it  
"ColumnMapper" - one mapper shared among all rows). The row's internal  
storage can still be an array of strings for low overhead, but the Row  
class has a trick up its sleeve. It overrides -valueForUndefinedKey:  
so that it can still look up associative values (like a dictionary)  
but without storing them. The storage occurs once in the ColumnMapper.


  When asked for a field value for a column, a Row asks the  
ColumnMapper for the index (the index in its storage array) for the  
field the column represents. Likewise for storing a field value. This  
works because, since Row doesn't respond to these column ids as keys,  
it KVC falls back to -valueForUndefinedKey: and our Row class  
overrides this and relies on the central ColumnMapper to determine  
where in its internal storage the value for that column ID is located.


  This solves the sorting issue quite nicely too, if you sort using  
descriptors. Since NSSortDescriptor uses KVC, it "just works". Don't  
forget to google around for "Finder-like sorting" ... the built-in  
methods make a mess of alphanumeric strings. I leave implementing that  
to your imagination ... it's actually really easy if you spend a few  
minutes with Google.


  Note also this approach requires that all rows have the same number  
of columns/fields. Your parsing logic will have to account for this by  
either automatically adjusting (fraught with complexities and  
assumptions) or rejecting the file and informing the user of the first  
row where trouble begins - ie, the first row where the number of  
fields/columns differ from the rest. You really should take this route  
anyway, since the missing field in a row might be somewhere other than  
the end ... so what do you do with the remaining fields in the row?  
They are probably in the wrong column and there's no way to know  
because of CSV's inherent lack of solid structure.


  The only remaining problem is bindings. If you want to be able to  
handle any CSV file (ie, the "fields" are unknown), I'm afraid there's  
no way to use bindings in IB. You'll have to create the table columns  
(and bind them) in code once you've parsed your file and determined  
the number of columns. In this regard, you might find it just as easy  
(if not easier) to eschew Cocoa Bindings altogether and just use the  
NSTableDatasource protocol. It gives you more precise control over  
what to refresh and when. Trust me, this will come up.


  Of course for very large files, both methods will be slow (and  
memory-intensive), and the problem becomes far more complex because  
then you need to start considering low-level solutions that don't  
ignore encodings. The anthesis to this concern is that, as the  
complexity and size increase, the likelihood that a human will want to  
see it as a table they will

Re: How do I extract the int value from an xml node/element?

2009-07-26 Thread Scott Andrew
If this is on a Mac read the documentation for NSXMLDocument. If this  
is the iPhone check out TouchXML (http://code.google.com/p/touchcode/wiki/TouchXML 
). Both have a low level XML parser as well.


Scott

On Jul 25, 2009, at 11:05 PM, Rick Schmidt wrote:

Hi I am trying to extract the value in an XML node/element as an  
int.  Here

is a snip of what the xml looks like.

   
 1
 
   
 1
 gi|229264291|gb|CP001598.1|
 Bacillus anthracis str. A0248, complete genomeHit_def>

 CP001598
 5227419

What I need to get at is the number for  and others in the  
file.  I
know this must be an easy thing to do I just cannot find a simple  
way to do

it.  Any ides...? Thanks

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/scottandrew%40roadrunner.com

This email sent to scottand...@roadrunner.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: How do I extract the int value from an xml node/element?

2009-07-26 Thread Scott Andrew
Hit send too soon . For the mac there are ways to get integer values  
out of the NSElement. I believe TouchXML has the same mechanism, it is  
a wrapper around libXML2 that mimics NSXML classes on the Mac. If  
using NSXMLParser you'll need to keep track of where you are at in the  
file and convert the value the parser:foundCharacters selector is  
called on your delegate. NSString has an intValue call. I would  
recommend doing some reading in the Apple documentation on the NSXML  
classes.


Sctt


On Jul 26, 2009, at 8:49 AM, Scott Andrew wrote:

If this is on a Mac read the documentation for NSXMLDocument. If  
this is the iPhone check out TouchXML (http://code.google.com/p/touchcode/wiki/TouchXML 
). Both have a low level XML parser as well.


Scott

On Jul 25, 2009, at 11:05 PM, Rick Schmidt wrote:

Hi I am trying to extract the value in an XML node/element as an  
int.  Here

is a snip of what the xml looks like.

  
1

  
1
gi|229264291|gb|CP001598.1|
Bacillus anthracis str. A0248, complete genomeHit_def>

CP001598
5227419

What I need to get at is the number for  and others in the  
file.  I
know this must be an easy thing to do I just cannot find a simple  
way to do

it.  Any ides...? Thanks

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/scottandrew%40roadrunner.com

This email sent to scottand...@roadrunner.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/scottandrew%40roadrunner.com

This email sent to scottand...@roadrunner.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: Display csv in a tableView with bindings

2009-07-26 Thread Scott Andrew
If x number of objects in your CSV file represent an object, then  
parse it by hand and put the data into an object that it represents.   
For example:


Scott Andrew, 40, Computer Programmer

These might get parsed into a contact class that has properties name,  
age, profession. Then the bindings can be mapped to an array of  
contacts. This assumes that the values represent an object. Of course  
there are catch 22's that are mentioned else where in this thread.


Scott

On Jul 24, 2009, at 5:11 PM, gumbo...@mac.com wrote:


I need some direction please.

I would like to load a csv file and display the contents in an  
NSTableView. What is the best way to achieve this with bindings?


Should the model store the data in an array of arrays (rows and  
columns) or a dictionary of arrays (keyed columns and rows)?


___

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/scottandrew%40roadrunner.com

This email sent to scottand...@roadrunner.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: Display csv in a tableView with bindings

2009-07-26 Thread I. Savant

On Jul 26, 2009, at 12:04 PM, Scott Andrew wrote:

If x number of objects in your CSV file represent an object, then  
parse it by hand and put the data into an object that it represents.


  This assumes your CSV will always represent a certain data type.  
That's a pretty big assumption for a data format that is purposefully  
wide open so that it can define a multitude of "record" formats.


  If you already know the structure, then it's a well-defined format  
and you're unlikely to be using CSV anyway. Of course, only the OP can  
answer this in his case.


--
I.S.


___

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: Expanding NSScrollView

2009-07-26 Thread Andrew Shamel
Thanks so much for your help!  I got this to work beautifully, the  
only problem is that I can't now get the scrollview (or its enclosing  
view, etc.) to shrink back when the text/rows get shorter, since the  
frame of the documentView does not seem to get smaller as the text  
recedes (I haven't tried it with a table yet).  The notification stops  
being sent, since the documentView and contentView seem to stop  
changing size.


Any thoughts?

Thanks again.

Peace,

Andy Shamel



On 21 Jul 2009, at 3:51 PM, Quincey Morris wrote:


Ack! That seems far too complicated.

You can have your window controller (or whatever equivalent  
controller you're using) register via  
'addObserver:selector:name:object:' to be notified when the  
NSTextView or NSTableView frame changes. (Note that you have to call  
'setPostsFrameChangedNotifications:YES' on those views to be able to  
get these notifications.)


When you get a notification, compare the frame of the NSTextView or  
NSTableView with the bounds of the scroll view's clip view (the  
documentView frame and the clipView bounds are in the same  
coordinate system) to determine whether the clip view is too big,  
too small or just right.


If the clip view is the wrong size, you need to resize the view  
containing the scroll view (so that the things adjacent to the  
scroll view move out of its way) by the amount that the clip view is  
wrong. Autoresizing should then trickle down and produce the results  
you want.


There are a few things to be careful of:

-- resizing view while you're in the notification handler method may  
cause additional notifications, and you need to handle that


-- if you want the number of line/rows to change for other reasons  
(e.g. when you resize the window), you might have to observe the  
clip view frame too


-- if you have autohiding vertical scroll bars on you NSTextView or  
NSTableView, you may end up in a situation where the scroll view  
size change "bounces" up and down, and you need to handle that


HTH


___

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

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

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

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


Re: How do I extract the int value from an xml node/element?

2009-07-26 Thread Rick Schmidt
Thanks everybody I think I have it all figured out now.
Rick

On Sun, Jul 26, 2009 at 10:58 AM, Scott Andrew
wrote:

> Hit send too soon . For the mac there are ways to get integer values out of
> the NSElement. I believe TouchXML has the same mechanism, it is a wrapper
> around libXML2 that mimics NSXML classes on the Mac. If using NSXMLParser
> you'll need to keep track of where you are at in the file and convert the
> value the parser:foundCharacters selector is called on your delegate.
> NSString has an intValue call. I would recommend doing some reading in the
> Apple documentation on the NSXML classes.
>
> Sctt
>
>
>
> On Jul 26, 2009, at 8:49 AM, Scott Andrew wrote:
>
>  If this is on a Mac read the documentation for NSXMLDocument. If this is
>> the iPhone check out TouchXML (
>> http://code.google.com/p/touchcode/wiki/TouchXML). Both have a low level
>> XML parser as well.
>>
>> Scott
>>
>> On Jul 25, 2009, at 11:05 PM, Rick Schmidt wrote:
>>
>>  Hi I am trying to extract the value in an XML node/element as an int.
>>>  Here
>>> is a snip of what the xml looks like.
>>> 
>>>  
>>>1
>>>
>>>  
>>>1
>>>gi|229264291|gb|CP001598.1|
>>>Bacillus anthracis str. A0248, complete genome
>>>CP001598
>>>5227419
>>>
>>> What I need to get at is the number for  and others in the file.
>>>  I
>>> know this must be an easy thing to do I just cannot find a simple way to
>>> do
>>> it.  Any ides...? Thanks
>>>
>>> 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/scottandrew%40roadrunner.com
>>>
>>> This email sent to scottand...@roadrunner.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/scottandrew%40roadrunner.com
>>
>> This email sent to scottand...@roadrunner.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: NSDictionary crash

2009-07-26 Thread slasktrattena...@gmail.com
On Sun, Jul 26, 2009 at 3:58 AM, Aaron Burghardt wrote:
> Why use Core Foundation?  How about (written in Mail):

Thanks for your reply. I ran a test, and it seems CF is slightly faster:

2009-07-26 18:11:52.545 tst[31180:813] CF: Read 4611 tracks in 0.505728 seconds
2009-07-26 18:11:53.585 tst[31180:813] NS: Read 4611 tracks in 0.545601 seconds
2009-07-26 18:11:54.547 tst[31180:813] CF: Read 4611 tracks in 0.507425 seconds
2009-07-26 18:11:55.580 tst[31180:813] NS: Read 4611 tracks in 0.539849 seconds
2009-07-26 18:11:56.543 tst[31180:813] CF: Read 4611 tracks in 0.503465 seconds
2009-07-26 18:11:57.568 tst[31180:813] NS: Read 4611 tracks in 0.528393 seconds
2009-07-26 18:11:58.542 tst[31180:813] CF: Read 4611 tracks in 0.501907 seconds
2009-07-26 18:11:59.585 tst[31180:813] NS: Read 4611 tracks in 0.545226 seconds
2009-07-26 18:12:00.546 tst[31180:813] CF: Read 4611 tracks in 0.506640 seconds
2009-07-26 18:12:01.587 tst[31180:813] NS: Read 4611 tracks in 0.547467 seconds
2009-07-26 18:12:02.547 tst[31180:813] CF: Read 4611 tracks in 0.507250 seconds
2009-07-26 18:12:03.604 tst[31180:813] NS: Read 4611 tracks in 0.564047 seconds

Both methods seem robust, no crashes so far. So, I'm happy for now :)

>
> - (NSDictionary *)dictionaryFromPropertyListFile:(NSString *)path
> error:(NSError **)outError
> {
>        NSData *data = [NSData dataWithContentsOfFile:path options:NULL
> error:&outError];
>        if (!data) return nil;
>
>        NSString *errorString;
>        NSDictionary *plist = [NSPropertyListSerialization
> propertyListFromData:data
>
>  mutabilityOption:NSPropertyListImmutable
>
>    format:NULL
>
>  errorDescription:&errorString];
>        if (!plist) {
>                NSDictionary *info = [NSDictionary
> dictionaryWithObject:errorString forKey:NSLocalizedDescriptionKey];
>                *outError = [NSError errorWithDomain:@"MyAppDomain" code:-1
> userInfo:info];
>                return nil;
>        }
>        return plist;
> }
>
> If there is a read error, the NSData method should be robust enough to catch
> it and just return a nil object. If the data is truncated, modified, or
> corrupted during the read, NSPropertyListSerialization should detect it and
> return nil.  If you are really concerned, wrap it all up in a @try/@catch.
>  Call it, if it fails, wait a couple seconds and try again.  If it continues
> to fail for 2 to 4 attempts, give up and report an error to the user.
>
> Also, it should be faster to just read the content of the file into an
> NSData than to open the file, parse the contents into a plist, then close
> the file (assuming that is what your other approaches are doing.)
>
> Also also, I suggest a quick-and-dirty test.  Write a simple command line
> tool that calls this method repeatedly as fast as possible and logs all
> errors.  Start it up and modify your iTunes library to see if you can induce
> any failure points.
>
> Or use ScriptingBridge.
>
> Regards,
>
> Aaron
>
>
> On Jul 25, 2009, at 4:53 PM, slasktrattena...@gmail.com wrote:
>
>> On Sat, Jul 25, 2009 at 10:21 PM, Kyle Sluder
>> wrote:
>>>
>>> Also not a safe option; other Apple apps can access the XML file,
>>> includeing
>>> CoreServices (for the media picker in the Open panel). Unfortunately we
>>> don't know how they do it and therefore can't be guaranteed that they
>>> won't
>>> also break if you have a lock on the database file.
>>
>> Thanks for the heads up. I'm afraid the end users would be upset if
>> the app required iTunes to be running all of a sudden, though. So I'll
>> try with the Core Foundation methods for now (without locking the
>> file). Hopefully it won't result in a crash if the file is modified
>> while read, just a NULL pointer or invalid data (which is fine
>> considering how often the data is read, I'll just rely on the last
>> valid object).
>>
>> CFPropertyListRef CreateMyPropertyListFromFile( CFURLRef fileURL ) {
>>  CFPropertyListRef propertyList;
>>  CFStringRef       errorString;
>>  CFDataRef         resourceData;
>>  Boolean           status;
>>  SInt32            errorCode;
>>
>>  // Read the XML file.
>>  status = CFURLCreateDataAndPropertiesFromResource(
>>              kCFAllocatorDefault,
>>              fileURL,
>>              &resourceData,            // place to put file data
>>              NULL,
>>              NULL,
>>              &errorCode);
>>
>>  // Reconstitute the dictionary using the XML data.
>>  propertyList = CFPropertyListCreateFromXMLData( kCFAllocatorDefault,
>>              resourceData,
>>              kCFPropertyListImmutable,
>>              &errorString);
>>
>>  if (resourceData) {
>>       CFRelease( resourceData );
>>  } else {
>>       CFRelease( errorString );
>>   }
>>
>>  return propertyList;
>> }
>> ___
>>
>> 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.appl

Re: NSScrollView Not Updating

2009-07-26 Thread Pierce Freeman
> If you can't answer this question, you need to cover some basic
> fundamentals.  "Did you override -drawRect:" is a very simple question
> that you can answer by simply looking at what code you've written.

I kind of figured that I didn't do it, as I didn't write any code that would
have caused this to happen.  But I wasn't sure if it maybe was doing
something "behind the scenes" that caused it to be implemented.  Based upon
your answer, it's a "no".


>>            [subView addSubview:text1];
> 
> When you add a subview to a superview, it doesn't resize the
> superview.  NSScrollView has no idea about the contents of its
> document view's subviews, it only cares about its document view's
> size.  Since it never changes, there's nothing for it to scroll.

That makes a lot of sense.  So I called setFrame: on the NSView, and it
works really well now.  However, when I enlarge the window, the top element
seems to come down.  Is there some way to stop this from happening, in other
words, is there a way to "nail" an element in place.


___

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: NSScrollView Not Updating

2009-07-26 Thread Dave Keck
> seems to come down.  Is there some way to stop this from happening, in other
> words, is there a way to "nail" an element in place.

As Kyle suggested:
http://devworld.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/WorkingWithAViewHierarchy/WorkingWithAViewHierarchy.html

"Repositioning and Resizing Views"
___

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: NSScrollView Not Updating

2009-07-26 Thread Pierce Freeman
Thanks Dave, it works great now.


On 7/26/09 9:34 AM, "Dave Keck"  wrote:

>> seems to come down.  Is there some way to stop this from happening, in other
>> words, is there a way to "nail" an element in place.
> 
> As Kyle suggested:
> http://devworld.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/Worki
> ngWithAViewHierarchy/WorkingWithAViewHierarchy.html
> 
> "Repositioning and Resizing Views"


___

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: Display csv in a tableView with bindings

2009-07-26 Thread Aaron Burghardt


On Jul 26, 2009, at 10:53 AM, I. Savant wrote:


On Jul 26, 2009, at 6:32 AM, Aaron Burghardt wrote:

Neither, you want an array of dictionaries where each row of CSV is  
a dictionary in which the values keyed to column names and each row  
of CSV is one dictionary object in the array.


 This is a bit more complicated than that, actually.

 There's a bit of a catch-22 here. On the one hand, you have a  
performance consideration. On the other, you have an ease-of- 
programming consideration. Using NSDictionary is easier, but for  
moderately-sized files it is noticeably slow, for large files, it's  
unusably so.


Well, you are correct that I assumed that it was a beginner question  
and that the OP was working with a fixed number of known columns (a  
reasonable assumption, I suppose, since he wants to use bindings).  He  
could start with dictionaries, then switch to a custom class for rows  
if the performance using dictionaries was inadequate.


 If you go the dictionary route, using the keys to identify the  
"fields" in each row, you're storing *way* more than just the  
individual field contents. You're storing a copy of your field  
identifier keys for every field, for every row. Best-case scenario,  
you're storing a pointer to some object that represents the "column"  
to which the fields belong, but this defeats the ease-of-use with  
bindings as you need string keys.


Not necessarily.  If the keys are NSStrings, then they are copied when  
added to the dictionary, but a copy of an immutable string is  
optimized to just retain it, so the data isn't duplicated (assuming  
all rows have the same columns in the same order, an assumption you  
don't seem to be making).


As I mentioned above, with increasingly large files, this  
dramatically increases your reading/writing time and uses a lot of  
memory. But at least you get the ability to easily use bindings and  
to sort, all for free, performance be damned.


Keep in mind that an NSArrayController created in Interface Builder is  
defined by default to create an NSMutableDictionary for each item in  
the dictionary.  It's not unreasonable, and we don't know the OP's  
performance requirements.


 If you go another route (an array of arrays of strings), it's far  
more efficient, but adds a few programming complexities:


1 - How do you sort by a column? There's no key for sort descriptors  
and sorting via selector provides no way to pass additional  
information (such as column index or identifier).


2 - To what do you bind? The same limitation that causes concern in  
problem #1 makes #2 difficult ... and there is little by way of over- 
the-counter laxative to make #2 less difficult.


3 - If you intend to allow reordering of columns (built-in  
NSTableView feature) or even adding/removing columns, how do you  
handle keeping the columns mapped to the correct fields in the row  
array in the absence of an associative array (dictionary)?


 The easiest solution to all three of these problems (in my opinion)  
is to make a "row" a custom class and a helper class (we'll call it  
"ColumnMapper" - one mapper shared among all rows). The row's  
internal storage can still be an array of strings for low overhead,  
but the Row class has a trick up its sleeve. It overrides - 
valueForUndefinedKey: so that it can still look up associative  
values (like a dictionary) but without storing them. The storage  
occurs once in the ColumnMapper.


A reasonable idea if the circumstances require it.  It would certainly  
avoid storing a reference to each key in each row, so it would save a  
little memory, but with the mapping of indexes to column names, it may  
not be any faster than a dictionary.




 Of course for very large files, both methods will be slow (and  
memory-intensive), and the problem becomes far more complex because  
then you need to start considering low-level solutions that don't  
ignore encodings. The anthesis to this concern is that, as the  
complexity and size increase, the likelihood that a human will want  
to see it as a table they will manually manipulate decreases (or at  
least, the reasonableness of the request does). At that magic  
tipping point, it's easy to argue that a GUI editor is no longer  
feasible and most of this problem goes away.


Unfortunately, I know from experience that when the row count gets  
above 8xx,000, NSTableView can no longer accurately draw rows in the  
view (if they are the standard-sized text fields).  But that is well  
beyond that magic tipping point :-)


Regards,

Aaron



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email s

Re: Using Snow Leopard for development (was: NSString Retain Count of 2147483647)

2009-07-26 Thread Greg Guerin

Hamish Allan wrote:


> First, I partition my hard drive into three partitions:
> Beta
> Production
> Data

I'm just about to proceed with a multi-partition installation like
this, but I'm wondering about how it will interact with Time Machine.
Can I use the same TM volume for both Beta and Production?


Yes, if the TM disk has adequate free space.  I've had multiple  
partitions on my Leopard machine since long before Leopard.  It's  
currently 5 partitions (3 bootable, 2 not), and Time Machine has no  
apparent difficulties with it.


Time Machine will make a sub-dir for each volume-name it backs up.   
This sub-dir is located in the timestamp-named folder, which in turn  
is created under the machine-named folder in Backups.backupdb on the  
TM disk.


Because TM locates these sub-dirs by name (apparently), you may have  
to be careful about renaming the partitioned volumes.  I'm pretty  
sure a renamed volume will lead to a full backup, which duplicates  
data rather than using space-saving hard-links.  All my partitions  
have lots of data, so I'm reluctant to perform this experiment  
myself, but on a partition with very little data, it would be worth a  
little experiment.


TM's exclusion list stores alias-data (apparently) for each excluded  
volume, so renaming an excluded volume may not cause its data to be  
backed up.


As with anything undocumented and only determined experimentally, any  
of this may change at any time.


  -- GG
___

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

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

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

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


Problems with japanese characters

2009-07-26 Thread Development
Ok. I've googled it and it would seem that 日本 is how you represent  
japan in japanese. The app I need requires this data. I have to send  
it to a server and store it and am doing so in UTF8
I send the data with UTF8 encoding and this is what it sends:  
Êó•Êú¨ which makes no sense. this comes from NSLog(@"%s", 
[[location objectForKey:@"Country]UTF8String]);
Anyway the server gets the data and I urlencode it since that is the  
only way it will store in the database and not be completely  
destroyed. so this is in the database: "%E6%97" I assumed this was  
accurate. I was wrong. Back in the application when it gets the data  
back this is what I get: US. Now I am lost. How is this happening? Why  
am I getting not only the wrong country but the wrong language?
By the way the Database and the app are both using UTF8. The script  
does rawurlencode otherwise the information is mangled in the DB.



	NSString *myRequestString =[NSString stringWithFormat:@"UDID=%@&City= 
%@&State=%@&Country=%@&placeholder=1",

  [location 
objectForKey:@"UDID"],
  [location 
objectForKey:@"City"],
  [location 
objectForKey:@"State"],
  [location 
objectForKey:@"Country"]];

NSLog(@": %s",[[location objectForKey:@"Country"]UTF8String] );
	NSData *myRequestData = [ NSData dataWithBytes: [ myRequestString  
UTF8String ] length: [ myRequestString length ] ];



	NSMutableURLRequest *request = [ [ NSMutableURLRequest alloc ]  
initWithURL:url];

[ request setHTTPMethod: @"POST" ];
[ request setHTTPBody: myRequestData ];
	[request setValue:@"application/x-www-form-urlencoded"  
forHTTPHeaderField:@"content-type"];

NSURLResponse* urlResponse;
NSError* error;
	NSData* result = [NSURLConnection sendSynchronousRequest:request  
returningResponse:&urlResponse error:&error];


	NSString * responseString = [[NSString alloc]initWithData:result  
encoding:NSUTF8StringEncoding];
	NSDictionary * responseDict= [responseString  
propertyListFromStringsFileFormat];


NSLog(@"%@",responseDict);___

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: Display csv in a tableView with bindings

2009-07-26 Thread I. Savant
On Sunday, July 26, 2009, Aaron Burghardt  wrote:

> Not necessarily.  If the keys are NSStrings, then they are copied when added 
> to the dictionary, but a copy of an immutable string is optimized to just 
> retain it, so the data isn't duplicated (assuming all rows have the same 
> columns in the same order, an assumption you don't seem to be making).
>

  You're probably right about the strings ... but (continued below) ...

> A reasonable idea if the circumstances require it.  It would certainly avoid 
> storing a reference to each key in each row, so it would save a little 
> memory, but with the mapping of indexes to column names, it may not be any 
> faster than a dictionary.
>

  This I've tested. It (creation and manipulation) takes less than ten
percent of the time with this method than does the dictionary
approach. A dramatic difference as I said.


> Unfortunately, I know from experience that when the row count gets above 
> 8xx,000, NSTableView can no longer accurately draw rows in the view (if they 
> are the standard-sized text fields).  But that is well beyond that magic 
> tipping point :-)
>

  It certainly does.

--
I.S.
___

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: Display csv in a tableView with bindings

2009-07-26 Thread I. Savant

On Jul 26, 2009, at 3:52 PM, Aaron Burghardt wrote:

Not necessarily.  If the keys are NSStrings, then they are copied  
when added to the dictionary, but a copy of an immutable string is  
optimized to just retain it, so the data isn't duplicated (assuming  
all rows have the same columns in the same order, an assumption you  
don't seem to be making).


  Actually, I temporarily take back my "you're probably right"  
response. :-) I can't find a reference to this anywhere, but I  
admittedly only looked in the NSString API reference, the Introduction  
to Strings Programming Guide for Core Foundation and quickly perused  
the The Objective-C 2.0 Programming Language.


  Would you mind directing me to where this is stated? I'm not saying  
you're wrong - it sounds plausible - I'm just not sure you're right. :-)



Keep in mind that an NSArrayController created in Interface Builder  
is defined by default to create an NSMutableDictionary for each item  
in the dictionary.


  I missed this the first time around, sorry.

  With respect, I don't see how this is relevant to my point. It only  
illustrates that NSMutableDictionary is an acceptable container (and  
it's the default for NSArrayController because it's *the* generic  
Cocoa container that fits in nicely with KVC). That it's the default  
says nothing about its performance when there are hundreds of  
thousands of them to create and manipulate.



It's not unreasonable, and we don't know the OP's performance  
requirements.




  No, it's not unreasonable, but since we don't know the OP's  
performance requirements, the original blanket statement that  
NSDictionary is better won't do without these caveats (ie, "it's  
easier for bindings, but dog-slow on reasonably large files"). Rather  
than just say "there's more to it than that" as a drive-by correction,  
I wanted to provide a helpful explanation and workaround, since this  
is an area in which I have recent and detailed experience. :-)


--
I.S.




___

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: Using Snow Leopard for development (was: NSString Retain Count of 2147483647)

2009-07-26 Thread I. Savant

Hamish Allan wrote:


> First, I partition my hard drive into three partitions:



  Come on, guys, this is obviously off-topic for COCOA-DEV.

--
I.S.




___

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: Problems with japanese characters

2009-07-26 Thread Greg Guerin

Development wrote:

I send the data with UTF8 encoding and this is what it sends:  
Êó•Êú¨ which makes no sense. this comes from NSLog(@"%s",  
[[location objectForKey:@"Country]UTF8String]);
It does make sense if %s is ignorant of character encodings, and  
NSLog isn't decoding it as utf8.  For example, if it's being decoded  
as MacRoman or some other byte-per-character encoding.



NSData *myRequestData = [ NSData dataWithBytes: [ myRequestString  
UTF8String ] length: [ myRequestString length ] ];



NSMutableURLRequest *request = [ [ NSMutableURLRequest alloc ]  
initWithURL:url];

[ request setHTTPMethod: @"POST" ];
[ request setHTTPBody: myRequestData ];
[request setValue:@"application/x-www-form-urlencoded"  
forHTTPHeaderField:@"content-type"];


This doesn't work because you're sending binary UTF8 as the content- 
body, but your content-type header is declaring form-urlencoded.  You  
need to urlencode the UTF8 bytes, then set that as the body.


Doing the basic arithmetic, the two Unicode code-points 日本 will  
encode into six UTF8 bytes (3 bytes for each code-point).  Since each  
one of those bytes will always be in the range 0x80-0xFF (by the  
definition of UTF8), then each byte will be URLEncoded into a 3-byte  
sequence "%xx" where each "x" is in the range of chars [0-9a-f].  So  
in the end, after all the coding is done, you should have a total of  
3*3 or 9 bytes.  Each byte will be either a '%' or a digit '0'-'9' or  
a letter 'a'-'f'.  If that isn't what's sent as the content body and  
what gets received by the server, then something is wrong.


If that doesn't make sense, then you should probably review the  
details of character encodings, especially UTF8 and URL-encoding.


  -- GG

___

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

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

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

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


Re: Using Snow Leopard for development (was: NSString Retain Count of 2147483647)

2009-07-26 Thread Bill Bumgarner

On Jul 26, 2009, at 2:41 PM, I. Savant wrote:


Hamish Allan wrote:


> First, I partition my hard drive into three partitions:

 Come on, guys, this is obviously off-topic for COCOA-DEV.


Not really.   Being able to install multiple versions or  
configurations of the OS is rather important for testing/qualification  
purposes.


b.bum

___

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: Using Snow Leopard for development (was: NSString Retain Count of 2147483647)

2009-07-26 Thread Greg Guerin

I. Savant wrote:


Hamish Allan wrote:

> First, I partition my hard drive into three partitions:



  Come on, guys, this is obviously off-topic for COCOA-DEV.



It was my mistake, not Hamish Allan's.  I sent my reply to the wrong  
list.  It should have gone to xcode-users.  I was reluctant to post  
an apology to cocoa-dev, further cluttering the list with noise.


Sorry, wrong list.  Please ignore.

  -- GG

___

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

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

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

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


Re: Display csv in a tableView with bindings

2009-07-26 Thread Adam R. Maxwell


On Jul 26, 2009, at 2:38 PM, I. Savant wrote:


On Jul 26, 2009, at 3:52 PM, Aaron Burghardt wrote:

Not necessarily.  If the keys are NSStrings, then they are copied  
when added to the dictionary, but a copy of an immutable string is  
optimized to just retain it, so the data isn't duplicated (assuming  
all rows have the same columns in the same order, an assumption you  
don't seem to be making).


 Actually, I temporarily take back my "you're probably right"  
response. :-) I can't find a reference to this anywhere, but I  
admittedly only looked in the NSString API reference, the  
Introduction to Strings Programming Guide for Core Foundation and  
quickly perused the The Objective-C 2.0 Programming Language.


 Would you mind directing me to where this is stated? I'm not saying  
you're wrong - it sounds plausible - I'm just not sure you're  
right. :-)


"CFString objects perform other “tricks” to conserve memory, such as  
incrementing the reference count when a CFString is copied."


http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFStrings/Articles/StringStorage.html#//apple_ref/doc/uid/20001179


It's not unreasonable, and we don't know the OP's performance  
requirements.




 No, it's not unreasonable, but since we don't know the OP's  
performance requirements, the original blanket statement that  
NSDictionary is better won't do without these caveats (ie, "it's  
easier for bindings, but dog-slow on reasonably large files").  
Rather than just say "there's more to it than that" as a drive-by  
correction, I wanted to provide a helpful explanation and  
workaround, since this is an area in which I have recent and  
detailed experience. :-)


"Reasonably large files" is reasonably vague :).  We have an  
application that keeps an array of bibliographic references, where  
each is an NSMutableDictionary with other properties.  The largest  
file I recall throwing at it is ~20K items, and the main problem at  
that point was a beachball when using SearchKit...which was a nuisance  
to work around.  It doesn't use bindings, but there really aren't any  
lazy loading tricks either.





smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Display csv in a tableView with bindings

2009-07-26 Thread gumboots

Thanks People, This is excellent advice and very helpful.

The main purpose of the app was to load the CSV (exported from  
Numbers) and turn the data into an HTML table with some hard coded CSS  
hooks. This works well now, but the format required from the CSV is  
not very flexible. So I thought if I could display the data, somehow,  
the user could sort as they required and select values to add css.


Well, you are correct that I assumed that it was a beginner question  
and that the OP was working with a fixed number of known columns (a  
reasonable assumption, I suppose, since he wants to use bindings).   
He could start with dictionaries, then switch to a custom class for  
rows if the performance using dictionaries was inadequate.


Definitely a beginner question, I still have to squint quite hard when  
it comes to the magic of bindings.


If you go the dictionary route, using the keys to identify the  
"fields" in each row, you're storing *way* more than just the  
individual field contents. You're storing a copy of your field  
identifier keys for every field, for every row. Best-case scenario,  
you're storing a pointer to some object that represents the  
"column" to which the fields belong, but this defeats the ease-of- 
use with bindings as you need string keys.


Not necessarily.  If the keys are NSStrings, then they are copied  
when added to the dictionary, but a copy of an immutable string is  
optimized to just retain it, so the data isn't duplicated (assuming  
all rows have the same columns in the same order, an assumption you  
don't seem to be making).


As I mentioned above, with increasingly large files, this  
dramatically increases your reading/writing time and uses a lot of  
memory. But at least you get the ability to easily use bindings and  
to sort, all for free, performance be damned.


Keep in mind that an NSArrayController created in Interface Builder  
is defined by default to create an NSMutableDictionary for each item  
in the dictionary.  It's not unreasonable, and we don't know the  
OP's performance requirements.


Performance just needs to be usable at this stage, once the concept is  
proven I can look further into this.




If you go another route (an array of arrays of strings), it's far  
more efficient, but adds a few programming complexities:


1 - How do you sort by a column? There's no key for sort  
descriptors and sorting via selector provides no way to pass  
additional information (such as column index or identifier).


2 - To what do you bind? The same limitation that causes concern in  
problem #1 makes #2 difficult ... and there is little by way of  
over-the-counter laxative to make #2 less difficult.


3 - If you intend to allow reordering of columns (built-in  
NSTableView feature) or even adding/removing columns, how do you  
handle keeping the columns mapped to the correct fields in the row  
array in the absence of an associative array (dictionary)?


The easiest solution to all three of these problems (in my opinion)  
is to make a "row" a custom class and a helper class (we'll call it  
"ColumnMapper" - one mapper shared among all rows). The row's  
internal storage can still be an array of strings for low overhead,  
but the Row class has a trick up its sleeve. It overrides - 
valueForUndefinedKey: so that it can still look up associative  
values (like a dictionary) but without storing them. The storage  
occurs once in the ColumnMapper.


This is a very nice and tidy solution, I already have the tableView  
expanding to the size required to fit the data and the logic handles  
odd shaped tables. Can you go into a bit more detail with regard to  
the setting up the bindings? do I bind the tableView column to an  
arrayController which handles the rows? what model key path?


Unfortunately, I know from experience that when the row count gets  
above 8xx,000, NSTableView can no longer accurately draw rows in the  
view (if they are the standard-sized text fields).  But that is well  
beyond that magic tipping point :-)


I imagine the largest table would be about 15x300, but I don't like  
making these assumptions, Murphy's law #1)
I am a little concerned about this, how much sleep should I be losing  
over this problem?

___

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

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

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

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


Re: Display csv in a tableView with bindings

2009-07-26 Thread I. Savant

On Jul 26, 2009, at 5:52 PM, Adam R. Maxwell wrote:

"CFString objects perform other “tricks” to conserve memory, such as  
incrementing the reference count when a CFString is copied."


http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFStrings/Articles/StringStorage.html#//apple_ref/doc/uid/20001179

  Exactly what I was looking for, thanks. I stand corrected and give  
Aaron back the "probably right" upgraded to a full "you're absolutely  
right". :-)




"Reasonably large files" is reasonably vague :).


  Quite. Back to the old "we don't know the OP's requirements".  
Because of this, vague (and covering as many caveats as possible) is  
the best answer.



We have an application that keeps an array of bibliographic  
references, where each is an NSMutableDictionary with other  
properties.  The largest file I recall throwing at it is ~20K items,  
and the main problem at that point was a beachball when using  
SearchKit...which was a nuisance to work around.  It doesn't use  
bindings, but there really aren't any lazy loading tricks either.


  Well ... 20k items with only a couple of columns or 20k items with  
"many" columns. That one little detail makes all the difference. :-)


--
I.S.





___

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: Problems with japanese characters

2009-07-26 Thread Development


On Jul 26, 2009, at 2:45 PM, Greg Guerin wrote:


Development wrote:

I send the data with UTF8 encoding and this is what it sends:  
Êó•Êú¨ which makes no sense. this comes from NSLog(@"%s",  
[[location objectForKey:@"Country]UTF8String]);
It does make sense if %s is ignorant of character encodings, and  
NSLog isn't decoding it as utf8.  For example, if it's being decoded  
as MacRoman or some other byte-per-character encoding.



NSData *myRequestData = [ NSData dataWithBytes: [ myRequestString  
UTF8String ] length: [ myRequestString length ] ];



NSMutableURLRequest *request = [ [ NSMutableURLRequest alloc ]  
initWithURL:url];

[ request setHTTPMethod: @"POST" ];
[ request setHTTPBody: myRequestData ];
[request setValue:@"application/x-www-form-urlencoded"  
forHTTPHeaderField:@"content-type"];


This doesn't work because you're sending binary UTF8 as the content- 
body, but your content-type header is declaring form-urlencoded.   
You need to urlencode the UTF8 bytes, then set that as the body.


Doing the basic arithmetic, the two Unicode code-points 日本 will  
encode into six UTF8 bytes (3 bytes for each code-point).  Since  
each one of those bytes will always be in the range 0x80-0xFF (by  
the definition of UTF8), then each byte will be URLEncoded into a 3- 
byte sequence "%xx" where each "x" is in the range of chars [0-9a- 
f].  So in the end, after all the coding is done, you should have a  
total of 3*3 or 9 bytes.  Each byte will be either a '%' or a digit  
'0'-'9' or a letter 'a'-'f'.  If that isn't what's sent as the  
content body and what gets received by the server, then something is  
wrong.


If that doesn't make sense, then you should probably review the  
details of character encodings, especially UTF8 and URL-encoding.


 -- GG



Actually thank you this does make a lot of sense and I will begin  
corrections.



___

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/development%40fornextsoft.com

This email sent to developm...@fornextsoft.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: Display csv in a tableView with bindings

2009-07-26 Thread Kyle Sluder

On Jul 26, 2009, at 2:52 PM, "Adam R. Maxwell"  wrote:

"CFString objects perform other “tricks” to conserve memory, such  
as incrementing the reference count when a CFString is copied."


Not every NSString is necessarily a CFString. They're toll-free  
bridged, but that just means the CF implementation needs to be aware  
of any non-NSCFString instances it is handed. I belive the private  
NSPathStorage class might not be a subclass of NSCFString.


IOW, just because two types are toll-free bridged does not mean they  
have the same behavior. Look at NSDictionary for a known example; if  
you create a CFDictionary with certain options and then use it as an  
NSDictionary you do not get the same behavior (I believe the relevant  
option involves whether the dictionary should copy its keys).


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


[moderator] Re: Using Snow Leopard for development (was: NSString Retain Count of 2147483647)

2009-07-26 Thread Scott Anguish


On 2009-07-26, at 2:45 PM, Bill Bumgarner wrote:


On Jul 26, 2009, at 2:41 PM, I. Savant wrote:


Hamish Allan wrote:


> First, I partition my hard drive into three partitions:

Come on, guys, this is obviously off-topic for COCOA-DEV.


Not really.   Being able to install multiple versions or  
configurations of the OS is rather important for testing/ 
qualification purposes.





Actually, as I get to play moderator.  It is off-limits.

Workflow such as this fits much better under other lists. Perhaps  
xcode, or omni's list.


Also, cross-posting between lists is inappropriate (as bbum knows, but  
the original poster may not). 
___


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: Display csv in a tableView with bindings

2009-07-26 Thread Adam R. Maxwell


On Jul 26, 2009, at 2:58 PM, I. Savant wrote:

We have an application that keeps an array of bibliographic  
references, where each is an NSMutableDictionary with other  
properties.  The largest file I recall throwing at it is ~20K  
items, and the main problem at that point was a beachball when  
using SearchKit...which was a nuisance to work around.  It doesn't  
use bindings, but there really aren't any lazy loading tricks either.


 Well ... 20k items with only a couple of columns or 20k items with  
"many" columns. That one little detail makes all the difference. :-)


Good point.  8--10 displayed in the table (typically), but each item  
has an arbitrary number of values (typically < 20, though).  Users can  
also display an arbitrary number of columns, so there are lots of fun  
performance problems to find :).





smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Display csv in a tableView with bindings

2009-07-26 Thread Adam R. Maxwell


On Jul 26, 2009, at 2:53 PM, gumbo...@mac.com wrote:
Can you go into a bit more detail with regard to the setting up the  
bindings? do I bind the tableView column to an arrayController which  
handles the rows? what model key path?


Personally, I recommend that you avoid bindings like the plague until  
you're comfortable with the datasource approach.




Unfortunately, I know from experience that when the row count gets  
above 8xx,000, NSTableView can no longer accurately draw rows in  
the view (if they are the standard-sized text fields).  But that is  
well beyond that magic tipping point :-)


I imagine the largest table would be about 15x300, but I don't like  
making these assumptions, Murphy's law #1)
I am a little concerned about this, how much sleep should I be  
losing over this problem?


15x300 is trivial.




smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Display csv in a tableView with bindings

2009-07-26 Thread I. Savant

On Jul 26, 2009, at 6:05 PM, Adam R. Maxwell wrote:

Good point.  8--10 displayed in the table (typically), but each item  
has an arbitrary number of values (typically < 20, though).  Users  
can also display an arbitrary number of columns, so there are lots  
of fun performance problems to find :).




  The value of the column-mapper architecture I outlined increases  
with the number of columns. :-)


  I'm *still* finding new ways to make it even faster. Memory usage  
doesn't bother me as much as taking 40 seconds to scan through the  
rows looking for certain values to act upon (find/replace, convert,  
etc.). Sorting speed is about as fast either way, though.


--
I.S.




___

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: Display csv in a tableView with bindings

2009-07-26 Thread I. Savant


On Jul 26, 2009, at 5:53 PM, gumbo...@mac.com wrote:


Thanks People, This is excellent advice and very helpful.

The main purpose of the app was to load the CSV (exported from  
Numbers) and turn the data into an HTML table with some hard coded  
CSS hooks. This works well now, but the format required from the CSV  
is not very flexible.


  Then NSDictionary will probably be fine for you. Performance test  
it and find out. Best test: a test file with many rows and few  
columns, then another with the same rows and many columns. Stick with  
nice round numbers and be consistent. The measure, measure, measure.


  Ultimately in this situation, as long as it "feels" reasonably  
fast, you're probably fine.




This is a very nice and tidy solution,


  You're damn right it is!

  Er, what I meant was, "I humbly thank you for your compliment." ;-)


I already have the tableView expanding to the size required to fit  
the data and the logic handles odd shaped tables. Can you go into a  
bit more detail with regard to the setting up the bindings? do I  
bind the tableView column to an arrayController which handles the  
rows? what model key path?


  Generally speaking, you'd dynamically create NSTableColumn  
instances as needed. For each column, you'd bind its value to the  
array controller's arrangedObjects.key where "key" represents the key  
for that column (the one that corresponds to the field in your row  
dictionary that the column represents).


  It's the same as in Interface Builder; you're just setting it up  
with code. See these two:


http://developer.apple.com/documentation/Cocoa/Reference/CocoaBindingsRef/BindingsText/NSTableColumn.html#//apple_ref/doc/uid/NSTableColumn-DontLinkElementID_601

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Protocols/NSKeyValueBindingCreation_Protocol/Reference/Reference.html#//apple_ref/doc/uid/20002048-BCICHGHC


I imagine the largest table would be about 15x300, but I don't like  
making these assumptions, Murphy's law #1)
I am a little concerned about this, how much sleep should I be  
losing over this problem?


  For a first-pass, none at all. Go easy first, then optimize if  
necessary. Your users may not even notice. Given that Numbers itself  
is ... how shall we say ... unconcerned with performance ( :-) ), you  
can probably relax a bit yourself. In my situation (I actually have  
two separate ones with the same requirements), performance is  
everything and so is the ability to heavily reorganize and otherwise  
curate the data prior to using it.


  For me, it's worth losing some sleep over. YMMV.

--
I.S.



___

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: Display csv in a tableView with bindings

2009-07-26 Thread I. Savant

On Jul 26, 2009, at 6:09 PM, Adam R. Maxwell wrote:

Can you go into a bit more detail with regard to the setting up the  
bindings? do I bind the tableView column to an arrayController  
which handles the rows? what model key path?


Personally, I recommend that you avoid bindings like the plague  
until you're comfortable with the datasource approach.


  Agreed. For my case, the datasource approach was much easier to  
manage and didn't take away from the app at all. It's only a *little*  
more code than with Bindings (since KVO timing issues required some  
extra custom logic in several instances for me) so the decision was an  
easy one.


--
I.S.




___

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: Display csv in a tableView with bindings

2009-07-26 Thread Adam R. Maxwell


On Jul 26, 2009, at 3:04 PM, Kyle Sluder wrote:

On Jul 26, 2009, at 2:52 PM, "Adam R. Maxwell"   
wrote:


"CFString objects perform other “tricks” to conserve memory, such  
as incrementing the reference count when a CFString is copied."


Not every NSString is necessarily a CFString. They're toll-free  
bridged, but that just means the CF implementation needs to be aware  
of any non-NSCFString instances it is handed. I belive the private  
NSPathStorage class might not be a subclass of NSCFString.


Correct.  The same design principle applies for NS classes, though,  
and a quick test program shows that -[NSPathStore2 copy] returns the  
same pointer.


IOW, just because two types are toll-free bridged does not mean they  
have the same behavior. Look at NSDictionary for a known example; if  
you create a CFDictionary with certain options and then use it as an  
NSDictionary you do not get the same behavior (I believe the  
relevant option involves whether the dictionary should copy its keys).


Yeah, that's part of it.  If you use pointer equality and  
copyWithZone: doesn't return the same object, setObject:forKey: will  
break your dictionary.


http://www.cocoabuilder.com/archive/message/cocoa/2006/6/9/165304



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: NSDictionary crash

2009-07-26 Thread slasktrattena...@gmail.com
On Sun, Jul 26, 2009 at 8:04 PM, Aaron
Burghardt wrote:
> Interesting and not surprising. What I was suggesting, though, is that the
> amount of time needed to read the data is probably small compared to the
> time spent parsing the data into a plist.

Good point. So I ran a second test. Turns out CF is still your best
option for sucking in the data. But for the parsing,
NSPropertyListSerialization is somewhat faster. So, using a mixed up
method, you get a slightly better result. The difference is
negligible, but still...

2009-07-26 23:34:58.381 tst[91885:10b] CF: Read data in 0.017413 seconds
2009-07-26 23:34:59.385 tst[91885:10b] NS: Read data in 0.021142 seconds
2009-07-26 23:35:00.382 tst[91885:10b] CF: Read data in 0.018322 seconds
2009-07-26 23:35:01.406 tst[91885:10b] NS: Read data in 0.042197 seconds
2009-07-26 23:35:02.381 tst[91885:10b] CF: Read data in 0.017629 seconds
2009-07-26 23:35:03.384 tst[91885:10b] NS: Read data in 0.020038 seconds

2009-07-26 23:44:25.146 tst[93798:10b] CF: Parsed data in 0.560710 seconds
2009-07-26 23:44:26.091 tst[93798:10b] NS: Parsed data in 0.505121 seconds
2009-07-26 23:44:27.195 tst[93798:10b] CF: Parsed data in 0.609571 seconds
2009-07-26 23:44:28.082 tst[93798:10b] NS: Parsed data in 0.496928 seconds
2009-07-26 23:44:29.080 tst[93798:10b] CF: Parsed data in 0.494216 seconds
2009-07-26 23:44:30.076 tst[93798:10b] NS: Parsed data in 0.490349 seconds
2009-07-26 23:44:31.153 tst[93798:10b] CF: Parsed data in 0.567589 seconds
2009-07-26 23:44:32.077 tst[93798:10b] NS: Parsed data in 0.491887 seconds

Cheers.
___

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: Display csv in a tableView with bindings

2009-07-26 Thread Aaron Burghardt


On Jul 26, 2009, at 5:38 PM, I. Savant wrote:


On Jul 26, 2009, at 3:52 PM, Aaron Burghardt wrote:

Not necessarily.  If the keys are NSStrings, then they are copied  
when added to the dictionary, but a copy of an immutable string is  
optimized to just retain it, so the data isn't duplicated (assuming  
all rows have the same columns in the same order, an assumption you  
don't seem to be making).


 Actually, I temporarily take back my "you're probably right"  
response. :-) I can't find a reference to this anywhere, but I  
admittedly only looked in the NSString API reference, the  
Introduction to Strings Programming Guide for Core Foundation and  
quickly perused the The Objective-C 2.0 Programming Language.


 Would you mind directing me to where this is stated? I'm not saying  
you're wrong - it sounds plausible - I'm just not sure you're  
right. :-)




I didn't think it was documented anywhere, but Adam found a reference  
for at least some forms.  But, it's well-known on the list and easy to  
test (see example below).  Caveat: it's an implementation detail that  
you normally shouldn't be concerned with.  But, if you get to the  
point that you need to optimize memory consumption, it is worthwhile  
to confirm the behavior.  For example, if you pass mutable strings to  
the method that parses the CSV, then you need to make immutable copies  
first.


Keep in mind that an NSArrayController created in Interface Builder  
is defined by default to create an NSMutableDictionary for each  
item in the dictionary.


 With respect, I don't see how this is relevant to my point.


It was an unnecessary point.  I was interpreting your comments to be  
strongly advocating not using dictionaries, and I was trying to  
suggest it is more common than that.


It's not unreasonable, and we don't know the OP's performance  
requirements.




 No, it's not unreasonable, but since we don't know the OP's  
performance requirements, the original blanket statement that  
NSDictionary is better won't do without these caveats (ie, "it's  
easier for bindings, but dog-slow on reasonably large files").  
Rather than just say "there's more to it than that" as a drive-by  
correction, I wanted to provide a helpful explanation and  
workaround, since this is an area in which I have recent and  
detailed experience. :-)


You brought up some good discussion points, and I probably should have  
asked the OP to give us more details.  I inferred from his question  
that he didn't have a working solution, so I suggested the simplest  
working solution that was inline with his current mindset.  I didn't  
mean to imply it was the best solution, but my response was so short  
it easily could be read that way.  I assumed that if performance  
wasn't adequate, we would get a follow-up question.  But, I think it  
is better to start with an easy-to-understand working solution and  
then optimize it if necessary.


Regards,

Aaron


#import 

int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];

NSString *string1, *string2;

// create a string
	string1 = [[NSFileManager defaultManager]  
stringWithFileSystemRepresentation:argv[0] length:strlen(argv[0])];

NSLog(@"String value: %@", string1);
	NSLog(@"String 1 class: %@ address: %p retain count: %ld",  
NSStringFromClass([string1 class]), string1, [string1 retainCount]);

string2 = [string1 copy];
	NSLog(@"String 2 class: %@ address: %p retain count: %ld",  
NSStringFromClass([string2 class]), string2, [string2 retainCount]);


// create a path-optimized string
string1 = [string1 stringByDeletingLastPathComponent];
NSLog(@"String value: %@", string1);
	NSLog(@"String 1 class: %@ address: %p retain count: %ld",  
NSStringFromClass([string1 class]), string1, [string1 retainCount]);

string2 = [string1 copy];
	NSLog(@"String 2 class: %@ address: %p retain count: %ld",  
NSStringFromClass([string2 class]), string2, [string2 retainCount]);


[pool drain];
return 0;
}

Compile on the command line with:

$ gcc -framework Foundation -o test test.m

An example run:

$ /tmp/stringtest/test
2009-07-26 20:06:25.258 test[15385:903] String value: /tmp/stringtest/ 
test
2009-07-26 20:06:25.262 test[15385:903] String 1 class: NSCFString  
address: 0x10010c630 retain count: 1
2009-07-26 20:06:25.266 test[15385:903] String 2 class: NSCFString  
address: 0x10010c630 retain count: 2

2009-07-26 20:06:25.267 test[15385:903] String value: /tmp/stringtest
2009-07-26 20:06:25.267 test[15385:903] String 1 class: NSPathStore2  
address: 0x100110560 retain count: 1
2009-07-26 20:06:25.268 test[15385:903] String 2 class: NSPathStore2  
address: 0x100110560 retain count: 2





smime.p7s
Description: S/MIME cryptographic signature
___

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

Please do not post admin requests or moderator comment

Re: Rotating image

2009-07-26 Thread David Duncan

On Jul 26, 2009, at 1:00 AM, Agha Khan wrote:


HI:
I have an image which works fine.
UIImage *img = [UIImage imageNamed:@"background.png"];
[img drawAtPoint:CGPointMake(0,0)];
[img release];

Now suppose I want to rotate that image at 90 degree. Is there an  
easy way to accomplish this task?



CGContextRotateCTM(UIGraphicsGetCurrentContext(), M_PI / 2.0);
[img drawAtPoint...];
--
David Duncan
Apple DTS Animation and Printing

___

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

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

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

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


Re: I need a milder application badge (solution #2)

2009-07-26 Thread Jay Reynolds Freeman
Well, with great thanks to everybody, I think I now have a relatively  
clean implementation that does what I want.  There was enough interest  
that I think I will present what I have done, but in order not to  
waste bandwidth here I have put on my website both the interface and  
implementation files for "BadgedIconView", and a screen shot which  
shows (near right bottom, in the dock), some of the badged icons  
thereby created.  (I will remove those files in a while; if you  
stumble on this message after they are gone and would like to see  
them, send me EMail.)


The implementation is a subclass of NSView suitable for passing to - 
[NSDockTile setContentView:] for the application dock tile, to be  
followed up with sending "display" thereto.


I believe that if you mouse these links, the .h and .m files will  
download but the .png will pop up in your browser.


http://web.mac.com/Jay_Reynolds_Freeman/BadgedIconView.h
http://web.mac.com/Jay_Reynolds_Freeman/BadgedIconView.m
http://web.mac.com/Jay_Reynolds_Freeman/WSTrueColors.png

Thanks once again to all.  Any remaining mistakes or clumsiness in the  
implementation are of course nobody's fault but mine.


--  Jay Reynolds Freeman
-
jay_reynolds_free...@mac.com
http://web.mac.com/jay_reynolds_freeman (personal web site)


___

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: NSDictionary crash

2009-07-26 Thread Aaron Burghardt


On Jul 26, 2009, at 6:50 PM, slasktrattena...@gmail.com wrote:


On Sun, Jul 26, 2009 at 8:04 PM, Aaron
Burghardt wrote:
Interesting and not surprising. What I was suggesting, though, is  
that the
amount of time needed to read the data is probably small compared  
to the

time spent parsing the data into a plist.


Good point. So I ran a second test. Turns out CF is still your best
option for sucking in the data. But for the parsing,
NSPropertyListSerialization is somewhat faster. So, using a mixed up
method, you get a slightly better result. The difference is
negligible, but still...

2009-07-26 23:34:58.381 tst[91885:10b] CF: Read data in 0.017413  
seconds
2009-07-26 23:34:59.385 tst[91885:10b] NS: Read data in 0.021142  
seconds


2009-07-26 23:44:25.146 tst[93798:10b] CF: Parsed data in 0.560710  
seconds
2009-07-26 23:44:26.091 tst[93798:10b] NS: Parsed data in 0.505121  
seconds


Nice validation of the relative time difference between reading the  
data and parsing the data.


So, if I may don my professorial hat for a moment, you have  
substantially reduced the window of time in which you may collide with  
iTunes, but you haven't eliminated it.  You have an implementation  
that we *think* will be more robust when it does happen, but it hasn't  
been tested.  Can you confirm it?  Going back to your original  
problem, do you care, or are you satisfied that reading the data first  
is an adequate improvement?


Regards,

Aaron



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: mouse entered/exited in nscollectionviewitem's view

2009-07-26 Thread Mac First


On Jul 25, 2009, at 9:42 AM, Benjámin Salánki wrote:

hm, a quick answer to my own question:

inserting
	[self performSelector:@selector(updateTrackingAreas) withObject:nil  
afterDelay:0.01];

into scrollWheel: seems to fix my problem.



I missed the rest of the thread, so may be out of school here but, as  
a general rule, having to call [foo performSelector:afterDelay] with  
the intent being to wait[1] until the OS has done something else, then  
sending the correct signal[2] just seems like a bad design pattern,  
all around.  It may be a nice test to help indicate that there's  
something else going on, but the REAL solution has to be getting  
things to happen in the right order in the first place.


NOTE: if your system happens to block (say, on I/O) for 0.01s (not  
unreasonable) at exactly the wrong time (ok, less likely... ;), you'll  
get the world's weirdest un-reproducable bug.


We *HATE* those!


---
[1] Say, 1/100th of a second
[2] As opposed to because you like the "look & feel" of inserting a  
delay before something happens.


--
Build a man a fire and he will be warm for a day. Set a man on fire  
and he will be warm for the rest of his life.


___

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: Passing data between NSOperation and main thread

2009-07-26 Thread Greg Guerin

Meik Schuetz wrote:

I am just starting to test my little application for leaks using  
Instruments. I have got a NSOperation which is doing some JSON  
communication stuff with my server. The NSOperation is sending an  
NSDictionary object back to the main thread (using a delegate and  
performSelectorOnMainThread) when the thread is about to complete.


How was the NSDictionary produced?  Is it in the sending thread's  
autorelease pool?


Does the sending thread own the NSDictionary?  Are you transferring  
ownership to the receiving thread?  What does the receiving thread do  
with the NSDictionary once it's received?  Does it relinquish  
ownership properly?



It happens that the Leaks instrument is finding leaks just right  
there. To analyse the problem, I created a test app having the same  
communication method in the main thread.
Curiously, the Leaks instrument is not finding any leak in this  
test application.


Why should that be curious?  If it's all running on the main thread,  
then there won't be any inter-thread ownership issues, nor will there  
be any inter-thread autorelease pool issues.  You can't accurately  
simulate asynchronous threads using a single-threaded test.



I believe that the NSOperation's main method is encapsulated in  
some autorelease pool. Is there anything that I need to worry about  
when passing an NSDictionary between threads?


Ownership.  It all comes down to object ownership.  If you understand  
ownership, and transfer of ownership, then things will work  
properly.  If not, then things will go wrong.


You will probably have to post your code.  There's no way to know  
exactly what it's doing just by reading your description.


  -- GG

___

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

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

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

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


NSString -componentsSeparatedByString: line break

2009-07-26 Thread Chase Meadors

Say I have a string that looks like this


Hello. How are you?
This is the second line.

Fourth line.


I'm trying to get each line of the reciever by calling

[string componentsSeparatedByString:@"\n"];

This works fine, but assuming the string is actually laid out like this:

Hello. How are you?\nThis is the second line.\n\nFourth line.

The array contains

@"Hello. How are you?"
@"This is the second line."
@"" (???)
@"Fourth line."

The third line is what I'm having problems with. I would think it  
would simply be an empty string @"".  But,


Both of these:

[stringInQuestion isEqualToString:@""]; //outputs false
[stringInQuestion isEqualToString:@" "]; //also outputs false

output false. Even more puzzling, this

[stringInQuestion length] //outputs 1

outputs 1.

If the length of this mystery string is 1 and it's not a space, what  
is it???


Any help appreciated!
___

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


NSCoder Chicago Reminder Monday Night

2009-07-26 Thread Bob Frank

Reminder:

Tomorrow Monday July 27th is NSCoder Chicago at the 4th Floor Michigan  
Ave. Apple store 6:00 - 9:00 with drinking after.  Hope to see you  
there.




Future dates of interest:

August 11th 7:00 - 8:00: CocoaHeads / CAWUG Apple Store 2nd floor
August 31st 6:00 - 9:00: NSCoder Chicago Apple Store 4th floor
September 8th 7:00 - 8:00: CocoaHeads / CAWUG Apple Store 2nd floor


-Bob
___

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: NSString -componentsSeparatedByString: line break

2009-07-26 Thread Greg Guerin

Chase Meadors wrote:

If the length of this mystery string is 1 and it's not a space,  
what is it???


Use -characterAtIndex:0 and print the returned unichar using the "%x"  
format.


  -- GG

___

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

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

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

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


Re: NSString -componentsSeparatedByString: line break

2009-07-26 Thread Adam R. Maxwell


On Jul 26, 2009, at 7:11 PM, Greg Guerin wrote:


Chase Meadors wrote:

If the length of this mystery string is 1 and it's not a space,  
what is it???


Use -characterAtIndex:0 and print the returned unichar using the  
"%x" format.


Another sometimes-handy trick is to create a mutable copy and call  
CFStringTransform with kCFStringTransformToUnicodeName.




smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Document-Based Application

2009-07-26 Thread David Blanton
Should Document-Based Applications only be used for apps whose main  
data type is text?


If an apps main data type comes from a number of different file  
formats and is represented as a bitmap would a Document-Based  
Application be a choice?


Just askin'.

db

___

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: NSString -componentsSeparatedByString: line break

2009-07-26 Thread Rob Keniger


On 27/07/2009, at 12:23 PM, Adam R. Maxwell wrote:



On Jul 26, 2009, at 7:11 PM, Greg Guerin wrote:


Chase Meadors wrote:

If the length of this mystery string is 1 and it's not a space,  
what is it???


Use -characterAtIndex:0 and print the returned unichar using the  
"%x" format.


Another sometimes-handy trick is to create a mutable copy and call  
CFStringTransform with kCFStringTransformToUnicodeName.



You should also look at -getLineStart:end:contentsEnd:forRange: if  
you're parsing lines of text, as it takes into account a variety of  
possible line endings, not just \n.


--
Rob Keniger



___

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: Document-Based Application

2009-07-26 Thread David LeBer


On 26-Jul-09, at 10:50 PM, David Blanton wrote:

Should Document-Based Applications only be used for apps whose main  
data type is text?


If an apps main data type comes from a number of different file  
formats and is represented as a bitmap would a Document-Based  
Application be a choice?


Just askin'.



Sure.

"Document-Based Application" generally refers to an application that  
can have multiple document windows open at once and is probably built  
using Cocoa's document architecture (NSDocumentController/NSDocument/ 
NSWindowController). Those classes make no assumption about what those  
documents contain.


;david

--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site:   http://codeferous.com
blog:   http://davidleber.net
profile:http://www.linkedin.com/in/davidleber
twitter:http://twitter.com/rebeld
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org




___

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

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

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

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


Re: Document-Based Application

2009-07-26 Thread David Blanton

I am seeing that now with a sample app I am working with.

I have 22 file types, each with its own C++ methods for extracting its  
data.


Now, I could use just one subclass of NSDocument and in the

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error: 
(NSError **)outError


method do a case statement on typeName BUT I think it would be cleaner  
to  subclass NSDocument for each of my file types and override only  
the read and write methods.


Do I grok!


On Jul 26, 2009, at 9:13 PM, David LeBer wrote:



On 26-Jul-09, at 10:50 PM, David Blanton wrote:

Should Document-Based Applications only be used for apps whose main  
data type is text?


If an apps main data type comes from a number of different file  
formats and is represented as a bitmap would a Document-Based  
Application be a choice?


Just askin'.



Sure.

"Document-Based Application" generally refers to an application that  
can have multiple document windows open at once and is probably  
built using Cocoa's document architecture (NSDocumentController/ 
NSDocument/NSWindowController). Those classes make no assumption  
about what those documents contain.


;david

--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site:   http://codeferous.com
blog:   http://davidleber.net
profile:http://www.linkedin.com/in/davidleber
twitter:http://twitter.com/rebeld
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org








___

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

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

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

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


Cocoa Document-Based App v. Windows MDI App

2009-07-26 Thread David Blanton
I am the only Mac programmer where I work;  the rest being windows.  I  
am constantly challenged to make Mac programs look like windows to  
some extent.


Windows has an architecture called Multiple Document Interface.  Each  
doc opened is displayed in the same window 'frame' with a row of tab  
controls at the top to select a document.


A Cocoa Document-Based App is one document one window ... multiple  
windows.


How do I win the battle of 'too many windows floatin' around on the  
Mac, we want everything in one window like windows!" ?


Can I use Safari  tabs somehow?


db



___

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: Document-Based Application

2009-07-26 Thread Quincey Morris

On Jul 26, 2009, at 20:39, David Blanton wrote:

I have 22 file types, each with its own C++ methods for extracting  
its data.


Now, I could use just one subclass of NSDocument and in the

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName  
error:(NSError **)outError


method do a case statement on typeName BUT I think it would be  
cleaner to  subclass NSDocument for each of my file types and  
override only the read and write methods.


If the *only* reason for making separate subclasses is the code to  
extract the data, I don't see any great advantage. You need 22 pieces  
of code, and it's probably easier for housekeeping purposes to keep  
them all in one place than to spread them around. (But separate  
subclasses would be in no way wrong.)


If there are other behavioral differences, then it might make more  
sense to use different subclasses.


HTH IMO FWIW


___

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

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

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

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


Re: Cocoa Document-Based App v. Windows MDI App

2009-07-26 Thread Quincey Morris

On Jul 26, 2009, at 20:46, David Blanton wrote:

I am the only Mac programmer where I work;  the rest being windows.   
I am constantly challenged to make Mac programs look like windows to  
some extent.


Windows has an architecture called Multiple Document Interface.   
Each doc opened is displayed in the same window 'frame' with a row  
of tab controls at the top to select a document.


A Cocoa Document-Based App is one document one window ... multiple  
windows.


How do I win the battle of 'too many windows floatin' around on the  
Mac, we want everything in one window like windows!" ?


a. You can't win the battle. Not ever.

b. Your best strategy is probably to say, "The Mac frameworks just  
don't support that approach. Sorry. I could re-implement MDI on the  
Mac, but it would be about a man-year's work. Do you want me to do  
that?"


(I'm not saying this is true, just that it's your best strategic  
answer.)


Consider Adobe's adoption of a more-or-less MDI interface on the Mac,  
and the many-more-than-one man-years of work they put into it, and the  
huge outcry that resulted anyway.


Consider also that Windows (Vista and beyond) doesn't exactly use the  
MDI interface any more (not the traditional one), though it uses  
something related to it that's more complicated. You want to reinvent  
that?



___

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


CoreData many-to-many Relationship Question

2009-07-26 Thread Jean-Nicolas Jolivet
I'm using a many-to-many relationship with CoreData and I was wondering if I
have to set or unset the relationshop both ways?
For example, let's say I have a many-to-many relationship between an
Employee entity and a Manager entity...if I do the following:

[anEmployee addManagersObject:aManager];

I add the Manager to the Employee's Managers... but is the Employee added to
the Manager's Employee automatically (in other words, is the inverse
relationshop created automatically for me, or do I also have to do:
[aManager addEmployeesObject:anEmployee];)

Same for removeManagersObject and removeEmployeesObject... can I only delete
one side of the relationship or do I have to delete both?

Hopefully my question is clear, if not let me know I'll try to explain it
better...

Jean-Nicolas Jolivet
___

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


Ordered Arrays for Core Data managed objects

2009-07-26 Thread knicker kicker
First of all, I am clear about the rationale behind apple not
providing ordered arrays for core data objects. However, there *are*
situations when you need one. The common solution (adding a order-by
attribute to the objects you intend to store) was too intrusive for my
case. After long hours of googling, the best-case solution I found was
http://www.fatcatsoftware.com/blog/2008/per-object-ordered-relationships-using-core-data
but that too was not to my taste.

So I went about and have developed my own workaround to the problem.
Here is how you'd use it -

1. Derive your Managed Object (in which you want to add an array) from
the MRManagedObjectWithArray class.

2. Add an Transformable attribute for each array that you wish to add.

3. In your app delegate's applicationDidFinishLaunching, register the
custom Value Transformer by calling
[MRManagedObjectWithArrayTransformer registerTransformer];

4. Access your arrays with |arrayForKey| and |mutableArrayForKey|.

For example,

[[you mutableArrayForKey:@"beers"] addObject:[Beer pint]];

if( [[you arrayForKey:@"beers"] count] > 7 )
NSThink(@"I'm drunk!");




You can get the code at
http://gitorious.org/mrmanagedobjectwitharray/code/archive-tarball/master

or browse it online at the public VCS
http://gitorious.org/mrmanagedobjectwitharray/

My intention of posting this here is so that I can get some feedback
(and hopefully code improvements!) from you guys. I think the
implementation is complex, but the interface is very simple. There are
no unnecessary writes, and only a single copy of the array is
maintained (contrast with the other solutions on the net - most of
which copy the entire array each time a modification is made).
___

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


NSRuleEditor as a data structure editor

2009-07-26 Thread Paul Thomas
I may have bitten off more than I can chew, but I'm trying to use  
NSRuleEditor as a component to define and edit a Foundation data  
structure (general purpose tree of NSArray, NSDictionary, NSNumber  
etc.). This might be re-purposing the class a little and it certainly  
has little to do with predicates, but the user interaction is a good  
fit for what I want.


There seems to be very little information around about NSRuleEditor if  
it's not tied to predicates, particularly when it comes to  
subclassing. I haven't figured out how to make this work at all, so  
I'm currently relying on a delegate and a binding to the 'rows'  
property of the same delegate.


So my question: does anyone have any examples of _subclassing_  
NSRuleEditor?


I'm thinking that I could make the current delegate a subclass of  
NSRuleEditor, have it bind to itself and set itself as delegate, but  
then I need to hide the -setDelegate from the user. It sounds a bit  
icky, but I definitely don't want to be relying on internals that  
might change - so If anyone has any suggestions, I'd be grateful.


Paul.

___

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


When is an NSTextField editor created?

2009-07-26 Thread Jean-Nicolas Jolivet
I'm working on an NSTextField subclass and I'm trying to find out when an
NSTextField's editor (i.e.  its "currentEditor") is created so I can set its
caret color using the following:[[self currentEditor]
setInsertionPointColor:];

Problem is, each notification/event I try to override is either too soon
(i.e. currentEditor is still null) or too late (i.e.  the cursor changes
color when the user starts typing)...


Am I missing something or is it really that complex to change an
NSTextField's caret color?

Any help would be appreciatede!

Jean-Nicolas Jolivet
___

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: mouse entered/exited in nscollectionviewitem's view

2009-07-26 Thread Austin Grigg
I'm having a similar problem with my NSCollectionView and I was  
wondering what you did with copyWithZone to fix your problem.


I'm trying to allow the user to option-click and have my sub-classed  
view in my NSCollectionView item show an NSTextView and then when they  
finish editing, hide the NSTextView.  I have my custom view reading  
the option-click, but how should I delegate out the method to show/ 
hide the NSTextView used for editing?


Originally I created the NSTextView in IB and set it to hidden, then  
created an outlet to it in my sub-classed NSView that is being used by  
the collection view item, but the outlet doesn't seem to be copied  
because when I call setHidden:YES from my view on the NSTextView,  
nothing happens.


Austin


FROM : Benjámin Salánki
DATE : Sat Jul 25 18:36:10 2009

On Jul 24, 2009, at 3:23 PM, Keith Duncan wrote:

>> the setup code only gets called once and then none of the actually
>> displayed views in the collection handle any of my intended mouse
>> tracking.

>
> That's probably because your subclass of NSCollectionViewItem isn't
> getting created for each item. You can override -copyWithZone: to
> confirm this and fix it if need be.
>
> It's also prudent to ask for the mouse moved events to be sent too.
>


Thanks, after doing this I managed to get the results I was looking  
for!


>> Could anyone please point me into the right direction where to go
>> on from here?
>> Any help is appreciated.

>
> Yes, you'll also run into a problem when the user uses the scroll
> wheel to move around the collection view. The fix for this one is
> slightly more in depth.
>
> Your view under the mouse will first be send -scrollWheel: and it
> will work it's way up the responder chain to the scroll view from
> there. I inserted my NSCollectionViewItem subclass into the
> responder chain between the item view and it's superview so that the
> controller was sent -scrollWheel: before the scroll view.
>


And how would you go on about doing this? I just spent a couple hours
trying to find a workaround myself, but failed. I have the mouse
position tracking code up and running, but I guess it does not get
called at the right time.

Ben

> In that method I tracked the position of the mouse converting from
> window coordinates to collection view coordinates and determined
> which view the mouse was hovering over. Once you've done that it's a
> simple matter of posting a notification internal to the collection
> view item subclass to coordinate the hovering state between
> controllers so that only one is showing the hovering state at a
> given time.
>
> Keith
>

___

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: Document-Based Application

2009-07-26 Thread David Blanton

I agree that for house keeping not having 22 subclasses would be easy.

There is something about OOP and case statements to decide how to deal  
with data ... it just seems more OOPish if the 'system' (in this case  
Cocoa Document-Based App (can I say cdba)) picks for me based on a  
simple entry in an info.plist.


db




On Jul 26, 2009, at 10:09 PM, Quincey Morris wrote:


On Jul 26, 2009, at 20:39, David Blanton wrote:

I have 22 file types, each with its own C++ methods for extracting  
its data.


Now, I could use just one subclass of NSDocument and in the

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName  
error:(NSError **)outError


method do a case statement on typeName BUT I think it would be  
cleaner to  subclass NSDocument for each of my file types and  
override only the read and write methods.


If the *only* reason for making separate subclasses is the code to  
extract the data, I don't see any great advantage. You need 22  
pieces of code, and it's probably easier for housekeeping purposes  
to keep them all in one place than to spread them around. (But  
separate subclasses would be in no way wrong.)


If there are other behavioral differences, then it might make more  
sense to use different subclasses.


HTH IMO FWIW


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/airedale%40tularosa.net

This email sent to aired...@tularosa.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: CoreData many-to-many Relationship Question

2009-07-26 Thread Bryan Henry
Yes, as long as you object graphic consistency for you. You should  
look at the Core Data Programming Guide, which this excerpt is from:


"Since Core Data takes care of the object graph consistency  
maintenance for you, you only need to change one end of a relationship  
and all other aspects are managed for you. This applies to to-one, to- 
many, and many-to-many relationships."


- Bryan

On Jul 24, 2009, at 12:23 PM, Jean-Nicolas Jolivet wrote:

I'm using a many-to-many relationship with CoreData and I was  
wondering if I

have to set or unset the relationshop both ways?
For example, let's say I have a many-to-many relationship between an
Employee entity and a Manager entity...if I do the following:

[anEmployee addManagersObject:aManager];

I add the Manager to the Employee's Managers... but is the Employee  
added to

the Manager's Employee automatically (in other words, is the inverse
relationshop created automatically for me, or do I also have to do:
[aManager addEmployeesObject:anEmployee];)

Same for removeManagersObject and removeEmployeesObject... can I  
only delete

one side of the relationship or do I have to delete both?

Hopefully my question is clear, if not let me know I'll try to  
explain it

better...

Jean-Nicolas Jolivet
___

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

This email sent to bryanhe...@mac.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: Cocoa Document-Based App v. Windows MDI App

2009-07-26 Thread David Blanton

I think I'll use:

The Mac frameworks just don't support that approach. Sorry. I could re- 
implement MDI on the Mac, but it would be about a man-year's work. Do  
you want me to do that?"


Thanks for a few chuckles as well!

On Jul 26, 2009, at 10:20 PM, Quincey Morris wrote:


On Jul 26, 2009, at 20:46, David Blanton wrote:

I am the only Mac programmer where I work;  the rest being  
windows.  I am constantly challenged to make Mac programs look like  
windows to some extent.


Windows has an architecture called Multiple Document Interface.   
Each doc opened is displayed in the same window 'frame' with a row  
of tab controls at the top to select a document.


A Cocoa Document-Based App is one document one window ... multiple  
windows.


How do I win the battle of 'too many windows floatin' around on the  
Mac, we want everything in one window like windows!" ?


a. You can't win the battle. Not ever.

b. Your best strategy is probably to say, "The Mac frameworks just  
don't support that approach. Sorry. I could re-implement MDI on the  
Mac, but it would be about a man-year's work. Do you want me to do  
that?"


(I'm not saying this is true, just that it's your best strategic  
answer.)


Consider Adobe's adoption of a more-or-less MDI interface on the  
Mac, and the many-more-than-one man-years of work they put into it,  
and the huge outcry that resulted anyway.


Consider also that Windows (Vista and beyond) doesn't exactly use  
the MDI interface any more (not the traditional one), though it uses  
something related to it that's more complicated. You want to  
reinvent that?



___

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/airedale%40tularosa.net

This email sent to aired...@tularosa.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: When is an NSTextField editor created?

2009-07-26 Thread Adam R. Maxwell


On Jul 26, 2009, at 9:05 PM, Jean-Nicolas Jolivet wrote:

I'm working on an NSTextField subclass and I'm trying to find out  
when an
NSTextField's editor (i.e.  its "currentEditor") is created so I can  
set its

caret color using the following:[[self currentEditor]
setInsertionPointColor:];

Problem is, each notification/event I try to override is either too  
soon
(i.e. currentEditor is still null) or too late (i.e.  the cursor  
changes

color when the user starts typing)...


You should be able to use the NSWindow delegate method  
willReturnFieldEditor:toObject: to return a customized field editor.   
I'd also think about subclassing NSTextFieldCell and overriding  
setUpFieldEditorAttributes:, but I've never tried to change the  
insertion point color.





smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: When is an NSTextField editor created?

2009-07-26 Thread Kyle Sluder
On Jul 26, 2009, at 9:05 PM, Jean-Nicolas Jolivet > wrote:



Am I missing something or is it really that complex to change an
NSTextField's caret color?


Read this: 
http://developer.apple.com/documentation/Cocoa/Conceptual/TextEditing/Tasks/FieldEditor.html

--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: Document-Based Application

2009-07-26 Thread Graham Cox


On 27/07/2009, at 2:09 PM, Quincey Morris wrote:


On Jul 26, 2009, at 20:39, David Blanton wrote:

I have 22 file types, each with its own C++ methods for extracting  
its data.


Now, I could use just one subclass of NSDocument and in the

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName  
error:(NSError **)outError


method do a case statement on typeName BUT I think it would be  
cleaner to  subclass NSDocument for each of my file types and  
override only the read and write methods.


If the *only* reason for making separate subclasses is the code to  
extract the data, I don't see any great advantage. You need 22  
pieces of code, and it's probably easier for housekeeping purposes  
to keep them all in one place than to spread them around. (But  
separate subclasses would be in no way wrong.)


If there are other behavioral differences, then it might make more  
sense to use different subclasses.


HTH IMO FWIW



There are many other approaches you could take also.

In my app I have one document class but a simple schema for extending  
the types of files it can read and write by mapping file types (and/or  
UTIs) to specific method selectors. The mapping table is a simple  
dictionary. This allows me to add the method via a category, amend the  
mapping table and info.pList and away it goes. The core document class  
never changes so I can reuse that code in many different apps.


This is no better or worse in terms of the amount of code you need to  
write but it does make managing it quite easy.


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


Re: Cocoa Document-Based App v. Windows MDI App

2009-07-26 Thread Graham Cox


On 27/07/2009, at 1:46 PM, David Blanton wrote:

I am the only Mac programmer where I work;  the rest being windows.   
I am constantly challenged to make Mac programs look like windows to  
some extent.


Windows has an architecture called Multiple Document Interface.   
Each doc opened is displayed in the same window 'frame' with a row  
of tab controls at the top to select a document.


A Cocoa Document-Based App is one document one window ... multiple  
windows.


How do I win the battle of 'too many windows floatin' around on the  
Mac, we want everything in one window like windows!" ?



MDI is a travesty of UI design. Just one example - drag and drop  
between windows in different MDI apps is quite frankly, virtually  
unusable, where it is even attempted at all.


The Mac's approach is much better (i.e. more usable), though when  
there are a lot of windows it can appear confusing to some. However,  
system features such as Exposé were designed to help overcome the  
problem of finding a particular window among a lot of clutter and it  
works well. Spaces is also useful for managing windows among several  
apps working together in particular ways.


The people who are asking you to do this are misguided. If they want  
to make Mac apps, they should not be thinking about replicating the  
Windows version on the Mac, but instead fitting in with the way all  
other Mac apps work. Mac users are notoriously unforgiving of apps  
that don't work the "right" way, and apps that are an obvious Windows  
port do less well in terms of sales and user satisfaction, and in many  
cases will not be used unless there is absolutely no alternative. The  
same goes for Java apps to some extent. However I know how hard it can  
be to get those of a pointy-haired disposition to understand this  
argument, so you might have an uphill battle. Who matters more - the  
end user, or the people in the company who think a unified product is  
easier to handle? (even if in reality it's probably not).


Even if they cannot or will not be re-educated, you don't have much  
choice anyway - the Mac does not support MDI in the Windows sense and  
faking it would be a huge effort that would be more than entirely  
wasted - the app will sell less well and be reviewed poorly.


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


Re: How to display the file's basic information in the columns of

2009-07-26 Thread Bright


>> But when I drop the file into the table view, the app exited immediately.
>
>Find the crash report and look at it; if you don't figure it out from that,
>send another message here with the crash report.


Hi
Sorry, I can not figure  out the crash report. Could you tell me  how to 
find the crash
report in detail?  But, I debug the application and find out that the the 
problem is this code
"[theRecordsArray?insertObject:infoDictionary? atIndex:row+i];". Maybe I should 
not 
make the NSDictionary as the augment of the NSArray's "insertObject:atIndex" 
method.

___

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

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

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

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


Re:How to display the file's basic information in the columns of the tableview

2009-07-26 Thread Bright


>Hi 
>   In the "- (BOOL)tableView: acceptDrop: row: dropOperation:" method, I tried 
> to insert the information Dictionary into the  Array use the code 
> "[tableRecordsArray insertObject:infoDictionary  atIndex:row+i];".
>But when I drop the file into the table view, the app exited immediately.
Now, I find that the code "[tableRecordsArray insertObject:infoDictionary  
atIndex:row+i];" maybe is not 
correct.  maybe I should not make the NSDictionary as an argument of the 
NSArray's method.
Could anyone tell me how to display the objects of the NSDictionary class into 
the different columns of a table view? 
thank you!

___

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

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

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

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


Re: How to display the information in the columns of the table view?

2009-07-26 Thread Graham Cox


On 25/07/2009, at 11:56 PM, Bright wrote:


Hi all,
   In my application, I want to drag the file into the table view.  
At the same time, display the basic information in the columns of  
the table view.
   Now, I got the basic information of the file and saved it in a  
NSDictionary object.The code is :theInfoDictionary  
=[NSDictionarydictionaryWithObjectsAndKeys:[filePath  
lastPathComponent], @"name",[filePath pathExtension], @"extension",  
modDate, @"modifiedDate",nil];
 In the "- (BOOL)tableView: acceptDrop: row: dropOperation:" method,  
I tried to insert the information Dictionary into the  Array use the  
code "[tableRecordsArray insertObject:infoDictionary atIndex:row+i];".
But when I drop the file into the table view, the app exited  
immediately. But I do not know how to realize it.
  Note: The enclosure is the code of this application. I wish  
someone can find out the bug and amend it for me. Thank you.

 Any help greatly appreciated.



You asked the same question less than 24 hours ago. If you didn't get  
an answer, it's probably because nobody knows, didn't understand the  
question or couldn't be bothered to help.


I'm inclined to go with the last one because the question is ill- 
framed, contains no information that can help find the problem, no  
relevant code, and doesn't state what you've tried. This isn't  
debuggers anonymous - if you can't be bothered to help yourself why  
would anyone else feel obliged? Sorry to sound so harsh but I'm in a  
spiky mood today and your post got under my skin...


I will debug your code for you at my standard going consultation rate,  
which is around $100 per hour plus loss of earnings on anything else I  
have to drop to do it. Shouldn't take more than a few hours. OK with  
you?


--Graham

P.S. Your attachment was a 4.5MB download. That's pretty unfriendly to  
have thrown into my email inbox unsolicited at my own expense in terms  
of bandwidth.

___

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


Views in CDBA's

2009-07-26 Thread David Blanton

CDBA - Cocoa Document-Based Application.

I dragged a Scroll View from the LIbrary Objects Tab to the Window  
defined in MyDocument.xib.


All of my content to be displayed here will be bit maps.

So .. do I

1.  make a view, store in this nib.

2. Render my bit map to this view.

3. Set the document view of the scroll view to this view.

___

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: Cocoa Document-Based App v. Windows MDI App

2009-07-26 Thread Jeff Biggus

On Jul 26, 2009, at 10:46 PM, David Blanton wrote:

I am the only Mac programmer where I work;  the rest being windows.   
I am constantly challenged to make Mac programs look like windows to  
some extent.


Windows has an architecture called Multiple Document Interface.   
Each doc opened is displayed in the same window 'frame' with a row  
of tab controls at the top to select a document.


A Cocoa Document-Based App is one document one window ... multiple  
windows.


How do I win the battle of 'too many windows floatin' around on the  
Mac, we want everything in one window like windows!" ?


Can I use Safari  tabs somehow?



While the full MDI way of doing things would be a bad thing on a Mac  
for many reasons, simply having multiple documents per single NSWindow  
is common in Cocoa apps, and there are two main ways that I see people  
doing this: tabs across the top, like Safari; or a sidebar view down  
the side, like Mail, iTunes, iChat, etc.


Starting with Leopard, the NSSplitView IB widget can be used to set up  
the views and you can decide how to customize the look (it comes in  
both vertical and horizontal flavors). You can also used the excellent  
and flexible 3rd party solutions of RBSplitView and KFSplitView (which  
are also more backward compatible). If you want it to look like Safari  
tabs across the top you'll just have to do a little work to make that  
top "bar" view behave how you want. Side tabs are much easier to get  
up and running, and are often a better solution GUI-wise, depending on  
your app.


There are many other ways to skin this cat too, but this is probably  
the simplest, and it can look quite elegant.


jeff
___

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: Document-Based Application

2009-07-26 Thread Jeffrey Oleander

> On Mon, 2009/07/27, Graham Cox  wrote:
> From: Graham Cox 
> Subject: Re: Document-Based Application
> To: "David Blanton" 
> Cc: "cocoa-dev" 
> Date: Monday, 2009 July 27, 00:10
>> On 2009/07/27, at 2:09 PM, Quincey Morris wrote: 
>>> On 2009 Jul 26, at 20:39, David Blanton wrote:
>>> I have 22 file types, each with its own C++
>>> methods for extracting its data.
>>> 
>>> Now, I could use just one subclass of NSDocument

or you could have 22 classes, and use setDelegate
in your NSDocument sub-class to control which one
gets used for each file.


  
___

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

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

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

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


Re: Cocoa Document-Based App v. Windows MDI App

2009-07-26 Thread Andy Lee

On Jul 26, 2009, at 11:46 PM, David Blanton wrote:
I am the only Mac programmer where I work;  the rest being windows.   
I am constantly challenged to make Mac programs look like windows to  
some extent.


I guess I'd ask the question we often ask about coding questions: What  
are you really trying to do?  It sounds like the problem is that  
Windows users accustomed to MDI get visually confused by multiple  
windows from different apps overlapping each other willy-nilly.  One  
simple solution to that is Command-Option-H to hide all other apps;  
there's even a utility out there that will do this for you  
automatically when you switch apps.  There are also utility apps that  
place a dark gray background between your app's windows and all other  
apps' windows.


Windows has an architecture called Multiple Document Interface.   
Each doc opened is displayed in the same window 'frame' with a row  
of tab controls at the top to select a document.


A Cocoa Document-Based App is one document one window ... multiple  
windows.


How do I win the battle of 'too many windows floatin' around on the  
Mac, we want everything in one window like windows!" ?


First, there are certain realities that no amount of battling will  
change: some Windows users want MDI, and the Mac does not support it.   
Second, it seems to me, to borrow a business cliché, that you're all  
"on the same team," with the same goals -- delivering successful  
applications.  What's not clear to me is why the Windows developers  
care whether your apps are Windows-like, and why they have any  
influence over your design.  Are they also end-users?  Are your apps  
in-house apps?  Do they have authority over your UI decisions or  
merely complaints?  Aren't you there to be the person who knows better  
about Macs than they do -- or else *they'd* be writing your apps?



Can I use Safari  tabs somehow?


I don't know of any public framework for creating tabbed interfaces.   
I'm pretty sure there are some good third-party options.  If tabs are  
all it would take to satisfy your co-workers, then sure, you could  
create an interface they'd like better without violating Mac UI  
conventions.


However, as I recall, MDI is much more than a tabbed interface.  It's  
actually windows within a window, where each sub-window is a real  
window, complete with in-window menu bar, and the Mac frameworks  
simply do not support this.  The nearest thing would either be a  
tabbed interface as you suggested or an index-card metaphor like I've  
seen for at least one app (targeted at writers).  The latter would be  
a much different metaphor than "windows within a window," but people  
who don't get that applications should behave according to the UI  
rules of their respective platforms probably aren't too sensitive to  
such nuances.


--Andy

___

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: Cocoa Document-Based App v. Windows MDI App

2009-07-26 Thread Andrew Farmer

On 26 Jul 2009, at 22:57, Jeff Biggus wrote:
If you want it to look like Safari tabs across the top you'll just  
have to do a little work to make that top "bar" view behave how you  
want. Side tabs are much easier to get up and running, and are often  
a better solution GUI-wise, depending on your app.


Check out PSMTabBar. Turns a standard NSTabView into a "Safari-style"  
tab view, with tabs on any side you want - including all the tricky  
functionality like draggable tabs.

___

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: Views in CDBA's

2009-07-26 Thread Graham Cox


On 27/07/2009, at 3:44 PM, David Blanton wrote:


So .. do I

1.  make a view, store in this nib.

2. Render my bit map to this view.

3. Set the document view of the scroll view to this view.



Yes, that should work.

But there is an easier way. If you drag in a "custom view", set its  
class to your document view class, select it, then do Layout -> Embed  
Object In -> Scroll View, and it will set up the containment for you.  
It's a small thing, but it saves mistakes.


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


Re: How to display the information in the columns of the table view?

2009-07-26 Thread Bright
Hi Graham and Others,
  I am sorry for my doing. I am a new learning for cocoa. And the time using 
the Cocoa-dev
mailist for short time. So I am not familiar with the rules of the mailist very 
much.
  At the same time, English is not my mother language. So sometimes I do not 
know how to 
express myself and my questions.
I Am Sorry. Next time, I will comply the regulation. 
Bright
___

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: Cocoa Document-Based App v. Windows MDI App

2009-07-26 Thread Andy Lee


On Jul 27, 2009, at 12:50 AM, David Blanton wrote:


I think I'll use:

The Mac frameworks just don't support that approach. Sorry. I could  
re-implement MDI on the Mac, but it would be about a man-year's  
work. Do you want me to do that?"


Personally, I wouldn't tempt fate.  What if they say yes?  Or yes, but  
please work on it as a background task in addition to your existing  
responsibilities?  Next they'll be asking for resize widgets on all  
four sides of each window.  Then Windows-like menu bars within the  
windows that pop down when you hit Alt.


Writing Windows programs is the job of Windows programmers.  It makes  
no sense for them to ask a Mac developer to write a Windows program on  
a Mac.


--Andy




Thanks for a few chuckles as well!

On Jul 26, 2009, at 10:20 PM, Quincey Morris wrote:


On Jul 26, 2009, at 20:46, David Blanton wrote:

I am the only Mac programmer where I work;  the rest being  
windows.  I am constantly challenged to make Mac programs look  
like windows to some extent.


Windows has an architecture called Multiple Document Interface.   
Each doc opened is displayed in the same window 'frame' with a row  
of tab controls at the top to select a document.


A Cocoa Document-Based App is one document one window ... multiple  
windows.


How do I win the battle of 'too many windows floatin' around on  
the Mac, we want everything in one window like windows!" ?


a. You can't win the battle. Not ever.

b. Your best strategy is probably to say, "The Mac frameworks just  
don't support that approach. Sorry. I could re-implement MDI on the  
Mac, but it would be about a man-year's work. Do you want me to do  
that?"


(I'm not saying this is true, just that it's your best strategic  
answer.)


Consider Adobe's adoption of a more-or-less MDI interface on the  
Mac, and the many-more-than-one man-years of work they put into it,  
and the huge outcry that resulted anyway.


Consider also that Windows (Vista and beyond) doesn't exactly use  
the MDI interface any more (not the traditional one), though it  
uses something related to it that's more complicated. You want to  
reinvent that?



___

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/airedale%40tularosa.net

This email sent to aired...@tularosa.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/aglee%40mac.com

This email sent to ag...@mac.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: Cocoa Document-Based App v. Windows MDI App

2009-07-26 Thread Andy Lee

On Jul 27, 2009, at 2:22 AM, Andy Lee wrote:
I guess I'd ask the question we often ask about coding questions:  
What are you really trying to do?  It sounds like the problem is  
that Windows users accustomed to MDI get visually confused by  
multiple windows from different apps overlapping each other willy- 
nilly.  One simple solution to that is Command-Option-H to hide all  
other apps; there's even a utility out there that will do this for  
you automatically when you switch apps.  There are also utility apps  
that place a dark gray background between your app's windows and all  
other apps' windows.


And of course there's also Spaces.

--Andy


___

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: Views in CDBA's

2009-07-26 Thread Kyle Sluder
On Jul 26, 2009, at 10:44 PM, David Blanton   
wrote:


I dragged a Scroll View from the LIbrary Objects Tab to the Window  
defined in MyDocument.xib.


All of my content to be displayed here will be bit maps.


Well that's a bit of a tautology considering it's all going to be  
rendered into the window's backing store, which is a bitmap.



So .. do I


I'm assuming you're describing a procedure here, not laying out a set  
of options? That's how I'm interpreting it.



1.  make a view, store in this nib.


"Make a view" is a bit vague. Again assuming, this time that you're  
referring to "subclass NSView." In that case yes, but I don't know  
what "store in this nib" means.



2. Render my bit map to this view.


Yes. Typically this will happen in -drawRect:. You will probably be  
drawing NSBitmapImageReps here.



3. Set the document view of the scroll view to this view.


This is why I was confused about "store Im this nib" above. When you  
drag a scroll view in from the Library, it has a custom view inside of  
it, set up as the scroll view's document view. You can use the  
Identity inspector to change it's class to that which you created in  
step 1.


--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: Cocoa Document-Based App v. Windows MDI App

2009-07-26 Thread Jeff Biggus

On Jul 27, 2009, at 1:24 AM, Andrew Farmer wrote:

Check out PSMTabBar. Turns a standard NSTabView into a "Safari- 
style" tab view, with tabs on any side you want - including all the  
tricky functionality like draggable tabs.


Wow, that's great.


In reference to what to say to the Windows programmers, I'll give them  
the benefit of the doubt (assuming they aren't just harassing David  
for the sheer fun of it) that they just want to clean up what may be a  
clutter of multiple documents that show up on screen in the current  
version of the Mac implementation of their app. (I have no idea what  
the app is or does, so I'll presume this to be the case.) In which  
case they're probably just asking for the entirely reasonable request  
to consolidate the document windows. (I'll even grant them that  
relying and Exposé and/or Spaces isn't an elegant solution, as was the  
case with Safari before tabs.)


Entirely doable via several methods without having to have any foreign  
Windows GUI ideas invade a nice Cocoa app.


jeff___

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