Re: Multiple declarations of objc_msgSend_stret

2011-02-04 Thread Jean-Daniel Dupas
I don't know what the status of this feature in the last Xcode version, but 
clang supports the unused attribute on obj-c ivar.

I have something like this to workaround this kind of warning:

#if __has_feature(attribute_objc_ivar_unused)
  #define UNUSED_IVAR __attribute__((unused))
#else
  #define UNUSED_IVAR
#endif

and then

@interface Foo {
  int ivar UNUSED_IVAR;
}

@end



Le 4 févr. 2011 à 00:59, James Bucanek a écrit :

> Hamish Allan  wrote (Thursday, February 3, 2011 4:05 
> PM -):
> 
>> On 3 February 2011 22:46, James Bucanek  wrote:
>> 
>>> I have numerous instance variables which are
>>> only used by categories.
>> 
>> If you compile using -Xclang -fobjc-nonfragile-abi2, you can declare
>> instance variables in class extensions and kill two birds (improve
>> locality of reference, remove warnings) with one stone.
> 
> I thought non-fragile instance variables required 64-bit Intel and/or 10.5.
> 
> I still have to compile for 32-bit, PPC, and (occasionally) OS 10.4, so 
> moving my instance variables into categories doesn't seem practical at this 
> point in time.
> 
> 
> 
> James Bucanek
> 
> Author of Professional Xcode 3   ISBN: 9780470525227
> 
> and Learn Objective-C for Java DevelopersISBN: 9781430223696
> 
> 
> ___
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list  (xcode-us...@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/xcode-users/devlists%40shadowlab.org
> 
> This email sent to devli...@shadowlab.org

-- Jean-Daniel



___

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

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

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

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


RE: Drawing images on top of each other

2011-02-04 Thread Andrew Coad

>> You probably want either kCGBlendModeCopy

That fixed it. Thanks. Kicking myself that I didn't see that blend mode... 
Andrew Coad
  
___

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

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

Help/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: Multiple declarations of objc_msgSend_stret

2011-02-04 Thread Jean-Daniel Dupas
Oups, wrong mailing list (and subject). Sorry for the noise.

Le 4 févr. 2011 à 09:54, Jean-Daniel Dupas a écrit :

> I don't know what the status of this feature in the last Xcode version, but 
> clang supports the unused attribute on obj-c ivar.
> 
> I have something like this to workaround this kind of warning:
> 
>#if __has_feature(attribute_objc_ivar_unused)
>  #define UNUSED_IVAR __attribute__((unused))
>#else
>  #define UNUSED_IVAR
>#endif
> 
> and then
> 
> @interface Foo {
>  int ivar UNUSED_IVAR;
> }
> 
> @end
> 
> 
> 
> Le 4 févr. 2011 à 00:59, James Bucanek a écrit :
> 
>> Hamish Allan  wrote (Thursday, February 3, 2011 
>> 4:05 PM -):
>> 
>>> On 3 February 2011 22:46, James Bucanek  wrote:
>>> 
 I have numerous instance variables which are
 only used by categories.
>>> 
>>> If you compile using -Xclang -fobjc-nonfragile-abi2, you can declare
>>> instance variables in class extensions and kill two birds (improve
>>> locality of reference, remove warnings) with one stone.
>> 
>> I thought non-fragile instance variables required 64-bit Intel and/or 10.5.
>> 
>> I still have to compile for 32-bit, PPC, and (occasionally) OS 10.4, so 
>> moving my instance variables into categories doesn't seem practical at this 
>> point in time.
>> 
>> 
>> 
>> James Bucanek
>> 
>> Author of Professional Xcode 3   ISBN: 9780470525227
>> 
>> and Learn Objective-C for Java DevelopersISBN: 9781430223696
>> 
>> 
>> ___
>> Do not post admin requests to the list. They will be ignored.
>> Xcode-users mailing list  (xcode-us...@lists.apple.com)
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/xcode-users/devlists%40shadowlab.org
>> 
>> This email sent to devli...@shadowlab.org
> 
> -- Jean-Daniel
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org
> 
> This email sent to devli...@shadowlab.org

-- Jean-Daniel




___

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

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

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

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


Read Protected File

2011-02-04 Thread Jeremy Matthews
Hey folks, 

I'm trying to read a protected file (one which I don't have rights to access). 
The only way I know around this is with an Authorization routine + NSTask, or 
to create a Helper Tool. 
Is there a better way?

Also, I'm using auth in my own code for something else, but I'd love some other 
examples just to make sure I'm doing things properly...

Thanks,
jeremy

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

Best text rendering settings?

2011-02-04 Thread Gideon King
Hi, I have a layer I want to draw some text on (10.6 target). To actually draw 
the text, I am creating the NSGraphicsContext using the graphics port, and 
using drawBackgroundForGlyphRange... and drawGlyphsForGlyphRange... to draw the 
text.

The output never looks as good as plain old text in a text view. 

I started playing with some of the settings in the CGContext to see if I could 
make it better. Specifically, I tried:

CGContextSetAllowsAntialiasing
CGContextSetShouldAntialias

CGContextSetAllowsFontSmoothing 
CGContextSetShouldSmoothFonts

CGContextSetAllowsFontSubpixelPositioning
CGContextSetShouldSubpixelPositionFonts
CGContextSetAllowsFontSubpixelQuantization
CGContextSetShouldSubpixelQuantizeFonts

CGContextSetInterpolationQuality

...with various combinations of values, and both with screen fonts and without, 
but the best I got it was the same as what I got without changing any of the 
settings.

I have my layer aligned between device pixels, and all the rest of the drawing 
on the layer looks crisp. I have tried aligning the point that it is drawn both 
on and between device pixels.

Is there anything I can do to improve the rendering of the text on my layer? Is 
there some magic combination of the above factors or something else, that will 
improve the rendering? Is the issue because I'm switching to the 
NSGraphicsContext (and if so, how would I do the equivalent drawing using core 
functions)?

The documentation doesn't give very thorough explanations of what each option 
does and when you may want to use it, and doesn't tell you whether it is on or 
off by default, so I feel as if I'm flying blind to some extent. I did see a 
previous thread which did give a bit more information on some of the options, 
but not enough to solve this issue.

It looks "ok", but definitely not as good as the rendering of a text view.

TIA

Gideon





___

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

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

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

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


Web editing issue with WebKit

2011-02-04 Thread Bruce Cresanta
Hello,

I am trying to edit web pages using webkit's setEditable:YES attribute 
set.   It seems that I can edit body text very reliably, but this breaks down 
when I try to edit the text for links.When I try to edit the text for a 
link, the underlying DOM overwrites the   combination so that it all 
becomes body text.Is there a way to lock down the DOM so that only text is 
editable and the tag structure stays intact?

Thanks,

Bruce
___

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

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

Help/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: Smoothly decimating UIImageView images

2011-02-04 Thread Matt Neuburg
On Thu, 3 Feb 2011 12:06:25 -0800, Rick Mann  said:
>I'm doing a photo browser of sorts, as part of a larger app. We display a few 
>thumbnails, and if the user taps one, they're presented with the full-size 
>image.
>
>The problem is that I start with the large images, and when I set them on the 
>small UIImageView, they're scaled down and look pretty bad. I have access to a 
>better thumbnail-size version of the image, but that complicates the code to 
>display them.
>
>I don't see any way of changing the decimation algorithm on UIImageView or 
>UIImage, but I did find the minificationFilter on CALayer. Changing that 
>setting on the UIImageView had no effect. I also tried different 
>minificationFilterBias values, to no effect.

I don't know the answer to your question, but my feeling is that you shouldn't 
"show the large image on a small UIImageView": you should obtain a scaled image 
and show that. My understanding is that even if the image view is small, it 
must maintain the image you give it. Maintaining the memory for several large 
images can make your app less responsive or even kill it. If I'm wrong someone 
will correct me, but that's the impression I got from at least two different 
WWDC 2010 videos.

I haven't used the minification filter, but I'm not surprised that changing it 
had no effect, since this is a layer property, and you are not shrinking the 
layer.

My impulse, therefore, is to say: don't be lazy, use a thumbnail-size version 
of the image, even if that "complicates the code".

m.

--
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.apeth.net/matt/default.html#applescriptthings___

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

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

Help/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: Read Protected File

2011-02-04 Thread Ken Thomases
On Feb 4, 2011, at 7:10 AM, Jeremy Matthews wrote:

> I'm trying to read a protected file (one which I don't have rights to 
> access). The only way I know around this is with an Authorization routine + 
> NSTask, or to create a Helper Tool. 
> Is there a better way?

Don't know if it's better, but you can use the "authopen" command.  
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/authopen.1.html

Cheers,
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: Best Approach in displaying the Image in Core Animation Layer - During the animation

2011-02-04 Thread David Duncan
On Feb 3, 2011, at 11:11 PM, Sasikumar JP wrote:

> During the Edit mode(Wiggle Animation), Image in Grid(Layer) is not
> displayed properly.Even though i get 60 FPS during the wiggle
> animation,image edge is not smooth.

On iOS antialiasing doesn't occur between layers, which is why you get the 
jagged edge (the edgeAntialiasingMask property has no effect). If you want to 
smooth the edge, you will have to do so yourself by drawing the image into a 
slightly larger layer (1 pixel border should be enough)

> What is the difference in the following 2 approaches.
> Which is the best approach to display the icon image in layer during
> Animation (Wiggle Animation).
> 
> 1. Layer.content
> 2. Override drawLayer method and draw the image using [UIImage drawRect]
> method.


That depends on what exactly you are doing inside of -drawLayer:. If you are 
just drawing the image to the entire area of the context provided, then you are 
basically making a (likely unnecessary) copy of the image. If you are doing 
other drawing than just the image, then thats the difference.

For your specific case, making your layer 2 pixels wider and taller, then 
drawing the image into the center of that layer (to make a 1 pixel border) will 
likely give you the effect that you desire, although at the cost of additional 
rendering time since your layers will no longer be opaque.
--
David Duncan

___

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

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

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

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


Re: Best text rendering settings?

2011-02-04 Thread David Duncan
On Feb 4, 2011, at 5:15 AM, Gideon King wrote:

> The output never looks as good as plain old text in a text view. 


Do you draw a background for your text? If you are drawing over transparency 
then sub-pixel antialiasing doesn't work and when you do the final composite 
you see text that doesn't look as good as text drawn over a background.
--
David Duncan

___

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

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

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

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


Fwd: Best Approach in displaying the Image in Core Animation Layer - During the animation

2011-02-04 Thread Sasikumar JP

> 
> David,
> 
> On 04-Feb-2011, at 10:05 PM, David Duncan wrote:
> 
>> On Feb 3, 2011, at 11:11 PM, Sasikumar JP wrote:
>> 
>>> During the Edit mode(Wiggle Animation), Image in Grid(Layer) is not
>>> displayed properly.Even though i get 60 FPS during the wiggle
>>> animation,image edge is not smooth.
>> 
>> On iOS antialiasing doesn't occur between layers, which is why you get the 
>> jagged edge (the edgeAntialiasingMask property has no effect). If you want 
>> to smooth the edge, you will have to do so yourself by drawing the image 
>> into a slightly larger layer (1 pixel border should be enough)
>> 
>>> What is the difference in the following 2 approaches.
>>> Which is the best approach to display the icon image in layer during
>>> Animation (Wiggle Animation).
>>> 
>>> 1. Layer.content
>>> 2. Override drawLayer method and draw the image using [UIImage drawRect]
>>> method.
>> 
>> 
>> That depends on what exactly you are doing inside of -drawLayer:. If you are 
>> just drawing the image to the entire area of the context provided, then you 
>> are basically making a (likely unnecessary) copy of the image. If you are 
>> doing other drawing than just the image, then thats the difference.
>> 
>> For your specific case, making your layer 2 pixels wider and taller, then 
>> drawing the image into the center of that layer (to make a 1 pixel border) 
>> will likely give you the effect that you desire, although at the cost of 
>> additional rendering time since your layers will no longer be opaque.
>> --
>> David Duncan
>> 

Thank you for the response.

I understood the issue here. But i am not clear how to implement your solution. 
could you guide me what type of API i should use to implement your solution.

Thanks
Sasikumar JP


___

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

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

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

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


Processing Video Frame in Realtime

2011-02-04 Thread Rikza Azriyan
Anyone can help me...
I want to processing video frame in realtime, the video frame was got from 
sampleBuffer on AVCaptureVideoDataOutputDelegate Method.
My last destination is processing each frame by openCV and show up the result 
on the screen.

Please, i need your helps...

Thanks in Advance

Rikza Azriyan
Student of Sriwijaya University
Palembang, Indonesia

Sent from my iPhone
Provided by Telkomsel.
___

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

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

Help/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: Best Approach in displaying the Image in Core Animation Layer - During the animation

2011-02-04 Thread David Duncan
On Feb 4, 2011, at 8:55 AM, Sasikumar JP wrote:

> I understood the issue here. But i am not clear how to implement your 
> solution. could you guide me what type of API i should use to implement your 
> solution.


You already mentioned them yourself. You just draw the image into the a 
slightly larger layer as I mentioned, using the very same APIs that you 
mentioned :).
--
David Duncan

___

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

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

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

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


Re: Best text rendering settings?

2011-02-04 Thread Gideon King
Sometimes the layer is transparent, and sometimes it will have a color drawn 
behind where the text is (not a background color for the layer though). The 
superlayer is transparent, but behind that is an opaque view.

Even where there is an opaque fill drawn behind the text on the layer, it's 
still not quite as good as a text view.

Here's an image: http://flic.kr/p/9fzCPV

The one on the left with the box around it has a white filled path behind it on 
the layer. The middle one has no background drawn on the layer. The one on the 
right is an ordinary text view. All done in Arial 17pt.

On 05/02/2011, at 2:40 AM, David Duncan wrote:

> On Feb 4, 2011, at 5:15 AM, Gideon King wrote:
> 
>> The output never looks as good as plain old text in a text view. 
> 
> 
> Do you draw a background for your text? If you are drawing over transparency 
> then sub-pixel antialiasing doesn't work and when you do the final composite 
> you see text that doesn't look as good as text drawn over a background.
> --
> David Duncan
> 

___

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

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

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

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


Re: Best text rendering settings?

2011-02-04 Thread David Duncan
On Feb 4, 2011, at 9:42 AM, Gideon King wrote:

> Sometimes the layer is transparent, and sometimes it will have a color drawn 
> behind where the text is (not a background color for the layer though). The 
> superlayer is transparent, but behind that is an opaque view.

The layers behind won't matter, because by that point you are in the compositor 
and far beyond Quartz.

> Even where there is an opaque fill drawn behind the text on the layer, it's 
> still not quite as good as a text view.
> 
> Here's an image: http://flic.kr/p/9fzCPV
> 
> The one on the left with the box around it has a white filled path behind it 
> on the layer. The middle one has no background drawn on the layer. The one on 
> the right is an ordinary text view. All done in Arial 17pt.


Flicker won't let me download the silly thing so its harder to analyze, but the 
major difference between the first and third image looks like layout metrics 
(which is above Quartz) and so the question there might be what is Cocoa Text 
doing differently (which is beyond my knowledge). The first and second look 
like identical metrics with the issue I pointed out (sub-pixel on vs off).
--
David Duncan

___

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

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

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

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


Re: Best text rendering settings?

2011-02-04 Thread Gideon King
Thanks David. My users are used to very crisp fonts from previous releases of 
my software, so some of them are asking why the new version is not quite as 
good as the previous one. I'm pretty much taking your reply to mean that I'm 
doing the best I can with the technology I'm using. 

I'm surprised that there is a difference between the layouts when I draw it vs 
when the textview draws it.

Thanks

Gideon

On 05/02/2011, at 3:54 AM, David Duncan wrote:

> On Feb 4, 2011, at 9:42 AM, Gideon King wrote:
> 
>> Sometimes the layer is transparent, and sometimes it will have a color drawn 
>> behind where the text is (not a background color for the layer though). The 
>> superlayer is transparent, but behind that is an opaque view.
> 
> The layers behind won't matter, because by that point you are in the 
> compositor and far beyond Quartz.
> 
>> Even where there is an opaque fill drawn behind the text on the layer, it's 
>> still not quite as good as a text view.
>> 
>> Here's an image: http://flic.kr/p/9fzCPV
>> 
>> The one on the left with the box around it has a white filled path behind it 
>> on the layer. The middle one has no background drawn on the layer. The one 
>> on the right is an ordinary text view. All done in Arial 17pt.
> 
> 
> Flicker won't let me download the silly thing so its harder to analyze, but 
> the major difference between the first and third image looks like layout 
> metrics (which is above Quartz) and so the question there might be what is 
> Cocoa Text doing differently (which is beyond my knowledge). The first and 
> second look like identical metrics with the issue I pointed out (sub-pixel on 
> vs off).
> --
> David Duncan
> 

___

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

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

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

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


Re: Home-brewed code is 100X faster than -[NSScanner scanDecimal:] ??

2011-02-04 Thread Jerry Krinock

On 2011 Feb 03, at 13:57, glenn andreas wrote:

> Why not just use NSScanner's scanDouble: instead of trying to scan a string 
> that you think is valid and then convert to a double?

Well, because in running my tests I'd observed that using -scanDecimal: 
degraded performance even when it tried and failed to scan a non-number string, 
but I forgot that in real life you usually know enough about the structure of 
the string you're scanning that you rarely do this.

I've since realized that this thing is difficult to optimize in the general 
case.  What I'm actually trying to do is improve the performance of Blake 
Seely's BSJSONAdditions category on NSScanner, where it scans the JSON string 
representing a number value.  Blake used -scanDecimal:, which is bulletproof, 
but is sometimes way slow (read on), and few applications need 38 decimal 
places of accuracy.  The JSON standard allows "e/E" notation to be used in 
number strings, but does not allow for localized decimal separators; i.e. it's 
always ".".  And, in Blake's design, the method will not execute for valid JSON 
if there is not a valid number string at the scan location.  In my current 
project, the number strings are all integers, although many are 64-bit 
integers.  In some cases (accounting/finance??), one may need the 
38-decimal-digit precision of NSDecimal.

So, here's my last shot in case anyone is following this.  Probably there are 
still corner cases I haven't thought of, but anyhow, this works for me.  With 
the parameters as hard-coded below, the speedup of "not-accurately" vs. 
"scanDecimal" case is about 120x.  Anyone needing to optimize the performance 
of number-string scanning can adjust the parameters to fit their project.

One sure conclusion is that, if you plan to scan long strings, hundreds of KB, 
you will greatly improve performance, and possibly eliminate crashes, by 
surrounding -scanDecimal: with its own local autorelease pool.

Another conclusion is that the speedup is highly sensitive to the length of the 
string, which is controlled by the 'strexponent' in main().  For strings of 100 
characters or less, there is not much speed improvement.  However, for longer 
strings the speed improvement is approximately proportional to 2^strexponent, 
which is the length of the string.  This makes no sense to me, since, in my 
mind, -scanDecimal: should begin scanning at the scanLocation, scan whatever 
number string is there, and then stop.  It should not even need to know the 
characters before or after.  But probably I'm overlooking some unforeseen  
requirement of some corner case.

Thanks again for the feedback on this.

#import 

@interface NSScanner (Speedy)

/*!
 @briefScans for a string representing a number value, returning
 if found by reference, and offering an option to improve performance
 if "double precision" is sufficient.
 
 @details  The string to be scanned may be either a plain decimal
 number string such as "-123.456", or a string using scientific
 "e" notation such as "-123e10".
 
 The performance improvement when using accurately:NO is typically
 120x when scanning a string of 60K characters, and also autoreleased
 memory allocations are greatly reduced.  The improvement is
 propotional to the string length in this regime.
 
 This method is optimized assuming that the decimal point in the
 scanned numbers is the dot ".", and never localized to ",".
 
 Invoke this method with NULL as number to simply scan past a string
 representation of a number.
 
 @paramnumber  Upon return, contains the scanned value as either an
 NSNumber or NSDecimalNumber value.

 @paramaccurately  If YES, the 'number' pointed to upon return will
 be an NSDecimalNumber, with 38 decimal digits of precision.  If NO,
 the 'number' pointed to upon return will be an NSNumber whose value
 is only as accurate as the 'binary64' variant defined in the IEEE
 Standard for Floating-Point Arithmetic (IEEE Standard 754).
 
 @result   YES if the receiver scans anything, otherwise NO.
 */
- (BOOL)scanJSONNumber:(NSNumber**)number
accurately:(BOOL)accurately ;

@end

@implementation NSScanner (Speedy)

- (BOOL)scanJSONNumber:(NSNumber**)number
accurately:(BOOL)accurately {
BOOL result = NO ;

if (!accurately) {
NSCharacterSet* integerSet = [NSCharacterSet 
characterSetWithCharactersInString:@"0123456789+-"] ;
NSCharacterSet* floatSet = [NSCharacterSet 
characterSetWithCharactersInString:@"0123456789+-eE."] ;
NSInteger scanLocation = [self scanLocation] ;
[self scanCharactersFromSet:integerSet
 intoString:NULL] ;
NSInteger nextNonInteger = [self scanLocation] ;
[self setScanLocation:scanLocation] ;
[self scanCharactersFromSet:floatSet
 intoString:NULL] ;
NSInteger nextNonFloat = [self scanLocation] ;
[self setScanLocation:scanLocation] ;

BOOL isInteger = (nextNonFlo

Common Font Style Names

2011-02-04 Thread Gordon Apple
This used to work, but not under iOS 4.

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

Now I get names like "Oblique" instead of "Italic".  Is there a better way
to get the common style names for display?


___

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

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

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

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


Is childrenKeyPathForNode robust?

2011-02-04 Thread John Terranova
I'm trying to implement a source list type of NSOutlineView, where each section 
of the source list has a SourceListSection object. Each SourceListSection 
object has an NSArrayController, filled with a different type of managed object 
from core data. The NSOutlineView is populated through bindings to the 
NSTreeController, whose content is an NSArrayController of SourceListSections.

I use - (NSString *)childrenKeyPathForNode:(NSTreeNode *)node to return 
different children key paths based on the node's representedObject. For the 
SourceListSection I return @"itemsController.arrangedObjects" and for the 
managed objects I return @"children".

- (NSString *)childrenKeyPathForNode:(NSTreeNode *)node
{
id rep = [node representedObject];

if ([rep isKindOfClass:[SourceListSection class]])
return @"itemsController.arrangedObjects";

return @"children";
}


The problem is that when I edit the table entry for a managed object (just a 
name attribute), then valueForKeyPath:@"itemsController.arrangedObjects" is 
sent to the managed objects, where @"children" should be sent instead.

Is the parent's keyPath being wrongly sent to its children in Cocoa, or am I 
misusing childrenKeyPathForNode:? There is very little documentation, blogging, 
of other discussions about childrenKeyPathForNode: that I can find. Perhaps 
because it is not used very much?

Should I avoid using childrenKeyPathForNode:, work around its quirks, or just 
use it correctly (how?) ? Any enlightenment would be appreciated. Thanks.

john terranova
___

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

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

Help/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: Home-brewed code is 100X faster than -[NSScanner scanDecimal:] ??

2011-02-04 Thread Jerry Krinock
Sorry, in the last message I posted some stupid code which was written too late 
last night.  The -scanJSONNumber:accurately: implementation should be simply 
this:

- (BOOL)scanJSONNumber:(NSNumber**)number
accurately:(BOOL)accurately {
BOOL result = NO ;

if (!accurately) {
double daDouble ;
result = [self scanDouble:&daDouble] ;
if (result) {
*number = [NSNumber numberWithDouble:daDouble] ;
}
}
else {
NSDecimal decimal ;
// This local autorelease pool is quite necessary, when parsing
// strings with dense numbers, of 500K characters.  Otherwise,
// memory allocations go into the gigabytes.
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init] ;
result = [self scanDecimal:&decimal] ;
[pool release] ;
if (result) {
*number = [NSDecimalNumber decimalNumberWithDecimal:decimal] ;
}
}

return result ;
}

___

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

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

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

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


Identify key colour in video/photo

2011-02-04 Thread Michael Hanna
A few years back there was a sample code app that would use a key
colour(like bright pink) found in a movie frame and then replace the
content with this something else. In the movie the apple developer(I
presume) would move the bright pink ball around and the app would
superimpose an image of a duck.. anybody know where I can find this?

If not, what api would be useful to do this? something in quicktime?

regards,
Michael
___

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

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

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

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


IKImageView to NSImage?

2011-02-04 Thread Jim Leno
I have an IKIMageView inside of a scroll view that can be zoomed. I would like 
to be able to capture the visible portion of the image to an NSImage.

I've tried the following code example to create an image rep and then use that 
to create a new NSImage. I've tried it on the scroll view, the scroll clip view 
and the image view iself and none of them give me the portion of the image 
visible in the image view.  The scroll view and clip view return an all white 
image, and the image view seems to return nothing.

[view lockFocus];
NSBitmapImageRep *bits = [[NSBitmapImageRep alloc] initWithFocusedViewRect: 
[view bounds]];
[view unlockFocus];

I know the image view has a valid image because I can ask for it and construct 
a new image from the CGImageRef, but that is the original, full size image, not 
the visible scaled portion.

Thanks in advance for any suggestions.


___

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

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

Help/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: NSBitmapImageRep with floating point values

2011-02-04 Thread Ken Ferry
On Thu, Feb 3, 2011 at 2:37 PM, David Duncan  wrote:

> On Feb 3, 2011, at 1:32 PM, Paul Morel wrote:
>
> > in my application I would need to save an image where pixel intensities
> are floating point values. Apparently TIFF can support that.But I don't know
> I can do that in Objective-C. I saw that there is a bitmap format
> "NSFloatingPointSamplesBitmapFormat" that can be used. Does anybody knows
> how to use it? I tried to use a (float **) instead of (unsigned char **) but
> it doesn't work of course, because it is supposed to receive (unsigned char
> **)!
>
> Did you try just allocating an appropriately sized buffer and typecasting
> to (unsigned char **)? The type cast doesn't change the data, just the
> compiler's interpretation of it (and since this is a pointer that won't
> affect the data itself in anyway).
>

Yes, unsigned char here really is just intended to signify "raw data" - a
byte stream.  The byte stream may be interpreted as floating point data
channels.

-Ken


> --
> David Duncan
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com
>
> This email sent to kenfe...@gmail.com
>
___

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

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

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

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