Re: NSSavePanel does replace / in the filename with a :

2010-10-18 Thread Thorsten Lemke
Hi,
 
Ah - I convert the : now manually to a / for the following File Manger Calls
(not Cocoa). That does it.

Thorsten
> 
>> The problem is: 
>> I enter as name i.e.: Part 1/2.jpg into the save panel.
>> I click on ok.
>> I get as filename in the code: "Part 1:2.jpg".
>> 
>> So, how can I avoid this?
> 
> You don't avoid it.  You don't want to.
> 
> The *user-visible* file name is "Part 1/2.jpg".
> 
> The correct *internal representation* of that file name is "Part 1:2.jpg".
> 
> There's no reason for the internal representation to be the same as the
> user-visible name.  You shouldn't care what the internal representation is.
> And the user should never see it.  When you need to present a file name to the
> user, you use the methods I mentioned previously to obtain the appropriate
> user-visible display name.  But other than that, you should be working with
> the internal representation.
> 
> Regards,
> Ken
> 


___

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

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

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

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


Re: NSSavePanel does replace / in the filename with a :

2010-10-18 Thread Uli Kusterer
On 18.10.2010, at 09:54, Thorsten Lemke wrote:
> Ah - I convert the : now manually to a / for the following File Manger Calls
> (not Cocoa). That does it.

 What are you doing? Are you trying to read old preferences that contain Carbon 
paths? This should *not* be necessary.

-> If you're displaying file names to the user, use displayNameAtPath:. Not 
only does it substitute slashes for colons as needed, it also honors hidden 
file extensions, and shows localized names for folders on non-English operating 
systems. And componentsToDisplayForPath: will correctly add the hard disk name 
at the start, or remove /Volumes, just like the Finder does.

-> If you're accessing files, you can simply pass this "wrong" path with the 
colon in it to any POSIX or Cocoa call and it'll work.

-> If you're converting between POSIX/Cocoa paths and CoreServices file manager 
paths, use the existing conversion calls. CFURLRef includes some neat methods 
to let you convert between both kinds of paths. In any case, Apple's 
recommended format handling file paths is CFURLRef/NSURL*. Speaking in Carbon 
terms, that class wraps information not unlike an FSRef inside it, so it's a 
much faster and more efficient way of storing file references than paths (at 
least on 10.6 and later, where this actually got implemented). You can even get 
back alias-like data for storing on disk by grabbing the "bookmark data" from a 
NSURL.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de

___

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

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

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

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


Re: remove icon from Dock

2010-10-18 Thread Uli Kusterer
On Oct 13, 2010, at 5:57 AM, Kyle Sluder wrote:
> Meanwhile, iWork 09's installer does this very thing. It adds its
> icons to the dock and then quits it.

 Quod licet Iovi, non licet bovi.

 'nuff said.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."



___

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

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


Image Resolution

2010-10-18 Thread Amy Heavey

Hi,

I've got an app that generates composite images, so it places images  
onto a single canvas and saves that as a new image. It's working fine,  
but I'm struggling with the resolutions/representations issue.


The source images are not generated by us, they are from a variety of  
surces, and are generally 200pixels + on each side, however sometimes  
they are 72 dpi, and sometimes they are 300dpi. Even if an aimage is  
450pixels square, when it is set as 300 dpi it's reduced too small  
when my app reduces it it to fit a 75pixel square area.


I know this is to do with the bitmapRepresentation, but I can't work  
out how to change it. If I was doing this in photoshop I'd be keeping  
the actual pixel count, but changing the resolution from 300 to 72 for  
these images.


Can anyone point me in the right direction?  Here's the code I'm using  
at the moment:


while ((imgPath = [imageLoop nextObject])) {
NSImage *img = [[NSImage alloc]initWithContentsOfFile:imgPath];
[targetImage lockFocus];

		[img drawInRect:NSMakeRect(x,y,75,75) fromRect:NSMakeRect(20,20,0,0)  
operation:NSCompositeCopy fraction:1];



Thanks

Amy Heavey
___

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

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

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

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


NSArrayController making copies of my objects?

2010-10-18 Thread Trygve Inda
I am trying to figure out exactly what is happening here.

I have a mutable dictionary where each object is also an NSMutableDictionay
containing 9 string objects.

NSMutableDictionary*  myData;// this is in MyController object.

In a window, I have an NSTableView whose column data is tied to an
NSArrayController. The NSArrayController is bound to myData with IB:

Bind to MyController, keypath: myda...@allvalues

This all works fine, except

I would expect the following to have the same addresses:

NSMutableDictionary*myItemA =
[[[MyController myData] allValues] objectAtIndex:0];

NSMutableDictionary*   arrayContItemA =
[[myArrayController arrangedObjects] objectAtIndex:0];

The content is the same (the 9 strings) so it is coming from the right
place, but the addresses of the objects are different so for some reason the
NSArrayController is making a copy of my dictionary object somewhere along
the line.

I understand that the array returned by allValues is not mutable so the
NSArrayController may need to make a mutable copy of it, but the internal
objects are mutable... So why is it copying my objects?

If I add the following just before the above two lines, then the objects
have the same address as expected.

[MyController willChangeValueForKey:@"myData"];
[MyController didChangeValueForKey:@"myData"];

So I gather this is forcing the NSArrayController to write it's
copied/cached values back to myData.

The point is that I need to be able to edit the items in the NSTable, then
write myData back to disk and have the changes be saved. If I never call
will/didChangeValueForKey, then the changes are lost.

Since I am not changing myData directly but it is being changed by the
NSTableView and NSArrayController, why does this happen this way?

Thanks,

Trygve


___

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

Please do not post admin requests or moderator comments to the list.
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: Codesign additional items within an app bundle

2010-10-18 Thread Jerry Krinock

On 2010 Oct 17, at 07:53, Michael Diehr wrote:

> Taking my first stab at codesigning an OS X App, and I'm noticing that only 
> some items within the app bundle get signed

Didn't read all of your message, but looks like you probably need the same 
answer I got last year…

http://lists.apple.com/archives/Apple-cdsa/2009/May/msg00031.html

Also, you've got the wrong mailing list for this question.  Post any further 
discussion to Apple CDSA .

___

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

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


CMYK Text of Photoshop Layer rendered incorrectly

2010-10-18 Thread Peter Krajčík
Hi,
 
I am reading Photoshop layer images using this approach:
 
(simplified code)
 
for (i=0; i <= imageCount; i++)
{
unsigned long offset, size;
GraphicsImportSetImageIndex(importer, i);
GraphicsImportGetDataOffsetAndSize(importer, &offset, &size);
 
// create a Graphics Exporter component that will write Photoshop data
OSErr err = 
OpenADefaultComponent(GraphicsExporterComponentType,kQTFileTypePhotoShop, 
&exporter);
 
if (err == noErr)
{
 // set export parameters
 Handle bmpDataH = NewHandle(0);
 GraphicsExportSetInputGraphicsImporter(exporter, importer);
 GraphicsExportSetOutputHandle(exporter, bmpDataH);
 
 // export data to BMP into handle
 unsigned long actualSizeWritten = 0;
 err = GraphicsExportDoExport(exporter, &actualSizeWritten);
 
  if (err == noErr)
  {
 
   HLock(bmpDataH);
 
   //create a simple image with the tiff data, without the bound 
information, its rep will stored to layer as CGImageRef
   id image = [CIImage imageWithData:[NSData 
dataWithBytes:*bmpDataHlength:GetHandleSize(bmpDataH)]];
   NSBitmapImageRep* rep = [[[NSBitmapImageRep alloc] 
initWithCIImage:image]autorelease];
 
   CGImageRef imageRef = rep.CGImage;
   self.layerImage =CGImageRetain(imageRef);
   HUnlock(bmpDataH);
 }
 
 DisposeHandle(bmpDataH);
 CloseComponent(exporter);
 }
 
}
 
It works as expected, but when I open a psd file that has layers with TEXT (not 
rendered) and in CMYK color space, it looks like alpha channel of such layer is 
igonred and I'm getting a black rect instead (with text on top of it).
 
I have read in some old post (2005) that is is a bug in Apple importer. 
The fact is that I didn't find other way how to read in images from psd files.
 
A. Is there any tip how to fix the CMYK-TEXT alpha problem I described ?
B. Is there any other way how to read photoshop layer images ?
 
Thank you.
 
Peter___

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

Please do not post admin requests or moderator comments to the list.
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: CMYK Text of Photoshop Layer rendered incorrectly

2010-10-18 Thread Thorsten Lemke
Hi Peter,

I suggest to use the Core Image Import:
CGImageSourceRef imageSource =
CGImageSourceCreateWithURL((CFURLRef)[NSURL fileURLWithPath:path],
NULL);


That does handle CMYK, too.

Thorsten


> Von: Peter Krajčík 
> Datum: Mon, 18 Oct 2010 14:53:10 +0200
> An: 
> Betreff: CMYK Text of Photoshop Layer rendered incorrectly
> 
> Hi,
>  
> I am reading Photoshop layer images using this approach:
>  
> (simplified code)
>  
> for (i=0; i <= imageCount; i++)
> {
> unsigned long offset, size;
> GraphicsImportSetImageIndex(importer, i);
> GraphicsImportGetDataOffsetAndSize(importer, &offset, &size);
>  
> // create a Graphics Exporter component that will write Photoshop data
> OSErr err = 
> OpenADefaultComponent(GraphicsExporterComponentType,kQTFileTypePhotoShop,
> &exporter);
>  
> if (err == noErr)
> {
>  // set export parameters
>  Handle bmpDataH = NewHandle(0);
>  GraphicsExportSetInputGraphicsImporter(exporter, importer);
>  GraphicsExportSetOutputHandle(exporter, bmpDataH);
>  
>  // export data to BMP into handle
>  unsigned long actualSizeWritten = 0;
>  err = GraphicsExportDoExport(exporter, &actualSizeWritten);
>  
>   if (err == noErr)
>   {
>  
>HLock(bmpDataH);
>  
>//create a simple image with the tiff data, without the bound
> information, its rep will stored to layer as CGImageRef
>id image = [CIImage imageWithData:[NSData
> dataWithBytes:*bmpDataHlength:GetHandleSize(bmpDataH)]];
>NSBitmapImageRep* rep = [[[NSBitmapImageRep alloc]
> initWithCIImage:image]autorelease];
>  
>CGImageRef imageRef = rep.CGImage;
>self.layerImage =CGImageRetain(imageRef);
>HUnlock(bmpDataH);
>  }
>  
>  DisposeHandle(bmpDataH);
>  CloseComponent(exporter);
>  }
>  
> }


___

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

Please do not post admin requests or moderator comments to the list.
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: Heapshot Analysis to find Memory Accretion (Leaks)

2010-10-18 Thread Roland King
To my Cocoa Keepers file. 

Bill thank you very much, I didn't know what Heapshot did and what the output 
meant. Now I do. 



On 18-Oct-2010, at 11:52 AM, Bill Bumgarner wrote:

> Folks--
> 
>   I wrote up an article on how to use the "Mark Heap" / "Heapshot 
> Analysis" tools in Instruments to detect, analyze, and fix memory leaks, 
> including those that leaks can't find.
> 
>   
> http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/
> 
>   I would encourage everyone to give it a spin with your app.  If it is 
> document based, then:
> 
>   - launch your app under Instruments with the Allocations Instrument
>   - (1) open a document
>   - select a thing, copy, paste
>   - close the document (without saving)
>   - press Mark Heap in Instruments
>   - goto (1)
> 
> Ideally, each "Heapshot" iteration should show 0 growth in almost all cases.
> 
> enjoy,
> 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/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


Re: [Q] Using NSInvocation vs. selector with NSTimer

2010-10-18 Thread JongAm Park

 On 10/17/2010 4:11 PM, Joar Wingfors wrote:

On 17 okt 2010, at 15.51, JongAm Park wrote:


Although I know that NSInvocation was added (from Leopard?), I didn't use it 
much.


NSInvocation predates Mac OS X...



Oh. right. I forgot that.


Is there any benefit in using it? My guess is that an NSInvocation instance is used 
repeatedly, but using the "selector" based method is not inconvenient for the 
most of cases.
Is there any other benefit in using the NSInvocation?


NSInvocation is a very flexible class, and can be used for a wide variety of 
tasks, but it is also (therefore) more cumbersome to setup and use for the 
simpler things that you mention. It is not often used, so if you don't know 
that you need it, you probably don't.


j o a r



Well, what I asked actually is about the design philosophy and what the 
intention of creating of that was. Your last statement can't fulfill my 
curiosity. :)


Thanks anyway to spare your time to answer my question.

--
--
子曰 不而不改 是謂過矣니라
공자께서 말씀하시길, 잘못을 하고도 고치지 않는 것, 그것을 잘못이라 한다.
  - 論語<  衛 靈 公>편

JongAm Park
jongamp...@sbcglobal.net
Visit my personal blog at http://jongampark.blogspot.com
Visit my technical blog at http://jongampark.wordpress.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 allValues not mutable

2010-10-18 Thread Trygve Inda
 
> So if the master dictionary and the array for the NSTable are
> encapsulated together in a class, you could use NSMutableArray as the
> primary structure, and encapsulate a hidden NSMutableDictionary used
> only for faster searching.  Both are maintained in parallel by the
> enclosing class, so there's never any need to ask the dictionary for
> its array of values, nor to copy an immutable array to make a mutable
> version for table insertion.  In short, make a class that
> encapsulates all the desired behavior by itself, rather than using a
> naked dictionary and the supplementary arrays it makes.

How would I go about doing this and still bind to my NSArrayController?

I'd have a (singleton) class MyDataClass with two instance vars: myArray and
myDictionary both of which would hold the same objects and both would be
mutable.

So when I bind the NSArrayController to myArray, and the user adds an item
via the table (and thusly the add: of NSArrayController), how will my class
know that it needs to also add it to the myDictionary?

Thanks,

T.


___

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

Please do not post admin requests or moderator comments to the list.
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: NSSavePanel does replace / in the filename with a :

2010-10-18 Thread Ken Thomases
On Oct 18, 2010, at 3:20 AM, Uli Kusterer wrote:

> -> If you're converting between POSIX/Cocoa paths and CoreServices file 
> manager paths, use the existing conversion calls. CFURLRef includes some neat 
> methods to let you convert between both kinds of paths. In any case, Apple's 
> recommended format handling file paths is CFURLRef/NSURL*. Speaking in Carbon 
> terms, that class wraps information not unlike an FSRef inside it, so it's a 
> much faster and more efficient way of storing file references than paths (at 
> least on 10.6 and later, where this actually got implemented). You can even 
> get back alias-like data for storing on disk by grabbing the "bookmark data" 
> from a NSURL.

And if you're working with APIs which take FSRefs, take a look at 
FSPathMakeRef[WithOptions].  (CFURL can perform this same conversion, but it 
takes a couple of steps.)

Regards,
Ken

___

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

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

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

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


[Distant Objects] Problem passing custom objects bycopy

2010-10-18 Thread Oleg Krupnov
Hi,

I have a server and a client processes running on the same machine.
Per client request, the server does some job and returns the result to
the client in form of some MyObject.

This is the interface vended by the server:

- (out bycopy MyObject*)doSomeJob;

Despite bycopy, I see in debugger that instead of a copy, a proxy is returned.

Allright, I've read in this list that in order to make work, I also
need to override -replacementObjectForPortCoder: and I did this:

// in MyObject
- (id)replacementObjectForPortCoder:(NSPortCoder*)encoder
{
if ([encoder isBycopy])
{
 NSLog(@"replace by copy!!!")
return self;
}
return [super replacementObjectForPortCoder:encoder];
}

In this case, I see the "replace by copy!!!" string in the console,
but then the server process seems to hang and become unresponsive.
-[MyObject encodeWithCoder:] does not get called.

What am I doing wrong?

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: NSDictionary allValues not mutable

2010-10-18 Thread Ken Thomases
On Oct 18, 2010, at 10:22 AM, Trygve Inda wrote:

>> So if the master dictionary and the array for the NSTable are
>> encapsulated together in a class, you could use NSMutableArray as the
>> primary structure, and encapsulate a hidden NSMutableDictionary used
>> only for faster searching.  Both are maintained in parallel by the
>> enclosing class, so there's never any need to ask the dictionary for
>> its array of values, nor to copy an immutable array to make a mutable
>> version for table insertion.  In short, make a class that
>> encapsulates all the desired behavior by itself, rather than using a
>> naked dictionary and the supplementary arrays it makes.
> 
> How would I go about doing this and still bind to my NSArrayController?
> 
> I'd have a (singleton) class MyDataClass with two instance vars: myArray and
> myDictionary both of which would hold the same objects and both would be
> mutable.
> 
> So when I bind the NSArrayController to myArray, and the user adds an item
> via the table (and thusly the add: of NSArrayController), how will my class
> know that it needs to also add it to the myDictionary?

You are mistaking instance variables for properties.  Instance variables are 
implementation details, and nothing outside of your class should be aware of 
them.

Properties are part of your interface, essentially the accessor methods and 
their behavior.  (Remember that you can have properties that are not backed by 
instance variables.)

So, you should be thinking in terms of writing accessor methods which present a 
consistent view of the to-many relationship (which happens to be backed by an 
array and a dictionary).  Look up the indexed accessor pattern for to-many 
relationships in the KVC documentation 
.
  Also, take a look at "Managing a non-array collection, and filtering" on 
mmalc's page of Cocoa examples 
.

To keep yourself honest, and to help you learn, try making this to-many 
relationship property have a name completely different from the names of the 
instance variables which back it.  Also, I generally recommend that all of 
one's own classes should override +accessInstanceVariablesDirectly to return 
NO.  (I regard KVC's ability to bypass your interface and directly access your 
instance variables as A Bad Thing™.)

Regards,
Ken

___

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

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

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

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


Re: NSDictionary allValues not mutable

2010-10-18 Thread Trygve Inda
> On Oct 18, 2010, at 10:22 AM, Trygve Inda wrote:
> 
>>> So if the master dictionary and the array for the NSTable are
>>> encapsulated together in a class, you could use NSMutableArray as the
>>> primary structure, and encapsulate a hidden NSMutableDictionary used
>>> only for faster searching.  Both are maintained in parallel by the
>>> enclosing class, so there's never any need to ask the dictionary for
>>> its array of values, nor to copy an immutable array to make a mutable
>>> version for table insertion.  In short, make a class that
>>> encapsulates all the desired behavior by itself, rather than using a
>>> naked dictionary and the supplementary arrays it makes.
>> 
>> How would I go about doing this and still bind to my NSArrayController?
>> 
>> I'd have a (singleton) class MyDataClass with two instance vars: myArray and
>> myDictionary both of which would hold the same objects and both would be
>> mutable.
>> 
>> So when I bind the NSArrayController to myArray, and the user adds an item
>> via the table (and thusly the add: of NSArrayController), how will my class
>> know that it needs to also add it to the myDictionary?
> 
> You are mistaking instance variables for properties.  Instance variables are
> implementation details, and nothing outside of your class should be aware of
> them.
> 
> Properties are part of your interface, essentially the accessor methods and
> their behavior.  (Remember that you can have properties that are not backed by
> instance variables.)
> 
> So, you should be thinking in terms of writing accessor methods which present
> a consistent view of the to-many relationship (which happens to be backed by
> an array and a dictionary).  Look up the indexed accessor pattern for to-many
> relationships in the KVC documentation
>  eCoding/Concepts/AccessorConventions.html#//apple_ref/doc/uid/20002174-178830-
> BAJEDEFB>.  Also, take a look at "Managing a non-array collection, and
> filtering" on mmalc's page of Cocoa examples
> .
> 
> To keep yourself honest, and to help you learn, try making this to-many
> relationship property have a name completely different from the names of the
> instance variables which back it.  Also, I generally recommend that all of
> one's own classes should override +accessInstanceVariablesDirectly to return
> NO.  (I regard KVC's ability to bypass your interface and directly access your
> instance variables as A Bad Thing™.)

Yes, I meant properties...

I guess I am just not seeing how my NSArrayController would ties to this. So
I have a class MyDataClass and since my NSTableView is tied to an
NSArrayController, then the NSArrayController needs to get it's data from
MyDataClass.

So is there then a myArray property in MyDataClass that the
NSArrayController binds to?

Or does NSArrayController  somehow bind to a non-array property, but one
that responds as if it were an array?

Is there any sample code of this sort of set up?

T.


___

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

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

2010-10-18 Thread Trygve Inda
>> On Oct 18, 2010, at 10:22 AM, Trygve Inda wrote:
>> 
 So if the master dictionary and the array for the NSTable are
 encapsulated together in a class, you could use NSMutableArray as the
 primary structure, and encapsulate a hidden NSMutableDictionary used
 only for faster searching.  Both are maintained in parallel by the
 enclosing class, so there's never any need to ask the dictionary for
 its array of values, nor to copy an immutable array to make a mutable
 version for table insertion.  In short, make a class that
 encapsulates all the desired behavior by itself, rather than using a
 naked dictionary and the supplementary arrays it makes.
>>> 
>>> How would I go about doing this and still bind to my NSArrayController?
>>> 
>>> I'd have a (singleton) class MyDataClass with two instance vars: myArray and
>>> myDictionary both of which would hold the same objects and both would be
>>> mutable.
>>> 
>>> So when I bind the NSArrayController to myArray, and the user adds an item
>>> via the table (and thusly the add: of NSArrayController), how will my class
>>> know that it needs to also add it to the myDictionary?
>> 
>> You are mistaking instance variables for properties.  Instance variables are
>> implementation details, and nothing outside of your class should be aware of
>> them.
>> 
>> Properties are part of your interface, essentially the accessor methods and
>> their behavior.  (Remember that you can have properties that are not backed
>> by
>> instance variables.)
>> 
>> So, you should be thinking in terms of writing accessor methods which present
>> a consistent view of the to-many relationship (which happens to be backed by
>> an array and a dictionary).  Look up the indexed accessor pattern for to-many
>> relationships in the KVC documentation
>> 
>
u
>> 
eCoding/Concepts/AccessorConventions.html#//apple_ref/doc/uid/20002174-178830>>
-
>> BAJEDEFB>.  Also, take a look at "Managing a non-array collection, and
>> filtering" on mmalc's page of Cocoa examples
>> .
>> 
>> To keep yourself honest, and to help you learn, try making this to-many
>> relationship property have a name completely different from the names of the
>> instance variables which back it.  Also, I generally recommend that all of
>> one's own classes should override +accessInstanceVariablesDirectly to return
>> NO.  (I regard KVC's ability to bypass your interface and directly access
>> your
>> instance variables as A Bad Thing™.)
> 
> Yes, I meant properties...
> 
> I guess I am just not seeing how my NSArrayController would ties to this. So
> I have a class MyDataClass and since my NSTableView is tied to an
> NSArrayController, then the NSArrayController needs to get it's data from
> MyDataClass.
> 
> So is there then a myArray property in MyDataClass that the
> NSArrayController binds to?
> 
> Or does NSArrayController  somehow bind to a non-array property, but one
> that responds as if it were an array?
> 
> Is there any sample code of this sort of set up?

I was able to get the mmalc sample but even that shows the contents of the
NSArrayController being bound to a NSMutableArray... Not how to bind it to
some arbitrary class.

T.


___

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

Please do not post admin requests or moderator comments to the list.
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: [Q] Using NSInvocation vs. selector with NSTimer

2010-10-18 Thread Keary Suska
On Oct 18, 2010, at 9:00 AM, JongAm Park wrote:

>>> Is there any benefit in using it? My guess is that an NSInvocation instance 
>>> is used repeatedly, but using the "selector" based method is not 
>>> inconvenient for the most of cases.
>>> Is there any other benefit in using the NSInvocation?
>> 
>> NSInvocation is a very flexible class, and can be used for a wide variety of 
>> tasks, but it is also (therefore) more cumbersome to setup and use for the 
>> simpler things that you mention. It is not often used, so if you don't know 
>> that you need it, you probably don't.
> 
> Well, what I asked actually is about the design philosophy and what the 
> intention of creating of that was. Your last statement can't fulfill my 
> curiosity. :)

The common design use would be situations where the method you wish the timer 
to call requires additional data that would be passed as arguments. Essentially 
the point of using invocations is to permit the timer to call any method 
whatsoever, regardless of the method signature.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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

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

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

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


Re: Heapshot Analysis to find Memory Accretion (Leaks)

2010-10-18 Thread Bill Bumgarner

On Oct 18, 2010, at 8:42 AM, Matt Gough wrote:

> Perhaps Apple should aim Instruments at itself. Inspired by Bill's post, I 
> just did a HeapShot test on my own app. Instruments went up to 2.5GB real Mem 
> and stayed at that when I closed the Instrument window.

"2.5GB Real Mem" is relatively meaningless.   Furthermore, it is quite 
reasonable for it to not drop after you close all windows as the system isn't 
going to spend the cycles reaping memory unless there is demand for it.

Activity Monitor -- assuming that is where you got the "Real Mem" number -- is 
pretty much entirely useless for doing any kind of performance testing beyond 
monitoring for the most basic symptom of a problem.

If you see the "Real Mem" of an application climbing over time, that is a bad 
sign.  Maybe.   Beyond that, the number isn't useful.

'top' tends to be a much better tool for detecting such symptoms.   Open a 
Terminal window and issue the command "top -u -o pid".   It display something 
akin to Activity Monitor, but with the numbers broken down a bit more and a 
more detailed systemic summary.  It also uses less resources than AM in that it 
doesn't try to draw a picture.

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: [Q] Using NSInvocation vs. selector with NSTimer

2010-10-18 Thread JongAm Park

 On 10/18/2010 9:45 AM, Keary Suska wrote:

On Oct 18, 2010, at 9:00 AM, JongAm Park wrote:


Is there any benefit in using it? My guess is that an NSInvocation instance is used 
repeatedly, but using the "selector" based method is not inconvenient for the 
most of cases.
Is there any other benefit in using the NSInvocation?

NSInvocation is a very flexible class, and can be used for a wide variety of 
tasks, but it is also (therefore) more cumbersome to setup and use for the 
simpler things that you mention. It is not often used, so if you don't know 
that you need it, you probably don't.

Well, what I asked actually is about the design philosophy and what the 
intention of creating of that was. Your last statement can't fulfill my 
curiosity. :)

The common design use would be situations where the method you wish the timer 
to call requires additional data that would be passed as arguments. Essentially 
the point of using invocations is to permit the timer to call any method 
whatsoever, regardless of the method signature.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"



Thank you. So, it is about decoupling..


--
--
子曰 不而不改 是謂過矣니라
공자께서 말씀하시길, 잘못을 하고도 고치지 않는 것, 그것을 잘못이라 한다.
  - 論語<  衛 靈 公>편

JongAm Park
jongamp...@sbcglobal.net
Visit my personal blog at http://jongampark.blogspot.com
Visit my technical blog at http://jongampark.wordpress.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


AM/PM letter UNICODE issues

2010-10-18 Thread Alex Kac
I'm fairly certain my problem here is that I wasn't thinking about unicode 
terms here. 

What we are trying to do:
Shorten the AM/PM to just the first character in Western Languages so that a 
time is shown as "1:30a". 

NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
NSString* am = [[[formatter AMSymbol] substringToIndex:1] 
lowercaseString];
NSString* pm = [[[formatter PMSymbol] substringToIndex:1] 
lowercaseString];


This works in Western languages just fine. However in languages like Korean it 
does not work giving a random character seemingly. From reading on this list 
over time I believe its because I'm just getting one part of a multi-part 
character (I'm no good with unicode terms sorry). 

My guess is I need to use rangeOfComposedCharacterSequenceAtIndex and then get 
the range and use a substring with that range. But I'm not sure since my 
knowledge here is pretty limited. Would love some direction. 
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


NSOperation completionBlock not executed

2010-10-18 Thread ico
Hi all,

The block code set by the NSOperation setCompletionBlock: should be executed
automatically
or manually after the NSOperation object finished its task?
I thought it should be automatically and my block code is not executed.
Thanks.

-- 
==
Life isn't about finding yourself.
Life is about creating yourself.
___

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

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

2010-10-18 Thread Greg Guerin

Trygve Inda wrote:

Or does NSArrayController  somehow bind to a non-array property,  
but one

that responds as if it were an array?



Later in my original post, I suggested subclassing NSMutableArray, so  
it can bind to NSArrayController.  Your new class, i.e. MyDataClass,  
doesn't just respond *as if* it were an array, it *is* an actual  
subclass of NSMutableArray, albeit a specialized one.  The visible  
relationship between MyDataClass and NSMutableArray is *is-a*, not  
*has-a*.


Internally, MyDataClass keeps both an NSMutableArray (to provide the  
array behavior), and an NSMutableDictionary for fast searching.  You  
need to override the minimal methods of any NSMutableArray subclass,  
so it essentially forwards to the internal array.  You also override  
the add/remove methods so objects are added/removed from both the  
internal array and the internal dictionay.  You then override any of  
the find or search methods to use the internal dictionary.  Or you  
can add new methods that perform this fast search, and call those  
when you need fast search as distinct from linear search (a formal  
protocol is optional).


If you have a singleton class whose method you bind to, it could be  
declared as returning NSMutableArray, but it would actually return an  
instance of MyDataClass, i.e. your search-enhanced subclass of  
NSMutableArray.  In other words, you arrange the classes and bindings  
so NSArrayController gets an instance of your specialized data- 
container, instead of an instance of a generic array container.


The singleton whose method you bind to can be another class, or it  
can be an instance of MyDataClass itself.  In the latter case, the  
binded method simply returns self.


  -- 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: NSDictionary allValues not mutable

2010-10-18 Thread Ken Thomases
On Oct 18, 2010, at 10:59 AM, Trygve Inda wrote:

> I guess I am just not seeing how my NSArrayController would ties to this. So
> I have a class MyDataClass and since my NSTableView is tied to an
> NSArrayController, then the NSArrayController needs to get it's data from
> MyDataClass.
> 
> So is there then a myArray property in MyDataClass that the
> NSArrayController binds to?
> 
> Or does NSArrayController  somehow bind to a non-array property, but one
> that responds as if it were an array?

A property implemented in terms of the indexed accessor methods is appropriate 
for binding an NSArrayController's contentArray to.  And, if you must think of 
properties as "array" vs "non-array", then such a property is an array 
property.  It is more precisely called an indexed to-many relationship or an 
indexed collection.  (In particular, there's no reason to expect an NSArray* to 
be part of its interface.)

Regards,
Ken

___

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

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

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

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


Re: AM/PM letter UNICODE issues

2010-10-18 Thread glenn andreas

On Oct 18, 2010, at 12:19 PM, Alex Kac wrote:

> I'm fairly certain my problem here is that I wasn't thinking about unicode 
> terms here. 
> 
> What we are trying to do:
> Shorten the AM/PM to just the first character in Western Languages so that a 
> time is shown as "1:30a". 
> 
>   NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
>   NSString* am = [[[formatter AMSymbol] substringToIndex:1] 
> lowercaseString];
>   NSString* pm = [[[formatter PMSymbol] substringToIndex:1] 
> lowercaseString];
> 
> 
> This works in Western languages just fine.

Not sure that this is even true - in Germany, time is displayed normally using 
a "24 hour" notation (no AM/PM), and this true in many other locations as well. 
 See  for all 
sorts of other gory details and special cases.  Even for US cases, there are 
people who set their time format to use 24 hour time and so would expect to see 
"13:00" and not "1:00p".

Bottom line is trying to display time in a non-standard format is going to be 
problematic and have support issues.


Glenn Andreas  gandr...@gandreas.com 
The most merciful thing in the world ... is the inability of the human mind to 
correlate all its contents - HPL

___

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

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

2010-10-18 Thread Trygve Inda
> On Oct 18, 2010, at 10:59 AM, Trygve Inda wrote:
> 
>> I guess I am just not seeing how my NSArrayController would ties to this. So
>> I have a class MyDataClass and since my NSTableView is tied to an
>> NSArrayController, then the NSArrayController needs to get it's data from
>> MyDataClass.
>> 
>> So is there then a myArray property in MyDataClass that the
>> NSArrayController binds to?
>> 
>> Or does NSArrayController  somehow bind to a non-array property, but one
>> that responds as if it were an array?
> 
> A property implemented in terms of the indexed accessor methods is appropriate
> for binding an NSArrayController's contentArray to.  And, if you must think of
> properties as "array" vs "non-array", then such a property is an array
> property.  It is more precisely called an indexed to-many relationship or an
> indexed collection.  (In particular, there's no reason to expect an NSArray*
> to be part of its interface.)
> 
> Regards,
> Ken

So would you do something like the example you described:

http://homepage.mac.com/mmalc/CocoaExamples/controllers.html

Where the NSArrayController is bound not to an array at all but to a
property which responds to the proper indexed to-many messages...

Or a subclass of NSMutableArray as Greg suggested?

My array will rarely be edited (but needs to be mutable), but needs to be
searchable by key (for which instead of a keyed dictionary kept in tandem
with the array, I could just use a predicate filter on the array).

Each dictionary (or object with properties) will need to hold roughly 9
textual strings, and there will be on the order of 10,000 objects in the
array. I am guessing that dictionary will perform better than a predicate
filter given the number of objects.

Trygve



___

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

Please do not post admin requests or moderator comments to the list.
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: AM/PM letter UNICODE issues

2010-10-18 Thread A.M.

On Oct 18, 2010, at 2:41 PM, glenn andreas wrote:

> 
> On Oct 18, 2010, at 12:19 PM, Alex Kac wrote:
> 
>> I'm fairly certain my problem here is that I wasn't thinking about unicode 
>> terms here. 
>> 
>> What we are trying to do:
>> Shorten the AM/PM to just the first character in Western Languages so that a 
>> time is shown as "1:30a". 
>> 
>>  NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
>>  NSString* am = [[[formatter AMSymbol] substringToIndex:1] 
>> lowercaseString];
>>  NSString* pm = [[[formatter PMSymbol] substringToIndex:1] 
>> lowercaseString];
>> 
>> 
>> This works in Western languages just fine.
> 
> Not sure that this is even true - in Germany, time is displayed normally 
> using a "24 hour" notation (no AM/PM), and this true in many other locations 
> as well.  See 
>  for all 
> sorts of other gory details and special cases.  Even for US cases, there are 
> people who set their time format to use 24 hour time and so would expect to 
> see "13:00" and not "1:00p".
> 
> Bottom line is trying to display time in a non-standard format is going to be 
> problematic and have support issues.

In addition to this, some languages have no notion of individual characters or 
words, so trying to automatically abbreviate AMSymbol is a non-starter. The 
only way to accomplish this would be via localization.

Cheers,
M___

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

Please do not post admin requests or moderator comments to the list.
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: AM/PM letter UNICODE issues

2010-10-18 Thread Quincey Morris
On Oct 18, 2010, at 10:19, Alex Kac wrote:

> What we are trying to do:
> Shorten the AM/PM to just the first character in Western Languages so that a 
> time is shown as "1:30a". 
> 
>   NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
>   NSString* am = [[[formatter AMSymbol] substringToIndex:1] 
> lowercaseString];
>   NSString* pm = [[[formatter PMSymbol] substringToIndex:1] 
> lowercaseString];
> 
> 
> This works in Western languages just fine. However in languages like Korean 
> it does not work giving a random character seemingly. From reading on this 
> list over time I believe its because I'm just getting one part of a 
> multi-part character (I'm no good with unicode terms sorry). 
> 
> My guess is I need to use rangeOfComposedCharacterSequenceAtIndex and then 
> get the range and use a substring with that range. But I'm not sure since my 
> knowledge here is pretty limited.

This description seems pretty good (and short):


http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/stringsClusters.html

Basically, there are several nested levels of complexity:

1. UTF-16 units (which are the 16 bit values that are indexed by NSString's 
'...AtIndex:' methods)

2. Unicode code points (which are UTF-16 units or surrogate pairs of UTF-16 
units)

3. Composed characters (such as accented characters) made up of pairs of 
Unicode code points

4. Grapheme clusters, which are sequences of Unicode code points representing 
things that are written as a single unit (in some sense, depending on the 
language)

5. Related character sequences (I don't know there's an official name for this) 
such as German 'ß' and 'SS' that figure into algorithms for sorting and case 
changing.

According to the above-linked page, #3 and #4 aren't really different.

Also according to the above-linked page, 
'rangeOfComposedCharacterSequenceAtIndex:' does sound like the method to use. 

It's not obvious that taking the first grapheme is going to be semantically 
meaningful in every language (for example, if the English abbreviations 
happened to be MA and MP, taking the first grapheme wouldn't help you -- the 
assumption that the first character distinguishes the time range is not 
necessarily valid across all languages), but at least it's not going to give 
you an unrelated character.


___

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

Please do not post admin requests or moderator comments to the list.
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: AM/PM letter UNICODE issues

2010-10-18 Thread Alex Kac
Yes, we already take care of the 24 hour situation. This is explicitly for 
people who are showing their times using AM/PM. Not that its an iron-clad thing 
either, but we've been doing calendaring for over 10 years now so I'm aware of 
the date/time notation by country. But again this is explicitly for users who 
are showing their times in AM/PM.

On Oct 18, 2010, at 1:41 PM, glenn andreas wrote:

> 
> On Oct 18, 2010, at 12:19 PM, Alex Kac wrote:
> 
>> I'm fairly certain my problem here is that I wasn't thinking about unicode 
>> terms here. 
>> 
>> What we are trying to do:
>> Shorten the AM/PM to just the first character in Western Languages so that a 
>> time is shown as "1:30a". 
>> 
>>  NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
>>  NSString* am = [[[formatter AMSymbol] substringToIndex:1] 
>> lowercaseString];
>>  NSString* pm = [[[formatter PMSymbol] substringToIndex:1] 
>> lowercaseString];
>> 
>> 
>> This works in Western languages just fine.
> 
> Not sure that this is even true - in Germany, time is displayed normally 
> using a "24 hour" notation (no AM/PM), and this true in many other locations 
> as well.  See 
>  for all 
> sorts of other gory details and special cases.  Even for US cases, there are 
> people who set their time format to use 24 hour time and so would expect to 
> see "13:00" and not "1:00p".
> 
> Bottom line is trying to display time in a non-standard format is going to be 
> problematic and have support issues.
> 
> 
> Glenn Andreas  gandr...@gandreas.com 
> The most merciful thing in the world ... is the inability of the human mind 
> to correlate all its contents - HPL
> 

Alex Kac - President and Founder
Web Information Solutions, Inc.

"There will always be death and taxes; however, death doesn't get worse every 
year."
-- Anonymous




___

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

Please do not post admin requests or moderator comments to the list.
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: AM/PM letter UNICODE issues

2010-10-18 Thread Alex Kac
Right - some don't. We do take care of those situations. But many do and its 
nice to get that from OS itself.

On Oct 18, 2010, at 1:48 PM, A.M. wrote:

> 
> On Oct 18, 2010, at 2:41 PM, glenn andreas wrote:
> 
>> 
>> On Oct 18, 2010, at 12:19 PM, Alex Kac wrote:
>> 
>>> I'm fairly certain my problem here is that I wasn't thinking about unicode 
>>> terms here. 
>>> 
>>> What we are trying to do:
>>> Shorten the AM/PM to just the first character in Western Languages so that 
>>> a time is shown as "1:30a". 
>>> 
>>> NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
>>> NSString* am = [[[formatter AMSymbol] substringToIndex:1] 
>>> lowercaseString];
>>> NSString* pm = [[[formatter PMSymbol] substringToIndex:1] 
>>> lowercaseString];
>>> 
>>> 
>>> This works in Western languages just fine.
>> 
>> Not sure that this is even true - in Germany, time is displayed normally 
>> using a "24 hour" notation (no AM/PM), and this true in many other locations 
>> as well.  See 
>>  for all 
>> sorts of other gory details and special cases.  Even for US cases, there are 
>> people who set their time format to use 24 hour time and so would expect to 
>> see "13:00" and not "1:00p".
>> 
>> Bottom line is trying to display time in a non-standard format is going to 
>> be problematic and have support issues.
> 
> In addition to this, some languages have no notion of individual characters 
> or words, so trying to automatically abbreviate AMSymbol is a non-starter. 
> The only way to accomplish this would be via localization.
> 
> Cheers,
> M___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/alex%40webis.net
> 
> This email sent to a...@webis.net

Alex Kac - President and Founder
Web Information Solutions, Inc.

"The person who is not hungry says that the coconut has a hard shell."
-- African Tribal Saying






___

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

Please do not post admin requests or moderator comments to the list.
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: AM/PM letter UNICODE issues

2010-10-18 Thread Alex Kac
Right, our goal is not to make this a universal solution. Just one for the 
languages we know and support. Thanks. Appreciate the help.

On Oct 18, 2010, at 1:47 PM, Quincey Morris wrote:

> It's not obvious that taking the first grapheme is going to be semantically 
> meaningful in every language (for example, if the English abbreviations 
> happened to be MA and MP, taking the first grapheme wouldn't help you -- the 
> assumption that the first character distinguishes the time range is not 
> necessarily valid across all languages), but at least it's not going to give 
> you an unrelated character.

Alex Kac - President and Founder
Web Information Solutions, Inc. 

"If at first you don't succeed, skydiving is not for you."
-- Francis Roberts





___

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

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

2010-10-18 Thread Quincey Morris
On Oct 18, 2010, at 04:37, Amy Heavey wrote:

> The source images are not generated by us, they are from a variety of surces, 
> and are generally 200pixels + on each side, however sometimes they are 72 
> dpi, and sometimes they are 300dpi. Even if an aimage is 450pixels square, 
> when it is set as 300 dpi it's reduced too small when my app reduces it it to 
> fit a 75pixel square area.
> 
> I know this is to do with the bitmapRepresentation, but I can't work out how 
> to change it. If I was doing this in photoshop I'd be keeping the actual 
> pixel count, but changing the resolution from 300 to 72 for these images.
> 
> Can anyone point me in the right direction?  Here's the code I'm using at the 
> moment:
> 
> while ((imgPath = [imageLoop nextObject])) {
>   NSImage *img = [[NSImage alloc]initWithContentsOfFile:imgPath];
>   [targetImage lockFocus];
> 
>   [img drawInRect:NSMakeRect(x,y,75,75) 
> fromRect:NSMakeRect(20,20,0,0) operation:NSCompositeCopy fraction:1];

What does "too small" mean? Are you saying that your original image is being 
drawn somewhere inside your 75-pixel square, failing to fill it completely?

Also, I don't understand the intended significance of your 
'fromRect:NSMakeRect(20,20,0,0)' parameter. This should either be the part of 
the original image you want to transfer to the destination, or NSZeroRect to 
copy the whole thing.

If you're copying the whole image, I can't see that the "resolution" (in the 
sense of "dpi") has any significance to 'drawInRect:...'. It really only comes 
into play when relating the absolute (in points) size of two different images 
or contexts. You can always adjust the (effective) resolution of a NSImage by 
calling 'setSize:' with the absolute size you want. This does not change the 
pixel size of the underlying representation.


___

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

Please do not post admin requests or moderator comments to the list.
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: AM/PM letter UNICODE issues

2010-10-18 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/18/10 10:19 AM, Alex Kac wrote:
> This works in Western languages just fine. However in languages like
> Korean it does not work giving a random character seemingly. From
> reading on this list over time I believe its because I'm just getting
> one part of a multi-part character (I'm no good with unicode terms
> sorry).

As others have noted, you are likely to run into other problems with
exotic configurations.

I don't recall if it contains anything that will be directly pertinent
to your task, but I highly recommend you watch the "Internationalizing
Data" session video from WWDC 2010.  Even if it doesn't have the
specifics you are looking for, you will probably find it eye-opening.

The upshot of it is: the world is complicated, let the operating system
and AppKit/UIKit handle things for you.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFMvJhQaOlrz5+0JdURAm1wAJ9apqiVTA6amnsNWyN5aPhg9UWJeACeKy+I
FIocw+q416flQgP0JkHl8vg=
=uIeG
-END PGP 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: NSArrayController making copies of my objects?

2010-10-18 Thread Quincey Morris
On Oct 18, 2010, at 04:43, Trygve Inda wrote:

> I understand that the array returned by allValues is not mutable so the
> NSArrayController may need to make a mutable copy of it, but the internal
> objects are mutable... So why is it copying my objects?
> 
> If I add the following just before the above two lines, then the objects
> have the same address as expected.
> 
> [MyController willChangeValueForKey:@"myData"];
> [MyController didChangeValueForKey:@"myData"];
> 
> So I gather this is forcing the NSArrayController to write it's
> copied/cached values back to myData.

No, NSArrayController doesn't cache anything (well, it may cache something or 
other internally, but that has no relevance to its public functionality), and I 
can't think of any behavior that would cause it to unprovokedly copy objects.

The fact that issuing a KVO notification for the "myData" property "fixes" the 
problem most likely indicates that your code is changing the value of "myData" 
in a non-KVO compliant way, at some point. If the array controller has already 
bound to the old value at the time you do this, it won't know about the change.

I hope you won't mind if I go on to say that I think your entire design is 
misguided. For a start, as was pointed out in a different thread recently, you 
*really* can't rely on indexing into [someDictionary allValues]. There's 
*nothing* in the API that guarantees you'll get the dictionary objects in the 
same order every time you invoke 'allValues', even if the dictionary hasn't 
changed. Thus, your entire design is founded on an invalid assumption.

Further, as the discussion in a related thread seems to be trying to tell you, 
taking a shortcut by using naked NSMutableDictionary hierarchies is a lousy 
approach. Your data structure requirements are more complicated, and you'll 
likely do better (get to the solution faster) to create the class(es) needed to 
really encapsulate the behavior you want.


___

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

Please do not post admin requests or moderator comments to the list.
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: AM/PM letter UNICODE issues

2010-10-18 Thread Alex Kac
I actually attended that session - so thanks for reminding me about it. I 
should add I have worked with unicode, asian languages, etc.. on other 
platforms for many years and am aware of the complexities (though I've been 
working on the Mac since 1992 and Cocoa since 2007). Its not so much 
eye-opening as "sigh..." that it has to be that way. My issue is that I 
remembered the vague bits of this stuff at the moment as I thankfully have not 
had to deal with this area for awhile. I remember QuickDraw GX. ATSUI. So on. 
Vaguely at this point...

As for allowing AppKit/UIKit to handle things for me - usually yes I totally 
agree. And we do. However there are always specific cases where customizing a 
specific behavior makes sense for a specific purpose. Or if you have to use a 
lower level API instead of a higher level one; an example - we cannot use any 
of the NS* classes for calendar math on iOS because they are radically too slow 
(yes, we've profiled them and spent many hours with Apple engineers at WWDC 
labs). Instead we use the CF* classes - but this requires us to do a few things 
ourselves that UIKit does for you. Its fine. As iOS matures we've been able to 
remove old code we wrote and replace it with new UIKit code when the 
performance/functionality comes up and are happy to do so.

That all said, everything everyone said is true here about this not being a 
one-size fits all solution. Its not meant to be. That's the one reason I tend 
not to post here much - I feel like sometimes I have to give everyone a full 
design doc along my question otherwise I spend the next 20 posts trying to 
explain my purpose. But in the end I do get what I need and I thank everyone 
for that.

On Oct 18, 2010, at 1:56 PM, Conrad Shultz wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> On 10/18/10 10:19 AM, Alex Kac wrote:
>> This works in Western languages just fine. However in languages like
>> Korean it does not work giving a random character seemingly. From
>> reading on this list over time I believe its because I'm just getting
>> one part of a multi-part character (I'm no good with unicode terms
>> sorry).
> 
> As others have noted, you are likely to run into other problems with
> exotic configurations.
> 
> I don't recall if it contains anything that will be directly pertinent
> to your task, but I highly recommend you watch the "Internationalizing
> Data" session video from WWDC 2010.  Even if it doesn't have the
> specifics you are looking for, you will probably find it eye-opening.
> 
> The upshot of it is: the world is complicated, let the operating system
> and AppKit/UIKit handle things for you.
> 
> - -- 
> Conrad Shultz
> 
> Synthetiq Solutions
> www.synthetiqsolutions.com
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.7 (Darwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iD8DBQFMvJhQaOlrz5+0JdURAm1wAJ9apqiVTA6amnsNWyN5aPhg9UWJeACeKy+I
> FIocw+q416flQgP0JkHl8vg=
> =uIeG
> -END PGP SIGNATURE-

Alex Kac - President and Founder
Web Information Solutions, Inc.

"The optimist proclaims that we live in the best of all possible worlds; and 
the pessimist fears this is true."
-- James Clabell




___

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

Please do not post admin requests or moderator comments to the list.
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: CMYK Text of Photoshop Layer rendered incorrectly

2010-10-18 Thread Peter Krajčík
Hi Throsten,

what you suggested is a standard routine, but it reads just flattened image as 
it was stored by Photoshop 
to a .psd file.

I need to read layer images that are stored in .psd file. 
The only way I know is using 
>> GraphicsImportSetImageIndex(importer, i);

Where i is an index of image you want to decode from multi-image file - 
Photoshop psd in my case.


Peter


> 
> Message: 1
> Date: Mon, 18 Oct 2010 15:35:25 +0200
> From: Thorsten Lemke 
> Subject: Re: CMYK Text of Photoshop Layer rendered incorrectly
> To: 
> Message-ID: 
> Content-Type: text/plain; charset="ISO-8859-2"
> 
> Hi Peter,
> 
> I suggest to use the Core Image Import:
>CGImageSourceRef imageSource =
>CGImageSourceCreateWithURL((CFURLRef)[NSURL fileURLWithPath:path],
> NULL);
> 
> 
> That does handle CMYK, too.
> 
> Thorsten
> 
> 
>> Von: Peter Krajèík 
>> Datum: Mon, 18 Oct 2010 14:53:10 +0200
>> An: 
>> Betreff: CMYK Text of Photoshop Layer rendered incorrectly
>> 
>> Hi,
>> 
>> I am reading Photoshop layer images using this approach:
>> 
>> (simplified code)
>> 
>> for (i=0; i <= imageCount; i++)
>> {
>> unsigned long offset, size;
>> GraphicsImportSetImageIndex(importer, i);
>> GraphicsImportGetDataOffsetAndSize(importer, &offset, &size);
>> 
>> // create a Graphics Exporter component that will write Photoshop data
>> OSErr err = 
>> OpenADefaultComponent(GraphicsExporterComponentType,kQTFileTypePhotoShop,
>> &exporter);
>> 
>> if (err == noErr)
>> {
>> // set export parameters
>> Handle bmpDataH = NewHandle(0);
>> GraphicsExportSetInputGraphicsImporter(exporter, importer);
>> GraphicsExportSetOutputHandle(exporter, bmpDataH);
>> 
>> // export data to BMP into handle
>> unsigned long actualSizeWritten = 0;
>> err = GraphicsExportDoExport(exporter, &actualSizeWritten);
>> 
>>  if (err == noErr)
>>  {
>> 
>>   HLock(bmpDataH);
>> 
>>   //create a simple image with the tiff data, without the bound
>> information, its rep will stored to layer as CGImageRef
>>   id image = [CIImage imageWithData:[NSData
>> dataWithBytes:*bmpDataHlength:GetHandleSize(bmpDataH)]];
>>   NSBitmapImageRep* rep = [[[NSBitmapImageRep alloc]
>> initWithCIImage:image]autorelease];
>> 
>>   CGImageRef imageRef = rep.CGImage;
>>   self.layerImage =CGImageRetain(imageRef);
>>   HUnlock(bmpDataH);
>> }
>> 
>> DisposeHandle(bmpDataH);
>> CloseComponent(exporter);
>> }
>> 
>> }

___

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

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

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

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


Re: NSArrayController making copies of my objects?

2010-10-18 Thread Trygve Inda
> On Oct 18, 2010, at 04:43, Trygve Inda wrote:
> 
>> I understand that the array returned by allValues is not mutable so the
>> NSArrayController may need to make a mutable copy of it, but the internal
>> objects are mutable... So why is it copying my objects?
>> 
>> If I add the following just before the above two lines, then the objects
>> have the same address as expected.
>> 
>> [MyController willChangeValueForKey:@"myData"];
>> [MyController didChangeValueForKey:@"myData"];
>> 
>> So I gather this is forcing the NSArrayController to write it's
>> copied/cached values back to myData.
> 
> No, NSArrayController doesn't cache anything (well, it may cache something or
> other internally, but that has no relevance to its public functionality), and
> I can't think of any behavior that would cause it to unprovokedly copy
> objects.
> 
> The fact that issuing a KVO notification for the "myData" property "fixes" the
> problem most likely indicates that your code is changing the value of "myData"
> in a non-KVO compliant way, at some point. If the array controller has already
> bound to the old value at the time you do this, it won't know about the
> change.
> 
> I hope you won't mind if I go on to say that I think your entire design is
> misguided. For a start, as was pointed out in a different thread recently, you
> *really* can't rely on indexing into [someDictionary allValues]. There's
> *nothing* in the API that guarantees you'll get the dictionary objects in the
> same order every time you invoke 'allValues', even if the dictionary hasn't
> changed. Thus, your entire design is founded on an invalid assumption.
> 
> Further, as the discussion in a related thread seems to be trying to tell you,
> taking a shortcut by using naked NSMutableDictionary hierarchies is a lousy
> approach. Your data structure requirements are more complicated, and you'll
> likely do better (get to the solution faster) to create the class(es) needed
> to really encapsulate the behavior you want.

Thanks for this (all who have responded). I can see that binding to
@allValues isn't a great idea to get both an array and dict representing the
same objects. (Though I was never indexing into the array returned from
allValues).

I see that I have 3 "stages" of options here...

1. Have a property in MyDataController that is an NSMutableArray, bind the
NSArrayController to it and each element of the array is a 9-string-element
NSMutableDictionary.

2. Encapsulate the 9-string-element NSMutableDictionary into it's own Class
with 9 string properties. I'd probably add a method "dictionary" to retrieve
the properties as a dictionary for easy writing to disk in a plist.

3. Either subclass NSMutableArray or create a class that conforms to the
indexed to-many relationship accessor requirements which would then allow me
to internally store the classes (#2) or dicts (#1) in both an ordered array
as well as a keyed dictionary.

I think (hope?) this sums it up.

T.


___

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

Please do not post admin requests or moderator comments to the list.
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: AM/PM letter UNICODE issues

2010-10-18 Thread Uli Kusterer
On 18.10.2010, at 20:49, Alex Kac wrote:
> Yes, we already take care of the 24 hour situation. This is explicitly for 
> people who are showing their times using AM/PM. Not that its an iron-clad 
> thing either, but we've been doing calendaring for over 10 years now so I'm 
> aware of the date/time notation by country. But again this is explicitly for 
> users who are showing their times in AM/PM.

 German won't work anyway. Because we have a space at the start of the AM/PM 
suffix (They're " vorm.' and "nachm." by default. There are so many reasons why 
this could fail that you don't want to continue down this road. Just as an 
example, what if the first characters of the suffixes are the same?

 Moreover, nobody in Germany would understand what 10:00v or 10:00n could mean. 
If you want a custom date format, set a custom format string that you grab from 
your Localizable.strings file, and make sure it makes sense for every 
localization you have, but this will just confuse users.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de

___

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

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


How to Distinguish Between Two TableViews

2010-10-18 Thread Chris Share
Hi,

I'm new to Cocoa. I'm developing a simple application that contains two 
TableViews. What I can't figure out is how to distinguish between the two 
TableView pointers that are passed in to:

- (int)numberOfRowsInTableView:(NSTableView *) tableView
- (id)tableView:(NSTableView *)tableView 
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row

How do I do this?

In IB the Names and IDs of the two table views are different - do I somehow 
need 
to use these? If so, how?

Cheers,

Chris



___

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

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

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

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


Updating Core Data model object with an NSButtonCell

2010-10-18 Thread Jake
Hi everyone,

I have an NSOutlineView that is backed by a NSTreeController, which is bound
to a Core Data entity. One column in the outlineView is for the entity's
displayName, and the other column is an NSButtonCell. There is an
NSButtonCell for every row in the outlineView.

When a certain row's button is clicked, I would like to trigger a method in
that entity's class to set a variable in the entity. The problem is that
when I call the method, the variable changes seem to be made, but when I
click the button again, the variable is set as the same value it was before.
This leads me to believe that the value of the variable is actually
changing, but for some reason it is not "sticking" (i.e. I'm not performing
the method on the correct object or a proxy of that object or something).

Here's a screenshot to illustrate this in my app:
http://dl.dropbox.com/u/5232448/window.png

And here's the code in my subclass of NSTreeController that the NSButtonCell
is calling:

- (void) toggleTail:(id)sender {
 // Getting position and File object in row where button was clicked.
NSInteger position = [outlineView clickedRow];
 File *fileAtIndex = [[self flattenedContent] objectAtIndex:position];
 // If the file is tailing, stop it (and vice versa).
 // TODO: This doesn't work; it always stops.
NSLog(@"Beginng of controller toggle: %@", [[fileAtIndex isTailing]
stringValue]);
 [fileAtIndex toggleTail];
NSLog(@"End of controller toggle: %@", [[fileAtIndex isTailing]
stringValue]);
}

And here's the toggleTail method in my entity class:

- (void)toggleTail {
NSLog(@"Beginng of model toggle: %@", [[self isTailing] stringValue]);
 if ([[self isTailing] boolValue]) {
[self stopTail];
} else {
 [self startTail];
}
NSLog(@"End of model toggle: %@", [[self isTailing] stringValue]);
}

And, finally here are the startTail and stopTail methods in the entity
class:
- (void)startTail {
NSLog(@"Tail started for %...@.", [self displayName]);
...
// Updating the record to indicate the file is tailing.
[self setValue:[NSNumber numberWithBool:YES] forKey:@"isTailing"];
 }

- (void)stopTail {
NSLog(@"Tail stopped for %...@.", [self displayName]);
 ...
[self setValue:[NSNumber numberWithBool:NO] forKey:@"isTailing"];
}

As you can see, I have log messages scattered about through here in an
attempt to figure out exactly where the bug is. Here is the result of the
log messages:
2010-10-16 18:06:34.865 Tailr[95389:a0f] Beginng of controller toggle: 1
2010-10-16 18:06:34.865 Tailr[95389:a0f] Beginng of model toggle: 1
2010-10-16 18:06:34.866 Tailr[95389:a0f] End of model toggle: 0
2010-10-16 18:06:34.866 Tailr[95389:a0f] End of controller toggle: 0

The log messages are the same every time I click the button. Can anyone
please help me out? I'm kind of running out of ideas on my end. Thanks in
advance, and sorry for the data overload; just thought I'd be thorough in my
explaination.

--Jake
___

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

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

2010-10-18 Thread Nick Zitzmann

On Oct 17, 2010, at 5:29 PM, Chris Share wrote:

> I'm new to Cocoa. I'm developing a simple application that contains two 
> TableViews. What I can't figure out is how to distinguish between the two 
> TableView pointers that are passed in to:
> 
> - (int)numberOfRowsInTableView:(NSTableView *) tableView
> - (id)tableView:(NSTableView *)tableView 
> objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
> 
> How do I do this?



Nick Zitzmann


___

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

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

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

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


Re: How to Distinguish Between Two TableViews

2010-10-18 Thread Michael Dautermann

On Oct 17, 2010, at 4:29 PM, Chris Share wrote:

> I'm new to Cocoa. I'm developing a simple application that contains two 
> TableViews. What I can't figure out is how to distinguish between the two 
> TableView pointers that are passed in to:
> 
> - (int)numberOfRowsInTableView:(NSTableView *) tableView
> - (id)tableView:(NSTableView *)tableView 
> objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
> 
> How do I do this?
> 
> In IB the Names and IDs of the two table views are different - do I somehow 
> need 
> to use these? If so, how?

There's a number of ways to do this

Easiest is to match the incoming tableView to the IBOutlet from your XIB/NIB, 
e.g.:

- (int)numberOfRowsInTableView:(NSTableView *) tableView
{
if( tableView == myFirstTable )
{

} 
if( tableView == mySecondTable )
{

}
}

Tables don't have "names" per se.

Hope this helps,





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: AM/PM letter UNICODE issues

2010-10-18 Thread Uli Kusterer
On 18.10.2010, at 21:08, Alex Kac wrote:
> That all said, everything everyone said is true here about this not being a 
> one-size fits all solution. Its not meant to be. That's the one reason I tend 
> not to post here much - I feel like sometimes I have to give everyone a full 
> design doc along my question otherwise I spend the next 20 posts trying to 
> explain my purpose. But in the end I do get what I need and I thank everyone 
> for that.

 Still, I urge you to then build your strings manually. Make a struct tm from 
your date and create the actual time stamp from that, with *your own* AM/PM 
suffixes. Because "System Preferences" -> "Language & Text" -> "Formats" -> 
"Times" -> "Customize..." lets users change the complete date format, including 
the AM/PM suffix, order of components etc. You have no guarantee that the 
default strings will be the same on your system.

 Moreover, System Preferences lets you set date, time and number formats 
separately. Someone can be living in Bulgaria, run under US English-Language 
because he's a developer and can't wait for a localization pass to run their 
app that's developed in English, but have their number formats set to their 
native Swiss German number format (which is noticeably different from the 
Federal Republic's German). If you want to do your own date display, go to a 
lower level.

 Of course, you said you're on iOS, and I'm not sure where iOS gets its date 
settings from, so that may be a less pathological case, but honestly, you're 
asking for trouble.

 But as you said, I don't expect you to justify yourself. It's your program. I 
just think you (and anyone finding this thread in the archives via Google) 
should have all the facts.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de

___

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

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

2010-10-18 Thread Uli Kusterer
On 18.10.2010, at 01:29, Chris Share wrote:
> I'm new to Cocoa. I'm developing a simple application that contains two 
> TableViews. What I can't figure out is how to distinguish between the two 
> TableView pointers that are passed in to:
> 
> - (int)numberOfRowsInTableView:(NSTableView *) tableView
> - (id)tableView:(NSTableView *)tableView 
> objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
> 
> How do I do this?

 This is a code smell, i.e. a sign that you're likely doing something in a way 
that it wasn't intended to be done.

 Don't try to distinguish between them, give them each a separate data 
source/delegate object. That way, you get only one table's messages, and it's 
obvious which one it came from.

-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.masters-of-the-void.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 allValues not mutable

2010-10-18 Thread Charles Srstka
On Oct 18, 2010, at 1:45 PM, Trygve Inda wrote:

> So would you do something like the example you described:
> 
> http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
> 
> Where the NSArrayController is bound not to an array at all but to a
> property which responds to the proper indexed to-many messages...
> 
> Or a subclass of NSMutableArray as Greg suggested?
> 
> My array will rarely be edited (but needs to be mutable), but needs to be
> searchable by key (for which instead of a keyed dictionary kept in tandem
> with the array, I could just use a predicate filter on the array).
> 
> Each dictionary (or object with properties) will need to hold roughly 9
> textual strings, and there will be on the order of 10,000 objects in the
> array. I am guessing that dictionary will perform better than a predicate
> filter given the number of objects.
> 
> Trygve

I’d say the best solution is the one that Ken described. Implement the to-many 
accessors such as countOf, objectInAtIndex:, 
insertObject:inAtIndex:, and so forth. Then the underlying storage 
can be an NSDictionary, a skip list, or whatever you want, and as long as your 
accessors are abstracting it away properly, the rest of your code will neither 
know nor care what is actually being used to store your data.

Charles___

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

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

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

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


Re: How to Distinguish Between Two TableViews

2010-10-18 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/18/10 1:27 PM, Michael Dautermann wrote:
> 
> On Oct 17, 2010, at 4:29 PM, Chris Share wrote:
> 
>> I'm new to Cocoa. I'm developing a simple application that contains two 
>> TableViews. What I can't figure out is how to distinguish between the two 
>> TableView pointers that are passed in to:
> There's a number of ways to do this
> 
> Easiest is to match the incoming tableView to the IBOutlet from your XIB/NIB, 
> e.g.:

Additionally, at least two other approaches come to mind:

1) You can set tags in IB, and use NSView's tag method to compare, e.g.

if ([tableView tag] == TOP_TABLEVIEW_TAG) {}

(Assuming that TOP_TABLEVIEW_TAG is whatever you defined the
NSTableView's tag for, say, the top table view to be.)

I would still prefer Michael's IBOutlet approach, but thought I would
throw this out there.

2) If the tables serve even a remotely different purpose, I would
probably write two separate (delegate/dataSource) controller classes,
one for each table view.  This eliminates the need to test table
identity entirely, generally leading to cleaner code (and certainly
easier maintenance down the road).

If the two tables have aspects in common, there are various design
patterns that can help.  You could have each concrete controller class
derive from an abstract superclass.  Or you could have a separate class
that each controller calls upon when needed.  Such choices depend
largely on your specific objectives and application architecture.

Good luck!

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFMvLJlaOlrz5+0JdURAnRLAJ9FR17WZdzdgs/YbUoPX91823hOxACePIh7
ypAn9yMU4i7zpQu3819Lpgc=
=9tmn
-END PGP 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: AM/PM letter UNICODE issues

2010-10-18 Thread Aki Inoue
Alex,

Uli is giving very helpful recommendations here.

The leave-the-first-character logic doesn't work for Korean and Japanese, 
either.

They happen to spell AM/PM like MA/MP as Quincey warned.

If you have specific target locales in mind, I recommend providing a set of 
formatting configurations within your app.

Aki

On 18.10.2010, at 13:27, Uli Kusterer wrote:

> On 18.10.2010, at 21:08, Alex Kac wrote:
>> That all said, everything everyone said is true here about this not being a 
>> one-size fits all solution. Its not meant to be. That's the one reason I 
>> tend not to post here much - I feel like sometimes I have to give everyone a 
>> full design doc along my question otherwise I spend the next 20 posts trying 
>> to explain my purpose. But in the end I do get what I need and I thank 
>> everyone for that.
> 
> Still, I urge you to then build your strings manually. Make a struct tm from 
> your date and create the actual time stamp from that, with *your own* AM/PM 
> suffixes. Because "System Preferences" -> "Language & Text" -> "Formats" -> 
> "Times" -> "Customize..." lets users change the complete date format, 
> including the AM/PM suffix, order of components etc. You have no guarantee 
> that the default strings will be the same on your system.
> 
> Moreover, System Preferences lets you set date, time and number formats 
> separately. Someone can be living in Bulgaria, run under US English-Language 
> because he's a developer and can't wait for a localization pass to run their 
> app that's developed in English, but have their number formats set to their 
> native Swiss German number format (which is noticeably different from the 
> Federal Republic's German). If you want to do your own date display, go to a 
> lower level.
> 
> Of course, you said you're on iOS, and I'm not sure where iOS gets its date 
> settings from, so that may be a less pathological case, but honestly, you're 
> asking for trouble.
> 
> But as you said, I don't expect you to justify yourself. It's your program. I 
> just think you (and anyone finding this thread in the archives via Google) 
> should have all the facts.
> 
> Cheers,
> -- Uli Kusterer
> "The Witnesses of TeachText are everywhere..."
> http://www.zathras.de
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/aki%40apple.com
> 
> This email sent to a...@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: NSDictionary allValues not mutable

2010-10-18 Thread Trygve Inda

> You are mistaking instance variables for properties.  Instance variables are
> implementation details, and nothing outside of your class should be aware of
> them.
> 
> Properties are part of your interface, essentially the accessor methods and
> their behavior.  (Remember that you can have properties that are not backed by
> instance variables.)
> 
> So, you should be thinking in terms of writing accessor methods which present
> a consistent view of the to-many relationship (which happens to be backed by
> an array and a dictionary).  Look up the indexed accessor pattern for to-many
> relationships in the KVC documentation
>  eCoding/Concepts/AccessorConventions.html#//apple_ref/doc/uid/20002174-178830-
> BAJEDEFB>.  Also, take a look at "Managing a non-array collection, and
> filtering" on mmalc's page of Cocoa examples
> .
> 
> To keep yourself honest, and to help you learn, try making this to-many
> relationship property have a name completely different from the names of the
> instance variables which back it.  Also, I generally recommend that all of
> one's own classes should override +accessInstanceVariablesDirectly to return
> NO.  (I regard KVC's ability to bypass your interface and directly access your
> instance variables as A Bad Thing™.)
> 
> Regards,
> Ken

The example you cited uses:

@class Weapon;

@interface Combatant : NSObject {
NSString *name;
Weapon *weapon1;
Weapon *weapon2;
Weapon *weapon3;

Weapon *selectedWeapon;

int shieldRating;
}

- (unsigned int)countOfWeapons;
- (id)objectInWeaponsAtIndex:(unsigned int)index;


How does it derive the plural for he method name countOfWeapons from the
class name Weapon? What if my Class name was Ox... Surely it would not know
to use countOfOxen ?

I see where one can specify a plural in AppleScripting but not for a Cocoa
class.

Thanks,

T.


___

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

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

2010-10-18 Thread Charles Srstka
On Oct 18, 2010, at 4:22 PM, Trygve Inda wrote:

> How does it derive the plural for he method name countOfWeapons from the 
> class name Weapon?

It doesn’t. The property name is “weapons” in this case, the same name it would 
have had if it had been an NSArray. The only difference is that instead of two 
methods named -weapons and -setWeapons:, you have a few other methods with 
“Weapons” in their names. The only change is capitalizing the first letter to 
allow for CamelCase.

Charles___

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

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

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

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


Re: NSDictionary allValues not mutable

2010-10-18 Thread Greg Guerin

Trygve Inda wrote:

Each dictionary (or object with properties) will need to hold  
roughly 9
textual strings, and there will be on the order of 10,000 objects  
in the
array. I am guessing that dictionary will perform better than a  
predicate

filter given the number of objects.



Never guess at performance.  Always measure.  For one thing, "perform  
better" may be irrelevant.  "Good enough" is the only criterion worth  
evaluating.  If worse performance is good enough, then better  
performance serves no purpose (ignoring other tradeoffs, such as  
power consumption).  If array search is 10 msecs, and dictionary  
search is 10 usecs, the user will never perceive the thousand-fold  
difference if the search occurs at most 10 times per sec.


In addition, if the objects are ordered in the array, a binary search  
instead of linear is simpler than managing a parallel dictionary for  
keyed retrieval.  Binary search is O(log2(n)) worst-case.

http://en.wikipedia.org/wiki/Binary_search_algorithm

It almost seems like you're choosing representations and algorithms  
primarily on the existence of classes, instead of what might work  
best.  That is, because predicate filter classes exist, you don't  
have to write that class, so you've decided to use it for searching  
arrays instead of other algorithms that may have substantially better  
performance, but for which you'd have to write non-trivial code (or  
find it on the web).  And the only tradeoffs you're making are  
between varieties of existing Apple-supplied classes, e.g.  
NSDictionary vs. NSArray with predicate-search, rather than looking  
for third-party classes.


  -- 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: NSDictionary allValues not mutable

2010-10-18 Thread Trygve Inda
> On Oct 18, 2010, at 4:22 PM, Trygve Inda wrote:
> 
>> How does it derive the plural for he method name countOfWeapons from the
>> class name Weapon?
> 
> It doesn’t. The property name is “weapons” in this case, the same name it
> would have had if it had been an NSArray. The only difference is that instead
> of two methods named -weapons and -setWeapons:, you have a few other methods
> with “Weapons” in their names. The only change is capitalizing the first
> letter to allow for CamelCase.
> 
> Charles

So is "weapons" only defined in IB under the Array binding's model key path?

// Combatant.h:

#import 

@class Weapon;

@interface Combatant : NSObject {
NSString *name;
Weapon *weapon1;
Weapon *weapon2;
Weapon *weapon3;
Weapon *selectedWeapon;
int shieldRating;
}

- (unsigned int)countOfWeapons;
- (id)objectInWeaponsAtIndex:(unsigned int)index;
- (NSString *)name;
- (void)setName:(NSString *)newName;
- (Weapon *)weapon1;
- (void)setWeapon1:(Weapon *)newWeapon1;
- (Weapon *)weapon2;
- (void)setWeapon2:(Weapon *)newWeapon2;
- (Weapon *)weapon3;
- (void)setWeapon3:(Weapon *)newWeapon3;
- (Weapon *)selectedWeapon;
- (void)setSelectedWeapon:(Weapon *)aSelectedWeapon;


// Weapon.h

#import 

@interface Weapon : NSObject
{
NSString *name;
int damage;
}

- initWithName:(NSString *)newName damage:(int)newDamage;
- (NSString *)name;
- (void)setName:(NSString *)newName;
- (int)damage;
- (void)setDamage:(int)newDamage;



___

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

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

2010-10-18 Thread Trygve Inda
> Trygve Inda wrote:
> 
>> Each dictionary (or object with properties) will need to hold
>> roughly 9
>> textual strings, and there will be on the order of 10,000 objects
>> in the
>> array. I am guessing that dictionary will perform better than a
>> predicate
>> filter given the number of objects.
> 
> 
> Never guess at performance.  Always measure.  For one thing, "perform
> better" may be irrelevant.  "Good enough" is the only criterion worth
> evaluating.  If worse performance is good enough, then better
> performance serves no purpose (ignoring other tradeoffs, such as
> power consumption).  If array search is 10 msecs, and dictionary
> search is 10 usecs, the user will never perceive the thousand-fold
> difference if the search occurs at most 10 times per sec.
> 
> In addition, if the objects are ordered in the array, a binary search
> instead of linear is simpler than managing a parallel dictionary for
> keyed retrieval.  Binary search is O(log2(n)) worst-case.
> http://en.wikipedia.org/wiki/Binary_search_algorithm
> 
> It almost seems like you're choosing representations and algorithms
> primarily on the existence of classes, instead of what might work
> best.  That is, because predicate filter classes exist, you don't
> have to write that class, so you've decided to use it for searching
> arrays instead of other algorithms that may have substantially better
> performance, but for which you'd have to write non-trivial code (or
> find it on the web).  And the only tradeoffs you're making are
> between varieties of existing Apple-supplied classes, e.g.
> NSDictionary vs. NSArray with predicate-search, rather than looking
> for third-party classes.

This is probably true since this is a very minor part of my app... I simply
need an array to display in a table with the added functionality of being
able to locate a record uniquely (each object in the array has a unique ID
as one of it's properties).

T.


___

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

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

2010-10-18 Thread Charles Srstka
On Oct 18, 2010, at 4:42 PM, Trygve Inda wrote:

> So is "weapons" only defined in IB under the Array binding's model key path?

Yep, and Cocoa can automatically generate an array from it for 
NSArrayController.

#import 

@interface Combatant : NSObject {
@private
id weapon1;
id weapon2;
id weapon3;
}

- (NSUInteger)countOfWeapons;
- (id)objectInWeaponsAtIndex:(NSUInteger)index;

@end

@implementation Combatant

- (id)init {
self = [super init];

if(self) {
weapon1 = [@"Nerf gun" copy];
weapon2 = [@"Super Soaker" copy];
weapon3 = [@"Rubber Band" copy];
}

return self;
}

- (void)dealloc {
[weapon1 release];
[weapon2 release];
[weapon3 release];

[super dealloc];
}

- (NSUInteger)countOfWeapons {
return 3;
}

- (id)objectInWeaponsAtIndex:(NSUInteger)index {
switch (index) {
case 0:
return weapon1;
case 1:
return weapon2;
case 2:
return weapon3;
default:
return nil;
}
}

@end

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

Combatant *combatant = [[Combatant alloc] init];

NSLog(@"%@", [combatant valueForKey:@"weapons"]);

[combatant release];

[pool drain];
return 0;
}

---

Running this produces the following output:

2010-10-18 16:52:26.336 proptest[58175:a0f] (
"Nerf gun",
"Super Soaker",
"Rubber Band”
)

Charles___

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

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

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

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


Re: NSDictionary allValues not mutable

2010-10-18 Thread Trygve Inda

> I’d say the best solution is the one that Ken described. Implement the to-many
> accessors such as countOf, objectInAtIndex:,
> insertObject:inAtIndex:, and so forth. Then the underlying storage
> can be an NSDictionary, a skip list, or whatever you want, and as long as your
> accessors are abstracting it away properly, the rest of yo

___

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

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

2010-10-18 Thread Greg Guerin

Trygve Inda wrote:

This is probably true since this is a very minor part of my app...  
I simply
need an array to display in a table with the added functionality of  
being
able to locate a record uniquely (each object in the array has a  
unique ID

as one of it's properties).



I recommend doing the simplest thing that could possibly work, then  
measuring performance of that before making any other changes, or  
even thinking about changes.  If simple array searching is fast  
enough, then you've already wasted time by thinking about how to use  
a dictionary, posting on the list, etc.


Furthermore, there are simple additions to linear search of an  
ordered array that can greatly improve speed.  For example, copy the  
search-keys of every 100th element into another ordered array.   
Search it first to decide where to start a linear search in the main  
list, and it's guaranteed you won't have to scan more than 100 main  
elements.  This is effectively a type of tree structure for  
searching, and it can be recursively applied.  Even though it's  
simple, I wouldn't bother coding it unless actual measurements  
indicate a need for it.


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


Unarchiving cells out of order.

2010-10-18 Thread Ben Lachman
Hi all.

I have a work around for the problem that one runs into with custom subclassed 
controls that use custom cells being unarchived from nibs with standard cells.  
(this is covered many place, possibly most succinctly here: 
http://mikeash.com/pyblog/custom-nscells-done-right.html)

This works for every custom control I've written, including several types of 
buttons.  However the most recent custom checkbox I was working on today 
displays an odd behavior.  Instead of setting the cell class back to 
NSButtonCell correctly after unarchiving, it skips out of the method and moves 
to the next item to unarchive and doesn't come back until after all the rest of 
the cells have been unarchived.  This leads to any other NSButtonCells to be 
unarchived as my custom button cell subclass leading to odd appearances.

Any thoughts on why this might be happening would be instructive... 

My NSControl category looks thusly:

@implementation NSControl (CellClass)

+ (void) initialize { 
[[[self class] superclass] initialize]; 
Class NSControlClass = [NSControl class]; 

method_exchangeImplementations(class_getInstanceMethod(NSControlClass,@selector(initWithCoder:)),class_getInstanceMethod(NSControlClass,@selector(newInitWithCoder:)));
} 

- (id) newInitWithCoder:(NSCoder *)origCoder { 
BOOL sub = YES;

sub = sub && [origCoder isKindOfClass: [NSKeyedUnarchiver class]]; // 
no support for 10.1 nibs
sub = sub && ![self isMemberOfClass: [NSControl class]]; // no raw 
NSControls
sub = sub && [[self superclass] cellClass] != nil; // need to have 
something to substitute
sub = sub && [[self superclass] cellClass] != [[self class] cellClass]; 
// pointless if same
sub = sub && ([NSStringFromClass( [[self class] cellClass]) 
hasPrefix:@"NS"] == NO);

if( !sub ) {
self = [self newInitWithCoder:origCoder]; 
} else {
NSKeyedUnarchiver *unarchiver = (id)origCoder;

// gather info about the superclass's cell and save the 
archiver's old mapping
Class superCell = [[self superclass] cellClass];
NSString *oldClassName = NSStringFromClass( superCell );
Class oldClass = [unarchiver classForClassName:oldClassName];
if( !oldClass )
oldClass = superCell;

// override what comes out of the unarchiver
[unarchiver setClass: [[self class] cellClass] 
forClassName:oldClassName];

// unarchive
NSLog( @"unarchiving %@", NSStringFromClass([[self class] 
cellClass]));
self = [self newInitWithCoder:origCoder];
NSLog( @"done.");

// set it back
[unarchiver setClass:oldClass forClassName:oldClassName];   

}

return self;
}   

And the debug console look like this: 

2010-10-18 17:41:53.500 UI-test[54499:a0f] unarchiving CustomSearchFieldCell
2010-10-18 17:41:53.503 UI-test[54499:a0f] done.
2010-10-18 17:41:53.505 UI-test[54499:a0f] unarchiving DarkCheckboxButtonCell  
< this is the checkbox
2010-10-18 17:41:53.506 UI-test[54499:a0f] unarchiving DarkTextFieldCell
2010-10-18 17:41:53.507 UI-test[54499:a0f] done.
2010-10-18 17:41:53.508 UI-test[54499:a0f] unarchiving DarkTextFieldCell
2010-10-18 17:41:53.509 UI-test[54499:a0f] done.
2010-10-18 17:41:53.514 UI-test[54499:a0f] unarchiving GradientButtonCell
2010-10-18 17:41:53.530 UI-test[54499:a0f] done.
2010-10-18 17:41:53.530 UI-test[54499:a0f] unarchiving GradientButtonCell
2010-10-18 17:41:53.531 UI-test[54499:a0f] done.
2010-10-18 17:41:53.533 UI-test[54499:a0f] unarchiving GradientButtonCell
2010-10-18 17:41:53.534 UI-test[54499:a0f] done.
2010-10-18 17:41:53.535 UI-test[54499:a0f] done. < this is where it set the 
old class back


--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009

___

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

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

2010-10-18 Thread Graham Cox

On 19/10/2010, at 7:31 AM, Uli Kusterer wrote:

> This is a code smell, i.e. a sign that you're likely doing something in a way 
> that it wasn't intended to be done.
> 
> Don't try to distinguish between them, give them each a separate data 
> source/delegate object. That way, you get only one table's messages, and it's 
> obvious which one it came from.


This is not necessarily a code smell. If it were, why would the tableview 
object be passed as a parameter to the data source?

Sometimes the same data source for more than one table can be a sensible design.

Michael's answer is what I'd do.

--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: Updating Core Data model object with an NSButtonCell

2010-10-18 Thread Quincey Morris
On Oct 16, 2010, at 16:23, Jake wrote:

> 2010-10-16 18:06:34.865 Tailr[95389:a0f] Beginng of controller toggle: 1
> 2010-10-16 18:06:34.865 Tailr[95389:a0f] Beginng of model toggle: 1
> 2010-10-16 18:06:34.866 Tailr[95389:a0f] End of model toggle: 0
> 2010-10-16 18:06:34.866 Tailr[95389:a0f] End of controller toggle: 0

It's hard to see how you could possibly get this output from the code you 
posted. After the 2nd message is logged, either 'startTail' or 'stopTail' will 
be invoked, and either will log another message -- but this message does not 
appear.

Are you sure this is the code that produced this output? Can you set a 
breakpoint in 'toggleTail' to see if it takes the path you expect?


___

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

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

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

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


Framework Major versions

2010-10-18 Thread Alexander Cohen
Hello,

I'm about to make a change in the Major version of a framework ( new version 
will be B ). I've read through the docs and all but i'm not sure i understand 
how to set it up so i keep version A in my build but also build the new version 
B.

Has anyone done this and what should i do? Should i just keep A around and add 
it in a run script build phase?

thx

AC___

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

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

2010-10-18 Thread Nick Zitzmann

On Oct 18, 2010, at 4:50 PM, Alexander Cohen wrote:

> I'm about to make a change in the Major version of a framework ( new version 
> will be B ). I've read through the docs and all but i'm not sure i understand 
> how to set it up so i keep version A in my build but also build the new 
> version B.
> 
> Has anyone done this

Yes.

> and what should i do? 

You need to either move version A off to a separate project with the same 
target, or clone the target in the same project, with a new major version & its 
associated changes. Then you build both targets, and the framework versions 
will be merged with the same bundle. I think the "current" symlink is set to 
whatever version was built most recently.

Keep in mind that framework versioning is usually unnecessary, unless you have 
added variables to a fragile superclass, or if you've removed some obsolete 
stuff that might still be in use by old code, or if a bug fix in the framework 
is causing regressions in existing apps, or something similar. IOW, you 
probably don't need to do this if you added new content, or if the framework is 
private & you also own the dependencies. So it would help to know why you want 
to do this...

Nick Zitzmann


___

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

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

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

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


Re: Framework Major versions

2010-10-18 Thread Alexander Cohen
Thanks Nick, this will help a lot, i don't think its explained anywhere in the 
docs. You are spot on for why i need to do it. We've got some very old software 
that relies on things that have been deprecated for a long time and now we need 
to remove them. I think the best option is to rev the major version.

AC

On Oct 18, 2010, at 8:12 PM, Nick Zitzmann wrote:

> 
> On Oct 18, 2010, at 4:50 PM, Alexander Cohen wrote:
> 
>> I'm about to make a change in the Major version of a framework ( new version 
>> will be B ). I've read through the docs and all but i'm not sure i 
>> understand how to set it up so i keep version A in my build but also build 
>> the new version B.
>> 
>> Has anyone done this
> 
> Yes.
> 
>> and what should i do? 
> 
> You need to either move version A off to a separate project with the same 
> target, or clone the target in the same project, with a new major version & 
> its associated changes. Then you build both targets, and the framework 
> versions will be merged with the same bundle. I think the "current" symlink 
> is set to whatever version was built most recently.
> 
> Keep in mind that framework versioning is usually unnecessary, unless you 
> have added variables to a fragile superclass, or if you've removed some 
> obsolete stuff that might still be in use by old code, or if a bug fix in the 
> framework is causing regressions in existing apps, or something similar. IOW, 
> you probably don't need to do this if you added new content, or if the 
> framework is private & you also own the dependencies. So it would help to 
> know why you want to do this...
> 
> Nick Zitzmann
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/alex%40toomuchspace.com
> 
> This email sent to a...@toomuchspace.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: AM/PM letter UNICODE issues

2010-10-18 Thread Todd Dombrowski
Here's one way to accomplish your stated goal:

-- BEGIN CODE --
#import 

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

// NSDateFormatter, locale friendly
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateStyle:NSDateFormatterNoStyle];
[df setTimeStyle:NSDateFormatterShortStyle];
// Get time from date
NSString *timeString = [df stringFromDate:[NSDate date]];
[df release];

CFShow(timeString);

// Abbreviate time: "10:00 AM" to "10:00a"
NSString *abbreviateTimeString = [NSString stringWithString:timeString];
abbreviateTimeString = [timeString
stringByReplacingOccurrencesOfString:@" AM" withString:@"a"];
abbreviateTimeString = [timeString
stringByReplacingOccurrencesOfString:@" PM" withString:@"p"];

CFShow(abbreviateTimeString);

[pool drain];
return 0;
}
-- END CODE --

of course if you are on iOS 4.0 or later, you can play with the new
regex classes and add 30 more lines of code ;-)

Todd Dombrowski
pzlbox, llc

On Mon, Oct 18, 2010 at 10:19 AM, Alex Kac  wrote:
>
> I'm fairly certain my problem here is that I wasn't thinking about unicode 
> terms here.
>
> What we are trying to do:
> Shorten the AM/PM to just the first character in Western Languages so that a 
> time is shown as "1:30a".
>
>        NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
>        NSString* am = [[[formatter AMSymbol] substringToIndex:1] 
> lowercaseString];
>        NSString* pm = [[[formatter PMSymbol] substringToIndex:1] 
> lowercaseString];
>
>
> This works in Western languages just fine. However in languages like Korean 
> it does not work giving a random character seemingly. From reading on this 
> list over time I believe its because I'm just getting one part of a 
> multi-part character (I'm no good with unicode terms sorry).
>
> My guess is I need to use rangeOfComposedCharacterSequenceAtIndex and then 
> get the range and use a substring with that range. But I'm not sure since my 
> knowledge here is pretty limited. Would love some direction. 
> 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/todd%40pzlbox.com
>
> This email sent to t...@pzlbox.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: Return key should enter return in textfield and not press default button

2010-10-18 Thread Jim Correia
On Oct 11, 2010, at 2:21 AM, Thorsten Lemke wrote:

> I have a dialog in my app wich should let the user enter a carriage return.
> 
> How can I avoid pressing the default button with return? Only enter should
> press it in this case.

As you probably know, implementing this will be hugely popular with people who 
understand how it works, and confusing to everyone else.

That said…

For your edit field implement

- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView 
doCommandBySelector:(SEL)commandSelector;

When the command selector is insertNewline:, act accordingly based on the 
current event.

—Jim


___

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

Please do not post admin requests or moderator comments to the list.
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: Heapshot Analysis to find Memory Accretion (Leaks)

2010-10-18 Thread Gerriet M. Denkmann

On 18 Oct 2010, at 19:56, Bill Bumgarner  wrote:

>   I wrote up an article on how to use the "Mark Heap" / "Heapshot 
> Analysis" tools in Instruments to detect, analyze, and fix memory leaks, 
> including those that leaks can't find.
> 
>   
> http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/

First of all: Thank you very much for this very helpful article.

I just created a new Cocoa Document based app in Xcode (Version 3.2.4).
I did not edit any of the Xcode supplied files.
Clicked Build and then Run with Performance Tool → Allocations.
The I did 10 times:
New 
Close
Click "Mark Heap" in Instruments

But there are several kiloBytes of Heap Growth in (almost) each Heapshot.
These are:
CFBasicHash (value-store)
CFBasicHash (count-store)

None of these have any of my code (except main()) in their respective 
backtraces.

So, what to do now?
Conclude that AppKit is full of leaks?
Investigate further? If yes, in which direction?

The problem is not with this test app, but with some real apps, where I also 
see lots of stuff in the Heap Growth column, so that it is rather difficult to 
recognize things which are caused by errors in my own code.

> Ideally, each "Heapshot" iteration should show 0 growth in almost all cases.

Indeed.

Kind regards,

Gerriet.

___

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

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

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

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


Tracing an iPhone application/framework

2010-10-18 Thread Sandro Noël
Greetings.

The lead developer at my workplace left his brainchild behind but forgot to 
write any documentation for it.
the framework is now quite unusable because it is quite extensive an no one 
knows the depth of it's architecture.

I am mandated to document this framework. (Joy!)

The "framework" is built as a template application from which classe/functions 
can be overloaded to fit the needs of the being built application.
not much of an architecture if you ask me but i have to document it none the 
less.

Is there any application out there or method in Xcode where I could trace every 
function call and figure out what object is being called and what function, 
thru out the first run of an application using that framework?

Best regards.
Sandro.


___

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

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

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

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


Re: Problem using dictionary

2010-10-18 Thread Abhi Beckert

On 2010-10-09, at 6:14 AM, Remco Poelstra wrote:

> That seems reasonable, but makes the documentation harder to read. In the old 
> days where I used Delphi, the inherited methods were all shown as such and it 
> gives a direct overview of what is available. Especially in this case, where 
> the valueForKey* methods are neither mentioned in the NSObject docs, not that 
> NSObject followsNSKeyValueCoding. Well, maybe Apple adds such functionality 
> someday to their doc browser.


[NSObject valueForKey:] has nothing to do with dictionaries. It's an internal 
API feature that's used throughout the framework. The foo.bar syntax is 
essentially an alias for [foo valueForKey:@"bar"]. Understanding exactly how 
this method works is one of the first things you need to learn as a cocoa 
programmer. NSDictionary wouldn't even document valueForKey: at all, except 
that it changes the behaviour slightly.

You can't document every message NSDictionary will respond to, most have 
nothing to do with dictionaries. Eg. would you expect +alloc to be documented? 
What about -performSelectorOnMainThread:withObject:waitUntilDone:? Both can be 
used on an NSDictionary, and neither are mentioned in the documentation.

You just need to get used to looking up parent classes and categories. 
Similarly, NSMutableDictionary doesn't document valueForKey: or count, even 
though those are probably the most important two methods in an 
NSMutableDictionary object. They are implemented in a parent class, and won't 
me listed in the NSMutableDictionary class reference.

The NSDictionary Class Reference is exactly that — a reference. If you want an 
introduction of how to use it, you must read "Collections Programming Topics", 
which is linked in the sidebar of NSDictionary's reference page.

- Abhi

___

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

Please do not post admin requests or moderator comments to the list.
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: Unarchiving cells out of order.

2010-10-18 Thread Ben Lachman
Apparently I was working around a problem that no longer exists for most common 
cases.  You don't need to do any shenanigans with replacing or overriding 
-initWithCoder: to get custom cells to work from IB anymore.  To get a custom 
cell class unarchived directly from the nib, just keep clicking on a control 
until you notice that the inspector window's title has changed to the name of 
the cell class (e.g. for a search field the title would change from "Search 
Field..." to "Search Field Cell...").  Then navigate to the Identity tab (the i 
in a circle) and set the class to your custom cell class name.  Viola... less 
code, yay!

Hope this helps someone.

->Ben

On Oct 18, 2010, at 6:22 PM, Ben Lachman wrote:

> Hi all.
> 
> I have a work around for the problem that one runs into with custom 
> subclassed controls that use custom cells being unarchived from nibs with 
> standard cells.  (this is covered many place, possibly most succinctly here: 
> http://mikeash.com/pyblog/custom-nscells-done-right.html)
> 
> This works for every custom control I've written, including several types of 
> buttons.  However the most recent custom checkbox I was working on today 
> displays an odd behavior.  Instead of setting the cell class back to 
> NSButtonCell correctly after unarchiving, it skips out of the method and 
> moves to the next item to unarchive and doesn't come back until after all the 
> rest of the cells have been unarchived.  This leads to any other 
> NSButtonCells to be unarchived as my custom button cell subclass leading to 
> odd appearances.
> 
> Any thoughts on why this might be happening would be instructive... 
> 
> My NSControl category looks thusly:
> 
> @implementation NSControl (CellClass)
> 
> + (void) initialize { 
>[[[self class] superclass] initialize]; 
>Class NSControlClass = [NSControl class]; 
>
> method_exchangeImplementations(class_getInstanceMethod(NSControlClass,@selector(initWithCoder:)),class_getInstanceMethod(NSControlClass,@selector(newInitWithCoder:)));
> } 
> 
> - (id) newInitWithCoder:(NSCoder *)origCoder { 
>   BOOL sub = YES;
>   
>   sub = sub && [origCoder isKindOfClass: [NSKeyedUnarchiver class]]; // 
> no support for 10.1 nibs
>   sub = sub && ![self isMemberOfClass: [NSControl class]]; // no raw 
> NSControls
>   sub = sub && [[self superclass] cellClass] != nil; // need to have 
> something to substitute
>   sub = sub && [[self superclass] cellClass] != [[self class] cellClass]; 
> // pointless if same
>   sub = sub && ([NSStringFromClass( [[self class] cellClass]) 
> hasPrefix:@"NS"] == NO);
>   
>   if( !sub ) {
>   self = [self newInitWithCoder:origCoder]; 
>   } else {
>   NSKeyedUnarchiver *unarchiver = (id)origCoder;
>   
>   // gather info about the superclass's cell and save the 
> archiver's old mapping
>   Class superCell = [[self superclass] cellClass];
>   NSString *oldClassName = NSStringFromClass( superCell );
>   Class oldClass = [unarchiver classForClassName:oldClassName];
>   if( !oldClass )
>   oldClass = superCell;
>   
>   // override what comes out of the unarchiver
>   [unarchiver setClass: [[self class] cellClass] 
> forClassName:oldClassName];
>   
>   // unarchive
>   NSLog( @"unarchiving %@", NSStringFromClass([[self class] 
> cellClass]));
>   self = [self newInitWithCoder:origCoder];
>   NSLog( @"done.");
>   
>   // set it back
>   [unarchiver setClass:oldClass forClassName:oldClassName];   
> 
>   }
>   
>   return self;
> } 
> 
> And the debug console look like this: 
> 
> 2010-10-18 17:41:53.500 UI-test[54499:a0f] unarchiving CustomSearchFieldCell
> 2010-10-18 17:41:53.503 UI-test[54499:a0f] done.
> 2010-10-18 17:41:53.505 UI-test[54499:a0f] unarchiving DarkCheckboxButtonCell 
>  < this is the checkbox
> 2010-10-18 17:41:53.506 UI-test[54499:a0f] unarchiving DarkTextFieldCell
> 2010-10-18 17:41:53.507 UI-test[54499:a0f] done.
> 2010-10-18 17:41:53.508 UI-test[54499:a0f] unarchiving DarkTextFieldCell
> 2010-10-18 17:41:53.509 UI-test[54499:a0f] done.
> 2010-10-18 17:41:53.514 UI-test[54499:a0f] unarchiving GradientButtonCell
> 2010-10-18 17:41:53.530 UI-test[54499:a0f] done.
> 2010-10-18 17:41:53.530 UI-test[54499:a0f] unarchiving GradientButtonCell
> 2010-10-18 17:41:53.531 UI-test[54499:a0f] done.
> 2010-10-18 17:41:53.533 UI-test[54499:a0f] unarchiving GradientButtonCell
> 2010-10-18 17:41:53.534 UI-test[54499:a0f] done.
> 2010-10-18 17:41:53.535 UI-test[54499:a0f] done. < this is where it set 
> the old class back
> 
> 
> --
> Ben Lachman
> Acacia Tree Software
> 
> http://acaciatreesoftware.com
> 
> email: blach...@mac.com
> twitter: @benlachman
> mobile: 740.590.0009
> 
> _

Re: AM/PM letter UNICODE issues

2010-10-18 Thread Gerriet M. Denkmann

On 19 Oct 2010, at 00:54, Alex Kac  wrote:

>   NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
>   NSString* am = [[[formatter AMSymbol] substringToIndex:1] 
> lowercaseString];


Please note that substringToIndex does only sometimes return a valid string.

I just tried:

NSString *a = @"𝍢"; //  COUNTING ROD UNIT DIGIT THREE
NSLog(@"%s a \"%...@\"",__FUNCTION__, a);   //  ok

NSString *badString = [ a substringToIndex: 1 ];
NSLog(@"%s a \"%...@\" badString \"%...@\"",__FUNCTION__, a, badString);
// ← this never shows
// because "badString" is not a valid string at all (I would have expected some 
log message though).

NSRange aRange = [ a rangeOfComposedCharacterSequenceAtIndex: 0 ];
NSString *goodString = [ a substringWithRange: aRange ];
NSLog(@"%s a \"%...@\" goodString \"%...@\"",__FUNCTION__, a, goodString);  
 
// this works ok and contains the first "character" in of string "a".

I admit that it is rather unlikely that this will be a problem with normal 
Korean text (but I know nothing about Korean scripts).


Kind regards,

Gerriet.

___

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

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

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

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


Re: Problem using dictionary

2010-10-18 Thread Quincey Morris
On Oct 18, 2010, at 20:52, Abhi Beckert wrote:

> [NSObject valueForKey:] has nothing to do with dictionaries. It's an internal 
> API feature that's used throughout the framework. The foo.bar syntax is 
> essentially an alias for [foo valueForKey:@"bar"]. Understanding exactly how 
> this method works is one of the first things you need to learn as a cocoa 
> programmer. NSDictionary wouldn't even document valueForKey: at all, except 
> that it changes the behaviour slightly.

Aside from the fact that this thread was resolved quite some days ago, your 
analysis is factually incorrect, depending on what you mean by "alias". 
'foo.bar' does not execute '[foo valueForKey:@bar"]' but rather invokes the 
method '[foo bar]' directly. OTOH, the default implementation *in NSObject* of 
'valueForKey:' invokes a method whose name matches the key (i.e. '[foo bar]') 
if it exists. Using "alias" for either of these is perhaps torturing the word 
beyond helpfulness.

Also, NSDictionary changes the behavior of 'valueForKey:' radically, not so 
much "slightly". It changes the meaning of the parameter from something that's 
translated into a method name to something that's translated to a dictionary 
key (unless preceded by a "@"). 

Further, I'd suggest that another important reason it's documented is that it 
specifies *how* NSDictionary is KVC compliant, since its compliance is 
semantically different from that of the class it's inheriting from (namely 
NSObject). (This fact would be better documented at the start of the class 
reference, rather than being implied by the 'valueForKey:' method description.)


___

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

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