Re: AVFoundation and kYUVSPixelFormat from AVPlayer

2011-10-12 Thread vade
In my experience with AVFoundation, its really not ready for anything more than 
simple playback apps using Core Animation / AVPlayerLayer.

You have noticed there is no visual context replacement, and no way to get 
reasonably fast access to CVPixelbufferRefs of CVOpenGLTextureRefs at all. 
Anyone who wants to handle processing/display or do anything out of the 
ordinary with the pixels from an AVPlayerItem is, for the time being, probably 
wasting their time.

32 bit background process leveraging the older QTVisualContext API and sharing 
the frames with IOSurface provides more flexibility, more codec support, and 
higher performance (amazingly) in many scenarios.

I was very sad when I saw the limited codec support, and the API limitations of 
AVFoundation, its not quite a replacement for Quicktime, or even QTKit. I hope 
that changes soon though. FWIW, I did file a bug/request for expanded API 
usage,  and a complaint (and 5 or so) or performance of fetching CVPixelBuffers 
from Core Media Samples during the 10.7 beta...

2C++

On Oct 11, 2011, at 11:04 PM, Mr. Gecko wrote:

> I understand this and have things to account for this already working. I 
> would explain what my program does, but that will take a long time. Basically 
> the reason I need it in CVImageBufferRef using YUV format of pixles is 
> because I am doing off process playing of video and just receiving the images 
> to render using NSOpenGLView with memory maps and shared memory between the 
> processes.
> 
> On 10/11/11 9:46 PM, Robert Monaghan wrote:
>> Hi,
>> 
>> A quick word of warning, while QTKit is being deprecated for 
>> AVFoundation/Core Media, there is no third party codec support in the new 
>> APIs. I would consider this while you develop your app. I doubt that 3rd 
>> party codec support for Core media is going to arrive as fast (or as 
>> complete) as we would like.
>> 
>> bob.
>> (A quicktime codec developer that would love to write AVFoundation/Core 
>> Media Codecs, but can'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/vade%40vade.info
> 
> This email sent to v...@vade.info

___

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

Please do not post admin requests or moderator comments to the list.
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: AVFoundation and kYUVSPixelFormat from AVPlayer

2011-10-12 Thread Jean-Daniel Dupas

Le 12 oct. 2011 à 04:46, Robert Monaghan a écrit :

> Hi,
> 
> A quick word of warning, while QTKit is being deprecated for 
> AVFoundation/Core Media, there is no third party codec support in the new 
> APIs. I would consider this while you develop your app. I doubt that 3rd 
> party codec support for Core media is going to arrive as fast (or as 
> complete) as we would like.

Did you fill a feature request about it ? That the only thing we can do, but if 
there is enough request, maybe it may come faster than expected. CoreMediaIO 
already has a CoreMedia Unit private API (a seen in the Resources folder of the 
CoreMediaIO framework), so it may not require too much works to provide an API 
to third party codecs and muxer/demuxer writers.


-- 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: Keeping grayscale image grayscale

2011-10-12 Thread Heinrich Giesen

Jonathan Taylor wrote:
> I'm working with 16-bit grayscale images, and for the most part I'm just 
> manipulating bits within NSBitmapImageRep objects. However for convenience it 
> would be nice to do some stuff with NSImages, particularly when rescaling and 
> suchlike. The problem is that whenever I draw into such an NSImage it gets 
> converted to 3x8 bit RGB. Is there a simple way I can force things to stay 
> grayscale, or am I fighting a losing battle here.

You are not fighting a losing battle, you use the wrong methods to create an 
NSBitmapImageRep with properties you want.
If you want to create an NSImage/NSImageRep with special properties: there is a 
rule of thumb: don't use lockFocus.
  --> Re: bad behavior from unlockFocus on 10.6 by Ken Ferry.
Another rule of thumb is: if you need -[NSImage TIFFRepresentation] you do 
something wrong.
(There are of course counterexamples).

The following code does (I hope so) what you want:


NSImage *srcImage = [[NSImage alloc] initWithContentsOfFile:thePath];

// create a new empty NSBitmapImageRep
NSBitmapImageRep *newRep = [[NSBitmapImageRep alloc] 
initWithBitmapDataPlanes:NULL
pixelsWide: (NSInteger)newWidth
pixelsHigh: (NSInteger)newHeight
bitsPerSample: 16
samplesPerPixel: 1
hasAlpha: NO// YES is not supported
isPlanar: NO
colorSpaceName: NSCalibratedWhiteColorSpace
bytesPerRow: 0
bitsPerPixel: 0];

//Now save the current NSGraphicsContext and set a new one
[NSGraphicsContext saveGraphicsState];
NSGraphicsContext *newContext = [NSGraphicsContext 
graphicsContextWithBitmapImageRep: newRep];
[NSGraphicsContext setCurrentContext: newContext];

[srcImage drawInRect:NSMakeRect( 0, 0, [newRep pixelsWide], [newRep 
pixelsHigh] )
fromRect:NSZeroRect
operation:NSCompositeCopy
fraction:1.0];

// Restore the previous graphics context and state.
[NSGraphicsContext restoreGraphicsState];

and see what the newRep looks like:
NSLog( @"newRep is:%@", newRep );


This code creates a 16 bit grayscale image whatever the source image is.

Good luck
Heinrich





___

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

Please do not post admin requests or moderator comments to the list.
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: AVFoundation and kYUVSPixelFormat from AVPlayer

2011-10-12 Thread vade
Yes, I filled a request for a QTVisualContext like API, bug number 9262865, 
filed April 10th :)

On Oct 12, 2011, at 4:31 AM, Jean-Daniel Dupas wrote:

> 
> Le 12 oct. 2011 à 04:46, Robert Monaghan a écrit :
> 
>> Hi,
>> 
>> A quick word of warning, while QTKit is being deprecated for 
>> AVFoundation/Core Media, there is no third party codec support in the new 
>> APIs. I would consider this while you develop your app. I doubt that 3rd 
>> party codec support for Core media is going to arrive as fast (or as 
>> complete) as we would like.
> 
> Did you fill a feature request about it ? That the only thing we can do, but 
> if there is enough request, maybe it may come faster than expected. 
> CoreMediaIO already has a CoreMedia Unit private API (a seen in the Resources 
> folder of the CoreMediaIO framework), so it may not require too much works to 
> provide an API to third party codecs and muxer/demuxer writers.
> 
> 
> -- 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/vade%40vade.info
> 
> This email sent to v...@vade.info

___

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

Please do not post admin requests or moderator comments to the list.
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: AVFoundation and kYUVSPixelFormat from AVPlayer

2011-10-12 Thread Robert Monaghan
Believe me, the appropriate people at Apple are aware of this.

There is more to the problem than just Codecs. There is a lot of other 
functionality missing, too. (Custom Data handling, etc)
But in the meantime, I would really encourage developers to file enhancement 
requests of their own. Currently, QTKit is really the only game in town for 
Media usage.
Lets hope this changes sooner than later!

bob


On Oct 12, 2011, at 1:31 AM, Jean-Daniel Dupas wrote:

> 
> Le 12 oct. 2011 à 04:46, Robert Monaghan a écrit :
> 
>> Hi,
>> 
>> A quick word of warning, while QTKit is being deprecated for 
>> AVFoundation/Core Media, there is no third party codec support in the new 
>> APIs. I would consider this while you develop your app. I doubt that 3rd 
>> party codec support for Core media is going to arrive as fast (or as 
>> complete) as we would like.
> 
> Did you fill a feature request about it ? That the only thing we can do, but 
> if there is enough request, maybe it may come faster than expected. 
> CoreMediaIO already has a CoreMedia Unit private API (a seen in the Resources 
> folder of the CoreMediaIO framework), so it may not require too much works to 
> provide an API to third party codecs and muxer/demuxer writers.
> 
> 
> -- 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: Retain/Release and Properties clarification

2011-10-12 Thread Bayes Scott F
Someone on Matt's site mentioned the possibility that the synthesized ivar 
could be implemented indirectly, say as a member of a collection. Since the 
implementation's opaque, we don't know if that ever can happen.

So, is self->mySynthIvar safe (both lvalue and rvalue), or should we be 
messaging?

And does the compiler ever shortcut something like self.mySynthSimpleIntVar to 
self->mySynthSimpleIntVar, or does it always use the setter/getter?

Thanks


ScottB

On Oct 11, 2011, at 10:12 , David Duncan wrote:

> On Oct 11, 2011, at 9:57 AM, Matt Neuburg wrote:
> 
>> I did everything "right" when I named an ivar "firstResponder" (property, 
>> synthesized ivar, synthesized accessors) and totally broke my app because 
>> Apple was apparently already using an undocumented ivar called 
>> "firstResponder".
>> 
>> http://www.cocoabuilder.com/archive/cocoa/296662-assign-property-behaves-differently-from-simple-instance-variable.html
> 
> The problem wasn't an undocumented ivar, it was an undocumented method. The 
> @synthesize thus overrode the existing method and broke your project because 
> parts of UIKit were expecting the default implementation and got your 
> implementation instead.
> 
> As a rule, we strive to avoid this situation, but unfortunately this does 
> happen on occasion.
> 
>> Also, note that there are circumstances where a synthesized ivar won't work; 
>> see, for instance, this note:
>> 
>> http://www.cocoabuilder.com/archive/cocoa/298320-inherited-implicitly-created-member-is-no-member.html
> 
> The gist of this is that synthesized ivars are private, and the public 
> interface (the @property) doesn't tell you about private implementation 
> details (the ivar). As such, subclasses can't get at synthesized ivars, 
> precisely because the @synthesize declaration is hidden from them.
> --
> 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/scottbayes-dev%40comcast.net
> 
> This email sent to scottbayes-...@comcast.net

___

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

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

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

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


Re: drawRect not being called by NSCollectionView..

2011-10-12 Thread Robert Monaghan
Ok,

A further update:

After doing some reading on this list, and some additional reading Apple's 
site, I learned that Core Animation is being used.
Just for fun, I in my NSCollectionViewItem's NSView, I called 
"setWantsLayers:YES". Suddenly my items started showing up!
(Well, they are showing up if you like garbage all over the NSView.)

In IB, I enabled the Core Animation Layer for my NSView. Then I enabled a Core 
Animation layer for my NSCollectionView.
Things are almost working! However:

- Not all of the imagery is properly re-drawn.
- Why is my first NSCollectionView working just fine, yet my second one needs 
all of these Animation layers enabled?

Progress at least!
My hunch is this: Two separate NSCollectionViews needs some Core Animation 
tweaking to make work.

bob.


On Oct 10, 2011, at 7:43 PM, Robert Monaghan wrote:

> Well,
> 
> After some troubleshooting, it looks like the NSView that is attached to the 
> NSCollectionViewItem object is missing its superview.
> Does any know how this might be possible??
> 
> I can see my Subclassed NSView being created. AwakeFromNib works, as does 
> hitTest.
> The drawRect does get called, but the call to superview fails, because it is 
> set to nil.
> 
> Just for laughs, I created another NSCollectionView, with NSArrayController, 
> etc, and manually add objects. This works, with the NSViews displaying 
> properly.
> Is there a way to force NSCollectionView to reload/re-display the NSViews 
> with a proper superview set?
> 
> bob.
> 
> On Oct 10, 2011, at 4:49 PM, Robert Monaghan wrote:
> 
>> Hi Everyone,
>> 
>> I can't seem to get an NSCollectionView to render an of the 
>> NSCollectionViewItems' NSViews.
>> 
>> I have an NSCollectionView that is bound to an NSArrayController's 
>> arrangedObjects.
>> The NSCollectionViewItem is set up as a template, and also has its Outlet 
>> attached to an NSView.
>> For fun I added a text label as well as an image from the Media Library, as 
>> a placeholder image on the NSView.
>> (It helps to have something to look at!)
>> 
>> I don't have anything bound to the NSView at all.
>> I haven't subclassed anything either. These are the standard objects within 
>> IB.
>> 
>> My App inserts objects into an array using the NSArrayController as needed.
>> However, as this happens, *nothing* is rendered at all. As a test, I have 
>> subclassed the NSView, and checked the drawRect method.
>> 
>> Nothing.
>> 
>> I enabled selectable in my NSCollectionView and checked for a hitTest method 
>> in my view. I can blindly click inside the NSCollectionView to the 
>> approximate location of the view, and see an hitTest response. Strange! So I 
>> know that my NSView is being recognized by my NSCollectionView, as hitTest 
>> is being called. But drawRect isn't happening.
>> 
>> Can anyone hazard a guess at what I am doing wrong?
>> 
>> Some notes..
>> This interface is to drive a network device. As such, the UI doesn't 
>> actually populate with anything until it is discovered over the network.
>> As a matter of fact, the array that the NSArrayController uses doesn't even 
>> exit during the "awakeFromNib" process. The actual array is created as soon 
>> as the device comes online, and is attached using a binding. Perhaps I need 
>> to send some sort of message to the NSCollectionView after the new array is 
>> bound?
>> 
>> Thanks!
>> 
>> bob.
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/bob%40gluetools.com
>> 
>> This email sent to b...@gluetools.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: Retain/Release and Properties clarification

2011-10-12 Thread David Duncan
On Oct 12, 2011, at 9:21 AM, Bayes Scott F wrote:

> Someone on Matt's site mentioned the possibility that the synthesized ivar 
> could be implemented indirectly, say as a member of a collection. Since the 
> implementation's opaque, we don't know if that ever can happen.

I can't say that I know what could be done, thats something the compiler guys 
would have to figure out :).

> And does the compiler ever shortcut something like self.mySynthSimpleIntVar 
> to self->mySynthSimpleIntVar, or does it always use the setter/getter?


Due to the nature of C and Obj-C, the compiler can never safely short circuit 
the message send. From C's point of view this is due to the compiler seeing an 
opaque implementation of objc_msgSend*() where you see the accessor, as such 
the C compiler cannot inline the function. From an Obj-C point of view, the 
primary issue is that the compiler doesn't actually know for certain that other 
code in your application or the frameworks it links against haven't changed the 
implementation of your accessor and thus require it to be called for correct 
operation.
--
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: AVFoundation and kYUVSPixelFormat from AVPlayer

2011-10-12 Thread Mr. Gecko
Just so Apple knows we want this, I'll also fill an enhancement request for a 
QTVisualContext like API it's really useful for realtime video effects and off 
process video playing. The more people who files bug reports for the same 
thing, the more Apple knows we want this.

On Oct 12, 2011, at 11:11 AM, Robert Monaghan wrote:

> Believe me, the appropriate people at Apple are aware of this.
> 
> There is more to the problem than just Codecs. There is a lot of other 
> functionality missing, too. (Custom Data handling, etc)
> But in the meantime, I would really encourage developers to file enhancement 
> requests of their own. Currently, QTKit is really the only game in town for 
> Media usage.
> Lets hope this changes sooner than later!
> 
> bob
___

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

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

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

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


Re: Retain/Release and Properties clarification

2011-10-12 Thread Bayes Scott F
Thank you, David, that's pretty clear.

Sounds like safety first for my code: always use the setter/getter for 
synthesized properties, even in self.

Or use @private ivars.

ScottB

On Oct 12, 2011, at 09:46 , David Duncan wrote:

> On Oct 12, 2011, at 9:21 AM, Bayes Scott F wrote:
> 
>> Someone on Matt's site mentioned the possibility that the synthesized ivar 
>> could be implemented indirectly, say as a member of a collection. Since the 
>> implementation's opaque, we don't know if that ever can happen.
> 
> I can't say that I know what could be done, thats something the compiler guys 
> would have to figure out :).
> 
>> And does the compiler ever shortcut something like self.mySynthSimpleIntVar 
>> to self->mySynthSimpleIntVar, or does it always use the setter/getter?
> 
> 
> Due to the nature of C and Obj-C, the compiler can never safely short circuit 
> the message send. From C's point of view this is due to the compiler seeing 
> an opaque implementation of objc_msgSend*() where you see the accessor, as 
> such the C compiler cannot inline the function. From an Obj-C point of view, 
> the primary issue is that the compiler doesn't actually know for certain that 
> other code in your application or the frameworks it links against haven't 
> changed the implementation of your accessor and thus require it to be called 
> for correct operation.
> --
> 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: Retain/Release and Properties clarification

2011-10-12 Thread Greg Parker
On Oct 12, 2011, at 9:21 AM, Bayes Scott F wrote:
> Someone on Matt's site mentioned the possibility that the synthesized ivar 
> could be implemented indirectly, say as a member of a collection. Since the 
> implementation's opaque, we don't know if that ever can happen.

A property may be implemented using storage that is not an ivar. 
NSManagedObject uses this.

A *synthesized* property will always use an ivar. That's part of the definition 
of @synthesize.


> So, is self->mySynthIvar safe (both lvalue and rvalue), or should we be 
> messaging?

If it's your property, then you're free to access the ivar yourself. Of course, 
direct ivar access may bypass any atomicity or memory management behavior that 
the getter and setter methods enforce.


> And does the compiler ever shortcut something like self.mySynthSimpleIntVar 
> to self->mySynthSimpleIntVar, or does it always use the setter/getter?

Never. Omitting the method call would be an incorrect optimization, because 
(for example) KVO might override the method to perform KVO change 
notifications. To make that optimization safely, you would need something like 
runtime recompilation that could undo the optimization at runtime if necessary.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler


___

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

Please do not post admin requests or moderator comments to the list.
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: Retain/Release and Properties clarification

2011-10-12 Thread Bayes Scott F
Thanks, Greg.


ScottB

On Oct 12, 2011, at 12:12 , Greg Parker wrote:

> On Oct 12, 2011, at 9:21 AM, Bayes Scott F wrote:
>> Someone on Matt's site mentioned the possibility that the synthesized ivar 
>> could be implemented indirectly, say as a member of a collection. Since the 
>> implementation's opaque, we don't know if that ever can happen.
> 
> A property may be implemented using storage that is not an ivar. 
> NSManagedObject uses this.
> 
> A *synthesized* property will always use an ivar. That's part of the 
> definition of @synthesize.
> 
> 
>> So, is self->mySynthIvar safe (both lvalue and rvalue), or should we be 
>> messaging?
> 
> If it's your property, then you're free to access the ivar yourself. Of 
> course, direct ivar access may bypass any atomicity or memory management 
> behavior that the getter and setter methods enforce.
> 
> 
>> And does the compiler ever shortcut something like self.mySynthSimpleIntVar 
>> to self->mySynthSimpleIntVar, or does it always use the setter/getter?
> 
> Never. Omitting the method call would be an incorrect optimization, because 
> (for example) KVO might override the method to perform KVO change 
> notifications. To make that optimization safely, you would need something 
> like runtime recompilation that could undo the optimization at runtime if 
> necessary.
> 
> 
> -- 
> Greg Parker gpar...@apple.com Runtime Wrangler
> 
> 

___

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

Please do not post admin requests or moderator comments to the list.
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: urlFromString creating bad URLs with string containing []

2011-10-12 Thread Martin Linklater
Thanks Mike, 

At the moment I'm using [NSData +dataWithContentsOfURL] running in its own GCD 
dispatch queue. How much better performance should I expect to get using 
NSURLConnection ?

I'll need to weigh up the benefits before I go refactoring the server code.

Cheers.

On 7 Oct 2011, at 15:04, Mike Abdullah wrote:

> 
> On 7 Oct 2011, at 12:45, Martin Linklater wrote:
> 
>> Hi - I'm writing an iOS client for an online retailer and I'm having trouble 
>> with the way NSURL encodes square brackets. I'm building an http request 
>> using a string then converting it to a NSURL before calling [NSData 
>> dataWithContentsOfURL].
> 
> Aside from the URL problem you're having, do NOT use +dataWithContentsOfURL: 
> for this. Use a proper NSURLConnection so you can run it asynchronously 
> without having to fire up a thread.
> 

___

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

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


Locking an object's location to the scroll view (not the document)

2011-10-12 Thread James Maxwell
I'm using GCDrawKit, which has been an amazing help in getting my app's 
interface together. However, I've run into a problem that's making me slightly 
crazy...

My main view is a zooming scroll view. Thanks to drawKit, I generally have no 
problems at all; it handles the zooming beautifully, so I don't even think 
about it. However, what I need to do now is to have certain objects remain in a 
fixed position, relative to the viewable area -- so if, for example, an object 
is in the upper-left corner, it will remain there during scrolling and zooming 
(I DO want it to zoom, but it should stay in the upper-left corner). I managed 
to get this working (or I thought I did), by telling my enclosingScrollView to 
post frame changed notifications, then using those to update the position of 
the object. 

- (void)updateWithScroll
{
NSPoint selfOrigin = [self location];
DKDrawingView* view = [(DKDrawingDocument*)[[self drawing] owner] mainView];
NSRect bounds = [[[view enclosingScrollView] contentView] bounds];
NSPoint origin = bounds.origin;
if(self.lockXPositionToContentRect)
{
selfOrigin.x = origin.x + scrollOffset.x;
}
if(self.lockYPositionToContentRect)
{
selfOrigin.y = origin.y + scrollOffset.y;
}
[self setLocation:selfOrigin];
}

But unfortunately I forgot about zooming, so my objects only stay in their 
correct positions if I'm either: A) at a zoom scale of 1.0, or B) the scroll 
view is at the document's origin (i.e., 0,0 for both document and view). How do 
I do this for both scrolling and zooming? 
(I tried multiplying the location coordinates by the scaling amount, but that 
doesn't quite do it -- it's closer, but not correct.)

Any help appreciated.

J.

--
James B. Maxwell
Composer/Researcher/PhD Candidate
jbmaxw...@rubato-music.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


Can we talk iOS5 yet?

2011-10-12 Thread Jim Adams
Now that it is out can I resubmit my question?

Jim Adams
jim.ad...@sas.com
Principal Systems Developer
SAS Institute


___

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

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


Select model objects with NSTableView using cocoa bindings

2011-10-12 Thread Luc Van Bogaert
Hi,

In my program window, I have some kind of 'inspector' panel, containing an 
NSTableView object, bound to an NSArrayController, which in turn is bound to a 
NSMutableArray of DotController objects. These DotControllers control Dot 
objects, which are custom view objects. 

Adding or removing Dot objects in the program window is reflected correctly in 
the tableview, as rows are added or removed accordingly. Each table row 
correctly displays the Dot index number, X and Y coordinates. So far, so good.

Now, I would also like to use cocoa bindings to somehow link the table 
selection to my Dot objects and vice versa; ie. when I change the selection in 
the table, the corresponding Dot objects should become 'selected' (display in a 
different color), and when I click a Dot in my UI, the corresponding row in the 
table should get selected accordingly.

I wonder if someone could provide some general guidelines on how to implement 
this in IB using bindings.

I'm wondering if I should create a NSIndexSet property in my model object and 
bind it to the NSArrayController's 'selectedIndexes' key? But then, I should 
still somehow 'translate' the content of this indexset to the individual Dot 
(or DotController) objects in my model array…
Or, should I be able to use a BOOL 'selected' property of my DotController 
object and bind it directly to the NSArrayController's selectedIndexes?

I'm also wondering what would be needed, in this context, to get the Dot views 
to redraw themselves once their 'selected' property has been changed...

I hope all this is making some sense to someone on this list and I apologize 
for not being able to explain my problem more clearly.
Thanks for any suggestions.

-- 
Luc Van Bogaert




___

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

Please do not post admin requests or moderator comments to the list.
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: Select model objects with NSTableView using cocoa bindings

2011-10-12 Thread Quincey Morris
On Oct 12, 2011, at 13:31 , Luc Van Bogaert wrote:

> I'm wondering if I should create a NSIndexSet property in my model object and 
> bind it to the NSArrayController's 'selectedIndexes' key?

Yes, but you've got the terminology wrong. The relevant concept here is a 
binding name, and it's "selectionIndexes", not "selectedIndexes". 
NSArrayController also has a "selectionIndexes" property, but that's what the 
table view binds to, and is not involved here (except as an "intermediary" 
property between the table view and the data model -- which is why a 
NSArrayController is a "mediating" controller.) Also, binding actually goes in 
the other direction -- you bind the object with the binding (the array 
controller) to the object with the property (the model). But I'm pretty sure 
that's what you meant. :)

Now that I think about it, the correct place for the NSIndexSet property is 
your window controller (or whatever the window's nib's File's Owner object is), 
*unless* one of the following design considerations applies:

1. You intend to save to selection state to disk with the rest of the data 
model. In that case, the selection status is truly a data model property, not a 
UI-related property.

2. You have multiple windows onto the same data model, and you want them all to 
have the same selection, even if you don't want to save the selection status to 
disk.

> But then, I should still somehow 'translate' the content of this indexset to 
> the individual Dot (or DotController) objects in my model array…

There are various easy, reliable ways of doing this. The simplest is probably 
to implement the "tableViewSelectionDidChange:" method in your table view 
delegate (typically the window controller or File's Owner). Conceptually, all 
you need to do is loop through the Dot objects, and tell each one (a) its new 
selection status [YES or NO] and (b) setNeedsDisplay:YES. In practice, you'd 
fix that so as not to message or redraw the Dots whose state didn't change.

> Or, should I be able to use a BOOL 'selected' property of my DotController 
> object and bind it directly to the NSArrayController's selectedIndexes?

Well, you can't *bind* a binding that requires to a NSIndexSet property to a 
BOOL property, or whatever you're suggesting here. I'd recommend the brute 
force approach I already described, where you just adjust the individual 
selection statuses yourself. Also, I'd likely put the "selected" property on 
the Dot, not the DotController, but the answer will depend on the details of 
your application.

You can also do without an ivar-backed "selected" Dot property if you want. The 
Dot can presumably find out what its own DotController index is, and so can 
presumably find out whether its index is in the NSIndexSet property. In that 
case, you don't have to tell the Dot its status, you just tell it to redraw and 
it figures out the status at redraw time. Either way is fine.

> I'm also wondering what would be needed, in this context, to get the Dot 
> views to redraw themselves once their 'selected' property has been changed...

Again, brute force (as described above, in the delegate method) is the 
simplest, most direct approach: just tell them.


___

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

Please do not post admin requests or moderator comments to the list.
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: -dateWithTimeIntervalSinceNow: 64-bits may overflow

2011-10-12 Thread Sean McBride
On Sat, 8 Oct 2011 21:09:15 -0700, Jerry Krinock said:

>Don't do this:
>
>-[NSDate dateWithTimeIntervalSinceNow:FLT_MAX] ;
>
>Expected result: A date far off into the future which will always behave
>as though it is later than or equal to any other date.
>
>No problem ever in 32-bit executable.
>
>In 64-bit, -[NSDate compare:] and -[NSDate laterDate:] still work as
>expected.  But other methods may not.  For example, -[NSConditionLock
>lockWhenCondition:beforeDate:] seems to think that such a "float max
>date" has already past and returns NO immediately, regardless of its
>'condition'.
>
>I filed a bug, 10256461, but am posting here because I suppose Apple may
>consider this to be a programming error and not a bug.

Strange since NSTimeInterval is double in both 32 and 64 bit.  Why did you use 
FLT_MAX and not DBL_MAX?  No doubt the latter would be even worse. :)

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

Please do not post admin requests or moderator comments to the list.
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: List of registered URI handlers?

2011-10-12 Thread Tito Ciuro
Thanks Ken. I appreciate it.

Regards,

-- Tito

On Oct 11, 2011, at 8:06 PM, Ken Thomases wrote:

> On Oct 11, 2011, at 5:18 PM, Tito Ciuro wrote:
> 
>> How would I determine which URI handlers are registered with the system? For 
>> example, amzn://, fb://, etc.
>> 
>> Is there a way to determine this type of information?
> 
> Not programmatically, I don't believe.  (Launch Services will show you the 
> URI handler for a given scheme, but won't list the known schemes.)
> 
> You can extract that information from the output of
> 
> /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister
>  -dump
> 
> However, you probably can't rely on the format of that output being stable 
> from release to release.  I think that's considered a diagnostic tool, not a 
> supported interface.
> 
> 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: Locking an object's location to the scroll view (not the document)

2011-10-12 Thread James Maxwell
Holy smokes! 
Okay, just used the wrong Rect. Needed to use documentVisibleRect instead of 
the contentView's bounds. Ugh... Working fine now.

J.


On 2011-10-12, at 12:24 PM, James Maxwell wrote:

> I'm using GCDrawKit, which has been an amazing help in getting my app's 
> interface together. However, I've run into a problem that's making me 
> slightly crazy...
> 
> My main view is a zooming scroll view. Thanks to drawKit, I generally have no 
> problems at all; it handles the zooming beautifully, so I don't even think 
> about it. However, what I need to do now is to have certain objects remain in 
> a fixed position, relative to the viewable area -- so if, for example, an 
> object is in the upper-left corner, it will remain there during scrolling and 
> zooming (I DO want it to zoom, but it should stay in the upper-left corner). 
> I managed to get this working (or I thought I did), by telling my 
> enclosingScrollView to post frame changed notifications, then using those to 
> update the position of the object. 
> 
> - (void)updateWithScroll
> {
>NSPoint selfOrigin = [self location];
>DKDrawingView* view = [(DKDrawingDocument*)[[self drawing] owner] 
> mainView];
>NSRect bounds = [[[view enclosingScrollView] contentView] bounds];
>NSPoint origin = bounds.origin;
>if(self.lockXPositionToContentRect)
>{
>selfOrigin.x = origin.x + scrollOffset.x;
>}
>if(self.lockYPositionToContentRect)
>{
>selfOrigin.y = origin.y + scrollOffset.y;
>}
>[self setLocation:selfOrigin];
> }
> 
> But unfortunately I forgot about zooming, so my objects only stay in their 
> correct positions if I'm either: A) at a zoom scale of 1.0, or B) the scroll 
> view is at the document's origin (i.e., 0,0 for both document and view). How 
> do I do this for both scrolling and zooming? 
> (I tried multiplying the location coordinates by the scaling amount, but that 
> doesn't quite do it -- it's closer, but not correct.)
> 
> Any help appreciated.
> 
> J.
> 
> --
> James B. Maxwell
> Composer/Researcher/PhD Candidate
> jbmaxw...@rubato-music.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/jbmaxwell%40rubato-music.com
> 
> This email sent to jbmaxw...@rubato-music.com

--
James B. Maxwell
Composer/Researcher/PhD Candidate
jbmaxw...@rubato-music.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


-viewDidUnload not always called?

2011-10-12 Thread Rick Mann
I've got a fairly simple iOS 4 app, built from the Utility Application 
stationery. I've noticed that the FlipsideVeiwController's -viewDidUnload 
method is not called when that view controller is dismissed/dealloced (even 
though -dealloc is).

I can't tell from the docs for -viewDidUnload if it is not guaranteed to be 
called when cleaning up. It does say that it's called for low-memory 
situations, but also says it's called as a counterpart to -viewDidLoad, which 
is always called when a view controller is created.

The question I have, then: if viewDidUnload is not called when a VC is being 
released, is it guaranteed that it will never be called when a VC is being 
released? I may need to do cleanup in -viewDidUnload that can't be done twice 
(for example, removing a KVO).

I'm observing this behavior in the simulator, iOS 4.3.

-- 
Rick

___

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

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

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

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


Re: Locking an object's location to the scroll view (not the document)

2011-10-12 Thread Graham Cox
HI James,

I would say that even if you have got it working, you're going out on a limb 
there.

If you have elements in your interface that are positioned statically rather 
than part of the general content of the 'canvas' they might be better off being 
put into a separate view that is independent of DrawKit. Without knowing what 
these elements are however, it's hard to advise.

--Graham


On 13/10/2011, at 6:24 AM, James Maxwell wrote:

> I'm using GCDrawKit, which has been an amazing help in getting my app's 
> interface together. However, I've run into a problem that's making me 
> slightly crazy...
> 
> My main view is a zooming scroll view. Thanks to drawKit, I generally have no 
> problems at all; it handles the zooming beautifully, so I don't even think 
> about it. However, what I need to do now is to have certain objects remain in 
> a fixed position, relative to the viewable area -- so if, for example, an 
> object is in the upper-left corner, it will remain there during scrolling and 
> zooming (I DO want it to zoom, but it should stay in the upper-left corner). 
> I managed to get this working (or I thought I did), by telling my 
> enclosingScrollView to post frame changed notifications, then using those to 
> update the position of the object. 
> 
> - (void)updateWithScroll
> {
>NSPoint selfOrigin = [self location];
>DKDrawingView* view = [(DKDrawingDocument*)[[self drawing] owner] 
> mainView];
>NSRect bounds = [[[view enclosingScrollView] contentView] bounds];
>NSPoint origin = bounds.origin;
>if(self.lockXPositionToContentRect)
>{
>selfOrigin.x = origin.x + scrollOffset.x;
>}
>if(self.lockYPositionToContentRect)
>{
>selfOrigin.y = origin.y + scrollOffset.y;
>}
>[self setLocation:selfOrigin];
> }
> 
> But unfortunately I forgot about zooming, so my objects only stay in their 
> correct positions if I'm either: A) at a zoom scale of 1.0, or B) the scroll 
> view is at the document's origin (i.e., 0,0 for both document and view). How 
> do I do this for both scrolling and zooming? 
> (I tried multiplying the location coordinates by the scaling amount, but that 
> doesn't quite do it -- it's closer, but not correct.)
> 
> Any help appreciated.
> 
> J.
> 
> --
> James B. Maxwell
> Composer/Researcher/PhD Candidate
> jbmaxw...@rubato-music.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/graham.cox%40bigpond.com
> 
> This email sent to graham@bigpond.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: -dateWithTimeIntervalSinceNow: 64-bits may overflow

2011-10-12 Thread Jerry Krinock

On 2011 Oct 12, at 14:40, Sean McBride wrote:

> Strange since NSTimeInterval is double in both 32 and 64 bit.  Why did you 
> use FLT_MAX and not DBL_MAX?

Oh, probably when I wrote that code I wasn't aware DBL_MAX, and FLT_MAX was 
more than enough.

> No doubt the latter would be even worse. :)

Not necessarily.  Multiple overflows tend toward a random number generator.

___

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

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


Cocoaheads Lake Forest meeting CANCELLED for 10/12

2011-10-12 Thread Scott Ellsworth
No meeting tonight!

We will reconvene in November - happy halloween!

Scott
___

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

Please do not post admin requests or moderator comments to the list.
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: -dateWithTimeIntervalSinceNow: 64-bits may overflow

2011-10-12 Thread Greg Guerin

Jerry Krinock wrote:

Not necessarily.  Multiple overflows tend toward a random number  
generator.


Doubles overflow to +INF, as do floats.  Arithmetic on INFs typically  
yields one of the INFs (+INF or -INF).  It is decidedly non-random.


It would be an interesting experiment, though.

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


Best way to parse a time today?

2011-10-12 Thread Rick Mann
I have a situation where I have to parse times like "14:50 PDT". If I just set 
up an NSDateFormatter with dateFormat = @"HH:mm z", I end up with a time of day 
in 1970.

What's the best way to get it to give me that time of day today?

Thanks,
Rick

___

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

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

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

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


Re: Best way to parse a time today?

2011-10-12 Thread Roger Dalal
Rick:

The following code, which is likely what you are doing, will return the time in 
1970 (NSDate's reference date) because you have not specified a date:

NSString *timeString = @"14:50 PDT";
NSDateFormatter *df = [[NSDateFormatter alloc ] init];
[df setDateFormat:@"HH':'mm zzz"];
NSDate *date = [df dateFromString:timeString];
[df release];


Instead, you need to use date components to set the day as well as the time, 
per the following:

NSString *timeString = @"14:50 PDT";
NSDateFormatter *df = [[NSDateFormatter alloc ] init];
[df setDateFormat:@"HH':'mm zzz"];
NSDate *date = [df dateFromString:timeString];

NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *dateComponents = [calendar components:( NSYearCalendarUnit | 
NSMonthCalendarUnit |  NSDayCalendarUnit ) fromDate:[NSDate date]];
NSDateComponents *timeComponents = [calendar components:( NSHourCalendarUnit | 
NSMinuteCalendarUnit | NSSecondCalendarUnit ) fromDate: date ];

[dateComponents setHour:[timeComponents hour]];
[dateComponents setMinute:[timeComponents minute]];
[dateComponents setSecond:[timeComponents second]];

NSDate *timeToday = [calendar dateFromComponents:dateComponents];
[df release];

Change 'fromDate' in NSDateComponents *dateComponents to whatever date you want 
in order to create your time on a different day.

Best Wishes.

Roger Dalal




On Oct 12, 2011, at 9:30 PM, Rick Mann wrote:

> I have a situation where I have to parse times like "14:50 PDT". If I just 
> set up an NSDateFormatter with dateFormat = @"HH:mm z", I end up with a time 
> of day in 1970.
> 
> What's the best way to get it to give me that time of day today?
> 
> Thanks,
> Rick
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/roger.dalal%40gmail.com
> 
> This email sent to roger.da...@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


Re: Best way to parse a time today?

2011-10-12 Thread Dave DeLong
Be careful with this approach, since there are some weird edge cases where that 
time may not exist on the proposed day (think DST boundaries). 

Dave

Sent from my iPhone

On Oct 12, 2011, at 6:46 PM, Roger Dalal  wrote:

> Rick:
> 
> The following code, which is likely what you are doing, will return the time 
> in 1970 (NSDate's reference date) because you have not specified a date:
> 
> NSString *timeString = @"14:50 PDT";
> NSDateFormatter *df = [[NSDateFormatter alloc ] init];
> [df setDateFormat:@"HH':'mm zzz"];
> NSDate *date = [df dateFromString:timeString];
> [df release];
> 
> 
> Instead, you need to use date components to set the day as well as the time, 
> per the following:
> 
> NSString *timeString = @"14:50 PDT";
> NSDateFormatter *df = [[NSDateFormatter alloc ] init];
> [df setDateFormat:@"HH':'mm zzz"];
> NSDate *date = [df dateFromString:timeString];
> 
> NSCalendar *calendar = [NSCalendar currentCalendar];
> NSDateComponents *dateComponents = [calendar components:( NSYearCalendarUnit 
> | NSMonthCalendarUnit |  NSDayCalendarUnit ) fromDate:[NSDate date]];
> NSDateComponents *timeComponents = [calendar components:( NSHourCalendarUnit 
> | NSMinuteCalendarUnit | NSSecondCalendarUnit ) fromDate: date ];
> 
> [dateComponents setHour:[timeComponents hour]];
> [dateComponents setMinute:[timeComponents minute]];
> [dateComponents setSecond:[timeComponents second]];
> 
> NSDate *timeToday = [calendar dateFromComponents:dateComponents];
> [df release];
> 
> Change 'fromDate' in NSDateComponents *dateComponents to whatever date you 
> want in order to create your time on a different day.
> 
> Best Wishes.
> 
> Roger Dalal
> 
> 
> 
> 
> On Oct 12, 2011, at 9:30 PM, Rick Mann wrote:
> 
>> I have a situation where I have to parse times like "14:50 PDT". If I just 
>> set up an NSDateFormatter with dateFormat = @"HH:mm z", I end up with a time 
>> of day in 1970.
>> 
>> What's the best way to get it to give me that time of day today?
>> 
>> Thanks,
>> Rick
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/roger.dalal%40gmail.com
>> 
>> This email sent to roger.da...@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/davedelong%40me.com
> 
> This email sent to davedel...@me.com
___

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

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

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

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


Re: Best way to parse a time today?

2011-10-12 Thread Roger Dalal
Dave:

Would it be possible for you to present an improved approach, please? I use 
this solution frequently, and have not yet encountered any issues, but now you 
have me worried! What approach do you suggest?

Roger Dalal


On Oct 12, 2011, at 9:49 PM, Dave DeLong wrote:

> Be careful with this approach, since there are some weird edge cases where 
> that time may not exist on the proposed day (think DST boundaries). 
> 
> Dave
> 
> Sent from my iPhone
> 
> On Oct 12, 2011, at 6:46 PM, Roger Dalal  wrote:
> 
>> Rick:
>> 
>> The following code, which is likely what you are doing, will return the time 
>> in 1970 (NSDate's reference date) because you have not specified a date:
>> 
>> NSString *timeString = @"14:50 PDT";
>> NSDateFormatter *df = [[NSDateFormatter alloc ] init];
>> [df setDateFormat:@"HH':'mm zzz"];
>> NSDate *date = [df dateFromString:timeString];
>> [df release];
>> 
>> 
>> Instead, you need to use date components to set the day as well as the time, 
>> per the following:
>> 
>> NSString *timeString = @"14:50 PDT";
>> NSDateFormatter *df = [[NSDateFormatter alloc ] init];
>> [df setDateFormat:@"HH':'mm zzz"];
>> NSDate *date = [df dateFromString:timeString];
>> 
>> NSCalendar *calendar = [NSCalendar currentCalendar];
>> NSDateComponents *dateComponents = [calendar components:( NSYearCalendarUnit 
>> | NSMonthCalendarUnit |  NSDayCalendarUnit ) fromDate:[NSDate date]];
>> NSDateComponents *timeComponents = [calendar components:( NSHourCalendarUnit 
>> | NSMinuteCalendarUnit | NSSecondCalendarUnit ) fromDate: date ];
>> 
>> [dateComponents setHour:[timeComponents hour]];
>> [dateComponents setMinute:[timeComponents minute]];
>> [dateComponents setSecond:[timeComponents second]];
>> 
>> NSDate *timeToday = [calendar dateFromComponents:dateComponents];
>> [df release];
>> 
>> Change 'fromDate' in NSDateComponents *dateComponents to whatever date you 
>> want in order to create your time on a different day.
>> 
>> Best Wishes.
>> 
>> Roger Dalal
>> 
>> 
>> 
>> 
>> On Oct 12, 2011, at 9:30 PM, Rick Mann wrote:
>> 
>>> I have a situation where I have to parse times like "14:50 PDT". If I just 
>>> set up an NSDateFormatter with dateFormat = @"HH:mm z", I end up with a 
>>> time of day in 1970.
>>> 
>>> What's the best way to get it to give me that time of day today?
>>> 
>>> Thanks,
>>> Rick
>>> 
>>> ___
>>> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>> 
>>> Please do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>> 
>>> Help/Unsubscribe/Update your Subscription:
>>> http://lists.apple.com/mailman/options/cocoa-dev/roger.dalal%40gmail.com
>>> 
>>> This email sent to roger.da...@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/davedelong%40me.com
>> 
>> This email sent to davedel...@me.com

___

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

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

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

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


Using layers is very slow when using sandboxing

2011-10-12 Thread Vojtech Rinik
Example project: http://hron.fei.tuke.sk/~rinik/data/test.zip

When you click the button, it hangs for a couple of seconds. 

If you disable entitlements, it works fine.

---

Is this just me, or everyone? Could you please download the project (it has 
entitlements enabled), compile it and let me know?

---

I don't know about internals of Core Animation, but apparently it's doing I/O, 
and having entitlements enabled makes that slow: 
http://hron.fei.tuke.sk/~rinik/data/Screen%20Shot%202011-10-12%20at%206.46.01%20PM.png

---

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


[Moderator] Re: Can we talk iOS5 yet?

2011-10-12 Thread Scott Anguish
PR said that the OS would ship on the 12th. Therefore, the NDA would be lifted.

—
Scott Anguish [Moderator]
Think of what Steve would do and then try and do better. For him.



___

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

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

2011-10-12 Thread Ken Ferry
Thanks Heinrich. Your code looks correct to me!

See also .  I wrote most of
that.

-Ken
Cocoa Frameworks

On Wed, Oct 12, 2011 at 8:42 AM, Heinrich Giesen <
heinrich.gie...@t-online.de> wrote:

>
> Jonathan Taylor wrote:
> > I'm working with 16-bit grayscale images, and for the most part I'm just
> manipulating bits within NSBitmapImageRep objects. However for convenience
> it would be nice to do some stuff with NSImages, particularly when rescaling
> and suchlike. The problem is that whenever I draw into such an NSImage it
> gets converted to 3x8 bit RGB. Is there a simple way I can force things to
> stay grayscale, or am I fighting a losing battle here.
>
> You are not fighting a losing battle, you use the wrong methods to create
> an NSBitmapImageRep with properties you want.
> If you want to create an NSImage/NSImageRep with special properties: there
> is a rule of thumb: don't use lockFocus.
>  --> Re: bad behavior from unlockFocus on 10.6 by Ken Ferry.

Another rule of thumb is: if you need -[NSImage TIFFRepresentation] you do
> something wrong.
> (There are of course counterexamples).
>
> The following code does (I hope so) what you want:
>
>
> NSImage *srcImage = [[NSImage alloc] initWithContentsOfFile:thePath];
>
> // create a new empty NSBitmapImageRep
> NSBitmapImageRep *newRep = [[NSBitmapImageRep alloc]
> initWithBitmapDataPlanes:NULL
>pixelsWide: (NSInteger)newWidth
>pixelsHigh: (NSInteger)newHeight
>bitsPerSample: 16
>samplesPerPixel: 1
>hasAlpha: NO// YES is not supported
>isPlanar: NO
>colorSpaceName: NSCalibratedWhiteColorSpace
>bytesPerRow: 0
>bitsPerPixel: 0];
>
>//Now save the current NSGraphicsContext and set a new one
>[NSGraphicsContext saveGraphicsState];
>NSGraphicsContext *newContext = [NSGraphicsContext
> graphicsContextWithBitmapImageRep: newRep];
>[NSGraphicsContext setCurrentContext: newContext];
>
>[srcImage drawInRect:NSMakeRect( 0, 0, [newRep pixelsWide], [newRep
> pixelsHigh] )
>fromRect:NSZeroRect
>operation:NSCompositeCopy
>fraction:1.0];
>
>// Restore the previous graphics context and state.
>[NSGraphicsContext restoreGraphicsState];
>
> and see what the newRep looks like:
>NSLog( @"newRep is:%@", newRep );
>
>
> This code creates a 16 bit grayscale image whatever the source image is.
>
> Good luck
> Heinrich
>
>
>
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> 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


Simple PDF generation code not working as intended

2011-10-12 Thread Devarshi Kulshreshtha
Hi all,

I am trying a simple application to generate pdf from contents in a
text view.

I am using below code:

NSPrintInfo *pdfDisplayInfo = [[NSPrintInfo alloc]
initWithDictionary:[NSDictionary
dictionaryWithObjectsAndKeys:@"YES",NSPrintHeaderAndFooter,nil]];
[pdfDisplayInfo setVerticalPagination:NSAutoPagination];
[pdfDisplayInfo setHorizontalPagination:NSAutoPagination];
[pdfDisplayInfo setVerticallyCentered:NO];
NSFileManager *filemanager = [NSFileManager defaultManager];
NSMutableData *dataObtained = [[NSMutableData alloc] init];
NSPrintOperation *printOperation = [NSPrintOperation

PDFOperationWithView:contentView

insideRect:[contentView frame]

toData:dataObtained printInfo:pdfDisplayInfo];

[printOperation runOperation];
[filemanager createFileAtPath:[@"~/Documents/SamplePrint.pdf"
stringByExpandingTildeInPath] contents:dataObtained attributes:nil];

Problem is:

Though I have used setVerticalPagination as NSAutoPagination, content
in pdf generated is not distributed among multiple pages.

Can anyone suggest me - if I am doing anything wrong or missing
something?

Here is the link for, code :
http://db.tt/L9rM8NU7


Thanks,
Devarshi
___

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

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