Re: How to throttle rate of NSInputStream?

2012-03-27 Thread Steve Sisak

At 10:36 PM +0100 3/27/12, jonat...@mugginsoft.com wrote:
You probably already have this sorted but it occurred to me that 
when you receive NSStreamEventHasBytesAvailable you don't have to 
read the data there and then.


Quinn (DTS) gave Jens the following complete answer on 
macnetworkp...@lists.apple.com:


At 8:52 AM +0100 3/27/12, Quinn \"The Eskimo!\" wrote:

On 26 Mar 2012, at 21:28, Jens Alfke wrote:

 What can I do about this? Ideally I'd like the stream to hold off 
on reading more from the socket until my code finishes processing 
the buffer..


If you don't call -read:maxLength:, the stream won't send you 
another NSStreamEventHasBytesAvailable event.  So you can handle 
this case by:


on NSStreamEventHasBytesAvailable
  if we're still processing a buffer
set a flag indicating that data is available
  else
read and start processing a buffer
  end if
end

on bufferProcessingDone
  if we ignored a NSStreamEventHasBytesAvailable event
read and start processing a buffer
  end if
end

Obviously the buffer processing will need to be async (either via an 
NSOperation or GCD), and you should organise to call 
-bufferProcessingDone back on the main thread.


Share and Enjoy
--
Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware


Seems this should be shared here as well.

HTH,

-Steve
___

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

Please do not post 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: Is there a list solely for ObjC/compiler language issues?

2012-03-27 Thread Wade Tregaskis
> Just curious... :)

ObjC: objc-langu...@lists.apple.com 
(https://lists.apple.com/mailman/listinfo/objc-language)
Clang: cfe-...@cs.uiuc.edu (http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev)
___

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

Please do not post 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


Is there a list solely for ObjC/compiler language issues?

2012-03-27 Thread William Squires
Just curious... :)

___

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

Please do not post 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: Can't delete file on device

2012-03-27 Thread Mike Abdullah

On 27 Mar 2012, at 22:23, Rick Mann wrote:

>> There are a couple other issues:
>> 
>> 1) You shouldn't handle errors by testing (err != nil).  This might work
>> (since you initialized err to nil) assuming that removeItemAtURL: isn't
>> fiddling with err anyway, but it's not guaranteed.  The preferred
>> approach is to test the return value of removeItemAtURL: (it returns
>> BOOL for a reason!) and examine err iff the method returns NO.
> 
> Okay, I made that change, but it seems blatantly incorrect to create an error 
> return if it is also going to return true.

http://weblog.bignerdranch.com/?p=360
___

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

Please do not post 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: Can't delete file on device

2012-03-27 Thread Wade Tregaskis
> Okay, I made that change, but it seems blatantly incorrect to create an error 
> return if it is also going to return true.

It only returns you something if it says it did, by indicating that an error 
occurred.  Otherwise, the contents of the error parameter are undefined.

There are definitely some Apple frameworks which will modify the error 
parameter even if they succeed.  There are definitely some which won't.  So you 
can neither rely on it being nil nor on being non-nil, regardless of what you 
initialise it to.

So like it or not, this isn't about preference, it's about correctness.

ARC doesn't change much.  The callee is still free to write something into the 
error parameter and leave it there; it'll merely be released by the caller, 
rather than the callee (which without ARC momentarily leaves a dangling 
pointer).  So it'll reduce the incidence of leaks, but that's about it.
___

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

Please do not post 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 to throttle rate of NSInputStream?

2012-03-27 Thread jonat...@mugginsoft.com
On 27 Mar 2012, at 00:13, Jens Alfke wrote:
> 
> This seems to hinge on the way the stream calls my event handler. When I get 
> the NSStreamEventHasBytesAvailable, I only read 8k bytes of data at a time, 
> then return. What seems to happen is that, if that didn’t consume all of the 
> available data, the stream will keep sending me the event in a tight loop 
> without exiting back to the runloop in between.

Jens

You probably already have this sorted but it occurred to me that when you 
receive NSStreamEventHasBytesAvailable you don't have to read the data there 
and then. You
can defer the actual reading to some later moment and coalesce the reading 
operations. This may cause the NSInputStream to buffer up and give the run loop 
a breather.

Regards

Jonathan Mitchell
Mugginsoft LLP




___

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

Please do not post 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: Example implementation of NSAnimatablePropertyContainer?

2012-03-27 Thread Gideon King
I'd be interested in this too. 

In the past, I have created a subclass of NSView and just used the animation 
capabilities without ever inserting it in a view hierarchy, and that worked, 
but that was just a quick and dirty hack project - I'd like to know how to do 
it properly…

Regards

Gideon

On 28/03/2012, at 12:34 AM, Kenneth Baxter wrote:

> I have some objects that I want to use implicit animations for, but they are 
> not views. 
> 
> I understand that I should be able to implement the 
> NSAnimatablePropertyContainer protocol and it should just work from there. 
> 
> Unfortunately the documentation seems pretty light on how to implement the 
> protocol yourself, what the animator should return, etc. I have not been able 
> to find any example code to show how you would do this. Is there an example 
> around somewhere?
> 
> Thanks
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/gideon%40novamind.com
> 
> This email sent to gid...@novamind.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: Can't delete file on device

2012-03-27 Thread Gregory Weston
Rick Mann wrote:

> The file is generated and deleted by code; it's the same string passed 
> around, at least certainly in the existence check just before the attempted 
> delete. Surely that existence check would fail, too?

Not necessarily. The problem with patterns like "check if transient resource 
exists, then try to operate on transient resource" is that the existence of the 
resource can change between the test and the usage.

It might be amusing to perform your existence test again after the delete 
fails. (Although, you know, not strictly reliable for the above reason.)

Also: Can we see the code? I'm not sure if "that's just the way it is" but I'm 
a little confused about the bits where the log output says "NSURL=" and what 
follows is an unadorned path.
___

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

Please do not post 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: Can't delete file on device

2012-03-27 Thread Kyle Sluder
On Mar 27, 2012, at 2:23 PM, Rick Mann wrote:

> 
> On Mar 27, 2012, at 14:16 , Conrad Shultz wrote:
> 
>> As David already pointed out you should probably be using file URLs.
> 
> I made that change, and it behaves the same way. Even so, I don't see why 
> that particular difference would allow it to work on the sim and not on the 
> device.
> 
>> There are a couple other issues:
>> 
>> 1) You shouldn't handle errors by testing (err != nil).  This might work
>> (since you initialized err to nil) assuming that removeItemAtURL: isn't
>> fiddling with err anyway, but it's not guaranteed.  The preferred
>> approach is to test the return value of removeItemAtURL: (it returns
>> BOOL for a reason!) and examine err iff the method returns NO.
> 
> Okay, I made that change, but it seems blatantly incorrect to create an error 
> return if it is also going to return true.

Despite the impoliteness, the documentation used to explicitly warn that this 
was possible. The contract is "return value indicates success; if successful, 
*error is meaningless."

Nowadays with ARC, you can't trash *error without breaking ARC's rules.

> 
>> 2) Less likely, but still reasonably plausible since you are working
>> with cache files (which I imagine have other clearance mechanisms), is
>> that you are encountering a race condition.  It's possible that another
>> thread removed the file in the intervening time between your
>> fileExistsAtPath: and removeItemAtURL: calls.  This is a major reason
>> why it's usually not useful to to ask "can I delete a file?" but rather
>> to try "delete the file!" and handle any errors appropriately.
> 
> A race is possible, although I think unlikely (the call to the method that 
> does the deletion is serialized on the main queue, although I suppose it's 
> possible two operations are getting queued for the same file). In any case, I 
> wasn't checking for it first, and then deleting it. I was checking for it 
> only as a sanity check once I started seeing the problem. I was just deleting 
> it and handling the error.

The more unlikely you think a race condition is, the more likely you are going 
to hit it at a very bad time.

Don't play around with race conditions. This is a fairly canonical example of a 
filesystem race.

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


Re: Can't delete file on device

2012-03-27 Thread Rick Mann

On Mar 27, 2012, at 14:16 , Conrad Shultz wrote:

> As David already pointed out you should probably be using file URLs.

I made that change, and it behaves the same way. Even so, I don't see why that 
particular difference would allow it to work on the sim and not on the device.

> There are a couple other issues:
> 
> 1) You shouldn't handle errors by testing (err != nil).  This might work
> (since you initialized err to nil) assuming that removeItemAtURL: isn't
> fiddling with err anyway, but it's not guaranteed.  The preferred
> approach is to test the return value of removeItemAtURL: (it returns
> BOOL for a reason!) and examine err iff the method returns NO.

Okay, I made that change, but it seems blatantly incorrect to create an error 
return if it is also going to return true.

> 2) Less likely, but still reasonably plausible since you are working
> with cache files (which I imagine have other clearance mechanisms), is
> that you are encountering a race condition.  It's possible that another
> thread removed the file in the intervening time between your
> fileExistsAtPath: and removeItemAtURL: calls.  This is a major reason
> why it's usually not useful to to ask "can I delete a file?" but rather
> to try "delete the file!" and handle any errors appropriately.

A race is possible, although I think unlikely (the call to the method that does 
the deletion is serialized on the main queue, although I suppose it's possible 
two operations are getting queued for the same file). In any case, I wasn't 
checking for it first, and then deleting it. I was checking for it only as a 
sanity check once I started seeing the problem. I was just deleting it and 
handling the error.

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

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


Re: Can't delete file on device

2012-03-27 Thread Conrad Shultz
On 3/27/12 1:50 PM, Rick Mann wrote:
> 
> On Mar 27, 2012, at 12:05 , Mike Abdullah wrote:
> 
>> Show us some code.
> 
> NSURL* url = [NSURL URLWithString: ci.diskURI];
> if ([fm fileExistsAtPath: url.absoluteString])
> {
> NSLog(@"File exists: %@", url.absoluteString);
> }
> 
> NSError* err = nil;
> [fm removeItemAtURL: url error: &err];
> if (err != nil)
> {
> NSLog(@"Unable to delete file at %@: %@\n%@", url, err, err.userInfo);
> }

As David already pointed out you should probably be using file URLs.

There are a couple other issues:

1) You shouldn't handle errors by testing (err != nil).  This might work
(since you initialized err to nil) assuming that removeItemAtURL: isn't
fiddling with err anyway, but it's not guaranteed.  The preferred
approach is to test the return value of removeItemAtURL: (it returns
BOOL for a reason!) and examine err iff the method returns NO.

2) Less likely, but still reasonably plausible since you are working
with cache files (which I imagine have other clearance mechanisms), is
that you are encountering a race condition.  It's possible that another
thread removed the file in the intervening time between your
fileExistsAtPath: and removeItemAtURL: calls.  This is a major reason
why it's usually not useful to to ask "can I delete a file?" but rather
to try "delete the file!" and handle any errors appropriately.


-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.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: NSScrollView automatically changes scroller styles?

2012-03-27 Thread Nick Zitzmann

On Mar 27, 2012, at 2:09 PM, Nick Zitzmann wrote:

> I've searched around but didn't see anything relevant. Why would an 
> NSScrollView suddenly change its scroller style behind the application's back 
> during a resize?


I still wish I knew why this was happening, but I did find a workaround on my 
own in case anyone finds this in the archives: My code was using the Leopard 
animation proxy API to animate resizing a scroll view at the same time that a 
neighboring view was being resized into view by the same API. I took that out 
and used the older NSViewAnimation class to animate both views into place, and 
then the problem went away. :\

Nick Zitzmann



___

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

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

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

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


Re: Can't delete file on device

2012-03-27 Thread David Duncan
On Mar 27, 2012, at 1:50 PM, Rick Mann wrote:

>NSURL* url = [NSURL URLWithString: ci.diskURI];


Does ci.diskURI include the "file://" prefix or is it just a path? If the 
latter, then you should be using +fileURLWithString:.
--
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: Can't delete file on device

2012-03-27 Thread Rick Mann

On Mar 27, 2012, at 12:05 , Mike Abdullah wrote:

> Show us some code.

NSURL* url = [NSURL URLWithString: ci.diskURI];
if ([fm fileExistsAtPath: url.absoluteString])
{
NSLog(@"File exists: %@", url.absoluteString);
}

NSError* err = nil;
[fm removeItemAtURL: url error: &err];
if (err != nil)
{
NSLog(@"Unable to delete file at %@: %@\n%@", url, err, err.userInfo);
}


> 
> On 27 Mar 2012, at 19:47, Rick Mann wrote:
> 
>> The file is generated and deleted by code; it's the same string passed 
>> around, at least certainly in the existence check just before the attempted 
>> delete. Surely that existence check would fail, too?
>> 
>> -- 
>> Rick
>> 
>> On Mar 27, 2012, at 11:31 , Roland King wrote:
>> 
>>> and the fact it works on the sim and not on the device makes me think you 
>>> have a case issue, device is case sensitive, sim is not. 
>>> 
>>> On Mar 28, 2012, at 2:15 AM, Mike Abdullah wrote:
>>> 
 Well error code 4 is NSFileNoSuchFileError. I think you're trying to 
 delete a file that doesn't exist!
 
 On 27 Mar 2012, at 03:22, Rick Mann wrote:
 
> I'm trying to delete some image files I cache. Here's what I'm getting:
> 
> 2012-03-26 19:20:14.330 MyApp[5765:707] File exists: 
> /var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg
> 
> 2012-03-26 19:20:14.332 MyApp[5765:707] Unable to delete file at 
> /var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg:
>  Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be 
> completed. (Cocoa error 4.)" UserInfo=0x278590 
> {NSURL=/var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg}
> {
> NSURL = 
> "/var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg";
> }
> 
> This doesn't happen in the simulator. Xc4.3.2, iOS 5.1 9B176
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/rols%40rols.org
 
 This email sent to r...@rols.org
>>> 
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> 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: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread David Duncan
On Mar 27, 2012, at 1:04 PM, Andreas Mayer wrote:

> 
> Am 27.03.2012 um 20:13 schrieb David Duncan:
> 
>> Primarily because people abuse the resolution field, and as such it cannot 
>> be trusted for this particular function. In a perfect world, we would only 
>> ever see 72 (1x) or 144 (2x) in the resolution field, but instead the value 
>> tends to be practically random.
> 
> Oh. OK. In that case, shouldn't the framework offer an image format, that 
> works reliably?


Its not a matter of the image format, but a matter of the format's flexibility. 
In terms of general image authoring, the fact that PNG can specify practically 
any resolution is a hard requirement. In terms of generating an image to be 
used as part of a UI in an iOS application, its a fault that can't be easily 
dealt with without ensuring that all authoring is done in a particular way.
--
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


NSScrollView automatically changes scroller styles?

2012-03-27 Thread Nick Zitzmann
I've searched around but didn't see anything relevant. Why would an 
NSScrollView suddenly change its scroller style behind the application's back 
during a resize?

I noticed that, when running an app on a laptop with no external pointer 
connected and the system default set to show scroll bars automatically based on 
input device, an NSScrollView was suddenly changing its scroller style during 
an animation. I set a breakpoint in the debugger, and the stack trace looked 
like this:

frame #0: 0x7fff94ca1298 AppKit`-[NSScrollView setScrollerStyle:]
frame #1: 0x7fff94661fcc AppKit`-[NSScrollView 
_checkForAccessoryViewsInScrollerAreas] + 1898
frame #2: 0x7fff9465f0a7 AppKit`-[NSScrollView _tileWithoutRecursing] + 
57
frame #3: 0x7fff9465f050 AppKit`-[NSScrollView _update] + 27
frame #4: 0x7fff94664b82 AppKit`-[NSScrollView 
resizeSubviewsWithOldSize:] + 107
frame #5: 0x7fff94575996 AppKit`-[NSView setFrameSize:] + 955
frame #6: 0x7fff94664838 AppKit`-[NSScrollView setFrameSize:] + 506

The value of $rdx is 0 in frame #0, meaning the calling method is switching the 
scroller style to the "legacy" style. Why is this happening? I'm looking for a 
workaround now, but I was wondering if anyone has seen this before, and if so, 
then how did you work around it? I don't want the scroll view using the legacy 
style for any reason whatsoever.

Nick Zitzmann



___

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

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

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

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


Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer

Am 27.03.2012 um 20:13 schrieb David Duncan:

> Primarily because people abuse the resolution field, and as such it cannot be 
> trusted for this particular function. In a perfect world, we would only ever 
> see 72 (1x) or 144 (2x) in the resolution field, but instead the value tends 
> to be practically random.

Oh. OK. In that case, shouldn't the framework offer an image format, that works 
reliably?


Andreas
___

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

Please do not post 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: mogenerator and key path error

2012-03-27 Thread Quincey Morris
On Mar 27, 2012, at 11:56 , Ayers, Joseph wrote:

> 2012-03-27 14:39:38.533 Roboplasm[74089:403] Cocoa Bindings: Error accessing 
> value for key path tapes of object  (from bound 
> object [entity: tapes, number of selected 
> objects: 0]): [ valueForUndefinedKey:]: this 
> class is not key value coding-compliant for the key tapes.

Look at the error message. It still says that the entity name for a 
TapesController is "tapes". Is there another TapesController? OTOH, it might 
not really matter what the entity name is set to, if you're not actually having 
TapesController create any objects for you.

However, there's another problem, which I didn't notice before. Your app 
delegate really *isn't* KVC compliant for property "tapes":

On Mar 27, 2012, at 11:12 , Ayers, Joseph wrote:

> I declare an instance tapes in AppDelegate.h as:
> @property (nonatomic, retain)  Tapes* tapes;
> and in AppDelegate.m as
> @dynamic tapes;

Your app delegate isn't a Core Data object, so Core Data isn't going to provide 
the "tapes" property for you, as you promise with '@dynamic tapes'. You need to 
'@synthesize tapes', or write the getter/setter yourself.


___

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

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

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

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


Re: Can't delete file on device

2012-03-27 Thread Mike Abdullah
Show us some code.

On 27 Mar 2012, at 19:47, Rick Mann wrote:

> The file is generated and deleted by code; it's the same string passed 
> around, at least certainly in the existence check just before the attempted 
> delete. Surely that existence check would fail, too?
> 
> -- 
> Rick
> 
> On Mar 27, 2012, at 11:31 , Roland King wrote:
> 
>> and the fact it works on the sim and not on the device makes me think you 
>> have a case issue, device is case sensitive, sim is not. 
>> 
>> On Mar 28, 2012, at 2:15 AM, Mike Abdullah wrote:
>> 
>>> Well error code 4 is NSFileNoSuchFileError. I think you're trying to delete 
>>> a file that doesn't exist!
>>> 
>>> On 27 Mar 2012, at 03:22, Rick Mann wrote:
>>> 
 I'm trying to delete some image files I cache. Here's what I'm getting:
 
 2012-03-26 19:20:14.330 MyApp[5765:707] File exists: 
 /var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg
 
 2012-03-26 19:20:14.332 MyApp[5765:707] Unable to delete file at 
 /var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg:
  Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be 
 completed. (Cocoa error 4.)" UserInfo=0x278590 
 {NSURL=/var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg}
 {
 NSURL = 
 "/var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg";
 }
 
 This doesn't happen in the simulator. Xc4.3.2, iOS 5.1 9B176
>>> 
>>> ___
>>> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>> 
>>> Please do not post 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/rols%40rols.org
>>> 
>>> This email sent to r...@rols.org
>> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> 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: Can't delete file on device

2012-03-27 Thread Rick Mann
The file is generated and deleted by code; it's the same string passed around, 
at least certainly in the existence check just before the attempted delete. 
Surely that existence check would fail, too?

-- 
Rick

On Mar 27, 2012, at 11:31 , Roland King wrote:

> and the fact it works on the sim and not on the device makes me think you 
> have a case issue, device is case sensitive, sim is not. 
> 
> On Mar 28, 2012, at 2:15 AM, Mike Abdullah wrote:
> 
>> Well error code 4 is NSFileNoSuchFileError. I think you're trying to delete 
>> a file that doesn't exist!
>> 
>> On 27 Mar 2012, at 03:22, Rick Mann wrote:
>> 
>>> I'm trying to delete some image files I cache. Here's what I'm getting:
>>> 
>>> 2012-03-26 19:20:14.330 MyApp[5765:707] File exists: 
>>> /var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg
>>> 
>>> 2012-03-26 19:20:14.332 MyApp[5765:707] Unable to delete file at 
>>> /var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg:
>>>  Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be 
>>> completed. (Cocoa error 4.)" UserInfo=0x278590 
>>> {NSURL=/var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg}
>>> {
>>>  NSURL = 
>>> "/var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg";
>>> }
>>> 
>>> This doesn't happen in the simulator. Xc4.3.2, iOS 5.1 9B176
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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/rols%40rols.org
>> 
>> This email sent to r...@rols.org
> 


___

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

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

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

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

Re: mogenerator and key path error

2012-03-27 Thread Quincey Morris
On Mar 27, 2012, at 11:12 , Ayers, Joseph wrote:

> In mainMenu.xib I have a NSArrayController. TapesController:NSArrayController
> With ObjectController mode set to EntityName
> and the EntityName set to tapes

The entity name should be "Tapes", not "tapes".


___

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

Please do not post 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: Can't delete file on device

2012-03-27 Thread Roland King
and the fact it works on the sim and not on the device makes me think you have 
a case issue, device is case sensitive, sim is not. 

On Mar 28, 2012, at 2:15 AM, Mike Abdullah wrote:

> Well error code 4 is NSFileNoSuchFileError. I think you're trying to delete a 
> file that doesn't exist!
> 
> On 27 Mar 2012, at 03:22, Rick Mann wrote:
> 
>> I'm trying to delete some image files I cache. Here's what I'm getting:
>> 
>> 2012-03-26 19:20:14.330 MyApp[5765:707] File exists: 
>> /var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg
>> 
>> 2012-03-26 19:20:14.332 MyApp[5765:707] Unable to delete file at 
>> /var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg:
>>  Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be 
>> completed. (Cocoa error 4.)" UserInfo=0x278590 
>> {NSURL=/var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg}
>> {
>>   NSURL = 
>> "/var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg";
>> }
>> 
>> This doesn't happen in the simulator. Xc4.3.2, iOS 5.1 9B176
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/rols%40rols.org
> 
> This email sent to r...@rols.org


___

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

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

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

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

Re: How to throttle rate of NSInputStream?

2012-03-27 Thread Andreas Grosam

On Mar 27, 2012, at 1:13 AM, Jens Alfke wrote:

> [I posted this to macnetworkprog earlier today, but 3 hours later it hasn’t 
> shown up yet, so I’m trying here too.]
> 
> I’m using an async NSInputStream to read from a TCP socket. Given a good 
> connection, the data comes in faster than an iOS device can parse it (it’s a 
> stream of small JSON docs, one per line.)

You may look at JPJson framework available on GitHub 
.

The class JPAsyncParser solves this problem. Please examine the 
"NSURLConnectionDownload" example which shows how to download and parse 
simultaneously, without stressing memory. It also shows how the parser 
integrates nicely with NSURLConnection. There is also AppleDoc documentation.

Simultaneous downloading and parsing is a really performance boost. I 
experienced, that when downloading larger documents, the parser is already 
finished when the last byte of the document arrived. No temporary file needed - 
and a really scaleable solution.


Basically, the parser (JPAsyncParser) runs on a secondary thread and parses one 
or more JSON documents per connection. A client will be "notified" about a 
complete JSON representation or errors through a Blocks API.

The size of the document containing one or more JSON documents can be 
unlimited. The parser also does not queue more than one NSData object which 
will be received in a NSURLConnection delegate method - that is, the memory is 
bounded. This is accomplished through blocking the thread where the connection 
delegates will be scheduled.

You can control whether you process the JSON representations *synchronously* 
with the JSON parser (recommend) or asynchronously (which possibly causes GCD 
to queue many JSON objects).

For a reason, it avoids using NSStreams.

Caution:  the state is still Beta - but all major tests pass.


Have fun!


Regards
Andreas



> I’m performance-tuning my code, and finding that NSInputStream is shoving all 
> of the data down my throat at once, without giving the runloop a chance to 
> process any other input sources. This means that my thread is blocked, and 
> other tasks scheduled on it don’t get a chance to run, until I’ve read the 
> whole feed, which takes over a minute. (And there’s also the fact that 
> CFNetwork must be buffering megabytes of data from the socket that my code 
> hasn’t read yet.)
> 
> This seems to hinge on the way the stream calls my event handler. When I get 
> the NSStreamEventHasBytesAvailable, I only read 8k bytes of data at a time, 
> then return. What seems to happen is that, if that didn’t consume all of the 
> available data, the stream will keep sending me the event in a tight loop 
> without exiting back to the runloop in between.
> 
> What can I do about this? Ideally I’d like the stream to hold off on reading 
> more from the socket until my code finishes processing the buffer. As a 
> second choice, I’d like it to at least return the runloop more often so my 
> other tasks get time to run.
> 
> —Jens
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/agrosam%40onlinehome.de
> 
> This email sent to agro...@onlinehome.de


___

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

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

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

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

Re: Can't delete file on device

2012-03-27 Thread Rick Mann
Yet, I check for the existence of the file before to verify its there, as you 
can see in the output. 

Sent from my iPhone

On Mar 27, 2012, at 11:15, Mike Abdullah  wrote:

> Well error code 4 is NSFileNoSuchFileError. I think you're trying to delete a 
> file that doesn't exist!
> 
> On 27 Mar 2012, at 03:22, Rick Mann wrote:
> 
>> I'm trying to delete some image files I cache. Here's what I'm getting:
>> 
>> 2012-03-26 19:20:14.330 MyApp[5765:707] File exists: 
>> /var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg
>> 
>> 2012-03-26 19:20:14.332 MyApp[5765:707] Unable to delete file at 
>> /var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg:
>>  Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be 
>> completed. (Cocoa error 4.)" UserInfo=0x278590 
>> {NSURL=/var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg}
>> {
>>   NSURL = 
>> "/var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg";
>> }
>> 
>> This doesn't happen in the simulator. Xc4.3.2, iOS 5.1 9B176

___

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

Please do not post 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: Can't delete file on device

2012-03-27 Thread Mike Abdullah
Well error code 4 is NSFileNoSuchFileError. I think you're trying to delete a 
file that doesn't exist!

On 27 Mar 2012, at 03:22, Rick Mann wrote:

> I'm trying to delete some image files I cache. Here's what I'm getting:
> 
> 2012-03-26 19:20:14.330 MyApp[5765:707] File exists: 
> /var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg
> 
> 2012-03-26 19:20:14.332 MyApp[5765:707] Unable to delete file at 
> /var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg:
>  Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be 
> completed. (Cocoa error 4.)" UserInfo=0x278590 
> {NSURL=/var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg}
> {
>NSURL = 
> "/var/mobile/Applications/6BBF21B1-97B3-4016-88B0-FE1C18D736D7/Library/Caches/Images/4149/5414582865_932fac9c82_b.jpg";
> }
> 
> This doesn't happen in the simulator. Xc4.3.2, iOS 5.1 9B176

___

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

Please do not post 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: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread David Duncan
On Mar 27, 2012, at 10:59 AM, Andreas Mayer wrote:

> 
> Am 27.03.2012 um 19:29 schrieb David Duncan:
> 
>> Simplest solution is to save the scale along side the image itself 
> 
> That's what I just implemented. But I still think PNG images should retain 
> the scale factor. Why saving that information elsewhere when the format 
> explicitly supports this?


Primarily because people abuse the resolution field, and as such it cannot be 
trusted for this particular function. In a perfect world, we would only ever 
see 72 (1x) or 144 (2x) in the resolution field, but instead the value tends to 
be practically random.
--
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


mogenerator and key path error

2012-03-27 Thread Ayers, Joseph
I have a CoreData entity named Tapes.
I used mogenerator to create:
_Tapes.h  where:
@interface Tapes : _Tapes {}

and Tapes.h where
@interface _Tapes : NSManagedObject {}

I declare an instance tapes in AppDelegate.h as:
@property (nonatomic, retain)  Tapes* tapes;
and in AppDelegate.m as
@dynamic tapes;

In mainMenu.xib I have a NSArrayController. TapesController:NSArrayController
With ObjectController mode set to EntityName
and the EntityName set to tapes
In ContentController TapeController is bound to AppDelegate
with Model Key Path set to tapes and Raises For Not Applicable Keys checked
Under parameters, ManagedObjectContext is bound to 
AppDelegate.managedObjectContext

A Second NSArrayController VideoClip has a ContentSet
TapesController.selection.VideoClip
Under parameters, ManagedObjectContext is bound to 
AppDelegate.managedObjectContext

At run time, I get the Error:

2012-03-27 13:53:09.787 Roboplasm[72209:403] Cocoa Bindings: Error accessing 
value for key path tapes of object  (from bound 
object [entity: tapes, number of selected 
objects: 0]): [ valueForUndefinedKey:]: this class 
is not key value coding-compliant for the key tapes.

Any Idea where I have gone astray?

Thanks,
Joseph
___

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

Please do not post 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


NSTextFinder - don't use an NSView subclass for the client

2012-03-27 Thread Eric Slosser
Don't use a subclass of NSView for the object that you pass as 'client'.

The NSTextFinderClient protocol's -(BOOL)isEditable method will be called from 
-[NSView inputContext] as your view's window is being dealloc'd, and you may 
crash.
___

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

Please do not post 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: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer

Am 27.03.2012 um 19:29 schrieb David Duncan:

> Simplest solution is to save the scale along side the image itself 

That's what I just implemented. But I still think PNG images should retain the 
scale factor. Why saving that information elsewhere when the format explicitly 
supports this?


Andreas
___

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

Please do not post 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: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer

Am 27.03.2012 um 19:19 schrieb Ray:

> Edit: I just checked and they say they do this for compatibility reasons. 
> It's around the 9'40'' mark, session 134 - Optimize your iPhone App for the 
> Retina Display (WWDC 2010, I assume you have access)...

I'll check this out, thanks.


Andreas
___

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

Please do not post 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: File types...

2012-03-27 Thread Randy Widell
Eh.  Looks like you're right.  I reconfigured the Info.plist with 
public.database as Item 0 and public.data as Item 1 and it worked this time 
around.  Originally, I added public.data, cleaned and rebuilt, and the files 
were still showing as gray in the open panel.  But, I cannot reproduce that 
again.  So, all is right with the world, I guess.


On Mar 27, 2012, at 9:13 AM, Randy Widell wrote:

> Yup, that was it.  public.data has to be the first item in the array.  I 
> tried:
> 
> * public.database (item 0) only: fail.
> * public.database (item 0), public.data (item 1): fail.
> * no conformance declarations: fail.
> * public.data (item 0), public.database (item 1): success.
> * public.data (item 0) only: success.
> 
> Thanks so much.  That was driving me crazy.
> 
> Randy Widell
> 
> 
> On Mar 27, 2012, at 7:50 AM, Kyle Sluder wrote:
> 
>> On Mar 26, 2012, at 11:14 PM, Randy Widell  wrote:
>> 
>>> It is a custom UTI, so, of course, I export it:
>>> 
>>>  UTExportedTypeDeclarations
>>>  
>>>  
>>>  UTTypeConformsTo
>>>  
>>>  public.database
>>>  
>> 
>> Not sure this will fix your problem, but you haven't declared conformance to 
>> a physical UTI. public.database is purely a functional UTI and does not 
>> conform to any physical UTIs.
>> 
>> If your documents are flat files, you need to add public.data to this array; 
>> if your documents are packages, you need to add com.apple.package.
>> 
>> See: 
>> http://developer.apple.com/library/mac/DOCUMENTATION/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html
>> 
>> --Kyle Sluder
> 


___

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

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

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

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


Re: File types...

2012-03-27 Thread Kyle Sluder

On Mar 27, 2012, at 9:13 AM, Randy Widell wrote:

> Yup, that was it.  public.data has to be the first item in the array.  I 
> tried:
> 
> * public.database (item 0) only: fail.
> * public.database (item 0), public.data (item 1): fail.
> * no conformance declarations: fail.
> * public.data (item 0), public.database (item 1): success.
> * public.data (item 0) only: success.
> 
> Thanks so much.  That was driving me crazy.

As far as I can tell, order should not matter. You might have nudged Launch 
Services in just the right way at the same time as you changed the order of 
your conformance declarations. Launch Services caches UTI info; if you don't 
bump your CFBundleVersion or otherwise force Launch Services to purge its cache 
using lsregister, it's undefined when LS will update its cache.

If you are able to reliably reproduce a dependence on the order in which you 
declare your UTI conformance, I'd suggest filing a bug. Alternatively, if you 
can point out documentation that says that the physical UTIs must come before 
functional UTIs, I'd love to hear about it. But I doubt such a statement exists.

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


Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread David Duncan
On Mar 27, 2012, at 2:57 AM, Giacomo Tufano wrote:

> That's what I use to generate a thumbnail of sideSize side lenght in iOS3.x 
> code.
> It uses iOS4+ functions for retina displays (I remember that you can assume 
> iOS4+ with retina displays).
> 
> CGSize newSize = CGSizeMake(sideSize, sideSize);
> #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
>   if(UIGraphicsBeginImageContextWithOptions != NULL)
>   UIGraphicsBeginImageContextWithOptions(newSize, NO, [[UIScreen 
> mainScreen] scale]);
>   else
> #endif
>   UIGraphicsBeginImageContext(newSize);
> UIGraphicsBeginImageContext(newSize);
> [self drawInRect:CGRectMake(0, 0, sideSize, sideSize)];
> // Get the new image from the context
> UIImage *thumbnailImage = UIGraphicsGetImageFromCurrentImageContext();
> // End the context
> UIGraphicsEndImageContext();
> 
> It works correctly on retina displays.
> To be honest I don't remember why I use that macro to test for iOS4, there 
> were a reason and that was a workaround but cannot remember why. It works, 
> anyway. :)


Your macro check is to attempt to remain compatible with the 3.2 or earlier 
SDK. It has served its purpose and can be retired :). If you no longer support 
iOS 3.x you can even remove the existence check for 
UIGraphicsBeginImageContextWithOptions.
--
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: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread David Duncan
On Mar 27, 2012, at 12:38 AM, Ray wrote:

> Now, when I generate a new image on an iPhone with a retina screen, in which 
> case the above UIGraphicsBeginImageContextWithOptions uses a scale of 2.0, 
> the image in the table view shows too big. This is because [UIImage 
> imageWithData:item.listImage] always returns a 1.0 scaled image. Now I can 
> solve this by using something like:
> 
> UIImage *theImage = [UIImage imageWithData:listImage];
> [UIImage imageWithCGImage:theImage.CGImage scale:theImage.size.width > 44.0 ? 
> 2.0 : 1.0 orientation:theImage.imageOrientation];
> 
> But this seems kludgy and it's using programmer's knowledge, so to speak. I 
> watched WWDC2010 session 134 "Optimize your iPhone App for the Retina 
> Display" again, searched stackoverflow etc. but I can't find a more elegant 
> solution. What would be a more thorough approach? Maybe it's staring me in 
> the face but I don't see it...


Simplest solution is to save the scale along side the image itself (under the 
assumption that this data can possibly end up on a non-retina device for some 
reason) or to create a new UIImage with the screen scale via 
+imageWIthCGImage:scale:orientation: (assuming it cannot) after you load it 
with +imageWithData:.
--
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: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Andreas:

On Mar 27, 2012, at 6:41 PM, Andreas Mayer wrote:

> So either imageWithData does not restore the scale from PNG data or 
> UIImagePNGRepresentation() does not store it in the first place.

When I set a breakpoint at UIImagePNGRepresentation(newImage) I can see that 
the scale of newImage is 2.0.



___

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

Please do not post 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: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Andreas:

On Mar 27, 2012, at 6:41 PM, Andreas Mayer wrote:

> The scale value is the same as set in 
> UIGraphicsBeginImageContextWithOptions(), as far as I can tell.

Right, that was what I meant actually.


> But it will be lost when creating PNG data and reading it again. (Since I 
> don't see a way of creating a PNG file without using 
> UIImagePNGRepresentation() it doesn't seem to matter if the data was saved to 
> a file or not.)

You have a point here ;)


> So either imageWithData does not restore the scale from PNG data or 
> UIImagePNGRepresentation() does not store it in the first place.
> 
> I see that as a bug, since the PNG format is able to hold that information.

Yes, I think it is imageWithData that is the culprit. In this WWDC session, 
they actually state that they specifically did this because some older 
applications would get in trouble. I don't remember how they worded it, it was 
addressed very briefly. I will watch that part again. Edit: I just checked and 
they say they do this for compatibility reasons. It's around the 9'40'' mark, 
session 134 - Optimize your iPhone App for the Retina Display (WWDC 2010, I 
assume you have access)...



___

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

Please do not post 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: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer

Am 27.03.2012 um 17:31 schrieb Ray:

>> So I would expect PNG images to retain their scale value when saved and 
>> loaded.
>> 
>> If this does not work, there seems to be a bug somewhere.
>> Ray, did you try to explicitly set the image's scale value before creating 
>> the PNG representation?
> 
> Well, I don't save it to a file, but to a NSData property on a Core Data 
> managed object, and I use UIGraphicsBeginImageContextWithOptions, after which 
> newImage = UIGraphicsGetImageFromCurrentImageContext() will set the scale of 
> "newImage" appropriately (under retina to 2.0, I checked with setting a 
> breakpoint and looking at the scale variable of the image)... It is more that 
> the imageWithData class method on UIImage always will report a scale of 1.0

The scale value is the same as set in UIGraphicsBeginImageContextWithOptions(), 
as far as I can tell.
But it will be lost when creating PNG data and reading it again. (Since I don't 
see a way of creating a PNG file without using UIImagePNGRepresentation() it 
doesn't seem to matter if the data was saved to a file or not.)

So either imageWithData does not restore the scale from PNG data or 
UIImagePNGRepresentation() does not store it in the first place.

I see that as a bug, since the PNG format is able to hold that information.


Andreas
___

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

Please do not post 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: File types...

2012-03-27 Thread Randy Widell
Yup, that was it.  public.data has to be the first item in the array.  I tried:

* public.database (item 0) only: fail.
* public.database (item 0), public.data (item 1): fail.
* no conformance declarations: fail.
* public.data (item 0), public.database (item 1): success.
* public.data (item 0) only: success.

Thanks so much.  That was driving me crazy.

Randy Widell


On Mar 27, 2012, at 7:50 AM, Kyle Sluder wrote:

> On Mar 26, 2012, at 11:14 PM, Randy Widell  wrote:
> 
>> It is a custom UTI, so, of course, I export it:
>> 
>>   UTExportedTypeDeclarations
>>   
>>   
>>   UTTypeConformsTo
>>   
>>   public.database
>>   
> 
> Not sure this will fix your problem, but you haven't declared conformance to 
> a physical UTI. public.database is purely a functional UTI and does not 
> conform to any physical UTIs.
> 
> If your documents are flat files, you need to add public.data to this array; 
> if your documents are packages, you need to add com.apple.package.
> 
> See: 
> http://developer.apple.com/library/mac/DOCUMENTATION/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html
> 
> --Kyle Sluder


___

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

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

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

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


Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray

On Mar 27, 2012, at 4:50 PM, Andreas Mayer wrote:

> The documentation for UIImage -scale says:
> 
> "If you load an image from a file whose name includes the @2x modifier, the 
> scale is set to 2.0. If the filename does not include the modifier but is in 
> the PNG or JPEG format and has an associated DPI value, a corresponding scale 
> factor is computed and reflected in this property. "
> 
> So I would expect PNG images to retain their scale value when saved and 
> loaded.
> 
> If this does not work, there seems to be a bug somewhere.
> Ray, did you try to explicitly set the image's scale value before creating 
> the PNG representation?

Well, I don't save it to a file, but to a NSData property on a Core Data 
managed object, and I use UIGraphicsBeginImageContextWithOptions, after which 
newImage = UIGraphicsGetImageFromCurrentImageContext() will set the scale of 
"newImage" appropriately (under retina to 2.0, I checked with setting a 
breakpoint and looking at the scale variable of the image)... It is more that 
the imageWithData class method on UIImage always will report a scale of 1.0 (is 
mentioned in this WWDC session I was talking about). Hmm...


___

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

Please do not post 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: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Right, cell.imageView sets its own frame, no matter where you try to set it 
manually. I could of course add my own image view to the cell's contentView...

On Mar 27, 2012, at 4:21 PM, Roland King wrote:

> UIImageView's scale automatically so just setting the frame of the 
> UIImageView containing the UIImage to ( x, y, 44, 44 ), possibly after you 
> load the image into it, will just work whatever size the image actually is on 
> whatever type of display you are using.


___

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

Please do not post 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: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Andreas Mayer

Am 27.03.2012 um 13:47 schrieb Marco Tabini:

> When you save to a file format that supports metadata, like JPEG, some of the 
> metadata is stored there, while other is derived from the file name. So, for 
> example, if you were to save a PNG file to disk with an @2x suffix, upon 
> loading it with -imageNamed: UIImage would automatically know to set up the 
> resulting object as a 2x scale image.
> 
> When the filename convention is not available, that metadata needs to be 
> saved somewhere—in your case, you derive it from the file size, which, as you 
> mention, is not very portable.

The documentation for UIImage -scale says:

"If you load an image from a file whose name includes the @2x modifier, the 
scale is set to 2.0. If the filename does not include the modifier but is in 
the PNG or JPEG format and has an associated DPI value, a corresponding scale 
factor is computed and reflected in this property. "

So I would expect PNG images to retain their scale value when saved and loaded.

If this does not work, there seems to be a bug somewhere.
Ray, did you try to explicitly set the image's scale value before creating the 
PNG representation?

Something like this:

UIImage *newImage;
NSData *imageData;

UIGraphicsBeginImageContext(CGSizeMake(44.0, 44.0));
[selectedImage drawInRect:CGRectMake(0.0, 0.0, 44.0, 44.0)];
newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
newImage.scale = 2.0;  // <---

imageData = UIImagePNGRepresentation(newImage);


Andreas
___

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

Please do not post 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: File types...

2012-03-27 Thread Kyle Sluder
On Mar 26, 2012, at 11:14 PM, Randy Widell  wrote:

> It is a custom UTI, so, of course, I export it:
> 
>UTExportedTypeDeclarations
>
>
>UTTypeConformsTo
>
>public.database
>

Not sure this will fix your problem, but you haven't declared conformance to a 
physical UTI. public.database is purely a functional UTI and does not conform 
to any physical UTIs.

If your documents are flat files, you need to add public.data to this array; if 
your documents are packages, you need to add com.apple.package.

See: 
http://developer.apple.com/library/mac/DOCUMENTATION/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html

--Kyle Sluder
___

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

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

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

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


Example implementation of NSAnimatablePropertyContainer?

2012-03-27 Thread Kenneth Baxter

I have some objects that I want to use implicit animations for, but they are 
not views. 

I understand that I should be able to implement 
the NSAnimatablePropertyContainer protocol and it should just work from there. 

Unfortunately the documentation seems pretty light on how to implement the 
protocol yourself, what the animator should return, etc. I have not been able 
to find any example code to show how you would do this. Is there an example 
around somewhere?

Thanks

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

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

Rotating CALayer on iDevice rotation

2012-03-27 Thread Eric E. Dolecki
In my viewDidLoad I have this code which sets up some drawing on a CALayer:

rootLayer = [CALayer layer];

rootLayer.frame = CGRectMake(164, 243, 30, 30);

[self.view.layer addSublayer:rootLayer];


It's positioned properly. Now, I'd like to have it rotate around it's
"registration" point. Adding a background color to the layer I can see that
my drawing uses the top left corner of the layer.

I have this method with only works correctly for portrait, for the others
all i want to do is see it rotate 90º and then I can figure the rest out.
This is rotating the layer but on device rotation, the whole layer is
shifting around. I'd like to lock it down to the original corner:

-
(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration {

if(toInterfaceOrientation == UIInterfaceOrientationPortrait){

rootLayer.transform = CATransform3DMakeRotation(0.0, 0.0, 0.0, 0.0);

} else {

rootLayer.transform = CATransform3DMakeRotation(90.0/180 * M_PI,
0.0, 0.0, 0.0);//rotates but moves down to the left

}

}
___

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

Please do not post 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 to throttle rate of NSInputStream?

2012-03-27 Thread Roland King

On Mar 27, 2012, at 7:13 AM, Jens Alfke wrote:

> [I posted this to macnetworkprog earlier today, but 3 hours later it hasn’t 
> shown up yet, so I’m trying here too.]
> 
> I’m using an async NSInputStream to read from a TCP socket. Given a good 
> connection, the data comes in faster than an iOS device can parse it (it’s a 
> stream of small JSON docs, one per line.) I’m performance-tuning my code, and 
> finding that NSInputStream is shoving all of the data down my throat at once, 
> without giving the runloop a chance to process any other input sources. This 
> means that my thread is blocked, and other tasks scheduled on it don’t get a 
> chance to run, until I’ve read the whole feed, which takes over a minute. 
> (And there’s also the fact that CFNetwork must be buffering megabytes of data 
> from the socket that my code hasn’t read yet.)
> 
> This seems to hinge on the way the stream calls my event handler. When I get 
> the NSStreamEventHasBytesAvailable, I only read 8k bytes of data at a time, 
> then return. What seems to happen is that, if that didn’t consume all of the 
> available data, the stream will keep sending me the event in a tight loop 
> without exiting back to the runloop in between.
> 
> What can I do about this? Ideally I’d like the stream to hold off on reading 
> more from the socket until my code finishes processing the buffer. As a 
> second choice, I’d like it to at least return the runloop more often so my 
> other tasks get time to run.
> 
> —Jens
> 

Don't think you have any control to do that. The TCP connection runs in the 
kernel and shoves data at you. If the NSInputStream was at that level then 
perhaps not reading would eventually fill a kernel buffer and stop the flow, 
but probably not what's happening here. So the data is going to come in whether 
you like it or not and it's going to queue up somewhere. Once of course you've 
read it from the NSInputStream, you've moved it from one place to another, so 
if you assume you can't stop it flowing in, doesn't really matter if you read 
it or not, you're just moving it around buffers. If it's megabytes of data, 
then it is, megabytes of data is one camera image, the phone should have enough 
storage unless you have REALLY insane feeds. 

In this case I'd probably read the data in 8kb chunks, if that's the size you 
like, as fast as I possibly can and throw those chunks on an operation queue or 
something for later processing. Just get the stream read as fast as you can and 
move the data elsewhere, then process it at the speed you can. 

Alternatively, if this is an HTTP style request can you ask for the data in 
chunks, HTTP supports it, get a bit, process it, get the next bit. 
___

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

Please do not post 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: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Roland King
UIImageView's scale automatically so just setting the frame of the UIImageView 
containing the UIImage to ( x, y, 44, 44 ), possibly after you load the image 
into it, will just work whatever size the image actually is on whatever type of 
display you are using. 


On Mar 27, 2012, at 3:38 PM, Ray wrote:

> OK, so I have this iOS 3.x code base that I need to update. I have the 
> following code, to make a thumbnail image:
> 
> ...
> // let's say we have a UIImage *selectedImage with a size of 1000 x 1000
> UIImage *newImage;
> NSData *imageData;
> 
> UIGraphicsBeginImageContext(CGSizeMake(44.0, 44.0));
> [selectedImage drawInRect:CGRectMake(0.0, 0.0, 44.0, 44.0)];
> newImage = UIGraphicsGetImageFromCurrentImageContext();
> UIGraphicsEndImageContext();
> 
> imageData = UIImagePNGRepresentation(newImage);
> ...
> 
> Code is simplified, just for illustrative purposes. I store imageData as a 
> binary property (called "listImage") in a Core Data entity and use it as a 
> thumbnail image in a UITableView, like so:
> 
> cell.imageView.image = [UIImage imageWithData:item.listImage];
> 
> It's small, so no problems. On both a normal and retina screen iPhone running 
> iOS 4 this works OK, although we don't make use of the increased resolution, 
> yet. In order to do that, I update the code with:
> 
> UIGraphicsBeginImageContextWithOptions(CGSizeMake(44.0, 44.0), YES, 0);
> 
> Now, when I generate a new image on an iPhone with a retina screen, in which 
> case the above UIGraphicsBeginImageContextWithOptions uses a scale of 2.0, 
> the image in the table view shows too big. This is because [UIImage 
> imageWithData:item.listImage] always returns a 1.0 scaled image. Now I can 
> solve this by using something like:
> 
> UIImage *theImage = [UIImage imageWithData:listImage];
> [UIImage imageWithCGImage:theImage.CGImage scale:theImage.size.width > 44.0 ? 
> 2.0 : 1.0 orientation:theImage.imageOrientation];
> 
> But this seems kludgy and it's using programmer's knowledge, so to speak. I 
> watched WWDC2010 session 134 "Optimize your iPhone App for the Retina 
> Display" again, searched stackoverflow etc. but I can't find a more elegant 
> solution. What would be a more thorough approach? Maybe it's staring me in 
> the face but I don't see it...
> 
> Thanks for your answers,
> - Ray.
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/rols%40rols.org
> 
> This email sent to r...@rols.org


___

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

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

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

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


Re: PDFKit: translate point coordinates from view coordinates into page coordinates

2012-03-27 Thread Antonio Nunes
On 27 Mar 2012, at 12:19, Nick wrote:

> I would like to place a PDFAnnotation onto a PDF page in a place where
> the user clicked with the mouse.
[...]
> NSPoint locationInView = [self convertPoint:[theEvent
> locationInWindow] fromView:[[self window] contentView]];

You are receiving the event location in the window, but you are converting 
based on the content view. Pass NULL in fromView: to translate from window 
coordinates to local coordinates. Then let PDFView do the heave lifting for you 
to translate that point to a point on a page.


To convert the point to page coordinates use something to the effect of:

-(void)mouseDown:(NSEvent *)event
{
NSPoint mouseDownPoint = [self convertPoint:[event 
locationInWindow] fromView:NULL];
PDFPage *mouseDownPage = [self pageForPoint:mouseDownPoint 
nearest:NO];
NSPoint pagePoint = [self convertPoint: mouseDownPoint 
toPage:mouseDownPage];
...
}

The above should work at any scale factor.

-António

---
And you would accept the seasons of your
heart, even as you have always accepted
the seasons that pass over your field.

--Kahlil Gibran
---




___

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

Please do not post 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: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Hi Marco,

Thanks for your thoughts!

Let me first say, the original app is already out there, using the old 
UIGraphicsBeginImageContext (at the time there was no 
UIGraphicsBeginImageContextWithOptions to begin with), used now on a variety of 
devices with normal and retina screens etc. The problem you describe below 
(transferring between various iPhones/iPod Touches with different screens etc.) 
exists already, but still using UIGraphicsBeginImageContext so I guess I know 
all existing saved images are (as per the example) 44 *pixels*.

On Mar 27, 2012, at 1:47 PM, Marco Tabini wrote:

> When the filename convention is not available, that metadata needs to be 
> saved somewhere—in your case, you derive it from the file size, which, as you 
> mention, is not very portable. I would have saved the scale in a separate 
> Core Object 

Right, this crossed my mind as well, which would also mean a little Core Data 
data model migration.


> property, or avoided saving the image in a data store to start with, and used 
> a file cache, in which case UIImage is a bit more self-reliant.

At the time it seemed overkill, but now that would make sense. I checked some 
sample code (iPhoneCoreDataRecipes comes to mind) and it exhibits the same 
problem.


> In practice, I would want to look at more significant problems with your 
> approach in a real-life deployment scenario. For example, what happens when 
> your Core Data store is transferred from a non-Retina device to a Retina 
> device? This could happen in a variety of scenarios: the user could start 
> using your app on a non-Retina device (say, an iPad 2), then buy a new Retina 
> device (a New iPad), back up the old one and restore on the new one. Now, 
> your images are cached at 1x scale, but the device wants to run at 2x. Or, 
> perhaps, you may, at some point, want to sync your data store using iCloud, 

Yup, already happening. With the old UIGraphicsBeginImageContext, that is.


> Conversely, if your data is only ever used for caching purposes and is stored 
> in the Caches directory, then this is a non-problem. Since the images are 
> both going to be generated and used on the very same device, you don't need 
> to derive the scale of the image from its size—you can just use the scale of 
> your main screen both when creating and recreating your UIImage objects.

No, the images are meant to be persistent (coming off camera).


> Then again, if you move your images to individual files and save them with 
> the appropriate @2x suffix, this whole problem goes away altogether—so, 
> perhaps, that may be a better solution.

It might be indeed.

Thanks again, food for thought regarding this pesky problem!

- Ray.


___

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

Please do not post 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: PDFKit: translate point coordinates from view coordinates into page coordinates

2012-03-27 Thread Nick
Hi Alvaro
Thank you for the response!
Yes, this is it. I just found a sample code PDFKitLinker2, and it
showed how to do just what i need.


27 марта 2012 г. 15:05 пользователь Alvaro Costa Neto
 написал:
> Hey Nick, how are you?
>
> Try to use the PDFView's convertPoint/Rect:to/fromPage: methods 
> .
>  The trick is to always remember to use a common ground (the PDFView itself 
> in this case) before converting to/from page coordinates. I don't know if the 
> convert methods take scale factor into account, but I believe they do.
>
> Best regards,
> Alvaro Costa Neto
>
> Em 27/03/2012, às 08:19, Nick escreveu:
>
>> Hello
>>
>> I would like to place a PDFAnnotation onto a PDF page in a place where
>> the user clicked with the mouse.
>> Position for PDFAnnotations is specified using "page coordinates".
>> Mouse position - using global coordinates, which can be translated
>> into PDFView coordinates. However, I can't figure out how to translate
>> view coordinates into page coordinates correctly. Here's what  I am
>> doing:
>>
>>       NSPoint locationInView = [self convertPoint:[theEvent
>> locationInWindow] fromView:[[self window] contentView]];
>>       NSPoint locationOnPage = [self convertPoint:locationInView 
>> fromView:self];
>>       float scaleFactor = 1/[self scaleFactor];
>>       locationOnPage = NSMakePoint((locationOnPage.x)*scaleFactor,
>> (locationOnPage.y)*scaleFactor);
>>
>> This locationOnPage contains correct values (i.e., the annotation is
>> placed where the mouse button was clicked) only if the zooming was
>> 100%, and view boundaries exactly matched page boundaries (as shown on
>> the picture: http://rghost.net/37251215/image.png).
>> However, if the page is zoomed in/out, and does not exactly occupy the
>> whole PDFView space (http://rghost.net/37251118/image.png) I do not
>> get right coordinates: when I click in the bottom left corner of the
>> PDFView, i see annotation appear in the bottom left corner of the
>> page, which is not even on the page..
>>
>> How could I do this right?
>> All I need is the page origin position on the view, but there's no
>> such a method, as it seems..
>>
>> Thank you
>>
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/nepheus.br%40gmail.com
>>
>> This email sent to nepheus...@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/eveningnick%40gmail.com
>
> This email sent to eveningn...@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

Re: PDFKit: translate point coordinates from view coordinates into page coordinates

2012-03-27 Thread Alvaro Costa Neto
Hey Nick, how are you?

Try to use the PDFView's convertPoint/Rect:to/fromPage: methods 
.
 The trick is to always remember to use a common ground (the PDFView itself in 
this case) before converting to/from page coordinates. I don't know if the 
convert methods take scale factor into account, but I believe they do.

Best regards,
Alvaro Costa Neto

Em 27/03/2012, às 08:19, Nick escreveu:

> Hello
> 
> I would like to place a PDFAnnotation onto a PDF page in a place where
> the user clicked with the mouse.
> Position for PDFAnnotations is specified using "page coordinates".
> Mouse position - using global coordinates, which can be translated
> into PDFView coordinates. However, I can't figure out how to translate
> view coordinates into page coordinates correctly. Here's what I am
> doing:
> 
>   NSPoint locationInView = [self convertPoint:[theEvent
> locationInWindow] fromView:[[self window] contentView]];
>   NSPoint locationOnPage = [self convertPoint:locationInView 
> fromView:self];
>   float scaleFactor = 1/[self scaleFactor];
>   locationOnPage = NSMakePoint((locationOnPage.x)*scaleFactor,
> (locationOnPage.y)*scaleFactor);
> 
> This locationOnPage contains correct values (i.e., the annotation is
> placed where the mouse button was clicked) only if the zooming was
> 100%, and view boundaries exactly matched page boundaries (as shown on
> the picture: http://rghost.net/37251215/image.png).
> However, if the page is zoomed in/out, and does not exactly occupy the
> whole PDFView space (http://rghost.net/37251118/image.png) I do not
> get right coordinates: when I click in the bottom left corner of the
> PDFView, i see annotation appear in the bottom left corner of the
> page, which is not even on the page..
> 
> How could I do this right?
> All I need is the page origin position on the view, but there's no
> such a method, as it seems..
> 
> Thank you
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/nepheus.br%40gmail.com
> 
> This email sent to nepheus...@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

Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Marco Tabini
Hi Ray—

> But this seems kludgy and it's using programmer's knowledge, so to speak. I 
> watched WWDC2010 session 134 "Optimize your iPhone App for the Retina 
> Display" again, searched stackoverflow etc. but I can't find a more elegant 
> solution. What would be a more thorough approach? Maybe it's staring me in 
> the face but I don't see it...

UIImage does not represent the actual bits of an image, but, rather, provides 
the logical metadata wrapper of an underlying image object (in this case, a 
CGImage) to store information like scale and orientation. When you save to a 
file format that supports metadata, like JPEG, some of the metadata is stored 
there, while other is derived from the file name. So, for example, if you were 
to save a PNG file to disk with an @2x suffix, upon loading it with 
-imageNamed: UIImage would automatically know to set up the resulting object as 
a 2x scale image.

When the filename convention is not available, that metadata needs to be saved 
somewhere—in your case, you derive it from the file size, which, as you 
mention, is not very portable. I would have saved the scale in a separate Core 
Object property, or avoided saving the image in a data store to start with, and 
used a file cache, in which case UIImage is a bit more self-reliant.

In practice, I would want to look at more significant problems with your 
approach in a real-life deployment scenario. For example, what happens when 
your Core Data store is transferred from a non-Retina device to a Retina 
device? This could happen in a variety of scenarios: the user could start using 
your app on a non-Retina device (say, an iPad 2), then buy a new Retina device 
(a New iPad), back up the old one and restore on the new one. Now, your images 
are cached at 1x scale, but the device wants to run at 2x. Or, perhaps, you 
may, at some point, want to sync your data store using iCloud, causing some 
images to be generated on Retina devices, and some others at 1x scale.

Conversely, if your data is only ever used for caching purposes and is stored 
in the Caches directory, then this is a non-problem. Since the images are both 
going to be generated and used on the very same device, you don't need to 
derive the scale of the image from its size—you can just use the scale of your 
main screen both when creating and recreating your UIImage objects.

Then again, if you move your images to individual files and save them with the 
appropriate @2x suffix, this whole problem goes away altogether—so, perhaps, 
that may be a better solution.

Cheers,


—Mt.
___

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

Please do not post 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

PDFKit: translate point coordinates from view coordinates into page coordinates

2012-03-27 Thread Nick
Hello

I would like to place a PDFAnnotation onto a PDF page in a place where
the user clicked with the mouse.
Position for PDFAnnotations is specified using "page coordinates".
Mouse position - using global coordinates, which can be translated
into PDFView coordinates. However, I can't figure out how to translate
view coordinates into page coordinates correctly. Here's what I am
doing:

NSPoint locationInView = [self convertPoint:[theEvent
locationInWindow] fromView:[[self window] contentView]];
NSPoint locationOnPage = [self convertPoint:locationInView 
fromView:self];
float scaleFactor = 1/[self scaleFactor];
locationOnPage = NSMakePoint((locationOnPage.x)*scaleFactor,
(locationOnPage.y)*scaleFactor);

This locationOnPage contains correct values (i.e., the annotation is
placed where the mouse button was clicked) only if the zooming was
100%, and view boundaries exactly matched page boundaries (as shown on
the picture: http://rghost.net/37251215/image.png).
However, if the page is zoomed in/out, and does not exactly occupy the
whole PDFView space (http://rghost.net/37251118/image.png) I do not
get right coordinates: when I click in the bottom left corner of the
PDFView, i see annotation appear in the bottom left corner of the
page, which is not even on the page..

How could I do this right?
All I need is the page origin position on the view, but there's no
such a method, as it seems..

Thank you

___

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

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

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

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


Re: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
Thanks Giacomo for your answer, but the problem is not so much that the 
resizing doesn't work, but that [UIImage imageWithData:listImage] always 
returns a scale of 1.0 for the image. This means that I encounter the problem 
described, when images are saved using an iPhone with a retina screen... 
(deployment target is iOS 4).

On Mar 27, 2012, at 11:57 AM, Giacomo Tufano wrote:

> Il giorno 27/mar/2012, alle ore 09:38, Ray ha scritto:
> 
>> OK, so I have this iOS 3.x code base that I need to update. I have the 
>> following code, to make a thumbnail image:
>> Code is simplified, just for illustrative purposes. I store imageData as a 
>> binary property (called "listImage") in a Core Data entity and use it as a 
>> thumbnail image in a UITableView, like so:
>> 
>> But this seems kludgy and it's using programmer's knowledge, so to speak. I 
>> watched WWDC2010 session 134 "Optimize your iPhone App for the Retina 
>> Display" again, searched stackoverflow etc. but I can't find a more elegant 
>> solution. What would be a more thorough approach? Maybe it's staring me in 
>> the face but I don't see it...
> 
> That's what I use to generate a thumbnail of sideSize side lenght in iOS3.x 
> code.
> It uses iOS4+ functions for retina displays (I remember that you can assume 
> iOS4+ with retina displays).
> 
> CGSize newSize = CGSizeMake(sideSize, sideSize);
> #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
>   if(UIGraphicsBeginImageContextWithOptions != NULL)
>   UIGraphicsBeginImageContextWithOptions(newSize, NO, [[UIScreen 
> mainScreen] scale]);
>   else
> #endif
>   UIGraphicsBeginImageContext(newSize);
> UIGraphicsBeginImageContext(newSize);
> [self drawInRect:CGRectMake(0, 0, sideSize, sideSize)];
> // Get the new image from the context
> UIImage *thumbnailImage = UIGraphicsGetImageFromCurrentImageContext();
> // End the context
> UIGraphicsEndImageContext();
> 
> It works correctly on retina displays.
> To be honest I don't remember why I use that macro to test for iOS4, there 
> were a reason and that was a workaround but cannot remember why. It works, 
> anyway. :)
> 
> HTH,
> gt
> 
> ---
> Giacomo Tufano
> Stat rosa pristina nomine, nomina nuda tenemus.
> 
> 
> 


___

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

Please do not post 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 to throttle rate of NSInputStream?

2012-03-27 Thread jonat...@mugginsoft.com

On 27 Mar 2012, at 00:13, Jens Alfke wrote:

>  (And there’s also the fact that CFNetwork must be buffering megabytes of 
> data from the socket that my code hasn’t read yet.)
The network stack is there to deal with all this so I wouldn't fret about it.

> 
> This seems to hinge on the way the stream calls my event handler. When I get 
> the NSStreamEventHasBytesAvailable, I only read 8k bytes of data at a time, 
> then return. What seems to happen is that, if that didn’t consume all of the 
> available data, the stream will keep sending me the event in a tight loop 
> without exiting back to the runloop in between.
> 
> What can I do about this? Ideally I’d like the stream to hold off on reading 
> more from the socket until my code finishes processing the buffer. As a 
> second choice, I’d like it to at least return the runloop more often so my 
> other tasks get time to run.
> 
NSInputStream doesn't offer much in the way of flow control.
Dropping down to lower level APIs will naturally expose more of the network 
stack.

Unscheduling the stream from the run loop sounds like a good place to start. 

Or perhaps this is one of those rare occasions where polling (i.e.: manually 
scheduling NSInputStream -hasBytesAvailable on the runloop) as opposed to 
calling scheduleInRunLoop:forMode might be worth a try.

Regards

Jonathan Mitchell
Mugginsoft LLP


___

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

Please do not post 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: Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Giacomo Tufano
Il giorno 27/mar/2012, alle ore 09:38, Ray ha scritto:

> OK, so I have this iOS 3.x code base that I need to update. I have the 
> following code, to make a thumbnail image:
> Code is simplified, just for illustrative purposes. I store imageData as a 
> binary property (called "listImage") in a Core Data entity and use it as a 
> thumbnail image in a UITableView, like so:
> 
> But this seems kludgy and it's using programmer's knowledge, so to speak. I 
> watched WWDC2010 session 134 "Optimize your iPhone App for the Retina 
> Display" again, searched stackoverflow etc. but I can't find a more elegant 
> solution. What would be a more thorough approach? Maybe it's staring me in 
> the face but I don't see it...

That's what I use to generate a thumbnail of sideSize side lenght in iOS3.x 
code.
It uses iOS4+ functions for retina displays (I remember that you can assume 
iOS4+ with retina displays).

CGSize newSize = CGSizeMake(sideSize, sideSize);
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
if(UIGraphicsBeginImageContextWithOptions != NULL)
UIGraphicsBeginImageContextWithOptions(newSize, NO, [[UIScreen 
mainScreen] scale]);
else
#endif
UIGraphicsBeginImageContext(newSize);
UIGraphicsBeginImageContext(newSize);
[self drawInRect:CGRectMake(0, 0, sideSize, sideSize)];
// Get the new image from the context
UIImage *thumbnailImage = UIGraphicsGetImageFromCurrentImageContext();
// End the context
UIGraphicsEndImageContext();

It works correctly on retina displays.
To be honest I don't remember why I use that macro to test for iOS4, there were 
a reason and that was a workaround but cannot remember why. It works, anyway. :)

HTH,
gt

---
Giacomo Tufano
Stat rosa pristina nomine, nomina nuda tenemus.




___

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

Please do not post 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 to throttle rate of NSInputStream?

2012-03-27 Thread Ken Thomases
On Mar 26, 2012, at 6:13 PM, Jens Alfke wrote:

> What can I do about this? Ideally I’d like the stream to hold off on reading 
> more from the socket until my code finishes processing the buffer.

You can try simply unscheduling the stream from the run loop until you're ready 
for more.  I'm not 100% certain that that's safe, in the sense that no events 
will be lost.  It should be safe.  I would consider it a bug if it weren't, but 
you never know.  You can probably ameliorate that by attempting to read 
immediately after re-scheduling it on the run loop.

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

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

Question about UIImage, scaling, and UIGraphicsBeginImageContextWithOptions

2012-03-27 Thread Ray
OK, so I have this iOS 3.x code base that I need to update. I have the 
following code, to make a thumbnail image:

...
// let's say we have a UIImage *selectedImage with a size of 1000 x 1000
UIImage *newImage;
NSData *imageData;

UIGraphicsBeginImageContext(CGSizeMake(44.0, 44.0));
[selectedImage drawInRect:CGRectMake(0.0, 0.0, 44.0, 44.0)];
newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

imageData = UIImagePNGRepresentation(newImage);
...

Code is simplified, just for illustrative purposes. I store imageData as a 
binary property (called "listImage") in a Core Data entity and use it as a 
thumbnail image in a UITableView, like so:

cell.imageView.image = [UIImage imageWithData:item.listImage];

It's small, so no problems. On both a normal and retina screen iPhone running 
iOS 4 this works OK, although we don't make use of the increased resolution, 
yet. In order to do that, I update the code with:

UIGraphicsBeginImageContextWithOptions(CGSizeMake(44.0, 44.0), YES, 0);

Now, when I generate a new image on an iPhone with a retina screen, in which 
case the above UIGraphicsBeginImageContextWithOptions uses a scale of 2.0, the 
image in the table view shows too big. This is because [UIImage 
imageWithData:item.listImage] always returns a 1.0 scaled image. Now I can 
solve this by using something like:

UIImage *theImage = [UIImage imageWithData:listImage];
[UIImage imageWithCGImage:theImage.CGImage scale:theImage.size.width > 44.0 ? 
2.0 : 1.0 orientation:theImage.imageOrientation];

But this seems kludgy and it's using programmer's knowledge, so to speak. I 
watched WWDC2010 session 134 "Optimize your iPhone App for the Retina Display" 
again, searched stackoverflow etc. but I can't find a more elegant solution. 
What would be a more thorough approach? Maybe it's staring me in the face but I 
don't see it...

Thanks for your answers,
- Ray.


___

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

Please do not post 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