Re: notAKeyMarker crash

2012-03-05 Thread Kyle Sluder
On Mar 5, 2012, at 10:01 PM, Gideon King  wrote:

> Ah, of course - silly me. Working on assumptions instead of using my eyes.
> 
> So the relevant code is this:
>NSMapInsertKnownAbsent(windowsForSheets, sheet, docWindow);
> and seeing as windowForSheets is created with:
>windowsForSheets = NSCreateMapTable(NSObjectMapKeyCallBacks, 
> NSObjectMapValueCallBacks, 0);
> and NSObjectMapKeyCallBacks has a nil notAKeyMarker…
> 
> So if the sheet is nil, then an exception is raised. Not sure how that would 
> be possible in my code, but at least I now understand what is going on.

If your further research doesn't point to an obvious error on your part, please 
file an issue on our GitHub project: 
https://github.com/omnigroup/OmniGroup/issues

--Kyle Sluder
___

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

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

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

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

How do we know if iCloud actually contains a key/value pair?

2012-03-05 Thread G S
When our iPhone app is launched for the first time, it checks the user's
iCloud account to see if he has installed our app on another device.  If
so, he'll have a unique ID that we've stored in his iCloud account, which
is a database key that we use to manage his online content.  We grab it and
store it in local user defaults.

If the user doesn't have an ID in iCloud, we create one, store it in local
user defaults and save it to iCloud.

During appDidFinishLaunching, I instantiate the ubiquitous store and call
[synchronize].

After figuring out that we always have to listen for the
NSUbiquitousKeyValueStoreDidChangeExternallyNotification (even though the
external repository actually didn't change), I'm left with this question:
 How do I know if this call simply failed, or if the value is absent from
the remote server?

Will this notification be issued even if the key/value pair doesn't exist?
 If not, how do I ever know that key/value pair is absent from iCloud and
that I won't be overwriting it if I store a new one there?

Thanks for any insight.

Gavin
___

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

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

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

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


Efficiency Question...

2012-03-05 Thread R
I want to blend two colors as a background.  I'm adding a layer using
CAGradient layer, starting on the left with blue alpha=1. and ending
on the right with blue alpha=0.

I then add another layer using red on the left with alpha=0. and
ending on the right with alpha=1.

I wonder if it is best to draw this background, or, create a .png and
just post it.

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

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


Re: notAKeyMarker crash

2012-03-05 Thread Gideon King
Ah, of course - silly me. Working on assumptions instead of using my eyes.

So the relevant code is this:
NSMapInsertKnownAbsent(windowsForSheets, sheet, docWindow);
and seeing as windowForSheets is created with:
windowsForSheets = NSCreateMapTable(NSObjectMapKeyCallBacks, 
NSObjectMapValueCallBacks, 0);
and NSObjectMapKeyCallBacks has a nil notAKeyMarker…

So if the sheet is nil, then an exception is raised. Not sure how that would be 
possible in my code, but at least I now understand what is going on.

Regards

Gideon



On 06/03/2012, at 10:42 AM, Mike Abdullah wrote:

> -[OAApplication 
> beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:]
> 
> That's definitely not part of Cocoa! You have the source. Dig in to find the 
> problem.
> 
> On 5 Mar 2012, at 15:15, Gideon King wrote:
> 
>> Hi, I am getting occasional reports of an exception from users of my 
>> software, but they are not able to reproduce it, and nor am I.
>> 
>> I have a sheet which has an NSCollectionView on it and a couple of buttons 
>> and a slider. The NIB also instantiates an array controller which is used as 
>> the content for the collection view.
>> 
>> This is the exception I get:
>> 
>> *** NSMapInsertKnownAbsent(): attempt to insert notAKeyMarker
>> 
>> 0 CoreFoundation 0x7fff896a9fc6 __exceptionPreprocess + 198
>> 1 libobjc.A.dylib 0x7fff855ced5e objc_exception_throw + 43
>> 2 CoreFoundation 0x7fff896a9dfa +[NSException raise:format:arguments:] + 
>> 106
>> 3 CoreFoundation 0x7fff896a9d84 +[NSException raise:format:] + 116
>> 4 Foundation 0x7fff890f67bc -[NSClassicMapTable 
>> setItem:forKnownAbsentKey:] + 74
>> 5 OmniAppKit 0x00010051f008 -[OAApplication 
>> beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:] + 184
>> 
>> I do not instantiate an NSClassicMapTable explicitly in my code, but am 
>> assuming that either the array controller or the collection view uses such 
>> things.
>> 
>> I have never been able to reproduce the problem myself, either in a test 
>> environment or anywhere else either on 10/6 or 10.7 (users have reported it 
>> on both operating system versions).
>> 
>> If anyone has any suggestions as to where to look for this, I'd be very 
>> grateful.
>> 
>> 
>> Regards
>> 
>> 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:
>> https://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
>> 
>> This email sent to cocoa...@mikeabdullah.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Unclear on -initWithBytesNoCopy:

2012-03-05 Thread Wade Tregaskis
> I’m not sure I’d want that either, though. If the original string was a 
> 200-page dissertation and you took a one-word substring from it, it doesn’t 
> seem reasonable to keep the whole 200-page dissertation all in RAM just to 
> keep the one-word substring around.


But that's a very old problem that's been dealt with in numerous ways over the 
years.  It could easily be addressed as an implementation detail.

The key point however is that CFString/NSString are nowhere near that smart, 
and they're not likely to be (GNUstep or others aside).  If you're dealing with 
a large chunk of text like a dissertation then you're probably dealing with a 
lot of other elements as well, and using much higher-order objects to represent 
things.
___

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

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

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

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

Re: Unclear on -initWithBytesNoCopy:

2012-03-05 Thread Charles Srstka
On Mar 5, 2012, at 6:40 PM, Wade Tregaskis wrote:

> Perhaps the only 'correct' solution to this problem is to fall back to the 
> CFString level, where you can pass a custom CFAllocator to e.g. 
> CFStringCreateWithBytesNoCopy().  That way the lifetime is effectively 
> managed by the CFString, so it should behave correctly in all cases.

He’s using GNUstep, though. Does GNUstep even have the CFString level?

Charles
___

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

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

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

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

Re: Unclear on -initWithBytesNoCopy:

2012-03-05 Thread Charles Srstka
On Mar 3, 2012, at 3:03 PM, Eli Bach2 wrote:

> 
> On Mar 3, 2012, at 12:15 PM, Jens Alfke wrote:
> 
>> I filed a bug report* saying that this substring optimization shouldn’t be 
>> used if the source string uses an external buffer, just as it shouldn’t if 
>> the source string is mutable. They fixed it, but some people there argue 
>> that their original implementation was correct (even if not compatible with 
>> Apple’s.) I’m curious, so I’m asking here to see if anyone knows for sure 
>> what’s intended.
> 
> Well, you can argue that the substring can't just reference the original 
> string and bump it's retaincount to make sure the underlying data stays 
> around because the original string doesn't own the data buffer.  For it to be 
> 'correct', there would at least need to be some mechanism to notify the data 
> buffer owner that another object was using it.

I’m not sure I’d want that either, though. If the original string was a 
200-page dissertation and you took a one-word substring from it, it doesn’t 
seem reasonable to keep the whole 200-page dissertation all in RAM just to keep 
the one-word substring around.

Charles

___

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

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

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

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

Re: Unclear on -initWithBytesNoCopy:

2012-03-05 Thread Wim Lewis

On 3 Mar 2012, at 12:24 PM, Jens Alfke wrote:
> On Mar 3, 2012, at 11:28 AM, Dave Keck wrote:
> 
>> The buffer needs to remain intact until the NSString/NSData object is 
>> deallocated.
> 
> True; but a strict interpretation of this is that the buffer can _never_ be 
> destroyed, because you can never predict with 100% accuracy when an object is 
> going to be deallocated. (as discussed in all those “why -retainCount is 
> useless for debugging” threads.)

The other big use I have for -...withBytesNoCopy:, though, is referencing a 
statically allocated buffer, like a big table of data that's in my text 
segment. In that case, I *do* want the implementation to assume that the buffer 
is available indefinitely and make use of it as much as it can.

In the rare situation that I have a buffer with a finite lifetime and don't 
want the overhead of copying into a malloc buffer (memory-to-memory copies 
don't seem to show up on my profile data much any more), I've made a custom 
NSData subclass to hold it. That instance is properly retain-counted until the 
last reference to the buffer goes away, and it can do whatever cleanup is 
appropriate. This seems like the Right Way To Do It to me, though it does seem 
like an overly large hammer for a small problem.



___

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

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

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

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

Re: Releasing WSMethodInvocationInvoke()

2012-03-05 Thread Ian was here
Interesting. If that's the case, then the documentation for that method is 
correct, the caller is responsible for freeing the returned object. I will file 
a bug report.

Thanks.



- Original Message -
From: Gus Mueller 
To: Cocoa mailing list 
Cc: 
Sent: Monday, March 5, 2012 1:44 PM
Subject: Re: Releasing WSMethodInvocationInvoke()

On Mar 5, 2012, at 9:43 AM, Ian was here wrote:

> I'm having an issue with the following line of code:
> 
> NSDictionary*serviceResult = (NSDictionary *)WSMethodInvocationInvoke( 
> serviceCall );
> 
> [serviceResult release];
> 
> 
> According to the documentation and the WSMethodInvocation.h header file, it 
> is the caller's responsibility to release the returned serviceResult 
> dictionary. However, when I run my code through the analyzer in Xcode, it 
> says the serviceResult is released too many times, which would imply that it 
> is already autoreleased. I Googled this and found several examples where it 
> was not being released. If I comment-out the release code, the analyzer does 
> not complain.

That's because it's missing a CF_RETURNS_RETAINED in the header for that 
method, which the analyzer needs to know what's going on.  I'm not sure there's 
any way around this other than filing a bug and hoping Apple updates the 
headers in the next release.

(Another example of this is SecTransformExecute in Securty.framework)

-gus

--  

August 'Gus' Mueller
Flying Meat Inc.
http://flyingmeat.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:
https://lists.apple.com/mailman/options/cocoa-dev/howlewere%40yahoo.com

This email sent to howlew...@yahoo.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: How are views supposed to reload after being nillified by memory warnings?

2012-03-05 Thread G S
Well, at any rate, I have no such subview property.

I've also found that among my series of modal presentations, there's a view
that's displayed modally, whose user interaction works just fine, but whose
viewWillAppear and viewWillDisappear methods are never called.  As far as I
know, it could be this one that's displaying the white view.

At this point it's clear that Cocoa is confused by something; perhaps
because some of these transitions are animated and not completed when a new
one starts.

As a last resort, I'm going to have to refactor this entire sequence to
push the views onto the navigation controller, but cancel the sequence and
pop them all if the user hits the Back button before furnishing required
information.
___

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

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

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

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


Re: notAKeyMarker crash

2012-03-05 Thread Mike Abdullah
-[OAApplication 
beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:]

That's definitely not part of Cocoa! You have the source. Dig in to find the 
problem.

On 5 Mar 2012, at 15:15, Gideon King wrote:

> Hi, I am getting occasional reports of an exception from users of my 
> software, but they are not able to reproduce it, and nor am I.
> 
> I have a sheet which has an NSCollectionView on it and a couple of buttons 
> and a slider. The NIB also instantiates an array controller which is used as 
> the content for the collection view.
> 
> This is the exception I get:
> 
> *** NSMapInsertKnownAbsent(): attempt to insert notAKeyMarker
> 
> 0 CoreFoundation 0x7fff896a9fc6 __exceptionPreprocess + 198
> 1 libobjc.A.dylib 0x7fff855ced5e objc_exception_throw + 43
> 2 CoreFoundation 0x7fff896a9dfa +[NSException raise:format:arguments:] + 
> 106
> 3 CoreFoundation 0x7fff896a9d84 +[NSException raise:format:] + 116
> 4 Foundation 0x7fff890f67bc -[NSClassicMapTable 
> setItem:forKnownAbsentKey:] + 74
> 5 OmniAppKit 0x00010051f008 -[OAApplication 
> beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:] + 184
> 
> I do not instantiate an NSClassicMapTable explicitly in my code, but am 
> assuming that either the array controller or the collection view uses such 
> things.
> 
> I have never been able to reproduce the problem myself, either in a test 
> environment or anywhere else either on 10/6 or 10.7 (users have reported it 
> on both operating system versions).
> 
> If anyone has any suggestions as to where to look for this, I'd be very 
> grateful.
> 
> 
> Regards
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
> 
> This email sent to cocoa...@mikeabdullah.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Unclear on -initWithBytesNoCopy:

2012-03-05 Thread Wade Tregaskis
Perhaps the only 'correct' solution to this problem is to fall back to the 
CFString level, where you can pass a custom CFAllocator to e.g. 
CFStringCreateWithBytesNoCopy().  That way the lifetime is effectively managed 
by the CFString, so it should behave correctly in all cases.

'course, the implementation is relatively awkard compared to what *should* be a 
single method call.  Perhaps a variant of initWithBytesNoCopy:, one that takes 
a block with which to free the bytes, should be created.
___

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

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

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

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


Re: How are views supposed to reload after being nillified by memory warnings?

2012-03-05 Thread David Duncan
On Mar 5, 2012, at 3:40 PM, G S wrote:

> No. But if you've presented a modal view controller, your entire view 
> hierarchy (self.view) has been ripped out of the window, and if a memory 
> warning arrives, then self.view will be set to nil. What happens next depends 
> on if you implemented -viewDidUnload properly or if your view references are 
> strong or weak.
> 
> If they are strong and you did not implement -viewDidUnload properly, then 
> your view reference will be non-nil.
> 
> Not according to the Apple doc.  By the time viewDidUnload is called, the 
> view reference has already been set to nil:


I think you are confusing what I mean by "view reference" at the end there. 
Consider this interface:

@interface ViewController : UIViewController

@property (nonatomic, /* strong or weak */) UIView *subview;

@end;

My statement above refers to what happens to self.subview, not to self.view 
(hence why I used self.view the first time, then view reference the second 
time).
--
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: How are views supposed to reload after being nillified by memory warnings?

2012-03-05 Thread G S
>
> No. But if you've presented a modal view controller, your entire view
> hierarchy (self.view) has been ripped out of the window, and if a memory
> warning arrives, then self.view will be set to nil. What happens next
> depends on if you implemented -viewDidUnload properly or if your view
> references are strong or weak.
>
> If they are strong and you did not implement -viewDidUnload properly, then
> your view reference will be non-nil.


Not according to the Apple doc.  By the time viewDidUnload is called, the
view reference has already been set to nil:

"viewDidUnload

Called when the controller’s view is released from memory.
- (void)viewDidUnload
Discussion

When a low-memory condition occurs and the current view controller’s views
are not needed, the system may opt to remove those views from memory. This
method is called after the view controller’s view has been released and is
your chance to perform any final cleanup. If your view controller stores
separate references to the view or its subviews, you should use this method
to release those references. You can also use this method to remove
references to any objects that you created to support the view but that are
no longer needed now that the view is gone. You should not use this method
to release user data or any other information that cannot be easily
recreated.
At the time this method is called, the view property is nil. "
___

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

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

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

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

Re: Convert PDF CGContextRef to NSView for hi-res printing

2012-03-05 Thread Wim Lewis

On 5 Mar 2012, at 12:13 PM, Gilles Celli wrote:
> I'm stuck on a problem on how to print high resolution graphs on Mac OS X, by 
> using the wonderful CorePlot (1) framework.
> I've asked on the Coreplot mailing list but no answer...maybe it's too 
> obvious that I don't see the tree in the forest:
> 
> My method produces a CGContextRef (with CGPDFContextCreate) which then writes 
> the drawing / plotting as a PDF.
> This works great: The written PDF file doesn't have any jaggies since it is 
> vector based. [...] So is it possible to print directly a PDF based 
> CGContextRef ?

I haven't looked at CorePlot, but from the -exportActiveGraphsToPDF: 
implementation, it looks like you could print vector PDF by getting the 
CGContextRef corresponding to the current NSGraphicsContext:

NSGraphicsContext *nsContext = [NSGraphicsContext currentContext];
[self renderGraphsInContext:[nsContext graphicsPort]];

If this is in the -drawRect: method that is called during printing, then 
[NSGraphicsContext currentContext] will be the graphics context that is writing 
PDF to the print file, and -renderGraphsInContext: can emit vector output 
without any extra conversions.



___

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

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

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

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


Re: NSURLRequests and Firewalls

2012-03-05 Thread Alex Zavatone

On Mar 5, 2012, at 3:13 PM, Mike Abdullah wrote:

> 
> On 5 Mar 2012, at 19:21, Alex Zavatone wrote:
> 
>> I just found out why some JSON parsing was failing, the data returned from 
>> the NSURLRequest was the HTML for our firewall authentication page.
> 
> You mean NSURLConnection right? URL requests themselves are purely data 
> objects, they don't do any networking.

DOH.  Too much caffeine.  I sit corrected.

>> Is there an established practice or set of documents on the iOS Dev Lib that 
>> shows how to handle this?  I scanned the sample code and found nothing.  
>> Searching teh googles for NSURL and firewall doesn't return much either.
> 
> NSURLConnection happily returns to its delegate any valid HTTP response it 
> receives. It is your responsibility to check that the URL and error code etc. 
> are as expected from methods like -connection:didReceiveResponse: and 
> -connection:willSendRequest:redirectResponse:


OK.  That's what I was afraid of.  Thanks much.


___

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

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

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

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


Re: Convert PDF CGContextRef to NSView for hi-res printing

2012-03-05 Thread Graham Cox

On 06/03/2012, at 7:13 AM, Gilles Celli wrote:

> Hi,
> 
> I'm stuck on a problem on how to print high resolution graphs on Mac OS X, by 
> using the wonderful CorePlot (1) framework.
> I've asked on the Coreplot mailing list but no answer...maybe it's too 
> obvious that I don't see the tree in the forest:
> 
> My method produces a CGContextRef (with CGPDFContextCreate) which then writes 
> the drawing / plotting as a PDF.
> This works great: The written PDF file doesn't have any jaggies since it is 
> vector based. 
> 
> However if I want print the graphs via the Printer Panel, I need first to 
> create a bitmap-based NSImageView as far as I understand,
> so the prints never seem to be vector based, there will always be jaggies in 
> the plots and text.

Your understanding is definitely wrong.

You need a view to cooperate with the print subsystem, but it doesn't have to 
be NSImageView, and usually is not. Ultimately, the print system ends up 
calling the view's -dataWithPDFInsideRect: method. If you override that method 
to return your PDF data, you're done. Of course there will be other things to 
consider, such as pagination, so that approach might be too simplistic, but 
might give you a starting point. Printing is entirely built around PDF, so 
there is no reason to accept bitmaps, jaggies or any other artefact of 
rasterization.

--Graham



___

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

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

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

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


Re: Releasing WSMethodInvocationInvoke()

2012-03-05 Thread Gus Mueller
On Mar 5, 2012, at 9:43 AM, Ian was here wrote:

> I'm having an issue with the following line of code:
> 
> NSDictionary*serviceResult = (NSDictionary *)WSMethodInvocationInvoke( 
> serviceCall );
> 
> [serviceResult release];
> 
> 
> According to the documentation and the WSMethodInvocation.h header file, it 
> is the caller's responsibility to release the returned serviceResult 
> dictionary. However, when I run my code through the analyzer in Xcode, it 
> says the serviceResult is released too many times, which would imply that it 
> is already autoreleased. I Googled this and found several examples where it 
> was not being released. If I comment-out the release code, the analyzer does 
> not complain.

That's because it's missing a CF_RETURNS_RETAINED in the header for that 
method, which the analyzer needs to know what's going on.  I'm not sure there's 
any way around this other than filing a bug and hoping Apple updates the 
headers in the next release.

(Another example of this is SecTransformExecute in Securty.framework)

-gus

--  

August 'Gus' Mueller
Flying Meat Inc.
http://flyingmeat.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: NSURLRequests and Firewalls

2012-03-05 Thread Jens Alfke

On Mar 5, 2012, at 11:21 AM, Alex Zavatone wrote:

> I just found out why some JSON parsing was failing, the data returned from 
> the NSURLRequest was the HTML for our firewall authentication page.

Well that sucks. I believe a more correct response would have been 407Proxy 
Authentication Required, but the vendor probably wanted a “prettier” login 
screen.

> Is there an established practice or set of documents on the iOS Dev Lib that 
> shows how to handle this? I scanned the sample code and found nothing.  
> Searching teh googles for NSURL and firewall doesn't return much either.

Presumably the firewall sent back a redirect to the original response, which 
pointed to its magic login page. So that’s one way to tell something’s up. 
Another is that the Content-Type for the end response is text/html instead of 
application/json.

I don’t know if there’s any de-facto standard for being able to detect 
firewall/router login pages. iOS and Lion seem to be able to do it. I heard 
something about a recent proposed standard for logins to WiFi hot-spots, which 
may or may not be relevant.

This question is more relevant to the macnetworkprog list. I would recommend 
reposting it there.

—Jens

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

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


Re: NSURLRequests and Firewalls

2012-03-05 Thread Alex Zavatone
Yeah, at this facility, I get a web page asking to log in with auth parameters, 
so it's going to be interesting.

Using the simulator, even if I enter the auth parameters in Safari, I'll run 
the app again from Xcode and get the same HTML telling me that permission was 
denied and asking for auth params.  If I switch to the guest network and run 
the app in the simulator form Xcode, I can grab any external file without an 
issue.

Joy.

On Mar 5, 2012, at 3:19 PM, Erik Stainsby wrote:

> I think generally a firewall ought to return an http status code of 302 
> redirected which you could probably key off for a login handler. 
> 
> Time Dwarf,
> Roaring Guy
> 
> On 2012-03-05, at 11:21 AM, Alex Zavatone  wrote:
> 
>> I just found out why some JSON parsing was failing, the data returned from 
>> the NSURLRequest was the HTML for our firewall authentication page.
>> 
>> Is there an established practice or set of documents on the iOS Dev Lib that 
>> shows how to handle this?  I scanned the sample code and found nothing.  
>> Searching teh googles for NSURL and firewall doesn't return much either.
>> 
>> Thanks in advance.
>> - Alex Zavatone
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/erik.stainsby%40roaringsky.ca
>> 
>> This email sent to erik.stain...@roaringsky.ca

___

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

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

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

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


Re: NSURLRequests and Firewalls

2012-03-05 Thread Erik Stainsby
I think generally a firewall ought to return an http status code of 302 
redirected which you could probably key off for a login handler. 

Time Dwarf,
Roaring Guy

On 2012-03-05, at 11:21 AM, Alex Zavatone  wrote:

> I just found out why some JSON parsing was failing, the data returned from 
> the NSURLRequest was the HTML for our firewall authentication page.
> 
> Is there an established practice or set of documents on the iOS Dev Lib that 
> shows how to handle this?  I scanned the sample code and found nothing.  
> Searching teh googles for NSURL and firewall doesn't return much either.
> 
> Thanks in advance.
> - Alex Zavatone
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca

___

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

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

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

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


Convert PDF CGContextRef to NSView for hi-res printing

2012-03-05 Thread Gilles Celli
Hi,

I'm stuck on a problem on how to print high resolution graphs on Mac OS X, by 
using the wonderful CorePlot (1) framework.
I've asked on the Coreplot mailing list but no answer...maybe it's too obvious 
that I don't see the tree in the forest:

My method produces a CGContextRef (with CGPDFContextCreate) which then writes 
the drawing / plotting as a PDF.
This works great: The written PDF file doesn't have any jaggies since it is 
vector based. 

However if I want print the graphs via the Printer Panel, I need first to 
create a bitmap-based NSImageView as far as I understand,
so the prints never seem to be vector based, there will always be jaggies in 
the plots and text.
Resizing-up the whole image could be a solution, but I don't think this is the 
best one.

So is it possible to print directly a PDF based CGContextRef ?

Here's my IBAction to create the PDF:

-(IBAction)exportActiveGraphsToPDF:(id)sender
NSSavePanel *pdfSavingDialog = [NSSavePanel savePanel];
[pdfSavingDialog setMessage:@"Export as PDF"];

NSArray *pdfType = [[NSArray alloc] initWithObjects:@"pdf", nil];
[pdfSavingDialog setAllowedFileTypes:pdfType];
[pdfType release];

if ( [pdfSavingDialog runModal] == NSOKButton ) {

NSMutableData *pdfData = [[NSMutableData alloc] init];
CGDataConsumerRef dataConsumer = 
CGDataConsumerCreateWithCFData((CFMutableDataRef)pdfData);

CGRect pdfMediaBox = NSRectToCGRect([allGraphsView bounds]);

CGContextRef pdfContext = CGPDFContextCreate(dataConsumer, &pdfMediaBox, 
NULL);
CGContextBeginPage(pdfContext, &pdfMediaBox);

// call renderGraphsInContext to draw the coreplot graphs in the given 
CGContextRef   
[self renderGraphsInContext:pdfContext];

CGContextEndPage(pdfContext);   
CGPDFContextClose(pdfContext);

[pdfData writeToURL:[pdfSavingDialog URL] atomically:NO];

CGContextRelease(pdfContext);
CGDataConsumerRelease(dataConsumer);
[pdfData release];
}
}

(1)
http://code.google.com/p/core-plot/

Any help is greatly appreciated.

Cheers,

Gilles

___

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

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

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

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


Re: NSURLRequests and Firewalls

2012-03-05 Thread Mike Abdullah

On 5 Mar 2012, at 19:21, Alex Zavatone wrote:

> I just found out why some JSON parsing was failing, the data returned from 
> the NSURLRequest was the HTML for our firewall authentication page.

You mean NSURLConnection right? URL requests themselves are purely data 
objects, they don't do any networking.
> 
> Is there an established practice or set of documents on the iOS Dev Lib that 
> shows how to handle this?  I scanned the sample code and found nothing.  
> Searching teh googles for NSURL and firewall doesn't return much either.

NSURLConnection happily returns to its delegate any valid HTTP response it 
receives. It is your responsibility to check that the URL and error code etc. 
are as expected from methods like -connection:didReceiveResponse: and 
-connection:willSendRequest:redirectResponse:


___

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

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

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

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


NSURLRequests and Firewalls

2012-03-05 Thread Alex Zavatone
I just found out why some JSON parsing was failing, the data returned from the 
NSURLRequest was the HTML for our firewall authentication page.

Is there an established practice or set of documents on the iOS Dev Lib that 
shows how to handle this?  I scanned the sample code and found nothing.  
Searching teh googles for NSURL and firewall doesn't return much either.

Thanks in advance.
- Alex Zavatone

___

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

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

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

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


Re: How are views supposed to reload after being nillified by memory warnings?

2012-03-05 Thread David Duncan
On Mar 3, 2012, at 8:57 AM, Matt Neuburg wrote:

> On Fri, 02 Mar 2012 10:17:43 -0800, David Duncan  
> said:
>> On Mar 2, 2012, at 1:28 AM, G S wrote:
>> 
>> In the vast majority of cases where I've seen this behavior, it is because 
>> in your delegate handler for the UIImagePickerController, you assign the 
>> returned image directly to a UIImageView that you have in your view 
>> hierarchy. If you've recently gotten a memory warning, then this image view 
>> is either nil, or will be released very soon, and you will end up with a 
>> view that has no image.
> 
> So let's say I have a view controller. And let's say that its view 
> (self.view) contains a UIImageView in its hierarchy (self.view.imageview). 
> You are saying that the runtime might summarily rip the UIImageView out of 
> the interface, so that self.view is *not* nil but self.view.imageview *is* 
> nil???


No. But if you've presented a modal view controller, your entire view hierarchy 
(self.view) has been ripped out of the window, and if a memory warning arrives, 
then self.view will be set to nil. What happens next depends on if you 
implemented -viewDidUnload properly or if your view references are strong or 
weak.

If they are strong and you did not implement -viewDidUnload properly, then your 
view reference will be non-nil. On the next load however, that reference will 
be replaced by a newly created view. If they are weak, or you implemented 
-viewDidUnload properly, then the view reference will be nil, and the usual 
message to nil semantics will take over.
--
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Releasing WSMethodInvocationInvoke()

2012-03-05 Thread Ian was here
I'm having an issue with the following line of code:

NSDictionary*serviceResult = (NSDictionary *)WSMethodInvocationInvoke( 
serviceCall );

[serviceResult release];


According to the documentation and the WSMethodInvocation.h header file, it is 
the caller's responsibility to release the returned serviceResult dictionary. 
However, when I run my code through the analyzer in Xcode, it says 
the serviceResult is released too many times, which would imply that it is 
already autoreleased. I Googled this and found several examples where it was 
not being released. If I comment-out the release code, the analyzer does not 
complain.

What's interesting is that if it were truly a double-free, then it would crash. 
It doesn't. It runs just fine. Either the documentation is wrong or the 
analyzer is. Given how often this is called, it could potentially leak memory 
like crazy.

___

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

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

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

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

[MEET] Toronto Cocoaheads / tacow - March 13

2012-03-05 Thread Karl Moskowski
tacow's next meeting is scheduled for 6:30 PM on Tuesday, March 13, 2012 in 
room 310 of Metro Hall. This is the first meeting on our new every-other-month 
schedule.

Details, directions, etc. at .

All are welcome, and we look forward to seeing you there.


Karl Moskowski 
Voodoo Ergonomics Inc. 



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

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


notAKeyMarker crash

2012-03-05 Thread Gideon King
Hi, I am getting occasional reports of an exception from users of my software, 
but they are not able to reproduce it, and nor am I.

I have a sheet which has an NSCollectionView on it and a couple of buttons and 
a slider. The NIB also instantiates an array controller which is used as the 
content for the collection view.

This is the exception I get:

*** NSMapInsertKnownAbsent(): attempt to insert notAKeyMarker

0 CoreFoundation 0x7fff896a9fc6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x7fff855ced5e objc_exception_throw + 43
2 CoreFoundation 0x7fff896a9dfa +[NSException raise:format:arguments:] + 106
3 CoreFoundation 0x7fff896a9d84 +[NSException raise:format:] + 116
4 Foundation 0x7fff890f67bc -[NSClassicMapTable setItem:forKnownAbsentKey:] 
+ 74
5 OmniAppKit 0x00010051f008 -[OAApplication 
beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:] + 184

I do not instantiate an NSClassicMapTable explicitly in my code, but am 
assuming that either the array controller or the collection view uses such 
things.

I have never been able to reproduce the problem myself, either in a test 
environment or anywhere else either on 10/6 or 10.7 (users have reported it on 
both operating system versions).

If anyone has any suggestions as to where to look for this, I'd be very 
grateful.


Regards

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

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


Re: [ANN] CoreParse (Version n+1)

2012-03-05 Thread Thomas Davie
I'm pretty sure I did this the first time I announced CoreParse too >.<

Thanks for the suggestion Uli: https://github.com/beelsebob/CoreParse

Tom Davie
if (*ra4 != 0xffc78948) { return false; }

On 5 Mar 2012, at 13:45, Uli Kusterer wrote:

> On 05.03.2012, at 12:09, Thomas Davie wrote:
>> A while ago I showed you all my parsing library 'CoreParse', and got some 
>> really useful feedback.  Today, I'd like to show you what's changed since 
>> then!
> 
> 
> You have a link to CoreParse? :-)
> 
> Cheers,
> -- Uli Kusterer
> "The Witnesses of TeachText are everywhere..."
> 

___

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

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

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

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


[ANN] CoreParse (Version n+1)

2012-03-05 Thread Thomas Davie
Hi All,

A while ago I showed you all my parsing library 'CoreParse', and got some 
really useful feedback.  Today, I'd like to show you what's changed since then!

 • Easier processing of syntax trees into your data structures.
   In earlier versions of CoreParse you had to use a parser delegate to 
construct your data structures from the result of parsing expressions.  Not so 
in the new version!  Instead, Simply implement the CPParseResult protocol, and 
CoreParse will call -initWithSyntaxTree: when it finds something of that class.
 • Archiving and Unarchiving of parsers and tokenisers.
   Construction of large parsers can be quite slow and memory consuming, 
because of that you don't always want to do it at run time.  The new version of 
CoreParse implements NSCoding for both parsers and tokenisers, allowing you to 
quickly load them without creating them on the fly.
 • Error handling and recovery.
   Previous versions of CoreParse simply bailed out when they found something 
that couldn't be tokenised or parsed.  The new version adds support for several 
delegate callbacks allowing you to specify how the parser should deal with the 
situation:
   -tokeniser:didNotFindTokenOnInput:position:error: Allows you to advance the 
token position to skip unrecognised input, and to insert error tokens into the 
token stream.
   -parser:didEncounterErrorOnInput:expecting: Allows you to specify a recovery 
action for the parser to take (choose from deleting the token, inserting a 
dummy token, falling back to the previous item in the parse stack, or fail 
immediately), and do your own error reporting/handling.

CoreParse has now been used in a couple of significant projects and proven to 
be stable and reliable:
 • I have used it to parse MapCSS in OpenStreetPad 
(https://github.com/beelsebob/OpenStreetPad).
 • Matt Mower has used it in his StateC state machine library 
(https://github.com/mmower/statec).  He has contributed significant feedback to 
make sure that the error handling is as robust as possible and provides as much 
information as it can for you to accurately report errors.

Thanks

Tom Davie
if (*ra4 != 0xffc78948) { return false; }

___

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

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

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

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

Re: e: setAllowedFileTypes: (or similar) for NSPasteboard

2012-03-05 Thread Rick C.
Thanks all.  Yeah I had the validateDrop part, but I guess what I was looking 
for was UTTypeConformsTo.  I think it's under control now thanks for the help!


On Mar 5, 2012, at 5:41 AM, David Riggle wrote:

> I think you also need to register for the drag types via 
> -registerForDraggedTypes. I pass in a mix of UTIs and legacy pboard types and 
> it seems to work. For example:
> 
>   [tableView registerForDraggedTypes:[NSArray arrayWithObjects:(NSString 
> *)kUTTypeURL, NSPasteboardTypeString, @"ABPeopleUIDsPboardType", nil]];
> 
> In your -validateDrop method you can check the pasteboard for URLs that 
> conform to local image files, for example.
> 
> The new NSPasteboard routines are poorly documented and badly represented in 
> the sample code. Good luck figuring them out.
> 
>> Message: 5
>> Date: Sun, 04 Mar 2012 07:01:30 -0800
>> From: Jerry Krinock 
>> To: Cocoa-Dev List 
>> Subject: Re: setAllowedFileTypes: (or similar) for NSPasteboard
>> Message-ID: <7c036771-17a3-44da-85ff-ff04dad10...@ieee.org>
>> Content-Type: text/plain; charset=utf-8
>> 
>> 
>> On 2012 Mar 04, at 01:28, Rick C. wrote:
>> 
>>> I want to make a UTI array to limit what can be dragged onto my TableView.
>> 
>> Implement -tableView:validateDrop:proposedRow:proposedDropOperation: and 
>> return NSDragOperationNone if the [info draggingPasteboard] contains stuff 
>> you don't want.
>> 
>>> Sorry if I'm missing the obvious here
>> 
>> Drag and drop is not obvious.  See: Table View Programming Guide ▸ Using 
>> Drag and Drop in Tables.
>> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/rickcorteza%40gmail.com
> 
> This email sent to rickcort...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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