Re: Write Finder plugin

2012-07-26 Thread Rakesh Singhal
Hi Ronald,

Thank you very much and now I am using PyObjC. But it doesn't add the items
in Services if my app is installed in /Applications folder. If you have any
idea then please let me know. Is it possible to enable these items only for
particular folder in finder?

Regards,
Rakesh Singhal

On Mon, Jul 16, 2012 at 12:45 PM, Ronald Oussoren wrote:

>
> On 13 Jul, 2012, at 18:11, Mark Munz wrote:
>
> > But the OP *could* create a Workflow OS X Services Item that has a Run
> > Shell Script action with a python script.
>
> Or use PyObjC.
>
> Ronald
>
> >
> > On Thu, Jul 12, 2012 at 11:16 PM, Eric Schlegel 
> wrote:
> >>
> >> On Jul 12, 2012, at 10:45 PM, Rakesh Singhal 
> wrote:
> >>
> >>> Hi Eric,
> >>>
> >>> Thanks. I am trying to do it using Services but I couldn't find any
> sample code.  Can I do it in python?
> >>
> >> No, you can only write a Service with Objective C. You can read about
> implementing a service here:
> https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/SysServices/introduction.html
> .
> >>
> >> -eric
> >>
> >>
> >> ___
> >>
> >> 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/unmarked%40gmail.com
> >>
> >> This email sent to unmar...@gmail.com
> >
> >
> >
> > --
> > Mark Munz
> > unmarked software
> > http://www.unmarked.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/ronaldoussoren%40mac.com
> >
> > This email sent to ronaldousso...@mac.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: Write Finder plugin

2012-07-26 Thread Rakesh Singhal
It worked. Pbs was indexing the old build.

On 10.7, I am not getting the file path instead of that I get something
like "file:///.file/id=6571367.3388989". In 10.6, I am getting full path.
Is there something, I am missing?

Regards,
Rakesh Singhal

On Thu, Jul 26, 2012 at 2:36 PM, Rakesh Singhal wrote:

> Hi Ronald,
>
> Thank you very much and now I am using PyObjC. But it doesn't add the
> items in Services if my app is installed in /Applications folder. If you
> have any idea then please let me know. Is it possible to enable these items
> only for particular folder in finder?
>
> Regards,
> Rakesh Singhal
>
>
> On Mon, Jul 16, 2012 at 12:45 PM, Ronald Oussoren 
> wrote:
>
>>
>> On 13 Jul, 2012, at 18:11, Mark Munz wrote:
>>
>> > But the OP *could* create a Workflow OS X Services Item that has a Run
>> > Shell Script action with a python script.
>>
>> Or use PyObjC.
>>
>> Ronald
>>
>> >
>> > On Thu, Jul 12, 2012 at 11:16 PM, Eric Schlegel 
>> wrote:
>> >>
>> >> On Jul 12, 2012, at 10:45 PM, Rakesh Singhal 
>> wrote:
>> >>
>> >>> Hi Eric,
>> >>>
>> >>> Thanks. I am trying to do it using Services but I couldn't find any
>> sample code.  Can I do it in python?
>> >>
>> >> No, you can only write a Service with Objective C. You can read about
>> implementing a service here:
>> https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/SysServices/introduction.html
>> .
>> >>
>> >> -eric
>> >>
>> >>
>> >> ___
>> >>
>> >> 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/unmarked%40gmail.com
>> >>
>> >> This email sent to unmar...@gmail.com
>> >
>> >
>> >
>> > --
>> > Mark Munz
>> > unmarked software
>> > http://www.unmarked.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/ronaldoussoren%40mac.com
>> >
>> > This email sent to ronaldousso...@mac.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: Write Finder plugin

2012-07-26 Thread Kyle Sluder
On Jul 26, 2012, at 3:56 AM, Rakesh Singhal  wrote:

> It worked. Pbs was indexing the old build.
> 
> On 10.7, I am not getting the file path instead of that I get something
> like "file:///.file/id=6571367.3388989". In 10.6, I am getting full path.
> Is there something, I am missing?

That's a file reference URL. Use -[NSURL filePathURL] to convert it to a normal 
file URL.

--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: Using NSTerminateLater with a Status Item

2012-07-26 Thread Trygve Inda
> Hi Olivier.
> 
> rdar://problem/6001460
> 
> See http://lapcatsoftware.com/rdar/6001460/index.html for an explanation.
> 
> In short, you won't be able to do it with a LSUIElement app.
> 
> -Jeff
> 

Is there a work-around for this?

I need to delay shutdown of a LSUIElement app during logout for a few
seconds to let a system call complete.

I have tried calling:

[[NSApplication sharedApplication] setActivationPolicy:
NSApplicationActivationPolicyRegular];


During a NSWorkspaceWillPowerOffNotification callback.

Doesn't work.

I have tried using NSTerminateLater with a timer, same results.

Any other way to do this or to get notified any earlier of an impending
shutdown or log out?

Trygve



___

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: Forcing Core Data to save attribute changed behind its back?

2012-07-26 Thread Sean McBride
On Tue, 24 Jul 2012 13:32:21 -0700, Sixten Otto said:

>On Tue, Jul 24, 2012 at 11:27 AM, Sean McBride 
>wrote:
>> Yes.  My object is a subclass of NSObject and I don't override
>isEqual:.  As I test, I overrode it and always return NO.  At first, I
>thought this did the trick, since Core Data passed through this and
>saved properly; but alas, it only seems to go through the path once
>after the document is opened, not every time I ask it to save.
>
>Are you still also triggering the KVO notices and/or using the setter?

Yes.

>My thinking was that you probably need both things: first, to take an
>action that causes Core Data to notice you're changing the value (like
>calling -will/didChangeValueForKeyPath:), and second, that when Core
>Data compares the before and after values, that they are not -isEqual:
>to one another.
>
>(But, to be clear, this is untested supposition on my part.)

I thought it was a very clever idea, alas it only half worked.  Like Kyle says, 
somewhere someone is doing pointer-equal checks.

Thanks!

-- 

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

iOS Rendering PDFs on a Background Thread

2012-07-26 Thread Dave

Hi All,

I like to be able to fire off a Background thread that Renders PDF  
pages to UIImage's.


I've got the code working on the Main Thread, but now the tricky bit  
because since I am using UIGraphicsBeginImageContextWithOptions and  
UIGraphicsEndImageContext in order to capture the Image, and, as far  
as I know these methods can only be called on the Main Thread. Is  
this correct?


I can re-code this using CF/CG etc. but I'd like to know if:

1.  The CF/CG functions are thread safe.

2.  The CGPDF functions are also thread safe.

Any help appreciated.

All the Best
Dave

___

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: iOS Rendering PDFs on a Background Thread

2012-07-26 Thread David Duncan
On Jul 26, 2012, at 2:09 PM, Dave  wrote:

> I've got the code working on the Main Thread, but now the tricky bit because 
> since I am using UIGraphicsBeginImageContextWithOptions and 
> UIGraphicsEndImageContext in order to capture the Image, and, as far as I 
> know these methods can only be called on the Main Thread. Is this correct?


No, these methods are fine as long as you use the context only within the same 
invocation (that is, don't try to share the context between threads or split 
the begin/end between threads).
--
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: iOS Rendering PDFs on a Background Thread

2012-07-26 Thread Dave


On 26 Jul 2012, at 22:17, David Duncan wrote:


On Jul 26, 2012, at 2:09 PM, Dave  wrote:

I've got the code working on the Main Thread, but now the tricky  
bit because since I am using  
UIGraphicsBeginImageContextWithOptions and  
UIGraphicsEndImageContext in order to capture the Image, and, as  
far as I know these methods can only be called on the Main Thread.  
Is this correct?



No, these methods are fine as long as you use the context only  
within the same invocation (that is, don't try to share the context  
between threads or split the begin/end between threads).


Really? Just double checking you mean what you mean. My code basicall

UIGraphicsBeginImageContextWithOptions
UIGraphicsGetCurrentContext
---Reander PDF Page into the Context obtained above.
UIGraphicsGetImageFromCurrentImageContext
UIGraphicsEndImageContext

This is all in one method that runs in one thread, are you saying  
this will work ok?


Thanks a lot for your help.
Dave



___

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: iOS Rendering PDFs on a Background Thread

2012-07-26 Thread David Duncan
On Jul 26, 2012, at 2:39 PM, Dave  wrote:

> Really? Just double checking you mean what you mean. My code basicall
> 
> UIGraphicsBeginImageContextWithOptions
> UIGraphicsGetCurrentContext
> ---Reander PDF Page into the Context obtained above.
> UIGraphicsGetImageFromCurrentImageContext
> UIGraphicsEndImageContext
> 
> This is all in one method that runs in one thread, are you saying this will 
> work ok?


Should be fine. If you find an issue, please report a bug. This was a recent 
topic at WWDC2012 as well, see session 211 "Building Concurrent User Interfaces 
on iOS"
--
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: iOS Rendering PDFs on a Background Thread

2012-07-26 Thread Dave

Hi,

Thanks for that!

All the Best
Dave


On 26 Jul 2012, at 22:20, Evadne Wu wrote:

Probably not: http://stackoverflow.com/questions/10931155/ 
uigraphicsbeginimagecontextwithoptions-and-multithreading


Best,
Eve

On Jul 27, 2012, at 5:09 AM, Dave  wrote:


Hi All,

I like to be able to fire off a Background thread that Renders PDF  
pages to UIImage's.


I've got the code working on the Main Thread, but now the tricky  
bit because since I am using  
UIGraphicsBeginImageContextWithOptions and  
UIGraphicsEndImageContext in order to capture the Image, and, as  
far as I know these methods can only be called on the Main Thread.  
Is this correct?


I can re-code this using CF/CG etc. but I'd like to know if:

1.  The CF/CG functions are thread safe.

2.  The CGPDF functions are also thread safe.

Any help appreciated.

All the Best
Dave

___

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/ev%40monoceroi.com

This email sent to e...@monoceroi.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: iOS Rendering PDFs on a Background Thread

2012-07-26 Thread Dave


On 26 Jul 2012, at 22:52, David Duncan wrote:


On Jul 26, 2012, at 2:39 PM, Dave  wrote:


Really? Just double checking you mean what you mean. My code basicall

UIGraphicsBeginImageContextWithOptions
UIGraphicsGetCurrentContext
---Reander PDF Page into the Context obtained above.
UIGraphicsGetImageFromCurrentImageContext
UIGraphicsEndImageContext

This is all in one method that runs in one thread, are you saying  
this will work ok?



Should be fine. If you find an issue, please report a bug. This was  
a recent topic at WWDC2012 as well, see session 211 "Building  
Concurrent User Interfaces on iOS"

--
David Duncan



Fantastic!!!
Thanks a lot!
Dave


___

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: iOS Rendering PDFs on a Background Thread

2012-07-26 Thread Conrad Shultz

On Jul 26, 2012, at 2:09 PM, Dave wrote:

> Hi All,
> 
> I like to be able to fire off a Background thread that Renders PDF pages to 
> UIImage's.
> 
> I've got the code working on the Main Thread, but now the tricky bit because 
> since I am using UIGraphicsBeginImageContextWithOptions and 
> UIGraphicsEndImageContext in order to capture the Image, and, as far as I 
> know these methods can only be called on the Main Thread. Is this correct?


As David has pointed out, this is incorrect as of iOS (then iPhoneOS) 4.  From 
the release notes 
(http://developer.apple.com/library/ios/#releasenotes/General/WhatsNewIniPhoneOS/Articles/iPhoneOS4.html):

Drawing to a graphics context in UIKit is now thread-safe. Specifically:
The routines used to access and manipulate the graphics context can now 
correctly handle contexts residing on different threads.
String and image drawing is now thread-safe.
Using color and font objects in multiple threads is now safe to do.

I do see that the UIKit documentation has not been updated to reflect this 
fact.  I suggest filing a documentation bug.

-Conrad
___

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


NSPointerArray compact

2012-07-26 Thread James Maxwell
Hi All,

I'm using NSPointerArrays to store references for a complex object graph. The 
nodes themselves are stored in an NSDictionary for archiving, and the pointer 
arrays are just used to record the interconnectivity of the nodes (it's loopy 
and complex, which has been causing problems with NSKeyedUnarchiver). What I'm 
finding is that I'm getting nil references in my pointer arrays after 
unarchiving (which is a mystery I still have to solve), so I'd like to get rid 
of the nils before using the graph. However, calling -compact on them doesn't 
seem to work. No matter what I do, the nils are still in the arrays, and I'm 
really not sure what else I can do to get rid of them. The objects are 
instances of a custom class (i.e., not primitives) and I'm initializing with 
-pointerArrayWithWeakObjects.

Any thoughts appreciated.

J.


James B Maxwell
Composer/Doctoral Candidate
School for the Contemporary Arts (SCA)
School for Interactive Arts + Technology (SIAT)
Simon Fraser University


___

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


cocoa plugin in widget on 10.8 - is spctl a solution?

2012-07-26 Thread Chuck Soper
I have a cocoa plugin in a dashboard widget
 . This is also referred to as a
widget plugin 
 . I tested the
widget (and plug-in) on a developer preview version of Mountain Lion and it
worked fine. Yesterday, I discovered that it no longer works on the final
version of 10.8 and have lots of customers contacting me.

>From the man page of the the spctl command, the following examples show me
how to check or allow applications to run on the local system:
 spctl -a /Applications/Mail.app   #To check whether Mail.app is allowed to
run on the local system
 spctl --add --label "My Stuff" /Applications/Mail.app   #To allow
Frobozz.app to run on the local system
 
Does anyone know how to use the spctl command to allow a widget plugin to
run? I tried the following command and some variations, but always get the
error: "cannot find code object on disk."
 spctl --add --label "Vela Design Group" \
"~/Library/Widgets/VelaClock Deluxe.wdgt/VCDeluxePlugin.widgetplugin/"

Or, does anyone know where I can find more documentation or get questions
answered about the spctl command?

The following link under "Code Signing Tasks" and "Using the spctl Tool to
Test Code Signing" has some info, but I can't find the answer to my issue.
https://developer.apple.com/library/mac/#documentation/security/Conceptual/C
odeSigningGuide/Procedures/Procedures.html

Thanks,
Chuck



___

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: NSPointerArray compact

2012-07-26 Thread Graham Cox

On 27/07/2012, at 10:33 AM, James Maxwell wrote:

> I'm using NSPointerArrays to store references for a complex object graph. The 
> nodes themselves are stored in an NSDictionary for archiving, and the pointer 
> arrays are just used to record the interconnectivity of the nodes (it's loopy 
> and complex, which has been causing problems with NSKeyedUnarchiver). What 
> I'm finding is that I'm getting nil references in my pointer arrays after 
> unarchiving (which is a mystery I still have to solve), so I'd like to get 
> rid of the nils before using the graph. However, calling -compact on them 
> doesn't seem to work. No matter what I do, the nils are still in the arrays, 
> and I'm really not sure what else I can do to get rid of them. The objects 
> are instances of a custom class (i.e., not primitives) and I'm initializing 
> with -pointerArrayWithWeakObjects.
> 
> Any thoughts appreciated.


One problem I've run into with NSPointerArray is that the API only allows you 
to recover the pointer (or remove it) by index. Since compacting changes the 
indexes, doing this means you lose track of the pointers unless you have some 
complicated means of tracking which pointer has which index, which means you 
need some additional data structure to do that... and basically it all ends up 
needlessly complex. So instead, I just don't compact the array and allow the 
nils to build up so the indexes remains static. I'm not archiving it though so 
next run I start over, and the total number of pointers is pretty small anyway.

This might not have any bearing whatsoever on your problem, but I thought I'd 
share it anyway.

It could be that -compact doesn't work (I don't know, because I don't use it 
for the above reason), or perhaps this is the wrong choice of container class 
for your case.

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


iOS4.3 simulator with Xcode 4.4

2012-07-26 Thread Nathan Day
Does anybody know how to get the iOS4.3 simulator to work with Xcode 4.4, we 
need to support iOS 4 up. I did a google search and found a way to do it with 
earlier Xcode 4's, but when I try it with Xcode 4.4 the simulator complains it 
can not find the SDK.

Nathan Day
___

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


Debugging -setNeedsDisplayInRect:

2012-07-26 Thread Nick Zitzmann
I've got a view that, according to Quartz Debug, is invalidating a large and 
unnecessary portion of the view when certain user events happen.

The problem is, I have no idea what is causing this to happen. What strategies 
are best for debugging the -setNeedsDisplayInRect: method to find out 
specifically who is calling it where and with what frame?

I can't put a symbolic breakpoint on the method, because it gets called very 
often, including when the app is activated, which causes Xcode to reactivate 
itself and get in the way. I then changed the breakpoint to auto-continue and 
just print the stack trace each time the method is called, but now I feel like 
I'm looking for a needle within a huge console log. I really need it to break 
when the rect is of a certain size, but the NSRect data structure is more than 
twice as large as a CPU register on x86_64, so the structure is placed on the 
stack, but how do I break on a variable buried within the stack?

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


Reading Very Large Files (300 Mb to 3 Gb)

2012-07-26 Thread Thomas Wetmore
I need to process very large files, and below is the program I use to do the 
work. I have run this program on data files from very small up to over 3 Gb in 
length. Much of my testing has been done with files in the 200 to 300 Mb size, 
and the program works fine at that size.

However, when I move up files in the 2 to 4 Gb range, behavior changes. The 
program starts consuming great amounts of virtual memory, around 14 Gb, takes 
more than a half hour to run, and after the functional part of the program is 
over, it takes another half hour for the program to give back much of the 
virtual memory, and once the program does fully quit, it takes the operating 
system another 10 minutes or so of thrashing before the final amount of virtual 
memory is returned and the hard drive finally calms down.

I've never processed such massive files before, but I am surprised by the 
behavior. As you will see I'm using memory mapped NSData, and once I start 
processing the data I simply proceed through the data from beginning to end, 
separating the data into newline-separated lines and processing the lines. That 
processing is simple, just breaking each line into vertical-bar separated 
fields, and putting some of those field values into dictionaries.

If I am simply reading through memory mapped data like this, why does the 
program use about six times as much virtual memory as the amount of memory 
needed by the file itself; why does the virtual memory accumulate in the first 
place, since I never return to memory pages I have already read through, and 
why does it take three quarters of an hour for the system to calm down once 
again after the processing has finished.

I hope someone with some experience dealing with very large files might see 
something pretty silly in this code and have a pointer of two to share.

Thanks,

Tom Wetmore,
Chief Bottle Washer, DeadEnds Software



#import 

static void processLine (NSString*);

int main(int argc, const char * argv[])
{
@autoreleasepool {

NSError* error;
NSString* path = @"/Volumes/Iomega HDD/Data/data";
NSData* data = [NSData dataWithContentsOfFile: path
  options: 
NSDataReadingMappedAlways + NSDataReadingUncached
error: &error];
NSUInteger length = [data length];
const Byte* bytes = [data bytes];

NSUInteger start = 0;
NSUInteger end = 0;
NSString* line;
while (YES) {
if (start >= length) break;
while (end < length && bytes[end] != '\n') {
end++;
}
line = [[NSString alloc] initWithBytes: bytes + start length: end - 
start encoding: 4];
processLine(line);
start = end + 1;
end = start;
}
}
return 0;
}

void processLine (NSString* line)
{
... break link into 74 vertical-bar separated fields ... and do simple 
things
}


___

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

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

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

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


Re: Reading Very Large Files (300 Mb to 3 Gb)

2012-07-26 Thread Greg Parker
On Jul 26, 2012, at 8:20 PM, Thomas Wetmore  wrote:
> I need to process very large files, and below is the program I use to do the 
> work. I have run this program on data files from very small up to over 3 Gb 
> in length. Much of my testing has been done with files in the 200 to 300 Mb 
> size, and the program works fine at that size.
> 
> However, when I move up files in the 2 to 4 Gb range, behavior changes. The 
> program starts consuming great amounts of virtual memory, around 14 Gb, takes 
> more than a half hour to run, and after the functional part of the program is 
> over, it takes another half hour for the program to give back much of the 
> virtual memory, and once the program does fully quit, it takes the operating 
> system another 10 minutes or so of thrashing before the final amount of 
> virtual memory is returned and the hard drive finally calms down.
> 
> I've never processed such massive files before, but I am surprised by the 
> behavior. As you will see I'm using memory mapped NSData, and once I start 
> processing the data I simply proceed through the data from beginning to end, 
> separating the data into newline-separated lines and processing the lines. 
> That processing is simple, just breaking each line into vertical-bar 
> separated fields, and putting some of those field values into dictionaries.
> 
> If I am simply reading through memory mapped data like this, why does the 
> program use about six times as much virtual memory as the amount of memory 
> needed by the file itself; why does the virtual memory accumulate in the 
> first place, since I never return to memory pages I have already read 
> through, and why does it take three quarters of an hour for the system to 
> calm down once again after the processing has finished.

You should use the Allocations instrument to see what is hogging your memory. 

My guess is that the memory-mapped NSData is fine, but that your NSString and 
other code inside processLine() is allocating objects and not freeing them.

One simple possibility is that you are creating lots autoreleased objects, but 
not cleaning up any autorelease pools so they don't get deallocated until you 
are all done. Try this:

   while (YES) {
 @autoreleasepool {
   if (start >= length) break;
   while (end < length && bytes[end] != '\n') {
   end++;
   }
   line = [[NSString alloc] initWithBytes: bytes + start length: end - 
start encoding: 4];
   processLine(line);
   start = end + 1;
   end = start;
 }
   }

(Also, if you are not using ARC then that NSString is leaking, which will also 
cost lots of memory.)


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



___

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

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

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

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


Re: Reading Very Large Files (300 Mb to 3 Gb)

2012-07-26 Thread Thomas Wetmore
Greg,

Thanks for the INSTANT answer! I added the auto-release pool inside the read 
loop and ran the program on the largest data file I have, 3.46 Gb. The program 
ran perfectly in just under nine minutes and never built up any virtual memory.

In hindsight I am embarrassed I did not come to the answer myself, as I have a 
fairly good understanding of all the supported memory management models. ARC 
tends to make one stop worrying, which tends to make one stop thinking. No 
excuses, though. I was too dim to see it.

Thanks again. You nailed it for me.

Tom Wetmore

On Jul 26, 2012, at 11:29 PM, Greg Parker wrote:

> On Jul 26, 2012, at 8:20 PM, Thomas Wetmore  wrote:
>> I need to process very large files, and below is the program I use to do the 
>> work. I have run this program on data files from very small up to over 3 Gb 
>> in length. Much of my testing has been done with files in the 200 to 300 Mb 
>> size, and the program works fine at that size.
>> 
>> However, when I move up files in the 2 to 4 Gb range, behavior changes. The 
>> program starts consuming great amounts of virtual memory, around 14 Gb, 
>> takes more than a half hour to run, and after the functional part of the 
>> program is over, it takes another half hour for the program to give back 
>> much of the virtual memory, and once the program does fully quit, it takes 
>> the operating system another 10 minutes or so of thrashing before the final 
>> amount of virtual memory is returned and the hard drive finally calms down.
>> 
>> I've never processed such massive files before, but I am surprised by the 
>> behavior. As you will see I'm using memory mapped NSData, and once I start 
>> processing the data I simply proceed through the data from beginning to end, 
>> separating the data into newline-separated lines and processing the lines. 
>> That processing is simple, just breaking each line into vertical-bar 
>> separated fields, and putting some of those field values into dictionaries.
>> 
>> If I am simply reading through memory mapped data like this, why does the 
>> program use about six times as much virtual memory as the amount of memory 
>> needed by the file itself; why does the virtual memory accumulate in the 
>> first place, since I never return to memory pages I have already read 
>> through, and why does it take three quarters of an hour for the system to 
>> calm down once again after the processing has finished.
> 
> You should use the Allocations instrument to see what is hogging your memory. 
> 
> My guess is that the memory-mapped NSData is fine, but that your NSString and 
> other code inside processLine() is allocating objects and not freeing them.
> 
> One simple possibility is that you are creating lots autoreleased objects, 
> but not cleaning up any autorelease pools so they don't get deallocated until 
> you are all done. Try this:
> 
>   while (YES) {
> @autoreleasepool {
>   if (start >= length) break;
>   while (end < length && bytes[end] != '\n') {
>   end++;
>   }
>   line = [[NSString alloc] initWithBytes: bytes + start length: end - 
> start encoding: 4];
>   processLine(line);
>   start = end + 1;
>   end = start;
> }
>   }
> 
> (Also, if you are not using ARC then that NSString is leaking, which will 
> also cost lots of memory.)
> 
> 
> -- 
> Greg Parker gpar...@apple.com Runtime Wrangler
> 
> 


___

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

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

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

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


Re: iOS4.3 simulator with Xcode 4.4

2012-07-26 Thread Nathan Day
Sorry this really belongs on the Xcode mailing list

Nathan Day

On 27/07/2012, at 11:53 AM, Nathan Day  wrote:

> Does anybody know how to get the iOS4.3 simulator to work with Xcode 4.4, we 
> need to support iOS 4 up. I did a google search and found a way to do it with 
> earlier Xcode 4's, but when I try it with Xcode 4.4 the simulator complains 
> it can not find the SDK.
> 
> Nathan Day

___

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


FSEvents eventid (or perhaps event)'s life

2012-07-26 Thread Alfian Busyro

Hi, All.

Just curious how long an event ID (or perhaps an event) will be exist on 
the system ?
I'd like to store event ID on NSUserDefaults before application 
terminate itself,

and call it back at the startup to be use in new event stream.

Regards,
Alfian.
___

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