Memory issues when loading a document

2012-10-23 Thread Ulf Dunkel
I wonder if this issue is created by our app or if it is inherent in Mac
OS X:

Our app creates documents which can contain various content per document
page, e.g. PDF files. Assume you have created a document with 64 pages,
each of them contains a full-page PDF content. The document file's
weight is about 1 GB when it is saved.

When users try to reload the document on a Mac with 4 GB RAM, it cannot
be opened, because of a lack of memory. Tracking the allocations with
Instruments, I can see strange things happen:

- The app itself consumes about 300 MB RAM.
- The document is loaded in several steps, where the first step
allocates the document size with -[NSData(NSData) initWithContentsOfFile:].
- Then the RAM for page content files (the PDFs) is allocated and the
relevant PDF is being loaded - but:

- The first PDF load process allocates additional RAM for the first PDF.
- The 2nd PDF allocates additional RAM for the 1st and 2nd PDF.
- The 3rd PDF allocates additional RAM for the 1.-3. PDF.
- Etc.

So this procedure sums up to about 3.5 GB RAM which of course is
followed by an exception.

On bigger machines, the additional RAM for the PDFs is deallocated after
the document has been loaded successfully.

Is this a wanted behavior of Mac OS X, or are we able to control how
much RAM is being allocated in the document load process?

---Ulf Dunkel
___

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: Memory issues when loading a document

2012-10-23 Thread Mike Abdullah

On 23 Oct 2012, at 11:21, Ulf Dunkel dun...@calamus.net wrote:

 I wonder if this issue is created by our app or if it is inherent in Mac
 OS X:
 
 Our app creates documents which can contain various content per document
 page, e.g. PDF files. Assume you have created a document with 64 pages,
 each of them contains a full-page PDF content. The document file's
 weight is about 1 GB when it is saved.
 
 When users try to reload the document on a Mac with 4 GB RAM, it cannot
 be opened, because of a lack of memory.

Important bit you haven't told us: is your app 32bit, 64bit, or both?

 Tracking the allocations with
 Instruments, I can see strange things happen:
 
 - The app itself consumes about 300 MB RAM.
 - The document is loaded in several steps, where the first step
 allocates the document size with -[NSData(NSData) initWithContentsOfFile:].
 - Then the RAM for page content files (the PDFs) is allocated and the
 relevant PDF is being loaded - but:
 
 - The first PDF load process allocates additional RAM for the first PDF.
 - The 2nd PDF allocates additional RAM for the 1st and 2nd PDF.
 - The 3rd PDF allocates additional RAM for the 1.-3. PDF.
 - Etc.
 
 So this procedure sums up to about 3.5 GB RAM which of course is
 followed by an exception.
 
 On bigger machines, the additional RAM for the PDFs is deallocated after
 the document has been loaded successfully.
 
 Is this a wanted behavior of Mac OS X, or are we able to control how
 much RAM is being allocated in the document load process?

You have very fine-grained control available to you. Read up on the document 
architecture and the different NSDocument methods you can override.


___

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


sync drawing an ever-increasing path

2012-10-23 Thread Roland King
I want to animate the drawing of  CGPath in a UIView, so it looks as if it's 
being drawn. I have the UIView, I have the CGPath, I am able to split the 
CGPath at any point from 0 to 100% into that which should be drawn and that 
which shouldn't yet, that's all done, so I can, fairly efficiently, call 
-(CGPath)[ myObject fractionalPath:(CGFloat)fraction ] and get a path. 

The idea is to call setNeedsDisplay on the UIView from time to time, then 
figure out, when I get my -drawRect call how far through the animation I am, 
call fractionalPath: for that fraction of the total animation time, and draw 
it. The path isn't that complex, it doesn't take very long to draw and I'm 
compositing already-fully-drawn paths into a backing UIImage so there's only 
one 'live one' at any time. 

The bit I'm not sure about is how to sync this up with the natural framerate of 
the device. I could call setNeedsDisplay on a timer, or with a delay after each 
drawRect, but there is surely a better way to do this, is there not? If I do 
call setNeedsDisplay a lot, will I only get drawRect at most at the natural 
framerate of the device. 

Is there an obvious technology I'm missing? This is a pretty simple way to do a 
quick animation of a single path, so OpenGL or anything like that is massive 
overkill and I didn't see anything CALayer would give me which would help, but 
wondered if I'd missed something there as that does have the concept of 
animating a property, even a custom one, between two values and I wondered if I 
could hook into that. 
___

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: sync drawing an ever-increasing path

2012-10-23 Thread Roland King
hmm .. actually it looks like I can TOTALLY use CALayer for this. I need a 
better book, the one I have doesn't cover this. Hitting google. 


On 23 Oct, 2012, at 7:37 PM, Roland King r...@rols.org wrote:

 I want to animate the drawing of  CGPath in a UIView, so it looks as if it's 
 being drawn. I have the UIView, I have the CGPath, I am able to split the 
 CGPath at any point from 0 to 100% into that which should be drawn and that 
 which shouldn't yet, that's all done, so I can, fairly efficiently, call 
 -(CGPath)[ myObject fractionalPath:(CGFloat)fraction ] and get a path. 
 
 The idea is to call setNeedsDisplay on the UIView from time to time, then 
 figure out, when I get my -drawRect call how far through the animation I am, 
 call fractionalPath: for that fraction of the total animation time, and draw 
 it. The path isn't that complex, it doesn't take very long to draw and I'm 
 compositing already-fully-drawn paths into a backing UIImage so there's only 
 one 'live one' at any time. 
 
 The bit I'm not sure about is how to sync this up with the natural framerate 
 of the device. I could call setNeedsDisplay on a timer, or with a delay after 
 each drawRect, but there is surely a better way to do this, is there not? If 
 I do call setNeedsDisplay a lot, will I only get drawRect at most at the 
 natural framerate of the device. 
 
 Is there an obvious technology I'm missing? This is a pretty simple way to do 
 a quick animation of a single path, so OpenGL or anything like that is 
 massive overkill and I didn't see anything CALayer would give me which would 
 help, but wondered if I'd missed something there as that does have the 
 concept of animating a property, even a custom one, between two values and I 
 wondered if I could hook into that. 
 ___
 
 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


Open untitled file in Document-based app

2012-10-23 Thread ecir hana
Hello,

I would like my app to open new untitled document every time it starts. It
worked in 10.6 but now I upgraded to 10.8 and when I close the window with
cmd+w and then restart the application it wont open any windows.

Please, how to make it open a new window every time the app starts,
regardless of how it exited previously?

I tried to return YES in both applicationShouldOpenUntitledFile: and
applicationOpenUntitledFile: of the app delegate without luck.

Thanks in advance!
___

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


Running a-foul of bindings with multiple-value subfields

2012-10-23 Thread Erik Stainsby
Hello all,

I am working my way through trying to understand  the correct use of bindings 
for a non-trivial model.  

The model I am working on is derived from the contacts database ABPerson. I am 
unclear how to bind to the elements of a multiple entry list. 

A person has a handful of direct properties: firstName, lastName, organization, 
image, etc.
There are also three arbitrary length lists of related data:  postal addresses, 
phone numbers, email addresses.

I have no trouble using  - bind: toObject: withKeyPath: options: for the direct 
properties.  However, try as I might I can't seem to bind to the elements of 
lists.  

My question is ought I to be using (or subclassing) an arrayController for each 
of these lists ? And then binding through the selectedIndex or some such ?

I hope this makes enough sense to someone so that they can point me down a 
lighted path.  My code at the moment is a total mess, hence no samples.

OSX 10.8
XC 4.5.1
This is a learning exercise so no legacy issues.


___

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: Memory issues when loading a document

2012-10-23 Thread Ulf Dunkel
 Important bit you haven't told us: is your app 32bit, 64bit, or both?

Oh, sorry, it's a 32bit app which still supports at least Mac OS X
10.4.11. We're already working on the 64bit version of that app, but
this is a current version's issue which I would like to understand and -
hopefully - be able to fix even for the 32bit version.

 You have very fine-grained control available to you. Read up on the
 document architecture and the different NSDocument methods you can
 override.

As far as I can see, the loading behavior seems to be very ineffective.

Firstly, OS X loads the document. To be able to decode it, it has to be
loaded into the RAM. This needs the mentioned 900 MB RAM.

Then the Coder decodes the objects which gets the same stuff a second
time into the RAM.

Finally, when decoding PDFs, OS X creates another data segment for each
PDF object, decodes it and creates the PDF content.

So we have each PDF object being three times in the RAM:

1) in the loaded raw document,
2) in an object created from the document (containing the PDF raw data),
3) the PDF itself.

After this process has been done for the whole document, the RAM is
freed again to only keep the required about 900 MB.

To me, this seems to be very ineffective. I wonder if there is any way
to not decode the document as a kind of monolite, but decode and convert
object by object, deallocating RAM after a single object has been
created, not when the whole document has been processed.

---Ulf Dunkel
___

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


App Sandbox Container or Data Directory

2012-10-23 Thread Richard Somers
I do not understand what is going on with an application's sandboxed container 
or Data directory.

NSHomeDirectory for an OS X sandboxed app points here.

 ~/Library/Containers/bundle_id/Data

The sandbox Data directory is pre-populated with items.

 Data/Desktop (Alias)
 Data/Documents
 Data/Downloads   (Alias)
 Data/Library
 Data/Movies  (Alias)
 Data/Music   (Alias)
 Data/Pictures(Alias)

So here are some of the unusual things.

1. If you specify No Access to the Music, Movies, Pictures, or Downloads 
folders for the App Sandbox you can still save a document to those folders. So 
much for the sandbox.

2. When a file is saved to the Documents folder in a save dialog, the file is 
actually saved to ~/Documents not Data/Documents. So what is Data/Documents for?

3. Data/Documents is pre-populated with an iChat file alias. What is that for?

4. Local log files go in Data/Library/Logs but this location is not visible 
from Console app. So all local log files are visible from Console except for 
apps that are sandboxed. How can a user see local sandboxed log files?

5. Data/Library/Preferences is pre-populated with a bunch of preference plist 
file aliases. One of the items is an alias to com.apple.iWork.Pages.plist. Why 
would my app need default access to the Pages preference plist file? This seems 
like a violation of sandboxing.

A lot of this simply does not make sense. What am I missing?

--Richard Somers


___

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: App Sandbox Container or Data Directory

2012-10-23 Thread Mike Abdullah

On 23 Oct 2012, at 19:13, Richard Somers wrote:

 I do not understand what is going on with an application's sandboxed 
 container or Data directory.
 
 NSHomeDirectory for an OS X sandboxed app points here.
 
 ~/Library/Containers/bundle_id/Data
 
 The sandbox Data directory is pre-populated with items.
 
 Data/Desktop (Alias)
 Data/Documents
 Data/Downloads   (Alias)
 Data/Library
 Data/Movies  (Alias)
 Data/Music   (Alias)
 Data/Pictures(Alias)
 
 So here are some of the unusual things.
 
 1. If you specify No Access to the Music, Movies, Pictures, or Downloads 
 folders for the App Sandbox you can still save a document to those folders. 
 So much for the sandbox.

What exactly do you mean by “save a document” here?
 
 2. When a file is saved to the Documents folder in a save dialog, the file is 
 actually saved to ~/Documents not Data/Documents. So what is Data/Documents 
 for?

Yes, the open/save panels automatically translate any locations form within the 
container to outside. Anything within the container is not intended for regular 
users to see.

Your app could generate “documents” which get stored on disk in the Documents 
folder, but provide its own UI for managing that data perhaps, rather than the 
standard open/save panel approach.
 
 3. Data/Documents is pre-populated with an iChat file alias. What is that for?

Does it matter?
 
 4. Local log files go in Data/Library/Logs but this location is not visible 
 from Console app. So all local log files are visible from Console except for 
 apps that are sandboxed. How can a user see local sandboxed log files?

How are you generating these logs?
 
 5. Data/Library/Preferences is pre-populated with a bunch of preference plist 
 file aliases. One of the items is an alias to com.apple.iWork.Pages.plist. 
 Why would my app need default access to the Pages preference plist file? This 
 seems like a violation of sandboxing.

Some other apps have relied upon this, I would guess. Can your app actually 
access that plist while running though? Just because it’s there as a symlink 
doesn’t necessarily mean the app has access to 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: sync drawing an ever-increasing path

2012-10-23 Thread David Duncan
On Oct 23, 2012, at 4:37 AM, Roland King r...@rols.org wrote:

 I want to animate the drawing of  CGPath in a UIView, so it looks as if it's 
 being drawn. I have the UIView, I have the CGPath, I am able to split the 
 CGPath at any point from 0 to 100% into that which should be drawn and that 
 which shouldn't yet, that's all done, so I can, fairly efficiently, call 
 -(CGPath)[ myObject fractionalPath:(CGFloat)fraction ] and get a path. 


You can do this with a CAShapeLayer by animating the strokeEnd property. Should 
be very simple to do, although if your path is very complex it may make more 
sense to break it into pieces and use multiple shape layers animated 
sequentially.
--
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: sync drawing an ever-increasing path

2012-10-23 Thread David Rowland
This worked for me. When initializing your UIView, add an instance variable 
shapeLayer and do this,

shapeLayer = [CAShapeLayer layer];
[[self layer] addSublayer:shapeLayer];


In drawRect, set up your path and do this,

CABasicAnimation *pathAnimation = [CABasicAnimation 
animationWithKeyPath:@strokeEnd];
pathAnimation.duration = 4.0;
pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
[shapeLayer addAnimation:pathAnimation forKey:@strokeEndAnimation];



That seems to be all that is needed.

David




On Oct 23, 2012, at 11:37 AM, David Duncan david.dun...@apple.com wrote:

 On Oct 23, 2012, at 4:37 AM, Roland King r...@rols.org wrote:
 
 I want to animate the drawing of  CGPath in a UIView, so it looks as if it's 
 being drawn. I have the UIView, I have the CGPath, I am able to split the 
 CGPath at any point from 0 to 100% into that which should be drawn and that 
 which shouldn't yet, that's all done, so I can, fairly efficiently, call 
 -(CGPath)[ myObject fractionalPath:(CGFloat)fraction ] and get a path. 
 
 
 You can do this with a CAShapeLayer by animating the strokeEnd property. 
 Should be very simple to do, although if your path is very complex it may 
 make more sense to break it into pieces and use multiple shape layers 
 animated sequentially.
 --
 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/rowlandd%40sbcglobal.net
 
 This email sent to rowla...@sbcglobal.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: App Sandbox Container or Data Directory

2012-10-23 Thread Richard Somers
On Oct 23, 2012, at 1:29 PM, Mike Abdullah cocoa...@mikeabdullah.net wrote:

 The sandbox is intended to limit what an *app* can do by itself, not what a 
 *user* can do. Users are free to save things wherever they like; the only 
 entitlement that plays a role in that is 
 com.apple.security.files.user-selected.read-only

Not true. The user can navigate in the save panel to where ever but saving to 
an unapproved location will result in an error. The document could not be 
saved. You don't have permission.

 As in you’re setting up ASL to write to a specific file within your container?

Yes, writing to NSHomeDirectory/Library/Logs using ASL but sandboxed library 
logs do not show up in Console.

 I have not tried to access the Pages plist file.
 
 I strongly suspect any attempt to access it would fail unless you have a 
 temporary entitlement to do so.

You are correct. The Pages plist file is readable but not writable.

--Richard Somers


___

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: sync drawing an ever-increasing path

2012-10-23 Thread David Duncan

On Oct 23, 2012, at 12:34 PM, David Rowland rowla...@sbcglobal.net wrote:

 This worked for me. When initializing your UIView, add an instance variable 
 shapeLayer and do this,
 
 shapeLayer = [CAShapeLayer layer];
 [[self layer] addSublayer:shapeLayer];
 
 
 In drawRect, set up your path and do this,

There is no need to do this inside of drawRect. In fact by doing so (unless 
your UIView actually needs to draw something) you've unnecessarily increased 
your memory footprint and reduce the performance to start the animation.

If you want the animation to happen as soon as the view is placed in the 
window, the correct place to do this is inside of -[UIView didMoveToWindow:]. 
Just check that the moved to window is not nil (or nothing will happen).

 
 CABasicAnimation *pathAnimation = [CABasicAnimation 
 animationWithKeyPath:@strokeEnd];
 pathAnimation.duration = 4.0;
 pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
 pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
 [shapeLayer addAnimation:pathAnimation forKey:@strokeEndAnimation];

You can also do this implicitly once the layer is in a layer tree by setting 
the animation duration on the current CATransaction and setting the strokeEnd 
directly.

 
 
 
 That seems to be all that is needed.
 
 David
 
 
 
 
 On Oct 23, 2012, at 11:37 AM, David Duncan david.dun...@apple.com wrote:
 
 On Oct 23, 2012, at 4:37 AM, Roland King r...@rols.org wrote:
 
 I want to animate the drawing of  CGPath in a UIView, so it looks as if 
 it's being drawn. I have the UIView, I have the CGPath, I am able to split 
 the CGPath at any point from 0 to 100% into that which should be drawn and 
 that which shouldn't yet, that's all done, so I can, fairly efficiently, 
 call -(CGPath)[ myObject fractionalPath:(CGFloat)fraction ] and get a path. 
 
 
 You can do this with a CAShapeLayer by animating the strokeEnd property. 
 Should be very simple to do, although if your path is very complex it may 
 make more sense to break it into pieces and use multiple shape layers 
 animated sequentially.
 --
 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/rowlandd%40sbcglobal.net
 
 This email sent to rowla...@sbcglobal.net
 

--
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: App Sandbox Container or Data Directory

2012-10-23 Thread Kyle Sluder
On Tue, Oct 23, 2012, at 01:05 PM, Richard Somers wrote:
 On Oct 23, 2012, at 1:29 PM, Mike Abdullah cocoa...@mikeabdullah.net
 wrote:
 
  The sandbox is intended to limit what an *app* can do by itself, not what a 
  *user* can do. Users are free to save things wherever they like; the only 
  entitlement that plays a role in that is 
  com.apple.security.files.user-selected.read-only
 
 Not true. The user can navigate in the save panel to where ever but
 saving to an unapproved location will result in an error. The document
 could not be saved. You don't have permission.

If by unapproved you mean my app's sandbox hasn't been extended to
include this path then you are incorrect. The user can choose the
destination, and the NSURL you get back from the open panel will carry
the rights to access that location.

If by unapproved you mean the user my app is running as doesn't have
write permission to this location, then yes that is expected behavior.

--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: App Sandbox Container or Data Directory

2012-10-23 Thread Sean McBride
On Tue, 23 Oct 2012 12:13:31 -0600, Richard Somers said:

 ~/Library/Containers/bundle_id/Data

 *SNIP*

A lot of this simply does not make sense. What am I missing?

Are you aware that, by default, all of ~/Library is hidden from the user, and 
it's basically expected that he won't go in that folder?

Cheers,

-- 

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



___

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

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

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

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

Re: sync drawing an ever-increasing path

2012-10-23 Thread David Rowland
There are several paths to be animated. I want each to appear when the user 
does some action. It seemed the best to but them in a method called by drawRect 
and redraw the view when something changed. Why would the memory footprint be 
enlarged?

thanks for pointing to didMoveToWindow.

David



On Oct 23, 2012, at 1:25 PM, David Duncan david.dun...@apple.com wrote:

 
 On Oct 23, 2012, at 12:34 PM, David Rowland rowla...@sbcglobal.net wrote:
 
 This worked for me. When initializing your UIView, add an instance variable 
 shapeLayer and do this,
 
 shapeLayer = [CAShapeLayer layer];
 [[self layer] addSublayer:shapeLayer];
 
 
 In drawRect, set up your path and do this,
 
 There is no need to do this inside of drawRect. In fact by doing so (unless 
 your UIView actually needs to draw something) you've unnecessarily increased 
 your memory footprint and reduce the performance to start the animation.
 
 If you want the animation to happen as soon as the view is placed in the 
 window, the correct place to do this is inside of -[UIView didMoveToWindow:]. 
 Just check that the moved to window is not nil (or nothing will happen).
 
 
 CABasicAnimation *pathAnimation = [CABasicAnimation 
 animationWithKeyPath:@strokeEnd];
 pathAnimation.duration = 4.0;
 pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
 pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
 [shapeLayer addAnimation:pathAnimation forKey:@strokeEndAnimation];
 
 You can also do this implicitly once the layer is in a layer tree by setting 
 the animation duration on the current CATransaction and setting the strokeEnd 
 directly.
 
 
 
 
 That seems to be all that is needed.
 
 David
 
 
 
 
 On Oct 23, 2012, at 11:37 AM, David Duncan david.dun...@apple.com wrote:
 
 On Oct 23, 2012, at 4:37 AM, Roland King r...@rols.org wrote:
 
 I want to animate the drawing of  CGPath in a UIView, so it looks as if 
 it's being drawn. I have the UIView, I have the CGPath, I am able to split 
 the CGPath at any point from 0 to 100% into that which should be drawn and 
 that which shouldn't yet, that's all done, so I can, fairly efficiently, 
 call -(CGPath)[ myObject fractionalPath:(CGFloat)fraction ] and get a 
 path. 
 
 
 You can do this with a CAShapeLayer by animating the strokeEnd property. 
 Should be very simple to do, although if your path is very complex it may 
 make more sense to break it into pieces and use multiple shape layers 
 animated sequentially.
 --
 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/rowlandd%40sbcglobal.net
 
 This email sent to rowla...@sbcglobal.net
 
 
 --
 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: sync drawing an ever-increasing path

2012-10-23 Thread David Duncan
On Oct 23, 2012, at 2:44 PM, David Rowland rowla...@sbcglobal.net wrote:

 There are several paths to be animated. I want each to appear when the user 
 does some action. It seemed the best to but them in a method called by 
 drawRect and redraw the view when something changed. Why would the memory 
 footprint be enlarged?

Because simply by implementing -drawRect:, your view will now consume 
pixelWidth * pixelHeight * 4 bytes of memory, and will need to be rendered onto 
the screen every time something changes.

You could do the exact same thing by just implementing an arbitrarily named 
method that you call instead of -setNeedsDisplay without the overhead.

 
 thanks for pointing to didMoveToWindow.
 
 David
 
 
 
 On Oct 23, 2012, at 1:25 PM, David Duncan david.dun...@apple.com wrote:
 
 
 On Oct 23, 2012, at 12:34 PM, David Rowland rowla...@sbcglobal.net wrote:
 
 This worked for me. When initializing your UIView, add an instance variable 
 shapeLayer and do this,
 
 shapeLayer = [CAShapeLayer layer];
 [[self layer] addSublayer:shapeLayer];
 
 
 In drawRect, set up your path and do this,
 
 There is no need to do this inside of drawRect. In fact by doing so (unless 
 your UIView actually needs to draw something) you've unnecessarily increased 
 your memory footprint and reduce the performance to start the animation.
 
 If you want the animation to happen as soon as the view is placed in the 
 window, the correct place to do this is inside of -[UIView 
 didMoveToWindow:]. Just check that the moved to window is not nil (or 
 nothing will happen).
 
 
 CABasicAnimation *pathAnimation = [CABasicAnimation 
 animationWithKeyPath:@strokeEnd];
 pathAnimation.duration = 4.0;
 pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
 pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
 [shapeLayer addAnimation:pathAnimation forKey:@strokeEndAnimation];
 
 You can also do this implicitly once the layer is in a layer tree by setting 
 the animation duration on the current CATransaction and setting the 
 strokeEnd directly.
 
 
 
 
 That seems to be all that is needed.
 
 David
 
 
 
 
 On Oct 23, 2012, at 11:37 AM, David Duncan david.dun...@apple.com wrote:
 
 On Oct 23, 2012, at 4:37 AM, Roland King r...@rols.org wrote:
 
 I want to animate the drawing of  CGPath in a UIView, so it looks as if 
 it's being drawn. I have the UIView, I have the CGPath, I am able to 
 split the CGPath at any point from 0 to 100% into that which should be 
 drawn and that which shouldn't yet, that's all done, so I can, fairly 
 efficiently, call -(CGPath)[ myObject fractionalPath:(CGFloat)fraction ] 
 and get a path. 
 
 
 You can do this with a CAShapeLayer by animating the strokeEnd property. 
 Should be very simple to do, although if your path is very complex it may 
 make more sense to break it into pieces and use multiple shape layers 
 animated sequentially.
 --
 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/rowlandd%40sbcglobal.net
 
 This email sent to rowla...@sbcglobal.net
 
 
 --
 David Duncan
 
 

--
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: Open untitled file in Document-based app

2012-10-23 Thread Graham Cox

On 24/10/2012, at 2:31 AM, ecir hana ecir.h...@gmail.com wrote:

 I tried to return YES in both applicationShouldOpenUntitledFile: and
 applicationOpenUntitledFile: of the app delegate without luck.


If you return YES from -applicationOpenUntitledFile: the application will NOT 
open a new file - it has assumed that this method has done it and by returning 
YES that's what you're telling it. You want to either return NO or else not 
override this method at all.

--Graham


___

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

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

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

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


Re: App Sandbox Container or Data Directory

2012-10-23 Thread Richard Somers
On Oct 23, 2012, at 2:43 PM, Kyle Sluder k...@ksluder.com wrote:

 If by unapproved you mean my app's sandbox hasn't been extended to
 include this path then you are incorrect. The user can choose the
 destination, and the NSURL you get back from the open panel will carry
 the rights to access that location.
 
 If by unapproved you mean the user my app is running as doesn't have
 write permission to this location, then yes that is expected behavior.

I sandboxed my app in Xcode. In the app target entitlement area there are 
access control options for Music, Movies, Pictures, and Downloads folders. 
Access to these folders remained the default No Access. I launched the app 
and and saved a new document. In the save panel the Music folder was showing as 
a Recent Place. I selected this as the save location and saving was a success. 
As a developer, based on the entitlement settings, I was expecting failure.

Saving a new document to the users home directory (choose the home directory in 
the save panel) resulted in failure. The document could not be saved. You 
don't have permission. As a developer this is what I expected.  From a users 
point of view I was surprised that the save panel let the user choose a 
location where a save was not allowed and subsequently would result in failure.

--Richard Somers


___

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: sync drawing an ever-increasing path

2012-10-23 Thread Roland King

On 24 Oct, 2012, at 2:37 AM, David Duncan david.dun...@apple.com wrote:

 On Oct 23, 2012, at 4:37 AM, Roland King r...@rols.org wrote:
 
 I want to animate the drawing of  CGPath in a UIView, so it looks as if it's 
 being drawn. I have the UIView, I have the CGPath, I am able to split the 
 CGPath at any point from 0 to 100% into that which should be drawn and that 
 which shouldn't yet, that's all done, so I can, fairly efficiently, call 
 -(CGPath)[ myObject fractionalPath:(CGFloat)fraction ] and get a path. 
 
 
 You can do this with a CAShapeLayer by animating the strokeEnd property. 
 Should be very simple to do, although if your path is very complex it may 
 make more sense to break it into pieces and use multiple shape layers 
 animated sequentially.
 --
 David Duncan
 

Thanks David, my shape is a bit complex for the strokeEnd property animation, I 
need to slowly and accurately 'trace' the outline of a path which has multiple 
elements and contains several closed paths. I already did the math to give me 
the first x% of the path, efficiently, even splitting any last bezier into a 
partial, so I'm happy with that bit, just needed to draw these partial and 
growing paths in sequence. Also I need the path to join correctly as it bends, 
so drawing it as one path, not different paths on different layers, is optimal. 

So I made a custom CALayer, gave it a 'percentage' property, made that 
@dynamic. I set needsDisplayForKey: to return YES for @percentage so I get 
the redraw calls and implemented drawInContext: so that it fetches 
self.percentage, gets the path for that percentage and draws it. This works. 
The one thing I had trouble with was getting the animation to start and animate 
between whatever percentage was and whatever I set it to, the UIViewController 
just does layer.percentage=1 and expects that to animate. Eventually I found 
actionForKey: and overrode that method to return a CABasicAnimation .. like this

-(idCAAction)actionForKey:(NSString*)key
{
if( [ key isEqualToString:@percentage ] )
{
CABasicAnimation *anim = [ CABasicAnimation 
animationWithKeyPath:@percentage ];
anim.duration = 2.0f;
anim.fromValue = [ self.presentationLayer valueForKey:key ];
// --- why oh why
return anim;
}
else
return  [ super actionForKey:key ]; 
}

Two things I don't understand here. 

First, why do I have to set the fromValue? I found without doing that, I don't 
get an animation, it just jumps instantly to the final point and draws the 
whole path? But the documentation for CABasicAnimation says that if fromValue, 
toValue and byValue are all nil, it should animate from the previous value of 
keypath to the new value, which is what I want, but doesn't do it. I got stuck 
on this for ages until I googled up an example showing how to get the current 
value off the presentation layer and set anim.fromValue, then it works. 

Secondly, [ self.presentationLayer valueForKey:@percentage ] gives me the 
current value of percentage, which I use for fromValue, fortunately I don't 
need to set toValue, that it manages to do itself, but if I did want the 'new' 
value of percentage, how could I get it at that point? I've tried the model 
layer and everything else I can think of. Is the 'new' value of percentage 
available at all at the point of actionForKey being called?. 

Or is actionForKey: the wrong place to return this animation? 



___

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


Security-scoped bookmarks linked to code signing?

2012-10-23 Thread Graham Cox
I'm using security-scoped bookmarks to save the location of certain folders 
between launches so that my sandboxed app works properly.

We've had reports that resolving these bookmarks sometimes crashes deep inside 
the security-scoping resolution but I have been unable to reproduce this. But 
one clue is that the apps that exhibit this problem were incorrectly codesigned 
(using the wrong developer certificate), and I was wondering if there was a 
connection between resolving SS bookmarks and codesigning. If there is that's 
probably the answer, but if not I'll know to keep looking for another reason.

--Graham



___

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

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

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

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


Re: How to programmatically detect that Mission Control is running?

2012-10-23 Thread Ken Thomases
On Oct 22, 2012, at 1:05 AM, Daiwei Li wrote:

 You should rely on key repeat events to let you know that you need to
 continue to respond to the key press. For mouse events, you should request
 periodic events.
 
 Could you point me towards the APIs that let me get key repeat and periodic
 mouse events?

So long as a key is held down, your app will continue to receive NSKeyDown 
events.  -[NSEvent isARepeat] returns TRUE for the repeat events.

You don't get periodic mouse events.  You can request to receive NSPeriodic 
events.  That's the standard way of continuing to do some action for as long as 
the mouse button is held down.  The canonical example from the docs is now 
outdated, but it was clicking on the arrow at the end of a scroll bar.  
Assuming the user doesn't move the mouse while holding the button down, there 
would not normally be a continuing stream of events to cause scrolling to 
continue for the duration.  So, the app should request periodic events so long 
as the mouse is down inside the button.

For the key repeat events, I strongly suspect you will stop receiving those 
when Mission Control activates.  I'm less sure about the periodic events.  
Although if you keep receiving those, you can probably check if the mouse is 
still on/over your app's control.  Perhaps using +[NSWindow 
windowNumberAtPoint:belowWindowWithWindowNumber:].

Regards,
Ken


___

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

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

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

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