Documents, Archived Objects, and Bindings

2008-04-15 Thread Seth Willits

Aloha,


I have a document which contains a model object created in the  
document's -init method, and I have a ton of bindings hooked up to  
this model by binding to the document nib's File's Owner and then  
using the key path "myModel.whateverProperty". This works spectacularly.


To save the document, I simply archive this model object, and save the  
resulting data. For reading document data, I simply unarchive the data  
and I get back an instance of the model object. This works  
spectacularly.


The tricky part is that I can't replace the existing model object that  
was created in the document's -init method because all of the bindings  
are hooked up to it. I thought I could simply get away with doing the  
steps below, but I still get an error at runtime because the bindings  
are still bound to the object that was released in the autorelease pool.


[self willChangeValueForKey:@"myModel"];
[myModel autorelease];
myModel = theUnarchivedModel;
[self didChangeValueForKey:@"myModel"];

So what should I do? After I unarchive the object I can certainly  
assign every property from theUnarchivedModel instance to the existing  
myModel instance, but that's tedious. Is there a correct and simple  
way of doing this? The only options I see are assigning properties one  
by one (ick), tearing down the bindings (major ick), or having some  
kind of proxy object which entails having a whole bunch of glue code  
(major ick).



Thanks,

--
Seth Willits




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Documents, Archived Objects, and Bindings

2008-04-15 Thread mmalc crawford


On Apr 15, 2008, at 12:27 AM, Seth Willits wrote:

So what should I do?

Add an object controller (NSObjectController) to which everything else  
is bound.
Then just set the content of the object controller to the unarchived  
model object.


mmalc

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Documents, Archived Objects, and Bindings [Nevermind...]

2008-04-15 Thread Seth Willits

On Apr 15, 2008, at 12:27 AM, Seth Willits wrote:


Aloha,


I'm sorry if you read any further than this line! :)

It was giving me an error because I didn't retain the newly created  
instance, not because I released the old instance. I *knew* it should  
have worked this way. :)



--
Seth Willits




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Documents, Archived Objects, and Bindings

2008-04-15 Thread mmalc crawford


On Apr 15, 2008, at 12:45 AM, mmalc crawford wrote:
Add an object controller (NSObjectController) to which everything  
else is bound.
Then just set the content of the object controller to the unarchived  
model object.


Rather better... you should bind the object controller's content to  
[File's Owner].myModel.


mmalc

___

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

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

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

This email sent to [EMAIL PROTECTED]


Image view binding doesn't update on nil values

2008-04-15 Thread Ben Lachman
I have an image view and its value binding is bound to a transient  
property of a CD object (a cached thumbnail).  However when a user  
removes an image from the image view I am sending the image view  
[imageView setImage:nil] (or any similar variant).  When I do this  
the CD object never gets its setter method called as I would expect.   
The reverse is also true--if I set the CD object's property using  
[imageMO setValue:nil forKey:@"thumbnail] the value is correctly set  
in the object but the imageview is not updated.  Any thoughts on why  
this doesn't happen automatically?


Thanks,
->Ben

--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

[EMAIL PROTECTED]
740.590.0009



___

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

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

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

This email sent to [EMAIL PROTECTED]


Getting feedback from application

2008-04-15 Thread parag vibhute
Hi guys,

I have created a cocoa application. Now I would like to have functionality
such that there will be a button, on clicking that application will send
feedback to me. Is there any class or any documentation available for this?

Please give your feedback/comments.

Thank,
Parag

-- 

There are many things in your life that will catch your eye but only a few
will catch your heartpursue those'.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to fetch remote file?

2008-04-15 Thread Chris Suter


On 15/04/2008, at 8:12 PM, Mike Abdullah wrote:


NSURLDownload would be the one.


Or you can just use +[NSData dataWithContentsOfURL:].

- Chris





smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: How to fetch remote file?

2008-04-15 Thread I. Savant

NSURLDownload would be the one.


Or you can just use +[NSData dataWithContentsOfURL:].



  I'd recommend the previous suggestions. NSURLDownload is non- 
blocking and uses callbacks to notify you when the download is  
complete (not to mention specific errors and progress). It also  
downloads the file to a temporary folder as opposed to loading the  
whole thing in memory.


  Even if the file is very small, there's no guarantee transmission  
won't be interrupted (or will be available at all), which takes time  
to time out, etc., blocking all the while.


--
I.S.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to fetch remote file?

2008-04-15 Thread Mike Abdullah

NSURLDownload would be the one.

Mike.

On 15 Apr 2008, at 11:08, parag vibhute wrote:


Hi,

I have implemented cocoa application in which I want to fetch a file  
which
is kept on remote machine. I know url of that file. But don't know  
how to

download that file. Can anybody please guide me how to do this?

Thanks,
Palav

--

There are many things in your life that will catch your eye but only  
a few

will catch your heartpursue those'.
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


How to fetch remote file?

2008-04-15 Thread parag vibhute
Hi,

I have implemented cocoa application in which I want to fetch a file which
is kept on remote machine. I know url of that file. But don't know how to
download that file. Can anybody please guide me how to do this?

Thanks,
Palav

-- 

There are many things in your life that will catch your eye but only a few
will catch your heartpursue those'.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to fetch remote file?

2008-04-15 Thread Michael Vannorsdel

Check out NSURLDownload or NSURLConnection.


On Apr 15, 2008, at 4:08 AM, parag vibhute wrote:

I have implemented cocoa application in which I want to fetch a file  
which
is kept on remote machine. I know url of that file. But don't know  
how to

download that file. Can anybody please guide me how to do this?


___

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

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

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

This email sent to [EMAIL PROTECTED]


App fails to kill NSTask processes

2008-04-15 Thread Alexander Reichstadt

Hi,

my app makes heavy use of NSTask. The tool it nstasks oftentimes falls  
asleep and doesn't return, I can't fix it cause I don't have the  
source code.
Til Tiger I worked around this behavior by making a custom class that  
contains an NSTask and a thread, run the task, and let the thread  
sleepUntilDate for a few seconds, then have the thread check on the  
task and if it is dead kill it. That worked fine. But ever since  
Leopard that doesn't work any more, neither main thread nor any other  
thread can terminate the task or sigkill it, it continues hanging  
around in the system. Only when I quit the app, it being the ppid of  
all the dead processes, does it take the dead processes with it. How  
can I kill those processes in Leopard?


Regards
Alexander Reichstadt
[EMAIL PROTECTED]





smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: How to fetch remote file?

2008-04-15 Thread parag vibhute
Thanks guys. I am going through the documentation of those classes & if have
any query then will ask. Thanks again.

Regards,
Palav


On Tue, Apr 15, 2008 at 3:50 PM, Chris Suter <[EMAIL PROTECTED]>
wrote:

>
> On 15/04/2008, at 8:12 PM, Mike Abdullah wrote:
>
>  NSURLDownload would be the one.
> >
>
> Or you can just use +[NSData dataWithContentsOfURL:].
>
> - Chris
>
>
>
>


-- 

There are many things in your life that will catch your eye but only a few
will catch your heartpursue those'.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: "hooking" into another app

2008-04-15 Thread I. Savant


  Though the link was funny, I'll ignore the flamebait and answer the  
technical aspect of this post:


You yourself said that the OS is resistant against this sort of  
attack in the following quotes:



Well, password fields are "special" and are 'resistant' to key
logging, but you don't have to 'hook into' any apps to log the rest.




  Note the quotes around 'resistant'. Password fields are not simply  
left open to key logging like everything else. Try it - write a key  
logger that logs all keyboard events on the system (you'll need  
Carbon). Then google around for the 'why'.


  Whether it's bullet proof or not was neither asserted by my post  
nor defended by others. It's merely 'resistant' to key logging. There  
are easier ways of getting a user's passwords (say, from their  
keychain) if you've managed to sneak an application on their system.


I dont know what could be confusing about logging text that is  
displayed in a text field, perhaps you could elaborate on how this  
was confusing.


  With the exception of the first misinterpretation (which was not a  
big deal, please forgive us our humanity), the OPs question was  
answered with several approaches: APE, AppleScript, and the  
Accessibility API. All are valid, all have advantages and disadvantages.


--
I.S.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: App fails to kill NSTask processes

2008-04-15 Thread Ken Thomases

On Apr 15, 2008, at 5:55 AM, Alexander Reichstadt wrote:
my app makes heavy use of NSTask. The tool it nstasks oftentimes  
falls asleep and doesn't return, I can't fix it cause I don't have  
the source code.
Til Tiger I worked around this behavior by making a custom class  
that contains an NSTask and a thread, run the task, and let the  
thread sleepUntilDate for a few seconds, then have the thread check  
on the task and if it is dead kill it. That worked fine. But ever  
since Leopard that doesn't work any more, neither main thread nor  
any other thread can terminate the task or sigkill it, it continues  
hanging around in the system. Only when I quit the app, it being  
the ppid of all the dead processes, does it take the dead processes  
with it. How can I kill those processes in Leopard?


There's quite a bit left unsaid in the above.  How do you kill it?   
Do you use kill(2) or -[NSTask terminate]?  If the former, what  
signal are you sending?


What does "ps" show as the status of the process?  See the ps man  
page for a description of some of these.  It is possible for a  
process to get stuck in the "Exiting" state, but in that case only a  
reboot usually fixes it.  That doesn't sound like the symptom you're  
seeing.  It sounds like your child processes are ending up as zombies  
waiting to be reaped by the parent.  I would expect Cocoa to take  
care of that for you.  However, it may be waiting for you to call - 
[NSTask waitUntilExit].  Are you ever calling that?


Are you registering for the NSTaskDidTerminateNotification?  If so,  
are you seeing it being delivered?


After you kill the task, do you keep the NSTask object around, or are  
you releasing it?


Lastly, as an aside, it seems like massive overkill to spawn a thread  
to monitor each task.  You can launch the task from the main thread  
and use an NSTimer to schedule an occasional check if it's still alive.


Cheers,
Ken
___

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

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

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

This email sent to [EMAIL PROTECTED]


Capture mouse events globally

2008-04-15 Thread Apparao Mulpuri
Is three any way to capture mouse events globally from my background app.

- Apparao
___

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

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

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

This email sent to [EMAIL PROTECTED]


Cannot get PDF document show up in PDFView

2008-04-15 Thread Rajeshwari Iyer

Hi,

I am a beginner with cocoa and am making an application where i want  
to display a PDF file in my app. window. I have subclassed PDFView to  
myPDFView and have attached a PDF view from interface builder to my  
window. Now how do i associate the PDF document that i want to  
display with this view? I came across this 2 line code to do this...


myDoc = [[[PDFDocument alloc] initWithURL: (NSURL *) [ NSURL  
fileURLWithPath: (NSString *)"Users/raj/Desktop/ObjectiveC.pdf"]]  
autorelease];


[pdfView setDocument: myDoc];

but i cannot understand where to add this in my sub class

can somebody please help?

THANKS!

___

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

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

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

This email sent to [EMAIL PROTECTED]


[ANN] Port mapping/forwarding framework (MIT license)

2008-04-15 Thread Dominik Wagner tcm

Hi.

We here at TheCodingMonkeys like to announce that we published an open- 
source framework for port mapping today: TCMPortMapper. It's MIT  
licensed and supports NAT-PMP and UPNP capable routers.


If you do peer-to-peer networking in your application or just would  
like to have your network-enabled application reachable from the  
internet when behind a NAT router, it's now as easy as putting in a  
few lines of code. TCMPortMapper takes care of forwarding the ports  
and letting you know the external IP you can be reached by.


It can also be used to make your Application location aware because it  
can give you the current routers MAC Address which most likely  
identifies your location. All on a Notification driven basis.


The project also includes a substantial sample application to map  
arbitrary ports and Apple's CocoaEcho sample extended with port mapping.


If you are interested, please have a look at http://www.codingmonkeys.de/portmap/ 
 and http://code.google.com/p/tcmportmapper/



All the best,
Dominik and Martin

--
Dominik Wagner  Mail: [EMAIL PROTECTED]
TheCodingMonkeyshttp://www.codingmonkeys.de/
Blog - DasGenie: !Scrap http://scrap.dasgenie.com/


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: App fails to kill NSTask processes

2008-04-15 Thread Alexander Reichstadt


Alexander Reichstadt
[EMAIL PROTECTED]



On 15.04.2008, at 13:29, Ken Thomases wrote:


On Apr 15, 2008, at 5:55 AM, Alexander Reichstadt wrote:
my app makes heavy use of NSTask. The tool it nstasks oftentimes  
falls asleep and doesn't return, I can't fix it cause I don't have  
the source code.
Til Tiger I worked around this behavior by making a custom class  
that contains an NSTask and a thread, run the task, and let the  
thread sleepUntilDate for a few seconds, then have the thread check  
on the task and if it is dead kill it. That worked fine. But ever  
since Leopard that doesn't work any more, neither main thread nor  
any other thread can terminate the task or sigkill it, it continues  
hanging around in the system. Only when I quit the app, it being  
the ppid of all the dead processes, does it take the dead processes  
with it. How can I kill those processes in Leopard?


There's quite a bit left unsaid in the above.  How do you kill it?   
Do you use kill(2) or -[NSTask terminate]?  If the former, what  
signal are you sending?


What does "ps" show as the status of the process?  See the ps man  
page for a description of some of these.  It is possible for a  
process to get stuck in the "Exiting" state, but in that case only a  
reboot usually fixes it.  That doesn't sound like the symptom you're  
seeing.  It sounds like your child processes are ending up as  
zombies waiting to be reaped by the parent.  I would expect Cocoa to  
take care of that for you.  However, it may be waiting for you to  
call -[NSTask waitUntilExit].  Are you ever calling that?


Are you registering for the NSTaskDidTerminateNotification?  If so,  
are you seeing it being delivered?


After you kill the task, do you keep the NSTask object around, or  
are you releasing it?


Lastly, as an aside, it seems like massive overkill to spawn a  
thread to monitor each task.  You can launch the task from the main  
thread and use an NSTimer to schedule an occasional check if it's  
still alive.


Cheers,
Ken


I tried both ways separately and in combination, terminate and kill,  
with kill I tried it with all signals available. I don't need to  
reboot, they do get reaped. Whether I waitUntilExit or not makes no  
difference, I also registered for the notification.


In Tiger NSTimer causes some problems in this context, so I resorted  
to detaching a thread. Upon your suggestion I reviewed this option now  
for Leopard using an NSTimer calling a method spawning the process  
with the tool using some sandbox app and it doesn't seem to cause this  
problem; even in cases where there is a zombie it always seems to  
expires permanently with the NSTimer instance. So thanks, I rewrite  
everything using timers.


Regards



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Inline Help Text Approaches

2008-04-15 Thread Steven Huey

Hi,

I want to add some "inline" help text to an app I'm working on, much  
like the text in the screenshot linked here from Apple Backup:


http://stevenhuey.net/pics/Backup.png

The text I'm describing is the gray text over the table views such as:  
"Add QuickPicks, files, and folders..." that appears over the table,  
but once you add something is hidden.


Are there any best practices or standard approaches to this? What  
about if I want to include an image as well?


Thanks,
Steve

--
Steven Huey Software - http://www.stevenhuey.com




___

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

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

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

This email sent to [EMAIL PROTECTED]


Updating IKImageBrowserView with Edited Image

2008-04-15 Thread Jamie Phelps
Hi, all. Does anyone know how I could go about updating the content of  
my IKImageBrowserView after editing an image in an IKImageView? So...


1) User has some images in an IKImageBrowserView.
2) User selects an image.
3) The selected image shows in an IKImageView
4) User edits the image (Adjust color, resize, crop, rotate, etc.)
5) User selects another image.
6) Edited image replaces old version in IKImageBrowserView
7) New image shows in IKImageView
8) Repeat 4-7

The idea is that the user would edit several images and then save them  
all when they've made all the edits. Currently, I have steps 1-5  
working, but when the selection changes, the edits are lost.


So far I don't see a delegate for the IKImageEditPanel to call when it  
is dismissed or any way to bind the image of the IKImageView to the  
selected item in the IKImageBrowserView. Does anyone have an idea how  
I could accomplish what I want to do? Am I missing something obvious  
or should I file this as an enhancement request?


Thanks,
Jamie
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: is this badly written code?

2008-04-15 Thread Jeff LaMarche


On Apr 14, 2008, at 10:53 PM, Adam Gerson wrote:


In cocoa its very tempting to write a single line of code like:
NSManagedObject *selectedTreeObject = [self delegate]
mainWindowController] treeController] selectedObjects]
objectAtIndex:0];

or to flush it out in to individual lines:

NSWindowController *mainWindow = [[self delegate]  
mainWindowController];

NSTreeController *treeController = [mainWindow treeController];
NSArray *selectedTreeObjects = [treeController selectedObjects];
NSManagedObject *selectedTreeObject =  [selectedTreeObjects  
objectAtIndex:0];



I'm not sure that you're going to find 100% agreement on this topic. I  
can tell you what I do, but I suspect there's a fair amount of  
personal preference in this.


When I first started writing Objective-C, well, at least once I really  
started to grok the language, I got into the habit of  doing crazy  
nesting like your first example. Well, maybe not quite that crazy, but  
still fairly crazy ;)  Then I started writing articles on Cocoa for  
MacTech magazine, and because the series was intended as an  
introduction to Cocoa for people unfamiliar with Objective-C  
(basically Carbon / Mac Toolbox programmers), I needed to make the  
code as clear and easy to understand as possible, so I started writing  
my code for the articles more like your second example to avoid  
confusion and there's no doubt the code was easier to read. Nowadays,  
my style is probably somewhere between your two examples, and I'm sure  
I'm not completely consistent about it. There are times when it makes  
sense to nest calls, times when it can cause you problems, and a great  
many situations where it probably just doesn't matter.


I almost never, for example, break out calls to alloc and init into  
two lines. Sometimes I'll even throw in an autorelease (if  
appropriate, of course) right on the line. When grabbing a reference  
to a singleton, I'll typically nest the call to the accessor (e.g.  
[NSFileHandle defaultFileHandle] in another call unless I'm going to  
be making many calls on the singleton object.  With few exceptions  
(such as the alloc/init/autorelease and some building of NSString  
using formats, I don't usually nest more than two message calls. But,  
as I said, I'm not 100% consistent. I just do what feels right to me  
and sometimes I'll write it one way and then change it later.


As a practical matter, all that your first example really gets you is  
some vertical space on the page and possibly a meaningless amount of  
memory to hold a few pointers (I'm not even sure about that - I don't  
know much about compiler optimizations on modern processors, it could  
be those chunks of code compile to the exact same end result but even  
if not, a few pointers on a modern machine is meaningless). The  
downside to the first example is that it makes the code harder to read  
and can be much, much harder to debug. When you set a breakpoint at  
that line of code, for example,  it will appear to stay at the same  
line through several instructions as you step through your code, and  
if it breaks during one of those nested calls, you'll have a harder  
time discerning which command it was on when it broke than if they  
were broken out.


I'd say, it's best to follow Wil's advice on this one (Shakespeare,  
not Shipley, although the latter probably has an opinion on the  
matter) - and be true to thine own self. Or, would that be YES to tine  
own self? Sorry, didn't get much sleep last night. I'll shut up now.


Peace,
Jeff
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSAllocateCollectable() questions

2008-04-15 Thread Alastair Houghton

On 15 Apr 2008, at 06:42, Brendan Younger wrote:


Hi all,

This is a re-post since I didn't receive any response on Sunday.

I've been writing a library that uses NSAllocateCollectable() quite  
a bit and I have a few questions about proper usage.


The problem is that your questions are quite involved and so the only  
people who can give a definitive answer at this point are the people  
inside Apple who deal with the GC.  Some of them do read the list, but  
since the mailing lists are volunteer-based, and since there's a lot  
of traffic and they're busy people, you might not always get their  
attention.



- Copying data
if I am copying to a malloc'd block, I can use memmove() regardless  
of whether the source is GC'd or not, right?
if I am copying to a GC block allocated with NSScannedOption, I need  
to use objc_memmove_collectable(), right?
if I am copying to a GC block allocated with nonscanned memory, I  
can use memmove(), right?


I *think* all three of these are correct.  Obviously in the first and  
last cases you don't want to have any pointers to GCable objects in  
the memory concerned, as they won't be traced by the collector.



- Zero'ing data
There does not seem to be a GC-compatible bzero().  If I loop  
through and zero out each pointer in a scanned block, that would  
generate a write barrier for each pointer which is expensive.   
However, if I use bzero(), then libauto won't know that I've messed  
with the block.  Will it eventually figure it out when it does an  
exhaustive scan?  Or will it never notice that I've zero'd out the  
block?


I might be wrong, but I don't *think* libauto will care if you zero  
something out; the problems arise when you write a pointer somewhere  
without a write barrier, expecting the pointed-to object to remain  
live.  There are two problems that doing that can cause:


1. If you write into an object that's part of an older generation, in  
which case the collector might not know that it needs to use this  
pointer as a root when collecting younger generations.


2. If you write into an object that has already been scanned during  
this GC cycle, in which case the collector won't know about the new  
pointer.


In either case, the GC may as a result throw away a live object,  
resulting in a later crash.  Now I don't have access to the GC source  
code, so there could be other potential problems also, but those are  
the two common ones from the literature.


But like I say, you'll need someone from Apple to give you a  
definitive answer on this.


FWIW there are a few other dangers with NSAllocateCollectable().  See  
e.g.


  

Kind regards,

Alastair.

--
http://alastairs-place.net


___

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

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

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

This email sent to [EMAIL PROTECTED]


RE: is this badly written code?

2008-04-15 Thread john darnell
I am a long-time C/C++ programmer, with roots in XBase and Basic.  Code
style is a subject that often comes up with newbie programmers
regardless of the language, and it deserves a thoughtful response.

I agree wholeheartedly with Mr. Stiles; more than anything else, your
style of coding *is* a matter of personal preference, but allow me to
add my two cents worth here as well, for your consideration.

Too often coders write their code for themselves.  After all, they
reason, they are the only ones who will ever touch the module, so what
does it matter how they style their modules?  Regrettably, that may not
be true, as I have often found out to my Tylenol-laced regret. And, if
you work on a team of programmers, that most definitely will not be
true.  So if there is even a remote possibility that someone else will
have to look at your code someday, write *friendly* code. I personally
would have broken Mr. Gerson's code into several lines and added some
additional padding, but that's just me.  Here are some of John's
Arbitrary Rules to Help Readability:

1.)  Use LOTS of white space.  It's free, and it greatly improves code
readability.  The compiler strips out white space when it does its
thing, so adding white space should not affect speed or size of the
final product.

2.)  Symmetry can add elegance to the visual aspect of your code, and
thus make it more pleasing to the eye, and easier to decipher. For
example, when I have a long list of includes, I often do this to them:

#include  
#include 
#include 

3.)  Instead of one massive scroll of code, break it up into small
groups of three or four lines, logically grouped wherever possible.  I
am not afraid to do something like this:

int height, 
weight, 
  mass, 

visibility, 
   opacity, 
   granularity, 

   density, 
xcoord, 
ycoord, 

volume, 
  spin, 

  tilt, 
   temperature; 

If I am feeling particularly obsessive-compulsive on that day, I may
even take the time to alphabetize this list.


4.)  Comment verbosely and often.  You may understand now what you are
doing and why, but six months from now, you won't.  Don't fool yourself
by saying "I'll add comments later," because, trust me, later never
comes.

5.)  If you have a function call or its Objective-C equivalent with
several arguments, spread them out over several lines.  Here's an
example using printf (note: what I am trying to illustrate here will not
come across as well if you are not using a non-proportional font):

printf("%s %s %s %s %s, 
"This",
  "is",
   "a",
  "printf",
"statement.\n");

There will be some who object to these rules because they take extra
time to implement.  Others will complain that writing code in this way
makes it harder to debug, because less code is on the screen.  As to the
first objection, I can't argue with it; it does.  But the programmer who
takes the time to do so will have code that is so much more readable
that the next programmer in line who is required to maintain it, will
bless him/her, and maybe even put him/her in her will. (grin)

As to the second point, well, all I can say is that the marked
improvement in code readability well offsets the disability of the
screen space it takes, IMHO.

Nevertheless, I will say it again to any who desire to flame me, this is
completely a matter of choice.  In the end, write code in the style that
works best for you.

R,
John
-Original Message-

The chained approach is tempting since it's short and convenient, so if 
the code is not prone to failure, I'd say go for it.

If you expect that you might need to see intermediate values in the 
debugger or there are weird edge cases where something might return nil,

I'd break it out into multiple lines.

This is really a matter of personal preference so YMMV here.


Adam Gerson wrote:
> In cocoa its very tempting to write a single line of code like:
> NSManagedObject *selectedTreeObject = [self delegate]
> mainWindowController] treeController] selectedObjects]
> objectAtIndex:0];
>
> or to flush it out in to individual lines:
>
> NSWindowController *mainWindow = [[self delegate]
mainWindowController];
> NSTreeController *treeController = [mainWindow treeController];
> NSArray *selectedTreeObjects = [treeController selectedObjects];
> NSManagedObject *selectedTreeObject =  [selectedTreeObjects
objectAtIndex:0];
>
> I am looking for some guidance on best practices in a situation with a
> lot of nested calls like this. If ultimately the only value I care
> about is the final one, selectedTreeObject, whats the best way to go
> about getting it? I know "best" is a subjective word. Interested to
> hear all of your opinions.
>
> Adam
___

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

Please do not post admin requests or moderator comments to the list.
Contact the m

to write to file except NSData*

2008-04-15 Thread Nick Rogers

Hi,
I am creating a file with:
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager createFileAtPath:path contents:nil attributes:nil];
===
then I got a fileHandle as:
NSFileHandle *fileHandle = [NSFileHandle  
fileHandleForWritingAtPath:path];

===
NSFileHandle has the method:
- (void)writeData:(NSData *)data

=

but i want to write the length of (NSData *)data, before I write it  
to file because I will be writing a lot of NSData to the file,
so that I will be able to read the length first and then read the  
following NSData.
SO how can I write the length which is an integer to file before I  
write the NSData.


Thanks,
Nick

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: to write to file except NSData*

2008-04-15 Thread Thomas Backman
Sorry to duck your question, but are you sure you don't want  
NSKeyedArchiver and similar classes?


/Thomas

On Apr 15, 2008, at 4:38 PM, Nick Rogers wrote:

Hi,
I am creating a file with:
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager createFileAtPath:path contents:nil attributes:nil];
===
then I got a fileHandle as:
NSFileHandle *fileHandle = [NSFileHandle  
fileHandleForWritingAtPath:path];

===
NSFileHandle has the method:
- (void)writeData:(NSData *)data

=

but i want to write the length of (NSData *)data, before I write it  
to file because I will be writing a lot of NSData to the file,
so that I will be able to read the length first and then read the  
following NSData.
SO how can I write the length which is an integer to file before I  
write the NSData.


Thanks,
Nick

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/serenity 
%40exscape.org


This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: is this badly written code?

2008-04-15 Thread Jeff LaMarche


On Apr 15, 2008, at 10:25 AM, john darnell wrote:


4.)  Comment verbosely and often.  You may understand now what you are
doing and why, but six months from now, you won't.  Don't fool  
yourself

by saying "I'll add comments later," because, trust me, later never
comes.


I'm not going to argue with you because I think you've given some  
pretty good advice here. I'm a fan of white space in my code as well,  
and though there are some stylistic differences between us, I concur  
with the basic concepts you laid out. I just thought a caveat  might  
be in order on #4 quoted above. And that caveat is simply "don't  
overdo it". Comments are good and necessary, and should be done  
contemporaneously with coding, on all that I agree completely. But it  
can also be frustrating to have to deal with code like the following  
hypothetical example (okay, this is may be a bit of an exaggeration,  
but I've seen comments not that different from this out of young, well- 
meaning programmers who take the "comment copiously" advice a bit too  
seriously):


// This is a loop. It loops through the values in an NSArray
// called myArray.  i is the loop variable, which we set
// to zero because arrays are zero-indexed in Obj-c
// we loop until i is less than [myArray count]  because
// it is zero-indexed and going past the last item in the
// array will generate an exception. If I had used <=
// instead of < then we would have iterated past the
// last item in the array. I like puppies, but they can't code.

int i;
NSString *myString
for (i = 0; i <  [myArray count]; i++)
{
myString = [myArray objectAtIndex:i];
NSLog(@"OMG, [EMAIL PROTECTED]", myString);
}

// Now that I've looped through my array using a for loop, I will
// ...etc. etc.

I think I would add to the end of your rule, " but don't waste time  
writing comments to explain what should be obvious to any competent  
programmer". Comments are to elucidate what shouldn't be clear.  
Unless, of course your code is intended as a teaching tool. In most  
cases, if your comment length exceeds your code length by a  
significant amount, you might want to step back and ask yourself if  
it's all necessary. 
___


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

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

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

This email sent to [EMAIL PROTECTED]


Re: to write to file except NSData*

2008-04-15 Thread Nick Rogers

Hi,
I will use NSKeyedArchiver to create a lot of NSData objects before  
writing to file.
I can't write one whole NSData to file because i have to write in GBs  
and also have to show the progress bar.


Thanks for the reply,
Nick

On 15-Apr-08, at 8:10 PM, Thomas Backman wrote:

Sorry to duck your question, but are you sure you don't want  
NSKeyedArchiver and similar classes?


/Thomas

On Apr 15, 2008, at 4:38 PM, Nick Rogers wrote:

Hi,
I am creating a file with:
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager createFileAtPath:path contents:nil attributes:nil];
===
then I got a fileHandle as:
NSFileHandle *fileHandle = [NSFileHandle  
fileHandleForWritingAtPath:path];

===
NSFileHandle has the method:
- (void)writeData:(NSData *)data

=

but i want to write the length of (NSData *)data, before I write  
it to file because I will be writing a lot of NSData to the file,
so that I will be able to read the length first and then read the  
following NSData.
SO how can I write the length which is an integer to file before I  
write the NSData.


Thanks,
Nick

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/serenity% 
40exscape.org


This email sent to [EMAIL PROTECTED]




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Subclassing NSArrayController

2008-04-15 Thread Jeff LaMarche


On Apr 14, 2008, at 11:53 PM, antikraft clover wrote:


If I am subclassing NSArrayController to provide and update an array
of objects, which methods do I need to implement ?


What are you trying to accomplish. The only time that I regularly  
subclass NSArrayController is to implement drag and drop. In most  
cases, you can just use the NSArrayController out-of-the-box and run  
with 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: to write to file except NSData*

2008-04-15 Thread Alastair Houghton

On 15 Apr 2008, at 15:49, Nick Rogers wrote:

I will use NSKeyedArchiver to create a lot of NSData objects before  
writing to file.
I can't write one whole NSData to file because i have to write in  
GBs and also have to show the progress bar.


So just use NSKeyedArchiver to generate a header before each of the  
larger NSData objects (for instance).


Or fill in an NSMutableData yourself, but if you do that you have to  
handle endianness somehow.


Kind regards,

Alastair.

--
http://alastairs-place.net


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: is this badly written code?

2008-04-15 Thread I. Savant
>  I'm not going to argue with you because I think you've given some pretty
> good advice here. I'm a fan of white space in my code as well, and though
> there are some stylistic differences between us, I concur with the basic
> concepts you laid out. I just thought a caveat  might be in order on #4
> quoted above. And that caveat is simply "don't overdo it".

  Agreed, but this is veering rapidly away from Cocoa. :-) The answer
to the OP seems to boil down to this:

* Write your code so it is readable (ie, 'take advantage of
whitespace', and 'nesting is okay in moderation but over-use is a
* to debug').
* Comment your code but don't explain every line, variable, and
concept (ie, you're not writing a book on programming, you're writing
a program).

  I think though, that debates on coding style in general probably
belong on another list. :-)

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: to write to file except NSData*

2008-04-15 Thread Navneet Kumar

ok,
so if i generate a header NSData object and write that to file, and  
then then write the larger NSData object,

how will i read one NSData after the another.
How will i know what length should I read.

excuse me if this sounds very newbie to you.

Wishes,
Nick

On 15-Apr-08, at 8:30 PM, Alastair Houghton wrote:


On 15 Apr 2008, at 15:49, Nick Rogers wrote:

I will use NSKeyedArchiver to create a lot of NSData objects  
before writing to file.
I can't write one whole NSData to file because i have to write in  
GBs and also have to show the progress bar.


So just use NSKeyedArchiver to generate a header before each of the  
larger NSData objects (for instance).


Or fill in an NSMutableData yourself, but if you do that you have  
to handle endianness somehow.


Kind regards,

Alastair.

--
http://alastairs-place.net




___

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

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

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

This email sent to [EMAIL PROTECTED]


RE: is this badly written code?

2008-04-15 Thread john darnell
Mr. LaMarche:

   I agree wholeheartedly.  Thanks for adding your very salient point.

Mr. IS:  

   My apologies. I have no desire to divert the list to some off-topic
subject.

R,
John


On Apr 15, 2008, at 10:25 AM, john darnell wrote:

> 4.)  Comment verbosely and often.  You may understand now what you are
> doing and why, but six months from now, you won't.  Don't fool  
> yourself
> by saying "I'll add comments later," because, trust me, later never
> comes.

I'm not going to argue with you because I think you've given some  
pretty good advice here. I'm a fan of white space in my code as well,  
and though there are some stylistic differences between us, I concur  
with the basic concepts you laid out. I just thought a caveat  might  
be in order on #4 quoted above. And that caveat is simply "don't  
overdo it". Comments are good and necessary, and should be done  
contemporaneously with coding, on all that I agree completely. But it  
can also be frustrating to have to deal with code like the following  
hypothetical example (okay, this is may be a bit of an exaggeration,  
but I've seen comments not that different from this out of young, well- 
meaning programmers who take the "comment copiously" advice a bit too  
seriously):

// This is a loop. It loops through the values in an NSArray
// called myArray.  i is the loop variable, which we set
// to zero because arrays are zero-indexed in Obj-c
// we loop until i is less than [myArray count]  because
// it is zero-indexed and going past the last item in the
// array will generate an exception. If I had used <=
// instead of < then we would have iterated past the
// last item in the array. I like puppies, but they can't code.

int i;
NSString *myString
for (i = 0; i <  [myArray count]; i++)
{
myString = [myArray objectAtIndex:i];
NSLog(@"OMG, [EMAIL PROTECTED]", myString);
}

// Now that I've looped through my array using a for loop, I will
// ...etc. etc.

I think I would add to the end of your rule, " but don't waste time  
writing comments to explain what should be obvious to any competent  
programmer". Comments are to elucidate what shouldn't be clear.  
Unless, of course your code is intended as a teaching tool. In most  
cases, if your comment length exceeds your code length by a  
significant amount, you might want to step back and ask yourself if  
it's all necessary. 

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: to write to file except NSData*

2008-04-15 Thread Jeff LaMarche

On Apr 15, 2008, at 10:38 AM, Nick Rogers wrote:


Hi,
I am creating a file with:
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager createFileAtPath:path contents:nil attributes:nil];
===
then I got a fileHandle as:
NSFileHandle *fileHandle = [NSFileHandle  
fileHandleForWritingAtPath:path];

===
NSFileHandle has the method:
- (void)writeData:(NSData *)data

=

but i want to write the length of (NSData *)data, before I write it  
to file because I will be writing a lot of NSData to the file,
so that I will be able to read the length first and then read the  
following NSData.
SO how can I write the length which is an integer to file before I  
write the NSData.



How is your length stored? Is it a short, or an int or an NSUInteger?  
One way I think you could tackle this would be to create an NSData  
that contains the length, write that first, then use:

[fileHandle truncateFileAtOffset:[aFileHandle seekToEndOfFile]];

which sets the file handle to write at the end of the file - basically  
to append data, then use writeData: as you said.


But there's a caveat here - we currently have both big-endian and  
little-endian Macs running OS X and NSData doesn't deal with  
endianness automatically - that's our responsibility. There are ways  
to convert,  such as the byte ordering functions documented here:


http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html

or you could also store the length as a string:

NSString *lengthString = [NSString stringWithFormat:@"%d", theLength];
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager createFileAtPath:path contents:nil attributes:nil];
NSFileHandle *fileHandle = [NSFileHandle  
fileHandleForWritingAtPath:path[;
[fileHandle writeData:[lengthString  
dataUsingEncoding:NSUTF8StringEncoding]];

[fileHandle truncateFileAtOffset:[fileHandle seekToEndOfFile]];
[fileHandle writeData:myActualNSDataObject];

etc.

HTH. This is untested code typed in e-mail, so I suspect there are  
errors, but hopefully it will point you in the right direction.


Jeff

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: to write to file except NSData*

2008-04-15 Thread Alastair Houghton

On 15 Apr 2008, at 16:06, Navneet Kumar wrote:


ok,
so if i generate a header NSData object and write that to file, and  
then then write the larger NSData object,

how will i read one NSData after the another.
How will i know what length should I read.

excuse me if this sounds very newbie to you.


Well it depends on how you generate it.  You're probably right that  
it's a bit of an assumption that using a keyed archiver will result in  
the same sized NSData every time (or indeed that there will be any  
particular limit), so perhaps the OP is best served here by encoding  
the lengths manually in an NSMutableData and then writing that (since  
at least then the header size could be fixed).


Endianness problems, of course, would need to be dealt with.

Kind regards,

Alastair.

--
http://alastairs-place.net


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: is this badly written code?

2008-04-15 Thread I. Savant
>  Mr. IS:

  *Mister* Idiot Savant? I like that. ;-)

>My apologies. I have no desire to divert the list to some off-topic
>  subject.

  I'm not a moderator. Scott (Anguish) may have a different opinion
and his is what counts. It pains me, because I think it is a good
debate but one that will never end and isn't really Cocoa-specific.
;-)

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cannot get PDF document show up in PDFView

2008-04-15 Thread Mike R. Manzano

Look up -awakeFromNib.

// Called when
@implementation MyPDFView

[...]

// Called when this view is loaded from the nib
- (void) awakeFromNib
{
myDoc = [[[PDFDocument alloc] initWithURL: [ NSURL  
fileURLWithPath:@"Users/raj/Desktop/ObjectiveC.pdf"]] autorelease];


[self setDocument: myDoc];}
}

[...]

@end

A few comments: you don't need the (NSURL *) and (NSString *) casts.  
As with C, you only need to cast if the value you're passing in has a  
different type than expected by the method signature. NSStrings start  
with an '@". This looks like "learning" code, but in a real program,  
you probably wouldn't hard-code a path like that.


Cheers,

Mike


On Apr 15, 2008, at 4:57 AM, Rajeshwari Iyer wrote:


Hi,

I am a beginner with cocoa and am making an application where i want  
to display a PDF file in my app. window. I have subclassed PDFView  
to myPDFView and have attached a PDF view from interface builder to  
my window. Now how do i associate the PDF document that i want  
to display with this view? I came across this 2 line code to do  
this...


myDoc = [[[PDFDocument alloc] initWithURL: (NSURL *) [ NSURL  
fileURLWithPath: (NSString *)"Users/raj/Desktop/ObjectiveC.pdf"]]  
autorelease];


[pdfView setDocument: myDoc];

but i cannot understand where to add this in my sub class

can somebody please help?

THANKS!

___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: App fails to kill NSTask processes

2008-04-15 Thread Scott Ribe
> Whether I waitUntilExit or not makes no
> difference

Try waitpid after killing the process.

-- 
Scott Ribe
[EMAIL PROTECTED]
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Getting feedback from application

2008-04-15 Thread Mike R. Manzano
Please read one of the many fine tutorials on the subject, including  
this one: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/objctutorial.pdf


Regards,

Mike


On Apr 15, 2008, at 1:31 AM, parag vibhute wrote:


Hi guys,

I have created a cocoa application. Now I would like to have  
functionality
such that there will be a button, on clicking that application will  
send
feedback to me. Is there any class or any documentation available  
for this?


Please give your feedback/comments.

Thank,
Parag


___

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

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

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

This email sent to [EMAIL PROTECTED]


RE: is this badly written code?

2008-04-15 Thread john darnell
Okay, this is now definitely veering off topic.

Fearing an electronic punch in the nose, I did not want to call you
Mister Idiot, and I thought Mister Savant might be just a bit too lofty
so I compromised on Mister IS.

I hope that minor, gentle banter of this sort is never considered
off-topic.  It's what glues a community together...

Take care.

John

-Original Message-
From: I. Savant [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 15, 2008 10:20 AM
To: john darnell
Cc: cocoa-dev Developers
Subject: Re: is this badly written code?

>  Mr. IS:

  *Mister* Idiot Savant? I like that. ;-)

>My apologies. I have no desire to divert the list to some off-topic
>  subject.

  I'm not a moderator. Scott (Anguish) may have a different opinion
and his is what counts. It pains me, because I think it is a good
debate but one that will never end and isn't really Cocoa-specific.
;-)

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: is this badly written code?

2008-04-15 Thread glenn andreas


On Apr 15, 2008, at 9:25 AM, john darnell wrote:


2.)  Symmetry can add elegance to the visual aspect of your code, and
thus make it more pleasing to the eye, and easier to decipher. For
example, when I have a long list of includes, I often do this to them:

#include  
#include 
#include 




Note that not everybody uses monospaced fonts everywhere - this is,  
after all, the 21st century.  Especially considering that Xcode allows  
you to specify that different elements can be different fonts, styles,  
etc...  For example, I've got my comments to be in a more readable non- 
monospaced font, and language keywords are in a bold font, etc...  
(funny how long it took for "modern" development systems to support  
features that Think Pascal nearly 20 years ago)


I've even seen code where people used "ascii art fonts" for major  
comment section headers.  Needless to say, they are completely  
illegible with a non-monospaced font.


Using spaces to line up code is generally bad (tabs are somewhat  
better, but not perfect due to the whole "how many spaces per tab").


Maybe someday we'll be able to have real "word-processing style"  
formatting in source code so we can use real alignment rules, real  
table formatting, included image diagrams, etc... (and have semantic  
features so we won't have to rely on "comment markup" like HeaderDoc).




Glenn Andreas  [EMAIL PROTECTED]
  wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next  
generation of fractal art




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Memory leak when re-alloc Methods

2008-04-15 Thread Mike R. Manzano

Are you calling release on everything you've alloc'd and retain'd?

Mike

On Apr 14, 2008, at 4:05 PM, [EMAIL PROTECTED] wrote:


Hi and sorry for my bad english.

I have a nasty leak problem when i realloc several methods of the  
main class of my app.


I have a button that initiate a series of methods of my Main Model  
Class for initialize and display sprites.  In a NSView, when i alloc  
the class for the first time every is fine, no noticiables memory  
leak in the app, however when i press the button that call the  
methods more than one time the memory consumed by my app increase  
heavily, perhaps when i re alloc and initialize the same methods the  
older version is still live in the computer memory, i dont know, but  
i can tell you, in every class i have created i implemented a  
dealloc method releasing all my objects but the memory leak is still  
here, thanks for your time and your opinions about this bug.



Enviado desde mi BlackBerry de Movistar

___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Getting feedback from application

2008-04-15 Thread I. Savant
On Tue, Apr 15, 2008 at 11:25 AM, Mike R. Manzano <[EMAIL PROTECTED]> wrote:
> Please read one of the many fine tutorials on the subject, including this
> one:
> http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/objctutorial.pdf

  In addition, there is:

http://www.cocoadevcentral.com/

  ... this is **FULL** of information for Cocoa beginners in the form
of tutorials. These do seem to assume, though, that you're not a
beginner in programming in general (you do need to have at least a bit
of programming experience in order not to struggle) but they are
*very* well-written and illustrated.

  There is also:

http://www.cocoadev.com/

  ... this is full of more of the "how-to" one-off answers. Please
don't post questions there in the form of wiki pages, though - post
them on that site's forums or on this list. Otherwise you'll get
yelled at. :-}

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: is this badly written code?

2008-04-15 Thread Michael Ash
On Tue, Apr 15, 2008 at 2:09 AM, Adam Leonard <[EMAIL PROTECTED]> wrote:
>  Paraphrasing Wil Shipley (I believe), variables are variable. They are
> supposed to change. If you are just creating a temporary variable to use
> only in the next step, it seems unnecessarily wasteful. Your variable names
> (as you see) end up being the same as the methods you call on that line.

I must disagree strongly like this. The word "variable" is just a
name, not a prescription for use.

For example, consider the mathematical equation "3x + 2 = 0". The
variable x has only one possible value here, but it's still called a
variable.

In general, every time you modify a variable you have the potential to
write a bug or confuse a future reader of your code. It's very easy to
read the first assignment to a variable, miss the second one, then
read the end of the code still thinking that the first value is
present. This is bad.

Of course there are some places where such changes are required, such
as in loops. But it should be limited where it's possible to do so.

If you find yourself changing the value of a variable in an arbitrary
place (i.e. not building up the value over the course of a couple of
adjacent lines or using a variable as a loop variant) consider whether
it might be better to simply declare a new variable for this new use.

And in going with my earlier post in this thread, if you find yourself
doing a lot of this kind of thing, consider whether it's a signal to
redesign. If your code is getting so complex that you need to start
asking these questions, maybe it's time to break it up. Personally I
find it much easier to read code consisting of 10 5-line methods than
of 1 50-line method.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: is this badly written code?

2008-04-15 Thread I. Savant
  "Idiot" is fine. ;-)

>  I hope that minor, gentle banter of this sort is never considered
>  off-topic.  It's what glues a community together...

  For the record, I think banter is safe, so long as it's accompanied
by relevance. Agreed 100% on the 'community glue' sentiment. Most of
us really *are* nice guys ...

  Oh ... er ... this is a way to create an autoreleased instance of NSObject:

id objectInstance = [[[NSObject alloc] init] autorelease];

  Alright, I really am done hypocritically contributing to a thread I
oh-so-righteously labeled off-topic. ;-)

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: is this badly written code?

2008-04-15 Thread Jean-Daniel Dupas


Note that not everybody uses monospaced fonts everywhere - this is,  
after all, the 21st century.  Especially considering that Xcode  
allows you to specify that different elements can be different  
fonts, styles, etc...  For example, I've got my comments to be in a  
more readable non-monospaced font, and language keywords are in a  
bold font, etc... (funny how long it took for "modern" development  
systems to support features that Think Pascal nearly 20 years ago)


I've even seen code where people used "ascii art fonts" for major  
comment section headers.  Needless to say, they are completely  
illegible with a non-monospaced font.


Using spaces to line up code is generally bad (tabs are somewhat  
better, but not perfect due to the whole "how many spaces per tab").


Maybe someday we'll be able to have real "word-processing style"  
formatting in source code so we can use real alignment rules, real  
table formatting, included image diagrams, etc... (and have semantic  
features so we won't have to rely on "comment markup" like HeaderDoc).


Though we have to reinvent source code format to reach this goal, and  
as we are in 2008 and sources files are plain ASCII or UTF-8 files, I  
doubt we will see this kind of feature until . (choose your decade).




2.)  Symmetry can add elegance to the visual aspect of your code, and
thus make it more pleasing to the eye, and easier to decipher. For
example, when I have a long list of includes, I often do this to  
them:


#include  
#include 
#include 


personnaly i prefere to sort line by size ;-)

#include  
#include 
#include  


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Memory leak when re-alloc Methods

2008-04-15 Thread I. Savant
>  I have a nasty leak problem when i realloc several methods of the main class 
> of my app.

  Without seeing your code, all I can suggest is making sure you've
followed these rules:

http://devworld.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html#

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: is this badly written code?

2008-04-15 Thread Johnny Lundy
My Cocoa coding is for hobby only, and only for about 4 years, so I do  
not have experience with working in teams or on multi-developer  
projects.


But I see this issue in other development environments of recent issue  
as well. Apple has provided a rich set of finely-granulated APIs,  
which allow a huge amount of flexibility and customization. The  
downside of this (true with the Carbon C APIs as well) is that to do a  
simple thing involves calling 3 or 4 APIs just to set the "default"  
values for pieces of the final method call that you want.


Here's an example I just finished. All I want is to retrieve 14 bytes  
of data from accessing a single URL. In a shell script I could do it  
with one "curl" call. In Cocoa, I have to


1) Make a string into an NSURL
2) Make an NSURLRequest from the NSURL
3) Call the convenience method "[NSURLConnection  
sendSynchronousRequest:..." to avoid having to even further specify  
details about what I want to do.


So this comes down to

[NSURLConnection sendSynchronousRequest: [NSURLRequest requestWithURL:  
[NSURL URLWithString: @"http://random.org/integers/?num=1&min=1&max=4&col=5&base=10&format=plain&rnd=new 
"]] returningResponse: NULL error:NULL];


Now that is going to be a bitch to debug if I write it that way to  
begin with, because there is no way to get the intermediate values  
without putting expressions in the gdb console. So I have developed  
the habit of doing it in the following way:


1) Write each portion of the code by assigning to intermediate ivars.  
This of course is easiest if you just type them in-line as you write  
them, but then of course they will not show up in the debugger so it  
is better to go ahead and type them in the @interface section.


(As an aside, wouldn't it be great if Xcode had a feature to add ivar  
declarations to @interface based on what you selected - e.g. select  
the "NSString *foo" part of a statement "NSString *foo = [NSString  
string]" statement and Xcode would automatically add "NSString *foo;"  
to the @interface and remove the characters up to the "f" in "foo"  
from the selected statement. I find myself doing this about 50 times a  
day.)


2) Debug the code block. If it runs correctly, then I am left with  
these single-use ivars which clog up my header file and make it  
difficult for another person to tell which is the real result  
variable. They also have to keep referring back to the intermediate  
vars to see what their values are in order to interpret the main API  
call. It becomes harder and harder to construct names for these ivars  
as they all have very similar contents and purposes. So you wind up  
with ivars named  
"voterCountForVoterAfterRandomChoiceIsMadeButBeforeFinalSorting" and  
so forth.


3) For each ivar that I used, I copy the right side of the assignment  
statement and paste it in place of the name of the ivar in the  
subsequent code lines.


4) Then after testing the new code, I delete all the ivar assignments  
and delete their definitions from @interface.


N.B.: I don't do this if the intermediate variables are used more than  
once in the final code call - in those cases I leave the variable name  
in there to avoid calculating it more than once.


What would be great is if Apple would give us many more convenience  
methods that pared it down to the most common things - like a "-  
(NSStriing *) NSSynchronousURLFetch:(NSString *)theURL" method that  
just takes a string which represents the URL and returns a string  
which is the content at that URL.


I'd also be very interested in others' views on this.



Date: Mon, 14 Apr 2008 22:53:16 -0400
From: "Adam Gerson" <[EMAIL PROTECTED]>
Subject: is this badly written code?
To: "cocoa-dev@lists.apple.com" 
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1

In cocoa its very tempting to write a single line of code like:
NSManagedObject *selectedTreeObject = [self delegate]
mainWindowController] treeController] selectedObjects]
objectAtIndex:0];

or to flush it out in to individual lines:

NSWindowController *mainWindow = [[self delegate]  
mainWindowController];

NSTreeController *treeController = [mainWindow treeController];
NSArray *selectedTreeObjects = [treeController selectedObjects];
NSManagedObject *selectedTreeObject =  [selectedTreeObjects  
objectAtIndex:0];


I am looking for some guidance on best practices in a situation with a
lot of nested calls like this. If ultimately the only value I care
about is the final one, selectedTreeObject, whats the best way to go
about getting it? I know "best" is a subjective word. Interested to
hear all of your opinions.

Adam

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/option

RE: is this badly written code?

2008-04-15 Thread john darnell


-Original Message-

>> 2.)  Symmetry can add elegance to the visual aspect of your code, and
>> thus make it more pleasing to the eye, and easier to decipher. For
>> example, when I have a long list of includes, I often do this to  
>> them:
>>
>> #include  
>> #include 
>> #include 

personnaly i prefere to sort line by size ;-)

#include  
#include 
#include  

[John Darnell says:] Yeah, that would work, too.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: is this badly written code?

2008-04-15 Thread Jean-Daniel Dupas


Le 15 avr. 08 à 17:44, Johnny Lundy a écrit :
My Cocoa coding is for hobby only, and only for about 4 years, so I  
do not have experience with working in teams or on multi-developer  
projects.


But I see this issue in other development environments of recent  
issue as well. Apple has provided a rich set of finely-granulated  
APIs, which allow a huge amount of flexibility and customization.  
The downside of this (true with the Carbon C APIs as well) is that  
to do a simple thing involves calling 3 or 4 APIs just to set the  
"default" values for pieces of the final method call that you want.


Here's an example I just finished. All I want is to retrieve 14  
bytes of data from accessing a single URL. In a shell script I could  
do it with one "curl" call. In Cocoa, I have to


1) Make a string into an NSURL
2) Make an NSURLRequest from the NSURL
3) Call the convenience method "[NSURLConnection  
sendSynchronousRequest:..." to avoid having to even further specify  
details about what I want to do.


So this comes down to

[NSURLConnection sendSynchronousRequest: [NSURLRequest  
requestWithURL: [NSURL URLWithString: @"http://random.org/integers/?num=1&min=1&max=4&col=5&base=10&format=plain&rnd=new 
"]] returningResponse: NULL error:NULL];


Now that is going to be a bitch to debug if I write it that way to  
begin with, because there is no way to get the intermediate values  
without putting expressions in the gdb console. So I have developed  
the habit of doing it in the following way:


1) Write each portion of the code by assigning to intermediate  
ivars. This of course is easiest if you just type them in-line as  
you write them, but then of course they will not show up in the  
debugger so it is better to go ahead and type them in the @interface  
section.


(As an aside, wouldn't it be great if Xcode had a feature to add  
ivar declarations to @interface based on what you selected - e.g.  
select the "NSString *foo" part of a statement "NSString *foo =  
[NSString string]" statement and Xcode would automatically add  
"NSString *foo;" to the @interface and remove the characters up to  
the "f" in "foo" from the selected statement. I find myself doing  
this about 50 times a day.)


2) Debug the code block. If it runs correctly, then I am left with  
these single-use ivars which clog up my header file and make it  
difficult for another person to tell which is the real result  
variable. They also have to keep referring back to the intermediate  
vars to see what their values are in order to interpret the main API  
call. It becomes harder and harder to construct names for these  
ivars as they all have very similar contents and purposes. So you  
wind up with ivars named  
"voterCountForVoterAfterRandomChoiceIsMadeButBeforeFinalSorting" and  
so forth.


3) For each ivar that I used, I copy the right side of the  
assignment statement and paste it in place of the name of the ivar  
in the subsequent code lines.


4) Then after testing the new code, I delete all the ivar  
assignments and delete their definitions from @interface.


N.B.: I don't do this if the intermediate variables are used more  
than once in the final code call - in those cases I leave the  
variable name in there to avoid calculating it more than once.


What would be great is if Apple would give us many more convenience  
methods that pared it down to the most common things - like a "-  
(NSStriing *) NSSynchronousURLFetch:(NSString *)theURL" method that  
just takes a string which represents the URL and returns a string  
which is the content at that URL.


[[NSString alloc] initWithContentsOfURL:[NSURL urlWithString:myString]  
usedEncoding:NULL error:NULL];


OK, it takes an URL and not a string as argument…



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Getting feedback from application

2008-04-15 Thread Matt Long

This might help you: http://www.matthew-long.com/2007/11/09/xcode-30-tutorial/

It's a bit shorter tutorial than the Apple one.

-Matt



On Apr 15, 2008, at 9:25 AM, Mike R. Manzano wrote:

Please read one of the many fine tutorials on the subject, including  
this one: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/objctutorial.pdf


Regards,

Mike


On Apr 15, 2008, at 1:31 AM, parag vibhute wrote:


Hi guys,

I have created a cocoa application. Now I would like to have  
functionality
such that there will be a button, on clicking that application will  
send
feedback to me. Is there any class or any documentation available  
for this?


Please give your feedback/comments.

Thank,
Parag


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/matt.long%40matthew-long.com

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: is this badly written code?

2008-04-15 Thread Michael Ash
On Tue, Apr 15, 2008 at 11:44 AM, Johnny Lundy <[EMAIL PROTECTED]> wrote:
>  What would be great is if Apple would give us many more convenience methods
> that pared it down to the most common things - like a "- (NSStriing *)
> NSSynchronousURLFetch:(NSString *)theURL" method that just takes a string
> which represents the URL and returns a string which is the content at that
> URL.

Nothing stops you from making such methods yourself. In fact, if
you're writing the long version more than once, that's exactly what
you ought to be doing. Using categories you can even make it look like
a "real" method on the class where it best belongs.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Getting feedback from application

2008-04-15 Thread Quincey Morris
I suspect the OP was asking about adding a button to an application  
that, when clicked by a user, would send feedback ("Your software  
sucks!") to the developer.


--

On Apr 15, 2008, at 09:01, Matt Long wrote:


This might help you: http://www.matthew-long.com/2007/11/09/xcode-30-tutorial/

It's a bit shorter tutorial than the Apple one.

-Matt



On Apr 15, 2008, at 9:25 AM, Mike R. Manzano wrote:

Please read one of the many fine tutorials on the subject,  
including this one:http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/objctutorial.pdf


Regards,

Mike


On Apr 15, 2008, at 1:31 AM, parag vibhute wrote:


Hi guys,

I have created a cocoa application. Now I would like to have  
functionality
such that there will be a button, on clicking that application  
will send
feedback to me. Is there any class or any documentation available  
for this?


Please give your feedback/comments.

Thank,
Parag




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Capture mouse events globally

2008-04-15 Thread Kyle Sluder
On Tue, Apr 15, 2008 at 7:41 AM, Apparao Mulpuri
<[EMAIL PROTECTED]> wrote:
> Is three any way to capture mouse events globally from my background app.

1) Why are you doing this?  I'm curious.
2) See Quartz Event Taps:
http://developer.apple.com/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Using the debugger with local variables was Re: is this badly written code?

2008-04-15 Thread Erik Buck
>1) Write each portion of the code by assigning to intermediate ivars.  
>This of course is easiest if you just type them in-line as you write  
>them, but then of course they will not show up in the debugger so it  
> is better to go ahead and type them in the @interface section.

Say what ?  Local variables show up perfectly fine in the debugger.  Creating 
an instance variable just to store intermediate results is of dubious value.

Even with nested messages, no special magic is needed.  To see intermediate 
values, just use the po command.  

> po [NSURL URLWithString:@"somestring"]
> po [NSURLRequest requestWithURL:[NSURL URLWithString: @"somestring"]]

I also highly recommend F-Script for this type of interactive 
testing/debugging: http://www.fscript.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: App fails to kill NSTask processes

2008-04-15 Thread Alexander Reichstadt
Thanks, had found wait(0) to work along with changing from thread to  
timer in some cases. The zombies are gone now.

On Apr 15, 2008, at 5:23 PM, Scott Ribe wrote:


Whether I waitUntilExit or not makes no
difference


Try waitpid after killing the process.

--
Scott Ribe
[EMAIL PROTECTED]
http://www.killerbytes.com/
(303) 722-0567 voice






smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: [ANN] Port mapping/forwarding framework (MIT license)

2008-04-15 Thread Jens Alfke


On 15 Apr '08, at 5:40 AM, Dominik Wagner tcm wrote:

We here at TheCodingMonkeys like to announce that we published an  
open-source framework for port mapping today: TCMPortMapper. It's  
MIT licensed and supports NAT-PMP and UPNP capable routers.


FYI, there's already some support for this built into 10.5. The lowest- 
level Bonjour API  has a new function called  
DNSServiceNATPortMappingCreate that talks to routers to open ports.


There's a bit of reference documentation, but I don't think anyone's  
ever specifically pointed out that this exists, so it probably went  
overlooked among the zillions of other API additions in Leopard.


http://developer.apple.com/documentation/Networking/Reference/DNSServiceDiscovery_CRef/dns_sd/CompositePage.html#/ 
/apple_ref/c/func/DNSServiceNATPortMappingCreate


By coincidence, just before I left Apple last December I submitted a  
piece of sample code that's a small Cocoa wrapper around this API; but  
it never made it to the outside world. I've just pinged ADC to see if  
they can un-stick it.


Of course the advantages of TheCodingMonkeys' library are
• It supports 10.4
• It allows you to find the identity of the router, for location- 
awareness

• It comes with full source code
• Cocoa wrapper available today

Conversely, the advantages of using the system API are
• Less code to add to your app
• Implementation will be automatically updated by Apple to fix bugs  
(always a good thing with networking code!)


I'll notify the list when (if?) the sample code gets released. In the  
interim I'll gladly offer advice to anyone wanting to work with the  
Leopard API.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: Using the debugger with local variables was Re: is this badly written code?

2008-04-15 Thread I. Savant
  >  Say what ?  Local variables show up perfectly fine in the
debugger.  Creating an instance variable just to store intermediate
results is of dubious value.
>
>  Even with nested messages, no special magic is needed.  To see intermediate 
> values, just use the po command.
>
>  > po [NSURL URLWithString:@"somestring"]
>  > po [NSURLRequest requestWithURL:[NSURL URLWithString: @"somestring"]]
>
>  I also highly recommend F-Script for this type of interactive 
> testing/debugging: http://www.fscript.org/

  Meh. The moderators don't seem to think this is off-topic, so I'll
shove my opinion into some unspecified orifice and join in. Though I
think this part is suited to xcode-users, I'll bite:

  Why put in the extra work for intermediate changes (especially if
you are monitoring a lot of changes in a tight loop of many
iterations) by typing po a million times? You can't see "[NSURL
URLWithString:@"somestring"]" for instance in your variable list
without it and typing it at each iteration is ridiculous. Even if you
automate it by setting an action at a breakpoint, the output is in the
run log and not at some useful place in your variable list. This is
*almost* as bad as using a crapload of NSLog() statements to debug and
skipping the debugger altogether, IMO. :-)

  Don't get me wrong, Eric (I'm not meaning to be confrontational),
your method works, but it's just not as efficient as writing
easily-digested lines of code, the products of which show up in one
neat list, easily explored and modified with the GUI app you're using
for your development. In short, this is not a modern solution.

  In the grand scheme, it costs you nothing to be verbose in this case
(using a variable) when your code is compiled. Unless you write
perfect code all the time, at some point you're going to need to debug
something that you've cleverly condensed from fifty lines into a
single line. If you've done so, kudos; you win the obfuscation prize.
Now try to debug it quickly and efficiently using a bunch of po's. ;-)

  Not everything has to be spaced out and named like so:

NSString * string1 = @"Pedantic planning produces pathetic processes";
NSString * string2 = [string1 stringByAppendingString:@" posthumously
predicating pathetic procedures"];
NSString * string3 = [string2 stringByAppendingString:@" precluding
practical productivity"];
NSString * string4 = [string3 stringByAppendingString:@"."];

  That would be ... prediculous. ;-) However, some small nested set of
commands that are easily-read and produce a well known object with a
set of at least fairly-well-known objects are about as deep as you'd
want to go so *visual* debugging is easier (with my apologies for the
lack of uniform e-mail fonts forcing me to put this all inline):

NSDictionary * d = [NSDictionary dictionaryWithObjectsAndKeys:[NSArray
arrayWithObjects:@"one", @"two", @"three", nil], @"stuff", [NSColor
redColor], @"roxanne", @"Microsoft", @"evil", nil];

  Here we're creating several objects (one of which is a list of other
objects) in the middle of creating another object. This wouldn't be
quick and easy to visually debug (and I rarely do such things for that
very reason) but it's not that hard to pick apart if you find
problems. A simple drag-and-drop operation and a few typed characters,
followed by a click on the old fix-and-continue button and it's
magically an order of magnitude (figures approximate) easier to debug
visually. I wouldn't want to get too much more complicated than that
for fear of my "nest" becoming a "rat's nest".

  My idiot $0.02.*

--
I.S.

* Idiot currency not good on any continent, island, body of water, or airspace.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Using the debugger with local variables was Re: is this badly written code?

2008-04-15 Thread John Stiles
IS makes a good point. Moreover, if you have some method which has a 
side effect or which might not return the same result every time, "po" 
is no good for debugging it. These simplistic examples (creating a URL 
from a string) will work the same no matter how many times you execute 
them, but a lot of real code isn't that simple.


We have an open radar for this issue:

rdar://5546527   [Xcode 3, Debugger] ER: please display return value 
when returning from a function

Developer Tools
Enhancement
17-Oct-2007 05:54 PM
Duplicate/2459838

Looks like this has been an issue for a while, if the dupe number starts 
with a 2 :)
Anyway, Dev Studio gets this right—the variable list adds a temporary 
entry when any function returns:


   "MyClass::MyFunc returned: 12345"

And let me tell you, it's super useful!
If you think this would be useful too, please file a radar and let them 
dupe it :)



I. Savant wrote:

  >  Say what ?  Local variables show up perfectly fine in the
debugger.  Creating an instance variable just to store intermediate
results is of dubious value.
  

 Even with nested messages, no special magic is needed.  To see intermediate 
values, just use the po command.

 > po [NSURL URLWithString:@"somestring"]
 > po [NSURLRequest requestWithURL:[NSURL URLWithString: @"somestring"]]

 I also highly recommend F-Script for this type of interactive 
testing/debugging: http://www.fscript.org/



  Meh. The moderators don't seem to think this is off-topic, so I'll
shove my opinion into some unspecified orifice and join in. Though I
think this part is suited to xcode-users, I'll bite:

  Why put in the extra work for intermediate changes (especially if
you are monitoring a lot of changes in a tight loop of many
iterations) by typing po a million times? You can't see "[NSURL
URLWithString:@"somestring"]" for instance in your variable list
without it and typing it at each iteration is ridiculous. Even if you
automate it by setting an action at a breakpoint, the output is in the
run log and not at some useful place in your variable list. This is
*almost* as bad as using a crapload of NSLog() statements to debug and
skipping the debugger altogether, IMO. :-)

  Don't get me wrong, Eric (I'm not meaning to be confrontational),
your method works, but it's just not as efficient as writing
easily-digested lines of code, the products of which show up in one
neat list, easily explored and modified with the GUI app you're using
for your development. In short, this is not a modern solution.

  In the grand scheme, it costs you nothing to be verbose in this case
(using a variable) when your code is compiled. Unless you write
perfect code all the time, at some point you're going to need to debug
something that you've cleverly condensed from fifty lines into a
single line. If you've done so, kudos; you win the obfuscation prize.
Now try to debug it quickly and efficiently using a bunch of po's. ;-)

  Not everything has to be spaced out and named like so:

NSString * string1 = @"Pedantic planning produces pathetic processes";
NSString * string2 = [string1 stringByAppendingString:@" posthumously
predicating pathetic procedures"];
NSString * string3 = [string2 stringByAppendingString:@" precluding
practical productivity"];
NSString * string4 = [string3 stringByAppendingString:@"."];

  That would be ... prediculous. ;-) However, some small nested set of
commands that are easily-read and produce a well known object with a
set of at least fairly-well-known objects are about as deep as you'd
want to go so *visual* debugging is easier (with my apologies for the
lack of uniform e-mail fonts forcing me to put this all inline):

NSDictionary * d = [NSDictionary dictionaryWithObjectsAndKeys:[NSArray
arrayWithObjects:@"one", @"two", @"three", nil], @"stuff", [NSColor
redColor], @"roxanne", @"Microsoft", @"evil", nil];

  Here we're creating several objects (one of which is a list of other
objects) in the middle of creating another object. This wouldn't be
quick and easy to visually debug (and I rarely do such things for that
very reason) but it's not that hard to pick apart if you find
problems. A simple drag-and-drop operation and a few typed characters,
followed by a click on the old fix-and-continue button and it's
magically an order of magnitude (figures approximate) easier to debug
visually. I wouldn't want to get too much more complicated than that
for fear of my "nest" becoming a "rat's nest".

  My idiot $0.02.*

--
I.S.

* Idiot currency not good on any continent, island, body of water, or airspace.
___

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

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

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

This email sent to [EMAIL PROTECTED]
  


Re: Cannot Remove Observer Error

2008-04-15 Thread Mark Piccirelli
How are KVO notifications for the Wine class' wineType property being  
done? KVO is complaining that not enough of them are being sent out.  
The rule for KVO-compliance in this case is that something must do  
[wine willChangeValueForKey:@"wineType"] before the value returned by  
[wine valueForKey:@"wineType"] would change and then something must  
invoke [wine didChangeValueForKey:@"wineType"] after the value  
returned by [wine valueForKey:@"wineType"] has changed. Automatic KVO  
notification does that, but only for changes done with [wine  
setWineType:aWineType], if there is such a method, or [wine  
setValue:aWineType forKey:@"wineType"]. If the wine type is stored in  
an instance variable and something changes the value of that ivar  
without doing -willChangeValueForKey:/-didChangeValueForKey: you'll  
get this exception.


What changed in your app? One guess is that nothing was observing any  
Wine's "wineType.name" before but you're now doing something different  
with Cocoa Bindings that is causing it to be observed.


-- Mark

On Apr 14, 2008, at 6:12 PM, Thaddeus Cooper wrote:
Starting earlier today, I started getting the following error in my  
software.


2008-04-14 17:59:41.535 WineCellar[4928:10b] Cannot remove an  
observer  for the key path "wineType.name 
" from , most likely because the value for the key  
"wineType" has changed without an appropriate KVO notification being  
sent. Check the KVO-compliance of the Wine class.


I haven't changed anything significant (well at least I don't think  
I did) and I definitely have not been messing around with the  
WineArrayController and/or the Wine classes. I can't figure out how  
to track this error down -- I've tried a number of things including  
putting a removeObserver:forKeyPath method in the array controller  
so I could look at the back trace and I've also put in enter and  
exit debug messages in a large portion of the code. Still the error  
seems to come from nowhere and I am stumped as to how I might find  
what the root cause of the problem is.


Does anyone have any suggestions as to how to track down this type  
of error.


Thanks very much.

Thaddeus O. Cooper
([EMAIL PROTECTED])



___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Using the debugger with local variables was Re: is this badly written code?

2008-04-15 Thread I. Savant
> These simplistic examples (creating a URL from a string)
> will work the same no matter how many times you execute them, but a lot of
> real code isn't that simple.

  Well *THANK* you, John! ;-)  Indeed as I was finishing up that
sermon and packing up my soapbox, I thought of the many shortcomings
of using string assignment and appendage (is that the right word?) but
I trust my meaning was clear.

  Your example is better - something I hadn't thought of. Something as
simple as -[myWidget explodeHamster] is clearly destructive to your
Hamster* which may hinder future debugging attempts. Perhaps even
better is -[myHamster multiplyEyesByTheTimeOfDay:] ... how many eyes
did your hamster have before? That's easy enough to see in the
debugger. How many will it have now? Well probably more (or less at
and just after noon or midnight) than it had before, that's for sure
...

  The point is, for debugging, nothing is easier than seeing (at a
glance) your variable and its value in a convenient list in your
debugger and being able to modify that (to see what happens if your
hamster has twenty-eight eyes and the time is given in 24-hour mode
versus 12-hour for that particular trip through your for loop.

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


binary search trees & binning

2008-04-15 Thread Boyd Collier

Hello all,

I need to place many thousands of doubles into size-class groups whose  
boundaries can be explicitly specified (much like one would do in  
constructing a histogram, though that's not what I'm doing).  The  
number of size-classes won't be great, usually fewer than 100, say.   
It occurred to me that using a binary search tree would be a  
reasonably simple approach, and I've down-loaded some code from  
LiteratePrograms to do this.  However, before trying to use this code,  
I thought I'd ask whether someone has done this sort of thing using  
various parts of Cocoa.


Thanks, Boyd
___

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

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

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

This email sent to [EMAIL PROTECTED]


[OT: security] smbclient

2008-04-15 Thread Stuart Malin
[sorry to post here, but I don't know what other list might be better/ 
more appropriate]


I run Little Snitch and it has popped up that smbclient wants to  
connect to some server (169.254.44.184) on port 139 (netbios-ssn).  
That IP doesn't resolve when I try to reverse lookup. I'm concerned  
about a potential security breach on my machine as I don't do  
anything with Windows on my machine or local network. Any suggestions  
about how I can learn further about this situation would be  
appreciated. (I'm running Tiger 10.4.11).

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [OT: security] smbclient

2008-04-15 Thread I. Savant
Stuart:

> [sorry to post here, but I don't know what other list might be better/more
> appropriate]

  This list is for Cocoa developers to talk about software
development. Not only do we know nothing about your computer's
configuration or your network environment, but it has positively
nothing to do with what is discussed on this list. You're essentially
walking into a random building asking for computer advice. ;-)

  A better place to post your question would be on one of the many
Mac-related support forums such as Apple's own support forums,
macfixit.com, etc.

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [OT: security] smbclient

2008-04-15 Thread Dave Camp

On Apr 15, 2008, at 12:52 PM, Stuart Malin wrote:
[sorry to post here, but I don't know what other list might be  
better/more appropriate]


I'd suggest the network list, since it's a network question...

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

This email sent to [EMAIL PROTECTED]


[ANN] JSKit - JavaScript Embedding Framework

2008-04-15 Thread glenn andreas
The first beta version of JSKit, an open sourced (MIT license)  
framework for embedding JavaScript inside Cocoa applications is now  
available at .


JSKit provides Objective-C wrappers around the lower level  
JavaScriptCore (available on 10.5 and 10.4 with Safari 3.0) and  
provides transparent two way bridging technologies, allowing you to  
call JavaScript objects from Objective-C and to write Objective-C that  
can be called from JavaScript (including both simple functions as well  
as full type-constructors).  JSKit is designed as a layered system  
with "opt-in" capabilities, making it well suited to using it as a  
macro/embedding/scripting solution for a Cocoa app, with explicit  
"exposing" of your Cocoa code code to JavaScript world (preventing  
malicious JavaScript from subverting your app).  Additional layers can  
be added to expose generic NSObject classes, and later versions will  
include the ability to write entire Cocoa apps in JavaScript.


JSKit also includes a simple command line interactive interpreter (for  
making JavaScript shell scripts), as well as utility classes for  
simple JavaScript savvy editors, and a fun little "turtle graphics"  
sample app (demonstrates how to use JavaScript as a scripting  
extension language in your app).


JSKit can be built and used by XCode 2.4 running on Tiger (with Safari  
3.0 installed), as well as 2.5 and 3.0 running on Leopard.


Glenn Andreas  [EMAIL PROTECTED]
  wicked fun!
quadrium | flame : flame fractals & strange attractors : build,  
mutate, evolve, animate




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSAllocateCollectable() questions

2008-04-15 Thread Greg Parker

Brendan Younger wrote:
I've been writing a library that uses NSAllocateCollectable() quite  
a bit and I have a few questions about proper usage.



For those of you playing along at home, let me summarize the reasons  
for the garbage collector's special functions.


Some heap blocks are "GC-managed". The garbage collector will destroy  
a GC-managed block if no pointers to it are found during the GC's  
scan. NSAllocateCollectable() and [NSObject alloc] return GC-managed  
blocks. malloc() does not.


Some memory areas are "GC-scanned". The garbage collector will look in  
these regions for interesting pointer values.  
NSAllocateCollectable(NSScannedOption) returns a block of scanned  
memory. NSAllocateCollectable(no NSScannedOption) and malloc() do not;  
their contents are invisible to the garbage collector.


The Rule for Write Barriers:

If you write a pointer to a GC-managed block into GC-scanned heap  
memory, you must use an appropriate write barrier.


Why? Speed. Write barriers allow the garbage collector to cheat, like  
not scanning large swaths of memory, or allowing other threads to  
continue running (and modifying memory) while a scan is in progress.  
Without write barriers, the collector might miss a pointer because  
it's cheating.


Usually, the compiler does this for you. If `variable` is of an  
Objective-C object type or a __strong pointer type, and you write  
`variable = value`, then the compiler will emit an appropriate write  
barrier for you.


Note that __weak memory, and memory outside the heap like globals and  
thread stacks, are all handled differently.




- Copying data
if I am copying to a malloc'd block, I can use memmove() regardless  
of whether the source is GC'd or not, right?
if I am copying to a GC block allocated with nonscanned memory, I  
can use memmove(), right?


Correct. If you're writing to GC-unscanned heap memory, then you don't  
need a write barrier. Of course, the contents of the malloc block and  
managed-but-unscanned block are invisible to the garbage collector, so  
you need to be wary of writing GC-managed pointers into it.



if I am copying to a GC block allocated with NSScannedOption, I need  
to use objc_memmove_collectable(), right?


Correct. The only exception is if the memory being copied contains no  
GC-managed pointer values then you may use memmove(). If you're not  
sure, use objc_memmove_collectable().




- Zero'ing data
There does not seem to be a GC-compatible bzero(). If I loop through  
and zero out each pointer in a scanned block, that would generate a  
write barrier for each pointer which is expensive. However, if I use  
bzero(), then libauto won't know that I've messed with the block.  
Will it eventually figure it out when it does an exhaustive scan? Or  
will it never notice that I've zero'd out the block?


You don't need a write barrier when erasing GC-scanned memory. The  
write barrier helps the collector see pointers that it might otherwise  
miss because it's cheating. It does not help the collector "forget" a  
value that it saw previously. (In particular, the old pointer value  
might be gone from the zeroed location, but without re-scanning  
everything there's no way to know that it doesn't still exist  
somewhere else.)



--
Greg Parker [EMAIL PROTECTED] Runtime Wrangler


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data for managing subtree?

2008-04-15 Thread Hamish Allan
Ben,

Thanks for your reply.

On Sun, Apr 13, 2008 at 11:54 PM, Ben Trumbull <[EMAIL PROTECTED]> wrote:

>  If you only want only some of the tree using Core Data objects, you could
> try having an array controller manage the extra entity, and wire its content
> into your tree controller.

Could you please elaborate on "wire its content into your tree controller"?

I have an array controller in entity mode managing the objects I want
the user to be able to add and remove from the user-editable part of
the source list. So far, so good. But to get that array to appear as
the children of one the nodes of that outline view, I have tried each
of the following (in SourceListController's awakeFromNib):

1)

NSMutableDictionary *sectionNode =
  [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"SECTION", @"displayName",
[NSNumber numberWithBool:FALSE], @"isLeaf",
nil];
[self setUserEditableObjects:[sectionNode mutableSetValueForKey:@"children"]];
mySourceListData = [[NSArray alloc] initWithObjects:sectionNode, nil];

Then in addition to binding the array controller's Managed Object
Context, I also bind its Content Set to the userEditableObjects of the
SourceListController. (I thought this might cause duplication, but I
thought I'd try it anyway.)

2)

NSMutableDictionary *sectionNode =
  [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"SECTION", @"displayName",
[NSNumber numberWithBool:FALSE], @"isLeaf",
nil];
[sectionNode bind:@"children" toObject:/*(IBOutlet)*/myArrayController
  withKeyPath:@"content" options:nil];
mySourceListData = [[NSArray alloc] initWithObjects:sectionNode, nil];

(I'm not sure whether myArrayController.content makes sense in entity
mode, either.)

Both of these attempts failed silently, i.e., just failed to display
anything in my source list when I added an item through the array
controller, but without logging a complaint.

So how can I wire the array controller's content into my tree controller?

Thanks,
Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [OT: security] smbclient

2008-04-15 Thread Jens Alfke


On 15 Apr '08, at 12:52 PM, Stuart Malin wrote:

I run Little Snitch and it has popped up that smbclient wants to  
connect to some server (169.254.44.184)


169.254.*.* is the self-assigned address range. If a computer connects  
to a LAN but finds no router or DHCP server on it (and it doesn't have  
a static address configured), it'll pick a random IP address out of  
that range. This allows a group of computers on a bare Ethernet, or a  
computer-to-computer AirPort network, use TCP/IP with no special  
configuration.



on port 139 (netbios-ssn).


I think this is part of Windows' LAN support, a DHCP-like protocol for  
configuring local networks. Not sure why the smbclient would be trying  
to connect to it, or even running at all.


—Jens

PS: Just replying here so this thread doesn't get left dangling as  
some scary "OMG a virus" thing. But further follow-ups should  
definitely go someplace else.

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: [ANN] JSKit - JavaScript Embedding Framework

2008-04-15 Thread Jens Alfke


On 15 Apr '08, at 1:07 PM, glenn andreas wrote:

JSKit provides Objective-C wrappers around the lower level  
JavaScriptCore (available on 10.5 and 10.4 with Safari 3.0) and  
provides transparent two way bridging technologies, allowing you to  
call JavaScript objects from Objective-C and to write Objective-C  
that can be called from JavaScript


What are the pros and cons compared to the existing JS/Cocoa bridging  
found in ?


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Frameworks in bundles?

2008-04-15 Thread Thomas Backman

Hi everybody.
I'm writing a plugin architecture for my app. I just moved a class  
from the main project to a new Bundle project, and got 18 errors  
because of a few missing frameworks. I'm using two frameworks that I  
ship with the app, since they're not included in OS X.
To start with, I'll have three plugins, all of which require those  
frameworks.
Now, that means that the three plugins, each with only 100-150 lines  
of code, need 4MB worth of frameworks... Is there a way to get around  
this without making it ugly, to include the frameworks *once*?


Obviously, it'd be great if the solution meant that plugin developers  
wouldn't have to include the frameworks as well...

Any ideas?

Regards,
Thomas
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: "hooking" into another app

2008-04-15 Thread Jens Alfke


On 14 Apr '08, at 2:39 PM, Bill Cheeseman wrote:


However, the
Accessibility API is also wonderfully useful for doing lots of other  
things,
such as hooking into a text chat window so that you can log the  
incoming

messages.


I'm not so enthusiastic about it … it's basically the GUI equivalent  
of Application Enhancer, or of HTML screen-scraping. Just as searching  
through the raw HTML of a website isn't a reliable way to get  
information from the server, groping through the views of another app  
isn't a reliable way to interact with it. In both cases, there's  
nothing to keep the layout of the user interface from changing in the  
future, and even minor changes that don't have a visual effect could  
break anything that's groping inside them. (For example, if the order  
of two buttons gets changed around for some reason in a nib, something  
using the accessibility API to drive those buttons is going to end up  
pressing the wrong one.)


I understand that sometimes there isn't any other way to get something  
done, but IMHO using accessibility to do such things is in the "skanky  
hack that just happens to work" category. In the case of iChat it  
would be a lot better to use its existing AppleScript support to add  
handlers for when messages are received.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: Inline Help Text Approaches

2008-04-15 Thread Jens Alfke


On 15 Apr '08, at 6:54 AM, Steven Huey wrote:


http://stevenhuey.net/pics/Backup.png

The text I'm describing is the gray text over the table views such  
as: "Add QuickPicks, files, and folders..." that appears over the  
table, but once you add something is hidden.


I would do this by subclassing NSTableView, and overriding the  
background-drawing method to first draw your help message if the  
current number of rows is zero.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: binary search trees & binning

2008-04-15 Thread Jean-Daniel Dupas


Le 15 avr. 08 à 21:02, Boyd Collier a écrit :

Hello all,

I need to place many thousands of doubles into size-class groups  
whose boundaries can be explicitly specified (much like one would do  
in constructing a histogram, though that's not what I'm doing).  The  
number of size-classes won't be great, usually fewer than 100, say.   
It occurred to me that using a binary search tree would be a  
reasonably simple approach, and I've down-loaded some code from  
LiteratePrograms to do this.  However, before trying to use this  
code, I thought I'd ask whether someone has done this sort of thing  
using various parts of Cocoa.


Thanks, Boyd


If you need a storage that provide binary search, you can probably use  
a CFBinaryHeap.


“CFBinaryHeap  implements a container that stores values sorted using  
a binary search algorithm. All binary heaps are mutable; there is not  
a separate immutable variety”.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: to write to file except NSData*

2008-04-15 Thread Jens Alfke


On Apr 15, 2008, at 10:38 AM, Nick Rogers wrote:

but i want to write the length of (NSData *)data, before I write it  
to file because I will be writing a lot of NSData to the file,
so that I will be able to read the length first and then read the  
following NSData.
SO how can I write the length which is an integer to file before I  
write the NSData.


Don't use NSFileHandle, then. Use NSOutputStream, open it on the file  
(I don't think you have to create the file beforehand) and use its - 
write:maxLength: method to write whatever bytes you want.


(Though to be honest, I don't ever do this. If I want to read and  
write bytes from raw files like that, I just use the standard C APIs  
like fopen, fread, fwrite...)


But are you really sure you need to roll your own file format and I/O  
code for this? It's annoying code to write, it has to deal with byte- 
ordering issues, and bugs in your code will often have nasty side  
effects like corrupting files or even allowing a maliciously-crafted  
file to take over your app. Why not just collect the NSDatas in an  
NSArray and call -writeToFile: on it? Then you could be done with the  
whole task in two minutes.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: [OT: security] smbclient

2008-04-15 Thread Stuart Malin
My apologies for bothering the list.  I didn't mean to raise a virus  
scare (and hope I haven't).
I.S. -- not quite a "random building" that I've posted to -- lots of  
very smart people here  -- and was hoping by my post here to be led  
to a _quality_ security related Mac mailing list or forum; still  
haven't found one... That said, enough said about this OT post here,  
though if anyone is qualified to discuss, I'd like to continue, but   
off list.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [ANN] JSKit - JavaScript Embedding Framework

2008-04-15 Thread glenn andreas


On Apr 15, 2008, at 4:13 PM, Jens Alfke wrote:



On 15 Apr '08, at 1:07 PM, glenn andreas wrote:

JSKit provides Objective-C wrappers around the lower level  
JavaScriptCore (available on 10.5 and 10.4 with Safari 3.0) and  
provides transparent two way bridging technologies, allowing you to  
call JavaScript objects from Objective-C and to write Objective-C  
that can be called from JavaScript


What are the pros and cons compared to the existing JS/Cocoa  
bridging found in ?




Cons of WSO:

WSO are a bit trickier to work with if you want to expose Objective-C  
objects to JavaScript (especially with regards to what is exposed and  
what isn't - some places take C-string, for example), but the biggest  
difference is that WSO requires making a webview to get the frame to  
get the root WSO object.  WSO then assumes that everything is inside  
of a web-page, and so the resulting JavaScript can do web-page related  
things you might not want (for example, installing a timer via  
setInterval that chews up all your CPU, or, if your WebView is not  
configured properly, calls external servers via XMLHTTPRequest or  
loads Java or Flash applets, etc...)


WSO also doesn't work well from command line tools (since it requires  
a webview and thus a connection to a window server).  There is also no  
support for making new constructors (i.e,  new "native types/classes"  
in Javascript), or simple (global) functions.  No opportunity for  
"transparent" bridging.


Pros of WSO:

It is built in.

It works back to 10.4 with older versions of Safari (and may even work  
on 10.3.9, I don't remember for sure).




Glenn Andreas  [EMAIL PROTECTED]
  wicked fun!
quadrium | flame : flame fractals & strange attractors : build,  
mutate, evolve, animate




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: binary search trees & binning

2008-04-15 Thread Jens Alfke


I need to place many thousands of doubles into size-class groups  
whose boundaries can be explicitly specified (much like one would do  
in constructing a histogram, though that's not what I'm doing).  The  
number of size-classes won't be great, usually fewer than 100, say.   
It occurred to me that using a binary search tree would be a  
reasonably simple approach


If you had millions of doubles, or even hundreds of thousands, I'd  
agree. But the time required to toss a few thousand numbers into  
buckets is likely to be unnoticeably short on today's hardware. Why  
not implement it in the simplest possible way first, minimizing  
implementation time instead of runtime, and then benchmark it and see  
how it does?


In other words, I'd probably first try using a C array of 100  
NSMutableArrays, and wrap the doubles in NSNumbers. On every insert  
you can do a simple binary search to figure out which of the 100  
buckets it should go in.
If that's too slow because of the overhead of allocating all those  
NSNumber objects, I'd switch to using C arrays of double[ ] instead,  
growing them in chunks using realloc.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: Frameworks in bundles?

2008-04-15 Thread Kyle Sluder
On Tue, Apr 15, 2008 at 5:15 PM, Thomas Backman <[EMAIL PROTECTED]> wrote:
>  Now, that means that the three plugins, each with only 100-150 lines of
> code, need 4MB worth of frameworks... Is there a way to get around this
> without making it ugly, to include the frameworks *once*?

Build your frameworks with the @executable_path macro in the install
path setting, and copy them into your app bundle's Frameworks
directory as part of the app target build.  People writing plugins can
then link against these frameworks, but their plugins will still work,
regardless of where your app loads them from (Application Support, its
internal Plug-Ins directory, anywhere).  See <
http://developer.apple.com/documentation/DeveloperTools/Conceptual/DynamicLibraries/Articles/DynamicLibraryDesignGuidelines.html#//apple_ref/doc/uid/TP40002013-SW21
> for more details.

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

This email sent to [EMAIL PROTECTED]


Re: "hooking" into another app

2008-04-15 Thread Don Arnel
Actually, after playing around with the Accessibility API I've found  
that changing the layout of UI elements won't adversely affect the  
external app's code at all.


On Apr 15, 2008, at 5:37 PM, Jens Alfke wrote:

I'm not so enthusiastic about it … it's basically the GUI equivalent  
of Application Enhancer, or of HTML screen-scraping. Just as  
searching through the raw HTML of a website isn't a reliable way to  
get information from the server, groping through the views of  
another app isn't a reliable way to interact with it. In both cases,  
there's nothing to keep the layout of the user interface from  
changing in the future, and even minor changes that don't have a  
visual effect could break anything that's groping inside them. (For  
example, if the order of two buttons gets changed around for some  
reason in a nib, something using the accessibility API to drive  
those buttons is going to end up pressing the wrong one.)


I understand that sometimes there isn't any other way to get  
something done, but IMHO using accessibility to do such things is in  
the "skanky hack that just happens to work" category. In the case of  
iChat it would be a lot better to use its existing AppleScript  
support to add handlers for when messages are received.


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

This email sent to [EMAIL PROTECTED]


Re: binary search trees & binning

2008-04-15 Thread John Stiles

Hmm, set sounds a lot easier than this to me.

Just use insert to put all the doubles into the set (one line), then use 
lower_bound to find the delineations between each group (another 
one-liner, though of course you'll need to loop over the number of 
groups you want). Then the distance between iterators is the size of 
each group (std::distance can compute this in another one-liner).


Unfortunately this is another case where Cocoa's collection classes just 
aren't very strong,  but STL is made for this sort of work... though 
Jens is probably right that performance isn't going to be a big problem 
if it's <1 items. The set<> will be a whole lot faster, but any 
naive implementation will be "fast enough" unless you expect your data 
set will eventually be a lot larger than this.



Jens Alfke wrote:


I need to place many thousands of doubles into size-class groups 
whose boundaries can be explicitly specified (much like one would do 
in constructing a histogram, though that's not what I'm doing).  The 
number of size-classes won't be great, usually fewer than 100, say.  
It occurred to me that using a binary search tree would be a 
reasonably simple approach


If you had millions of doubles, or even hundreds of thousands, I'd 
agree. But the time required to toss a few thousand numbers into 
buckets is likely to be unnoticeably short on today's hardware. Why 
not implement it in the simplest possible way first, minimizing 
implementation time instead of runtime, and then benchmark it and see 
how it does?


In other words, I'd probably first try using a C array of 100 
NSMutableArrays, and wrap the doubles in NSNumbers. On every insert 
you can do a simple binary search to figure out which of the 100 
buckets it should go in.
If that's too slow because of the overhead of allocating all those 
NSNumber objects, I'd switch to using C arrays of double[ ] instead, 
growing them in chunks using realloc.


—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:
http://lists.apple.com/mailman/options/cocoa-dev/jstiles%40blizzard.com

This email sent to [EMAIL PROTECTED]

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: "hooking" into another app

2008-04-15 Thread Ricky Sharp


On Apr 15, 2008, at 4:37 PM, Jens Alfke wrote:



On 14 Apr '08, at 2:39 PM, Bill Cheeseman wrote:


However, the
Accessibility API is also wonderfully useful for doing lots of  
other things,
such as hooking into a text chat window so that you can log the  
incoming

messages.


I'm not so enthusiastic about it … it's basically the GUI equivalent  
of Application Enhancer, or of HTML screen-scraping. Just as  
searching through the raw HTML of a website isn't a reliable way to  
get information from the server, groping through the views of  
another app isn't a reliable way to interact with it. In both cases,  
there's nothing to keep the layout of the user interface from  
changing in the future, and even minor changes that don't have a  
visual effect could break anything that's groping inside them. (For  
example, if the order of two buttons gets changed around for some  
reason in a nib, something using the accessibility API to drive  
those buttons is going to end up pressing the wrong one.)


That's not how accessibility works though.  When an app supports it  
(which most Cocoa apps do if using the Aqua UI), the visual UI  
hierarchy is ultimately flattened into an accessibility hierarchy (see  
various overview docs for more detail).  Also, you don't access things  
by absolute position, or physical order.  So, if layout changes, you  
can still access the required button.


Perhaps you're thinking of the specific case of GUI scripting?  In  
that case, you do sometimes end up with AppleScript commands that  
reference things by ordinal value (e.g. button 1 of window 3).


I understand that sometimes there isn't any other way to get  
something done, but IMHO using accessibility to do such things is in  
the "skanky hack that just happens to work" category. In the case of  
iChat it would be a lot better to use its existing AppleScript  
support to add handlers for when messages are received.



I will agree that this approach would be better.  After all, if  
accessibility is turned off,  there won't be any access to data via  
those APIs.  The AppleScript approach would be available no matter what.


Although, I have to say that I believe that of all apps out there,  
more probably support accessibility features than do AppleScript.   
Thus, YMMV.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
Instant Interactive(tm)   http://www.instantinteractive.com

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: "hooking" into another app

2008-04-15 Thread Jens Alfke


On 15 Apr '08, at 3:07 PM, Don Arnel wrote:

Actually, after playing around with the Accessibility API I've found  
that changing the layout of UI elements won't adversely affect the  
external app's code at all.


Changing the x/y coords of views in the nib won't, but other types of  
changes might, since the views just seem to be identified according to  
some numeric order. It might be the tab (responder-chain) order, or  
the order in which the views are listed in the compiled nib, but in  
any case it could change if the nib is changed. For example, if you  
decide to change the tab ordering, or if you delete a button and  
replace it with a new one.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Getting selection of IKImageView?

2008-04-15 Thread Colin Cornaby
I have an IKImageView that I am using as a preview view for working  
with a flatbed scanner. I'd like the user to be able to select the  
area they want to scan with the selection tool, and then hit a scan  
button to do a high quality scan. The issue I am having is that I  
can't seem to find a way to actually get the rect of the selected  
area. Am I just missing something here?


Thanks,
Colin
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: "hooking" into another app

2008-04-15 Thread Ricky Sharp


On Apr 15, 2008, at 5:13 PM, Jens Alfke wrote:



On 15 Apr '08, at 3:07 PM, Don Arnel wrote:

Actually, after playing around with the Accessibility API I've  
found that changing the layout of UI elements won't adversely  
affect the external app's code at all.


Changing the x/y coords of views in the nib won't, but other types  
of changes might, since the views just seem to be identified  
according to some numeric order. It might be the tab (responder- 
chain) order, or the order in which the views are listed in the  
compiled nib, but in any case it could change if the nib is changed.  
For example, if you decide to change the tab ordering, or if you  
delete a button and replace it with a new one.



See prior e-mail regarding GUI scripting.  I've personally done all of  
the above, and it had zero impact on my app being fully accessible.


I like to think of the accessibility frameworks as offering users  
this: "tell me what's there and I'll interact with it".  Meaning, the  
API queries what is there on the screen and listens to notifications  
to update that info.  This info offers objects (e.g. a button) and  
possible actions (e.g. 'press).  Users then use their assistive  
devices to take actions like moving the focus or to press buttons.


What specific tab of a tab view that comes up as the default is not an  
issue.  Users will be able to know that the original default is not  
currently selected, but will have the ability to select it.  And, then  
to interact with the controls contained therein.


As this is getting off of being Cocoa-specific, future responses may  
be better served on the dedicated accessibility list.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
Instant Interactive(tm)   http://www.instantinteractive.com

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Basic Core Animation question

2008-04-15 Thread Greg Sabo
I retained the layer object, and now the program no longer crashes! I'll be
sure to read up more on retaining objects, as that is clearly an important
concept.

Now just to get the circle to display. I'm not quite sure what you mean by
"set the layer to a view to be displayed," which means that I'm probably not
doing that. How would I go about doing this?

Here is the class as it is now:
//*
#import "GameBoard.h"

@implementation GameBoard

- (id) initWithFrame:(NSRect) frame {
if (self = [super initWithFrame: frame]) {
animateLayer = [CALayer layer];
[animateLayer setDelegate:self];
[animateLayer retain];
}
return self;
}

- (void) awakeFromNib {
[[self window] setAcceptsMouseMovedEvents: YES];
}

- (BOOL) acceptsFirstResponder {
return NO;
}

//draws the view
- (void)drawRect:(NSRect)rect {
[self drawBoardBackgroundInRect:rect];
[animateLayer setNeedsDisplay];
}

- (void)drawBoardBackgroundInRect:(NSRect)rect {
[NSBezierPath fillRect:rect];
}

- (void)drawLayer:(CALayer *)theLayer
inContext:(CGContextRef)theContext {

CGRect theRect = CGRectMake(0.5, 0.5, 1, 1);
CGContextSetRGBFillColor(theContext, 1, 0, 1, 1);
CGContextFillEllipseInRect(theContext, theRect );
}

On Mon, Apr 14, 2008 at 9:23 PM, Michael Vannorsdel <[EMAIL PROTECTED]>
wrote:

> In your initWithFrame: method you need to retain the layer object or the
> autorelease pool may deallocate it.  Also, where do you set the layer to a
> view to be displayed?
>
>
> On Apr 14, 2008, at 6:26 PM, Greg Sabo wrote:
>
>  I think I'm doing those things, see below:
> >
> > //Setting object as delegate for CALayer
> > - (id) initWithFrame:(NSRect) frame {
> >if (self = [super initWithFrame: frame]) {
> >animateLayer = [CALayer layer];
> >[animateLayer setDelegate:self];
> >}
> >return self;
> > }
> >
> > //drawing the view and setting setNeedsDisplay of CALayer to YES
> > - (void)drawRect:(NSRect)rect {
> >[self drawBoardBackgroundInRect:rect];
> >//whenever this next line is not commented out, the program crashes
> >//when I try to resize the window
> >[animateLayer setNeedsDisplay];
> > }
> >
> > //Implementation of drawLayer: inContext:
> > - (void)drawLayer:(CALayer *)theLayer
> >inContext:(CGContextRef)theContext {
> >
> >CGRect theRect = CGRectMake(0.5, 0.5, 1, 1);
> >CGContextSetRGBFillColor(theContext, 1, 0, 1, 1);
> >CGContextFillEllipseInRect(theContext, theRect );
> > }
> >
> > Thanks for your help, you guys are awesome!
> >
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/gregsabo%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Basic Core Animation question

2008-04-15 Thread Michael Vannorsdel

[myView setLayer:theLayer];
[myView setWantsLayer:YES];

You might want to read the Core Animation Programming Guide.  You can  
find a link to it at the top if the CALayer class docs.  It will  
explain a lot about how to use CALayers.



On Apr 15, 2008, at 4:49 PM, Greg Sabo wrote:

I retained the layer object, and now the program no longer crashes!  
I'll be sure to read up more on retaining objects, as that is  
clearly an important concept.


Now just to get the circle to display. I'm not quite sure what you  
mean by "set the layer to a view to be displayed," which means that  
I'm probably not doing that. How would I go about doing this?


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: "hooking" into another app

2008-04-15 Thread Bill Cheeseman
on 2008-04-15 5:37 PM, Jens Alfke at [EMAIL PROTECTED] wrote:

> I'm not so enthusiastic about it Š it's basically the GUI equivalent
> of Application Enhancer, or of HTML screen-scraping.

That really isn't fair. I avoid Application Enhancer like the plague. In
fact, I had to work with Unsanity so that I could modify my own applications
in order to avoid APE's interference.

The Accessibility API is a fully public and supported API from Apple. It is
designed to make all Mac applications accessible to users with disabilities,
so that Mac applications can meet federal legal requirements under the
Americans With Disabilities Act. There is nothing skanky about it. I've been
working with it for several years now, and I find it entirely reliable and
useful.

You may be confusing the Accessibility API with GUI Scripting. Although GUI
Scripting is based on the Accessibility API, GUI Scripting is designed only
to offer AppleScript services that are unrelated to the purpose of the
Accessibility API. It is certainly true that a scripter is well advised to
use an application's built-in AppleScript support, if available, before
resorting to GUI Scripting as a last resort, for exactly the reasons you
state. But that only has to do with AppleScript. If an application supports
AppleScript, it probably does so much better than GUI Scripting does. For
that reason GUI Scripting is a last resort for a scripter, to be used only
if direct AppleScript support is unavailable.

But the original poster wasn't asking how to use AppleScript. He was asking
how to write an application. The operations he wants his application to
perform are perfectly handled by the Accessibility API. In fact, they are
exactly what the Accessibility API was designed to do.

--

Bill Cheeseman - [EMAIL PROTECTED]
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com

PreFab Software - www.prefabsoftware.com


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: "hooking" into another app

2008-04-15 Thread Christopher Nebel

On Apr 15, 2008, at 3:20 PM, Ricky Sharp wrote:


On Apr 15, 2008, at 5:13 PM, Jens Alfke wrote:


On 15 Apr '08, at 3:07 PM, Don Arnel wrote:

Actually, after playing around with the Accessibility API I've  
found that changing the layout of UI elements won't adversely  
affect the external app's code at all.


Changing the x/y coords of views in the nib won't, but other types  
of changes might, since the views just seem to be identified  
according to some numeric order. It might be the tab (responder- 
chain) order, or the order in which the views are listed in the  
compiled nib, but in any case it could change if the nib is  
changed. For example, if you decide to change the tab ordering, or  
if you delete a button and replace it with a new one.


See prior e-mail regarding GUI scripting.  I've personally done all  
of the above, and it had zero impact on my app being fully  
accessible.  I like to think of the accessibility frameworks as  
offering users this: "tell me what's there and I'll interact with it".


Just because your application is accessible doesn't mean it's  
accessible in exactly the same ways, and that's what's required if  
you're going to start treating the accessibility of another  
application as API.  The second bit is exactly correct, and the key  
point is that that's *all* it does -- it lets you discover and  
manipulate what's on the screen *right now*.  This is perfectly  
sufficient for an assistive program like VoiceOver, but notice that it  
makes no guarantees about what will be on the screen tomorrow, even  
for the same application.  Attempting to write client application that  
works by manipulating another app's UI presumes a level of stability  
that really isn't there.  Maybe it'll work next time the application  
or OS is updated, maybe not.  This may be acceptable for your  
purposes, but you should be aware of the risk.



--Chris N.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Memory leak when re-alloc Methods

2008-04-15 Thread Mario Gajardo Tassara


El 15-04-2008, a las 14:21, [EMAIL PROTECTED] escribió:
I have a nasty leak problem when i realloc several methods of the  
main class of my app.


 Without seeing your code, all I can suggest is making sure you've
followed these rules:

http://devworld.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html#

--
I.S.


Problem solved !!! ,

I just moved the alloc and init of  "blisterModelClass_" from:

//the button to star the game and initialize several related methods

- (IBAction)button {

/*		blisterModelClass_=[[BlisterModel alloc]init]; */ // here was  
the leak problem


[blisterModelClass_ cleanMiscArrays];
[blisterModelClass_ initArrays];
[blisterModelClass_ initObjectsArrays];
[blisterModelClass_ initSpriteArrays];
[blisterModelClass_ setObjectsMainData];
[blisterModelClass_ initSpritesObjectsPosition:the_cg_rect_];   
[blisterModelClass_ changeCursor];

[NSTimer scheduledTimerWithTimeInterval:0.04

 target:self
   
selector:@selector(refreshDisplay)
   
userInfo:nil

repeats:YES];

blisterModelClass_ changeCursor];
}
}

to the NSView initWithFrameMethod:

-(id)initWithFrame:(NSRect)frameRect {

self=[super initWithFrame:frameRect];

if (self) {
blisterModelClass_=[[BlisterModel alloc]init]; //
is_full_screen_=FALSE;
is_anim_started_=FALSE;
}   
return self;
}

this prevent the re allocation of the same Class instance every time i  
hit the button to renew the state of the game.


Mario Gajardo Tassara
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data for managing subtree?

2008-04-15 Thread Hamish Allan
Further info (sorry for the reply to myself):

Having taken approach (2), if I dump [myTreeController contents], they
are ostensibly correct (e.g. having added a couple of items):

2008-04-16 01:56:55.558 Test[4187:10b] content (
{
children = (
 (entity: Item; id: 0x117300
 ; data: {
displayName = "item 1";
}),
 (entity: Item; id: 0x1c2100
 ; data: {
displayName = "item 2";
})
);
displayName = SECTION;
isLeaf = 0;
}
)

The section name "SECTION" displays correctly in the source list
outline view. However, the tree controller does not seem to observe
the content's "children". If I add another child through the
NSTreeController, thereby forcing an update, the managed objects
subsequently appear in the source list.

How can I make the tree controller observe changes to this "children"
key? Is it failing because the key value does not exist in its own
right, but is bound to another?

Thanks,
Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Resizing NSView with CABasicAnimation

2008-04-15 Thread Michael Fey

Folks,

I'm trying to perform a basic resize on an NSView subclass using an  
explicit animation.  The code compiles and runs without crashing, but  
also without performing the resize.  I'm obviously missing something  
very basic, but I haven't been able to find the answer elsewhere.   
Here's my sample code:


	CABasicAnimation* resizeAnimation = [CABasicAnimation  
animationWithKeyPath:@"frame.size"];

[resizeAnimation setDelegate:self];
resizeAnimation.duration = 3.0;
resizeAnimation.fromValue = [NSValue valueWithRect:[self frame]];
resizeAnimation.toValue = [NSValue valueWithRect:largerRect];
[[self layer] addAnimation:resizeAnimation forKey:@"frame"];

Thanks for any insights.

Regards,
 Michael Fey
___

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

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

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

This email sent to [EMAIL PROTECTED]


NSURL and certificates

2008-04-15 Thread Stephane Huaulme

when I try to fetch a web page on an internal server using:

[NSString stringWithContentsOfURL:[NSURL URLWithString: theURLString]  
encoding:NSASCIIStringEncoding error:&theError];


I get the following error:

{contents = "NSUnderlyingError"} =  
Error Domain=NSURLErrorDomain Code=-1203 UserInfo=0x15579210 "bad  
server certificate


what can I do about this?

my problem would likely go away if I could do something like:

wget --no-check-certificate

but i don't know how to do that with NSURL. Is it possibe?
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSURL and certificates

2008-04-15 Thread John Stiles
AFAIK, you'd need to use the lower-level NSURL* APIs (e.g. 
NSURLConnection) instead of stringWithContentsOfURL, which is going to 
be a little more work. Unless there is some trick I don't know about...


Also, you don't really want ASCII encoding—probably UTF8 is more what 
you had in mind. ASCII encoding will immediately fail (and return NULL) 
if any accented/non-English characters are present.



Stephane Huaulme wrote:

when I try to fetch a web page on an internal server using:

[NSString stringWithContentsOfURL:[NSURL URLWithString: theURLString] 
encoding:NSASCIIStringEncoding error:&theError];


I get the following error:

{contents = "NSUnderlyingError"} = 
Error Domain=NSURLErrorDomain Code=-1203 UserInfo=0x15579210 "bad 
server certificate


what can I do about this?

my problem would likely go away if I could do something like:

wget --no-check-certificate

but i don't know how to do that with NSURL. Is it possibe?
___

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

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

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

This email sent to [EMAIL PROTECTED]

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Getting selection of IKImageView?

2008-04-15 Thread Jamie Phelps

See last paragraph here: 
http://devworld.apple.com/documentation/GraphicsImaging/Conceptual/ImageKitProgrammingGuide/ImageViews/chapter_3_section_6.html

HTH
JP


On Apr 15, 2008, at 5:16 PM, Colin Cornaby wrote:

I have an IKImageView that I am using as a preview view for working  
with a flatbed scanner. I'd like the user to be able to select the  
area they want to scan with the selection tool, and then hit a scan  
button to do a high quality scan. The issue I am having is that I  
can't seem to find a way to actually get the rect of the selected  
area. Am I just missing something here?


Thanks,
Colin
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Memory leak when re-alloc Methods

2008-04-15 Thread Mike Manzano
Unless you perform  [blisterModelClass release] in your NSView's - 
dealloc, you are still potentially leaking.


Mike


On Apr 15, 2008, at 5:17 PM, Mario Gajardo Tassara wrote:

El 15-04-2008, a las 14:21, [EMAIL PROTECTED]  
escribió:
I have a nasty leak problem when i realloc several methods of the  
main class of my app.


Without seeing your code, all I can suggest is making sure you've
followed these rules:

http://devworld.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html#

--
I.S.


Problem solved !!! ,

I just moved the alloc and init of  "blisterModelClass_" from:
[…]

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: binary search trees & binning

2008-04-15 Thread Michael Ash
On Tue, Apr 15, 2008 at 5:38 PM, Jean-Daniel Dupas
<[EMAIL PROTECTED]> wrote:
>  If you need a storage that provide binary search, you can probably use a
> CFBinaryHeap.
>
>  "CFBinaryHeap  implements a container that stores values sorted using a
> binary search algorithm. All binary heaps are mutable; there is not a
> separate immutable variety".

Despite the name, CFBinaryHeap does not provide any binary search facilities.

It is a priority queue, heap being another name for that. In other
words, it's an object where you can put things into it in any order,
but when you get an object from it that object is always the smallest
one in the container, and it's implemented so that this is very fast,
O(log n).

I can see ways to use this object to implement this sort of histogram,
but it doesn't let you specify an input value and get an index to the
closest match.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSAllocateCollectable() questions

2008-04-15 Thread Michael Ash
On Tue, Apr 15, 2008 at 4:53 PM, Greg Parker <[EMAIL PROTECTED]> wrote:
>  You don't need a write barrier when erasing GC-scanned memory. The write
> barrier helps the collector see pointers that it might otherwise miss
> because it's cheating. It does not help the collector "forget" a value that
> it saw previously. (In particular, the old pointer value might be gone from
> the zeroed location, but without re-scanning everything there's no way to
> know that it doesn't still exist somewhere else.)

If this is the case then how does the collector know that you have
cleared the memory. It seems to me that without a write barrier, the
collector will not see the change and will think that that you
continue to hold the old pointer in this memory. This will result in a
memory leak of sorts, although it can't really grow without bound in
most scenarios. But still, the collector needs to know when you nil
out a variable so that it can know that a particular link no longer
exists, just like it needs to know when you store a non-nil value so
that it can know that a new link now exists.

In other words, not using a write barrier for nil isn't a disaster but
it can cause garbage to fail to be recognized as such.

What did I miss?

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


NSTreeController and NSOutlineView: How do I get to the outline view's item

2008-04-15 Thread Markus Spoettl

Hi,

  this probably sounds terribly stupid but apparently I can't find  
this out on my own so here I am asking for help again:


I have a NSDocument subclass with a simple tree structure attached to  
an NSOutlineView via NSTreeController and bindings. I learned -  
through this list - to add items in KVO compliant way like this


 TreeNode *node = [[TreeNode init] alloc];
 [[self mutableArrayValueForKeyPath:@"treeContent"] addObject:node];

this works very well the NSOutlineView gets updated and displays the  
structure I fill into my model.


The only thing that I can't seem to figure out is how to get to the  
NSOutlineView's item for a specific node that was added. Say I want to  
expand or collapse a specific node when it's added:


  [myOutlineView expandItem:node];

does not work - I believe because it's the model's data object not the  
item that represents it in the OutlineView (right?).


So how do I determine the outline item for a data node? I hope this  
makes any sense at all. I feel like a bloody beginner.


Regards
Markus
--
__
Markus Spoettl

___

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

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

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

This email sent to [EMAIL PROTECTED]


CGBitmapRef and User Space Coordinates

2008-04-15 Thread Carter R. Harrison

Hi All,

I have a CGBitmapRef that I am using as a backing store for my NSView  
subclass.  The CGBitmapRef has the same dimensions as my NSView.  Each  
time I draw to the backing store, I call my view's  
setNeedsDisplayInRect: method to invalidate the area in which I have  
drawn.  Is it necessary to convert the rectangle to which I have drawn  
into user space coordinates before feeding them into  
setNeedsDisplayInRect:?  It seems like I can get away without doing  
this because my view is the same size as the backing store, but I'm  
getting some weird behavior (things drawing correctly but in the wrong  
area).  Thanks in advance.


-Carter
___

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

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

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

This email sent to [EMAIL PROTECTED]


  1   2   >