Re: Memory management puzzle

2008-11-26 Thread Andy Lee

On Nov 26, 2008, at 6:49 PM, DKJ wrote:
I've got something this in my code, which is run several times by  
the app:


UIView *subView = [[MyView alloc] initWithFrame:frame];
[theView addSubview:subView];
[subView release];

Later on this happens:

[subView removeFromSuperView];
subView = nil;


I assume this is just a typo because you spelled it correctly (twice)  
later in your message, but on the off chance that you implemented a  
removeFromSuperView method, intending it to be an override, I wanted  
to point out that it's removeFromSuperview, not removeFromSuperView.


--Andy

___

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

Please do not post 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: Newbie question: Object as input arguments

2008-11-26 Thread
Thanks Ken for the information. I think that the best solution so far  
is the archiving thing.


Lastly, I have to say this is a pretty weird request.  Why do you  
want to chain applications like this?  If App_A is ending and  
passing work off to App_B, why not just have App_A "become" App_B by  
subsuming its responsibilities and perhaps changing its mode of  
operation?


Well I need it because App_A is somehow a plugin that an "Main App"  
launches. This plugin will (and must) run modal and hence will block  
the execution of the main application. As App_B is an expensive  
operation, it is mandatory not to block the main application for such  
a long time.


Any work around, besides the archiving thing?

Thanks a lot,

Best,
Jose


El 27/11/2008, a las 1:57, Ken Thomases escribió:

Spam detection software, running on the system  
"servint2.tedial.com", has

identified this incoming email as possible spam.  The original message
has been attached to this so you can view it (if it isn't spam) or  
label

similar future email.  If you have any questions, see
postmaster for details.

Content preview:  On Nov 25, 2008, at 2:14 AM, Jose A. Guerrero-Colón
 wrote: > Imagine that we have a cocoa application, "App_A" which  
create

 an > object with information introduced by the user (the object is
 rather > ellaborated and complex). At the very last point of this >
 application, I would like to pass that object as input to another >
 application, say "App_B", and then finish the execution ("App_A"). >
 What are the tools provided by cocoa / objective-C to cary this out?
 [...]

Content analysis details:   (3.5 points, 3.0 required)

pts rule name  description
 --  
--
3.5 BAYES_99   BODY: Bayesian spam probability is 99 to  
100%

   [score: 1.]



De: Ken Thomases <[EMAIL PROTECTED]>
Fecha: 27 de noviembre de 2008 01:57:03 GMT+01:00
Para: "Jose A. Guerrero-Colón" <[EMAIL PROTECTED]>
Cc: Cocoa-dev@lists.apple.com
Asunto: Re: Newbie question: Object as input arguments


On Nov 25, 2008, at 2:14 AM, Jose A. Guerrero-Colón wrote:

Imagine that we have a cocoa application, "App_A" which create an  
object with information introduced by the user (the object is  
rather ellaborated and complex). At the very last point of this  
application, I would like to pass that object as input to another  
application, say "App_B", and then finish the execution ("App_A").  
What are the tools provided by cocoa / objective-C to cary this out?


None, at least not in the way that you envision.

An object or object graph lives in a process's address space.  One  
process doesn't usually have access to the address space of  
another.  (You can use shared memory to overcome that, but you're  
going to create an awful mess if you try to make Cocoa objects play  
nicely with shared memory.)



I have been exploring and found NSKeyedArchive which may be useful,  
but I found it odd to force to the class of the objects (and all  
the classes that it uses) to conform NSCoding protocol. Is there a  
better option to do this?


You do have to make all the objects in the graph support coding.   
The way around the address space limitation is to archive the object  
graph, pass it as plain data to another process, and then  
reconstitute a copy of the object graph in that second process.


You have a couple of options for passing the data:

* Store it in a file
* Store it in the preferences (a.k.a. user defaults) database,  
although this is something of an abuse of the purpose of this database

* Store it in a pasteboard, perhaps
* Use Distributed Object in the brief period of time when both  
processes are running simultaneously.  Be sure to pass the objects  
by copy.



I wonder if that could be done in a "fork -exec" fashion as well,  
maybe using NSThreads? (Note that App_A will end just after calling  
App_B)


NSThreads are no help at all.  They are completely internal to their  
owning process.


Fork (without exec) is the way something like this would be done for  
a pure-C program, but it doesn't work for anything which uses the  
frameworks.  See the note "CoreFoundation and fork()" at this page .


A call to an exec*() routine would wipe the memory of the new  
process, thus obliterating your object graph.





Regards,
Ken





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Scheme for efficiently archiving images.

2008-11-26 Thread Graham Cox


On 27 Nov 2008, at 2:00 pm, Ken Thomases wrote:

First, it seems to me like you don't want an NSImage in your model.   
You want the original source of the image.  Either a file path or a  
blob of data with some meta-data (e.g. UTI) describing it and what  
it is.  You'd use NSImage as a view-enabling technology.


Yep, this is precisely how I'm coming to see it. One kink is that I  
need to keep old-format stuff working, which isn't too hard, but it  
means I need to be a little careful about how I eliminate NSImage from  
the archived model. One minor difficulty is that for old-format files,  
all I get is an archived NSImage, with no original data. That means  
that it's probably going to be impossible to convert those files to a  
more efficient approach. But for new files, I can do things  
differently - it won't be readable by an older version of the app but  
I can live with that.


If you get a file from the user, you might want to copy it to a  
temporary file of your own, to protect against the original file  
being deleted.


For now I think I'm going to work this by locally caching the data  
content of the file. It's less memory efficient but easier. Maybe if I  
can get that working smoothly I can move to the next step of not  
keeping the data in memory but read from disk as needed. By  
centralising this image cache in one class, I can extend it to work  
with on-disk images transparently. The reason for centralising the  
image cache in this way (per document) is that it also solves the  
several copies of the same image problem - it only ever keeps one data  
object for each image how ever many instances are created from it.  
Each instance just keeps a unique key that refers to the image data in  
the central cache.



Some possibilities of where to go from there:

Approach 1: This is a bit of a kludge.  Don't have your model  
archive its image.  Instead, have your NSDocument-subclass writing  
method directly query your model for the image information, so it  
can store it separately from the archived model object.  This  
supports putting it in a file in a package-style document.


This seems like a good idea, doesn't seem too kludgey to me actually.  
Since I'm already overriding NSDocument to build my package, adding a  
step to write out the image cache up front would be straightforward.


Approach 2: This is a refinement of approach 1 which makes it less  
kludgy.  Create a custom archiver class, subclassing  
NSKeyedArchiver.  Your NSDocument subclass would use that to archive  
your model.  It would be initialized with information about where to  
store image data out-of-band -- that is, not in the data object it  
creates as part of the archiving step.  In your image-holding model  
class, encodeWithCoder: would check for that special type of coder.   
If it's the special type, use methods of your own design to pass the  
image data to the archiver for out-of-band storage.  If it's a  
normal coder, just store the image data in the naive way.


With either approach, you'd do the complement for reading the  
document, of course.


Some interesting ideas. What I've started with so far is to stick with  
standard keyed archiving, but the very first thing that gets archived  
by the root object is the image cache object. Clients of this then  
just archive the image keys safe in the knowledge that the archive has  
been written already. If they have a key, it means they *must* have  
initialised their images from the cache - a nil key means the image  
data was given to them already created so they have no choice but to  
archive it wholesale. That way old-format files can still be saved  
without losing their images. Currently there's not much risk that the  
client objects could be archived without being part of the complete  
model, so they can assume the existence of the image cache. I guess I  
could add a check in encodeWithCoder: that it's part of a complete  
model archiving operation, or as you suggest, use a special archiver  
subclass to flag this.


Using a special archiver/dearchiver does address another issue too,  
which make it attractive, and that is the reachability of the image  
cache during dearchiving. Currently it works OK for the main object I  
need to adapt to this, since the object graph is complete enough at  
that point to reach the image cache owned by the root. But for another  
object type the cache is currently unreachable without a big kludge,  
so if it could be simply pulled out of the dearchiver that would solve  
that problem well.


In -initWithCoder: I can also assume that if there's no key, just  
unarchive the image as before.


So far, so good, with the exception of the strange NSImage behaviour I  
mentioned earlier. If I can solve that, I'll be home and dry, I think.


Thanks for your input - very valuable and much appreciated :)

cheers, Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists

Re: Using a string as filepath

2008-11-26 Thread Michael Ash
On Wed, Nov 26, 2008 at 7:09 PM, Knut Lorenzen <[EMAIL PROTECTED]> wrote:
> Dear list,
>
> I would like to name a file according to an user defined entry. However, the
> user's name entry might be illegal as a filepath, containing illegal
> characters for a pathname like "." or "-" as 1st character, "/", ":", etc.
>
> I've looked into the Cocoa docs for NSString and NSFileManager to no avail.
>
> Is there a recommended way to "clean" an NSString in order to get a valid
> filepath? One could simply replace all suspicious characters with an
> underscore (or something else), but that is not very elegant and feels like
> fighting the framework.

There really isn't, because it's a pretty hard problem.

The trouble is that legal characters depend mostly on the filesystem
you're writing to, and can vary widely. HFS+, for example, places no
limits on legal characters in filenames beyond what the POSIX
interface imposes on it, whereas FAT32 has a whole bunch of illegal
characters.

To make things worse, there's no way to query a filesystem and ask it
what characters it doesn't like (as far as I know). Worse yet, you
can't even reliably query a filesystem and find out what kind of
filesystem it actually *is*. Local filesystems can be queried, but if
you're connecting to a remote server via AFP, NFS, WebDav, or what
have you, the restrictions depend entirely on what the remote end is
running.

Add in the fact that there are not only character restrictions but
length restrictions (which are also all different) and you have a fine
mess.

Here's an approach I've taken in the past:

1) First, replace all instances of "/" with something else that's
reasonable, because "/" is never a legal filename character on any
filesystem. ":" is a good choice, because a ":" in a filename will be
rendered as a "/" in most GUI settings. This assumes you're using the
POSIX interfaces, or you're using something that uses them, like
anything that writes files in Cocoa.

2) Try to write the file. If it works, you're done.

3) If the above failed, truncate the name to a reasonable length, such
as 255 bytes. This is sort of tricky. Some filesystems care about the
number of unichars, some care about the number of bytes in the UTF-8
representation, and some probably care about weird things I don't know
about. Be careful when truncating to not chop up surrogate pairs (if
doing a unichar-based chop) or UTF-8 code runs (if doing a byte-based
chop).

4) Test again.

5) If that test failed, fall back to a simple known-working name.

Obviously you can insert more steps as you desire. Depending on how
much time you want to spend on this, it may be worthwhile stripping
out all characters disallowed by FAT32 and any other commonly-used
filesystems as an additional step, and it may be worthwhile trying an
even shorter truncation after step 4. But you see the general idea,
which is basically that the only way to know if a name will work is to
try it. I'm pretty sure there's no better way to go, although as
usual, I would very much like for someone to prove me wrong here.

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: Need some advice on multithreading

2008-11-26 Thread Peter N Lewis

At 9:00 -0800 26/11/08, David Phillip Oster wrote:
However, if instead of using 10 NSOperationQueues, you use a single 
global NSOperationQueue, the program stops crashing and becomes 
reliable.


If you want serialization, then use -[NSOperation addDependency:] 
that is what addDependency: is for.


Since the whole point of NSOperationQueue is to balance the mapping 
from cores to threads over the whole machine to get the best 
throughput for the end-user, for the end-user's mix of processes, it 
makes sense that Apple intended you to have a single 
NSOperationQueue per process.


This is an interesting observation, and you appear to be correct, I 
can't duplicate the crash using a single NSOperationQueue, so now we 
have the theory:


NSOperationQueue is safe if and only if

* You use addOperation on only the main thread (or possibly on only one thread)
or
* You have only a single NSOperationQueue
or
* You have only a single processor core

However, there is no way to guarantee any of these conditions in your 
code (even if they are sufficient) since you can't control the number 
of cores, and you can't guarantee that some other code in your 
application is not going to use NSOperationThread (for example, what 
if some part of Cocoa starts using NSOperationQueue, or some third 
party library you use uses it internally, or your work mate creates a 
new feature and uses his own NSOperationQueue).


Now if NSOperationQueue was actually a singleton, that would be 
different, but it isn't.


What a mess.  What's needed is for Apple to fix this in an update for 
Leopard, or for someone to write a drop in replacement for 
NSOperationQueue, even if it simplifies the options a bit, so that at 
least e can point people to an alternative that is less onerous than 
"go learn NSThreads".

   Peter.

--
  Keyboard Maestro 3 Now Available!
Now With Status Menu triggers!

Keyboard Maestro  Macros for your Mac
   
___

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

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

2008-11-26 Thread Scott Ribe
Are you sure your dealloc is not being called? Are you sure your dealloc has
the correct method signature? Because the "I got an EXC_BAD_ACCESS as well"
thing sure sounds like your view is being deallocated.

-- 
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: Scheme for efficiently archiving images.

2008-11-26 Thread Graham Cox


On 27 Nov 2008, at 12:49 pm, Ken Ferry wrote:


I don't have time to go much into this before I go off for the
holiday, but one thing:

On Wed, Nov 26, 2008 at 5:26 PM, Graham Cox <[EMAIL PROTECTED]>  
wrote:

For images from a file, I am thinking I can copy the
original file into my package and simply archive a relative path to  
it.


If you create an image with -initByReferencingURL:, the URL is all it
will archive.  The 'reference' here means that the app is permitted to
assume image remains accessible at the URL.  If you use
initWithContentsOfURL:, the app is contractually obligated to read the
data in immediately and no longer go back to the URL.



OK, that's fine - I'm not sure it will be a problem, but I will bear  
it in mind.


I'm already running into a few other problems though, basically  
because NSImage is too much of a black-box.


In order to cache the original data used to create an image, I need to  
grab it before the image is actually constructed. That isn't too bad,  
but for example, using [NSImage initWithPasteboard:] or [NSImage  
initWithContentsOfURL:], those methods covers up a lot of  
functionality. For example, it will correctly rotate an image that was  
saved with a rotation flag, whereas if I grab the data from the URL  
myself and make the image from that, it does not. That seems a bit  
strange to me, since it's surely the same, complete data.


i.e. these two bits of code give unexpectedly different results:

return [[[NSImage alloc] initWithContentsOfURL:url] autorelease];

and

NSData* data = [NSData dataWithContentsOfURL:url];
return NSImage alloc] initWithData:data] autorelease];

Why does that happen and what can I do to fix it?

If NSImage had a way to return its retained data (if I call  
setDataRetained:), none of this would seem to be necessary. Why  
doesn't it?


--Graham


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Memory management puzzle

2008-11-26 Thread Roland King
hmm - I do believe this works for me, I have views being destroyed in my 
app and they are going away.


Have you tried something a bit gross and disgusting which is getting the 
current refcount before and after the removeFromSuperView? I know that 
you cannot use the absolute value of your refcount to determine when 
something is going to be released, however you may be able to satisfy 
yourself that removeFomSuperView: is doing what it says and then go 
looking elsewhere.


DKJ wrote:

I've got something this in my code, which is run several times by the  
app:


UIView *subView = [[MyView alloc] initWithFrame:frame];
[theView addSubview:subView];
[subView release];

Later on this happens:

[subView removeFromSuperView];
subView = nil;

These two code snippets are in different controller methods. I'm  
certain they're called the same number of times.


The docs say that subView gets a release message when  
removeFromSuperview is called. But the NSLog statement I put in the  
dealloc method for MyView is never called. The ObjectAlloc instrument  
shows the count of MyView instances increasing by 1 each time the 
code  is run. And the Leaks instrument shows no leaks at all.


Just to see what would happen, I put [subView release] after the call  
to removeFromSuperview. My NSLog statement was then called twice; and  
of course I got an EXC_BAD_ACCESS as well.


I really want to get rid of these subView objects. Why aren't they  
being deallocated? And since they're not, why am I not getting any  
leaks when I set subView = nil?


dkj
___

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

Please do not post 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/rols%40rols.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: to get handle to "File/1.jpg"

2008-11-26 Thread Scott Ribe
> More to the point, from the perspective of both the Cocoa APIs and the
> low-level POSIX APIs that every other userland API...

This is specifically not true of some Carbon/Core APIs.

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


how to set up nextKeyView, full keyboard access etc, for custom subviews set up in code (rather than nib)

2008-11-26 Thread Rua Haszard Morris
I have a dialog that has a few controls as well as a complex custom  
view that itself contains other controls as subviews. The custom view  
(for various good reasons) is instantiated and added as a subview in  
code. A template view and NSView's replaceSubview:with is used so the  
positioning etc can be set in the nib.


To fully support keyboard access, I need to somehow set things up so  
that the user can tab from the nib-instantiated controls to the  
controls within the custom view and then back out again. How can I  
achieve this?


I'll also (presumably) need to set up the nextKeyView-chain for the  
controls within the custom view (composed of a hierarchy of subviews  
with their own subcontrols...), but I think I have an idea of how to  
do this.


thanks
Rua HM.
___

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

Please do not post 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: Scheme for efficiently archiving images.

2008-11-26 Thread Ken Thomases

On Nov 26, 2008, at 7:26 PM, Graham Cox wrote:

In my app I have a class that "has a" NSImage which it displays.  
Currently, when I archive the whole kit-n-kaboodle when saving to a  
file, the image simply gets archived as an object. [...]


There are a few issues though. When my image-owning objects gets its  
-encodeWithCoder: message, the package it's going to create may not  
exist yet, and I'm not sure how I can find out at that point what it  
will be. So I wondered if I could archive a file wrapper at that  
point with the original file data. Would that achieve anything? (I'm  
guessing not - a file wrapper embedded in the archive stream will  
not be visible to the high-level file archiving done by NSDocument  
so it's no advantage over archiving NSData - but correct me if I'm  
wrong).


First, it seems to me like you don't want an NSImage in your model.   
You want the original source of the image.  Either a file path or a  
blob of data with some meta-data (e.g. UTI) describing it and what it  
is.  You'd use NSImage as a view-enabling technology.


If you get a file from the user, you might want to copy it to a  
temporary file of your own, to protect against the original file being  
deleted.



Some possibilities of where to go from there:

Approach 1: This is a bit of a kludge.  Don't have your model archive  
its image.  Instead, have your NSDocument-subclass writing method  
directly query your model for the image information, so it can store  
it separately from the archived model object.  This supports putting  
it in a file in a package-style document.


Approach 2: This is a refinement of approach 1 which makes it less  
kludgy.  Create a custom archiver class, subclassing NSKeyedArchiver.   
Your NSDocument subclass would use that to archive your model.  It  
would be initialized with information about where to store image data  
out-of-band -- that is, not in the data object it creates as part of  
the archiving step.  In your image-holding model class,  
encodeWithCoder: would check for that special type of coder.  If it's  
the special type, use methods of your own design to pass the image  
data to the archiver for out-of-band storage.  If it's a normal coder,  
just store the image data in the naive way.


With either approach, you'd do the complement for reading the  
document, of course.



Good luck,
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]


Memory management puzzle

2008-11-26 Thread DKJ
I've got something this in my code, which is run several times by the  
app:


UIView *subView = [[MyView alloc] initWithFrame:frame];
[theView addSubview:subView];
[subView release];

Later on this happens:

[subView removeFromSuperView];
subView = nil;

These two code snippets are in different controller methods. I'm  
certain they're called the same number of times.


The docs say that subView gets a release message when  
removeFromSuperview is called. But the NSLog statement I put in the  
dealloc method for MyView is never called. The ObjectAlloc instrument  
shows the count of MyView instances increasing by 1 each time the code  
is run. And the Leaks instrument shows no leaks at all.


Just to see what would happen, I put [subView release] after the call  
to removeFromSuperview. My NSLog statement was then called twice; and  
of course I got an EXC_BAD_ACCESS as well.


I really want to get rid of these subView objects. Why aren't they  
being deallocated? And since they're not, why am I not getting any  
leaks when I set subView = nil?


dkj
___

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

Please do not post 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: Sort Through Commas in Cocoa

2008-11-26 Thread Nick Zitzmann


On Nov 26, 2008, at 7:28 PM, Pierce Freeman wrote:

Thanks for your reply.  I understand how you would do that much, but  
how exactly would you do that if Apple, Banana, Grape were stored in  
a variable?



Same thing as I wrote, except substitute the variable's name for the  
constant.


Nick Zitzmann




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Sort Through Commas in Cocoa

2008-11-26 Thread Pierce Freeman
Thanks for your reply.  I understand how you would do that much, but  
how exactly would you do that if Apple, Banana, Grape were stored in a  
variable?



Sent from my iPhone

On Nov 26, 2008, at 6:23 PM, Nick Zitzmann <[EMAIL PROTECTED]> wrote:



On Nov 26, 2008, at 7:12 PM, Pierce Freeman wrote:


Assuming that you get input from user via a regular text field, I am
wondering how you can sort through the commas and then save each of  
the
words that come before the commas into a array.  For example, the  
words

below would be what the user inputted:

Apple, banana, grapes



NSArray *fruitsAndBerries = [@"Apple, banana, grapes"  
componentsSeparatedByString:@", "];


Nick Zitzmann





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Sort Through Commas in Cocoa

2008-11-26 Thread Nick Zitzmann


On Nov 26, 2008, at 7:12 PM, Pierce Freeman wrote:


Assuming that you get input from user via a regular text field, I am
wondering how you can sort through the commas and then save each of  
the
words that come before the commas into a array.  For example, the  
words

below would be what the user inputted:

Apple, banana, grapes



NSArray *fruitsAndBerries = [@"Apple, banana, grapes"  
componentsSeparatedByString:@", "];


Nick Zitzmann




___

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

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

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

This email sent to [EMAIL PROTECTED]


Sort Through Commas in Cocoa

2008-11-26 Thread Pierce Freeman
Hi everyone.

Assuming that you get input from user via a regular text field, I am
wondering how you can sort through the commas and then save each of the
words that come before the commas into a array.  For example, the words
below would be what the user inputted:

Apple, banana, grapes

Then it would save Apple into someArray[0], banana into someArray[1], and
grapes into someArray[2].

Thanks for any help.


Sincerely,

Pierce F.


___

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

Please do not post 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: Scheme for efficiently archiving images.

2008-11-26 Thread Ken Ferry
I don't have time to go much into this before I go off for the
holiday, but one thing:

On Wed, Nov 26, 2008 at 5:26 PM, Graham Cox <[EMAIL PROTECTED]> wrote:
> For images from a file, I am thinking I can copy the
> original file into my package and simply archive a relative path to it.

If you create an image with -initByReferencingURL:, the URL is all it
will archive.  The 'reference' here means that the app is permitted to
assume image remains accessible at the URL.  If you use
initWithContentsOfURL:, the app is contractually obligated to read the
data in immediately and no longer go back to the URL.

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


Scheme for efficiently archiving images.

2008-11-26 Thread Graham Cox
In my app I have a class that "has a" NSImage which it displays.  
Currently, when I archive the whole kit-n-kaboodle when saving to a  
file, the image simply gets archived as an object. With small images  
it's not too bad, but I have noticed for some larger images a huge  
amount of inflation occurs. For example, loading a 400K JPEG image  
then archiving the result inflates to >20MB. This is unsurprising  
since archiving the raw NSImage object will save off all of its  
representations...


So, I'm thinking about ways to improve the situation. Images can enter  
the app in three ways, from a file, from the pasteboard and by  
unarchiving a file saved earlier. For images from a file, I am  
thinking I can copy the original file into my package and simply  
archive a relative path to it. For the pasteboard case I don't have a  
file but it could be in compressed form as NSData so I could archive  
that. I would also like to deal with the possibility that two objects  
have the same image, in which case I only need to save one copy.


There are a few issues though. When my image-owning objects gets its - 
encodeWithCoder: message, the package it's going to create may not  
exist yet, and I'm not sure how I can find out at that point what it  
will be. So I wondered if I could archive a file wrapper at that point  
with the original file data. Would that achieve anything? (I'm  
guessing not - a file wrapper embedded in the archive stream will not  
be visible to the high-level file archiving done by NSDocument so it's  
no advantage over archiving NSData - but correct me if I'm wrong).


Also, NSImage has -setDataRetained which could help, but I can't see a  
way to get that data from the image. Again, I assume I can workaround  
it by retaining the original data myself directly.


As for sharing copies of an image, I thought maybe a global or per- 
document dictionary that held the data and then just archive the key...


For bitmap images I could also archive a compressed TIFFRepresentation  
which would help somewhat without being lossy, but saving the original  
JPEG data would be better (most images come in as JPEG, but I support  
all formats that NSImage supports), and for PDF images, I want to keep  
them in that format, not convert to bitmaps.


Has anyone had experience of dealing with this, or has any ideas? At  
this stage I guess I'm just kicking around ideas to try and get a  
clearer idea of the right way to go.


thanks, Graham


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newbie question: Object as input arguments

2008-11-26 Thread Ken Thomases

On Nov 25, 2008, at 2:14 AM, Jose A. Guerrero-Colón wrote:

Imagine that we have a cocoa application, "App_A" which create an  
object with information introduced by the user (the object is rather  
ellaborated and complex). At the very last point of this  
application, I would like to pass that object as input to another  
application, say "App_B", and then finish the execution ("App_A").  
What are the tools provided by cocoa / objective-C to cary this out?


None, at least not in the way that you envision.

An object or object graph lives in a process's address space.  One  
process doesn't usually have access to the address space of another.   
(You can use shared memory to overcome that, but you're going to  
create an awful mess if you try to make Cocoa objects play nicely with  
shared memory.)



I have been exploring and found NSKeyedArchive which may be useful,  
but I found it odd to force to the class of the objects (and all the  
classes that it uses) to conform NSCoding protocol. Is there a  
better option to do this?


You do have to make all the objects in the graph support coding.  The  
way around the address space limitation is to archive the object  
graph, pass it as plain data to another process, and then reconstitute  
a copy of the object graph in that second process.


You have a couple of options for passing the data:

* Store it in a file
* Store it in the preferences (a.k.a. user defaults) database,  
although this is something of an abuse of the purpose of this database

* Store it in a pasteboard, perhaps
* Use Distributed Object in the brief period of time when both  
processes are running simultaneously.  Be sure to pass the objects by  
copy.



I wonder if that could be done in a "fork -exec" fashion as well,  
maybe using NSThreads? (Note that App_A will end just after calling  
App_B)


NSThreads are no help at all.  They are completely internal to their  
owning process.


Fork (without exec) is the way something like this would be done for a  
pure-C program, but it doesn't work for anything which uses the  
frameworks.  See the note "CoreFoundation and fork()" at this page .


A call to an exec*() routine would wipe the memory of the new process,  
thus obliterating your object graph.



Lastly, I have to say this is a pretty weird request.  Why do you want  
to chain applications like this?  If App_A is ending and passing work  
off to App_B, why not just have App_A "become" App_B by subsuming its  
responsibilities and perhaps changing its mode of operation?


Regards,
Ken

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: to get handle to "File/1.jpg"

2008-11-26 Thread Gregory Weston

Stefan Werner wrote:


Actually, it's probably not, because HFS can't store a file with a
":" in
it, but can store a file with a "/" in it. But the UNIX stuff means
much of
the OS can't handle a file with a "/" in it, so it gets mapped to
":" for
the OS. But some Mac APIs can't handle the ":" so that gets mapped
back to
"/".


Ideally, code should not even be aware of what the path separator is.
Always use the system provided methods to concatenate and split paths
(NSURL, CFURL, NSString, FSRefs), then your code couldn't care less if
10.7 should introduce HFS++Extreme with 'e' as path separator.


Ideally, that's true. And a key element of that is to make sure  
you're consistent about which API you're using. But you also may need  
to do some scrubbing if, for example, there's any chance of the user  
entering filename information directly.

___

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

Please do not post 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: Which Mac models use the new 64-bit Objective-C ABI?

2008-11-26 Thread Sean McBride
On 11/20/08 9:52 AM, Nick Zitzmann said:

>The 64-bit environment has sort of been a mixed bag in my experience

Agreed.  I'm very glad we didn't go 64 bit only.

In addition to Nick's great list, I'd add:

5. The tools don't support 64 bit as well as they do 32 bit.  Thread
Viewer.app doesn't support 64bit apps at all, Xcode/gdb have great
difficulty with simple debugging in 64bit, Shark sometimes doesn't show
symbols in 64bit apps, etc., etc.

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Using a string as filepath

2008-11-26 Thread Kiel Gillard

On 27/11/2008, at 11:09 AM, Knut Lorenzen wrote:


Dear list,

I would like to name a file according to an user defined entry.  
However, the user's name entry might be illegal as a filepath,  
containing illegal characters for a pathname like "." or "-" as 1st  
character, "/", ":", etc.


I've looked into the Cocoa docs for NSString and NSFileManager to no  
avail.


Is there a recommended way to "clean" an NSString in order to get a  
valid filepath? One could simply replace all suspicious characters  
with an underscore (or something else), but that is not very elegant  
and feels like fighting the framework.


Can you use NSSavePanel? It handles all that detail for you.  
Alternatively, try using NSString's stringByAppendingPathComponent:  
method, it may validate the path component you're trying to add.


Kiel

___

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

Please do not post 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 a string as filepath

2008-11-26 Thread Knut Lorenzen

Dear list,

I would like to name a file according to an user defined entry.  
However, the user's name entry might be illegal as a filepath,  
containing illegal characters for a pathname like "." or "-" as 1st  
character, "/", ":", etc.


I've looked into the Cocoa docs for NSString and NSFileManager to no  
avail.


Is there a recommended way to "clean" an NSString in order to get a  
valid filepath? One could simply replace all suspicious characters  
with an underscore (or something else), but that is not very elegant  
and feels like fighting the framework.


Cheers,

Knut

___

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

Please do not post 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: Figure out the size of an NSAttributedString

2008-11-26 Thread Jean-Nicolas Jolivet

Thanks to all

Somehow I assumed it wouldn't be something that is commonly used...  
now that I think about it, it makes perfect sense that one would need  
to know the size of a string that is do be drawn!...  apparently I  
should've dig a little deeper! A hearty RTFM to myself! :)


Thanks again...
J-N

On 26-Nov-08, at 6:14 PM, Jean-Nicolas Jolivet wrote:

I know this might seem like a weird idea, but I need to figure out  
the size (width and height) of an NSAttributedString that I am  
drawing... basically I need to know it because I am drawing it  
inside a larger image and I need to position it... however the  
string can be of any font/size/length... is there a way to do this??  
I'm guessing the height would probably be the font's point? (i.e.  
font size 24 would result in a height of 24pt?)  how about the  
width? any way to find that out before drawing it? (or even after  
drawing it to an intermediate image if I really need to?)


Any ideas are welcomed!

Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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/silvertab%40videotron.ca

This email sent to [EMAIL PROTECTED]


Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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: Figure out the size of an NSAttributedString

2008-11-26 Thread Gerd Knops


On Nov 26, 2008, at 5:14 PM, Jean-Nicolas Jolivet wrote:

I know this might seem like a weird idea, but I need to figure out  
the size (width and height) of an NSAttributedString that I am  
drawing... basically I need to know it because I am drawing it  
inside a larger image and I need to position it... however the  
string can be of any font/size/length... is there a way to do this??  
I'm guessing the height would probably be the font's point? (i.e.  
font size 24 would result in a height of 24pt?)  how about the  
width? any way to find that out before drawing it? (or even after  
drawing it to an intermediate image if I really need to?)



From "NSAttributedString Application Kit Additions Reference":

size
Returns the bounding box of the marks that the receiver draws.

- (NSSize)size

Works for me, at least in recent OS incarnations.

Gerd

___

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

Please do not post 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: Figure out the size of an NSAttributedString

2008-11-26 Thread Jean-Daniel Dupas


Le 27 nov. 08 à 00:14, Jean-Nicolas Jolivet a écrit :

I know this might seem like a weird idea, but I need to figure out  
the size (width and height) of an NSAttributedString that I am  
drawing... basically I need to know it because I am drawing it  
inside a larger image and I need to position it... however the  
string can be of any font/size/length... is there a way to do this??  
I'm guessing the height would probably be the font's point? (i.e.  
font size 24 would result in a height of 24pt?)  how about the  
width? any way to find that out before drawing it? (or even after  
drawing it to an intermediate image if I really need to?)


Any ideas are welcomed!



Google:  "getting size of nsattributedstring"

At least the first ten results.

And if you don't want to search, this is - [NSAttributedString size].

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSAttributedString_AppKitAdditions/Reference/Reference.html#/ 
/apple_ref/occ/instm/NSAttributedString/size


___

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

Please do not post 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: Figure out the size of an NSAttributedString

2008-11-26 Thread Nick Zitzmann


On Nov 26, 2008, at 4:14 PM, Jean-Nicolas Jolivet wrote:

I know this might seem like a weird idea, but I need to figure out  
the size (width and height) of an NSAttributedString that I am  
drawing... basically I need to know it because I am drawing it  
inside a larger image and I need to position it... however the  
string can be of any font/size/length... is there a way to do this??



Yes: 


In addition to what it says in the guide, you also need to set the  
typesetter behavior to NSTypesetterBehavior_10_2_WithCompatibility or  
you will get inaccurate results if this is a string that is drawn  
using one of the built-in methods for drawing.


Nick Zitzmann


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Figure out the size of an NSAttributedString

2008-11-26 Thread Douglas Davidson


On Nov 26, 2008, at 3:14 PM, Jean-Nicolas Jolivet wrote:

I know this might seem like a weird idea, but I need to figure out  
the size (width and height) of an NSAttributedString that I am  
drawing... basically I need to know it because I am drawing it  
inside a larger image and I need to position it... however the  
string can be of any font/size/length... is there a way to do this??  
I'm guessing the height would probably be the font's point? (i.e.  
font size 24 would result in a height of 24pt?)  how about the  
width? any way to find that out before drawing it? (or even after  
drawing it to an intermediate image if I really need to?)


You'll find the methods you need right alongside those for drawing the  
attributed string, in NSStringDrawing.h.


Douglas Davidson

___

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

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


Core Data modeling question

2008-11-26 Thread Markus Schneider

Hi All,

I have started using CoreData and have a modeling question.

My model has a managed object "TASK", which shall be executed each day  
during a time period.


Therefore, I have added a startDate and an endDate as attributes:

TASK
- startDate
- endDate



Now in this time period there are exceptions, when the task shall not  
be executed (e.g. holidays etc)


TASK
- startDate
- endDate

- exceptions
- day1
- day2
- day3


I thought on having a list of date objects containing the exceptions.  
But how should I model this? I cannot create a NSMutableArray to store  
the dates in the persistent store.
Shall I use  a MO class "DAY" and model the list as a to-many  
relationship?


TASK
- startDate 
- endDate

- exceptions  ->  DAY
  - date

Is this really necessary or is there a  more elegant way?

Any help/advice  appreciated.

Thanks,

Markus
___

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

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


Figure out the size of an NSAttributedString

2008-11-26 Thread Jean-Nicolas Jolivet
I know this might seem like a weird idea, but I need to figure out the  
size (width and height) of an NSAttributedString that I am drawing...  
basically I need to know it because I am drawing it inside a larger  
image and I need to position it... however the string can be of any  
font/size/length... is there a way to do this?? I'm guessing the  
height would probably be the font's point? (i.e. font size 24 would  
result in a height of 24pt?)  how about the width? any way to find  
that out before drawing it? (or even after drawing it to an  
intermediate image if I really need to?)


Any ideas are welcomed!

Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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: Live editing an NSTextView

2008-11-26 Thread Arved von Brasch


On 2008-11-27, at 05:57 , Douglas Davidson wrote:



On Nov 26, 2008, at 4:14 AM, Arved von Brasch wrote:

I have this working almost perfectly by listening for the  
NSTextDidChangeNotification and searching the text for the special  
sequence.  I've found this to be the best place to handle it, so  
that cut and paste operations containing the special sequence are  
converted properly as well.  The only problem with this is that it  
completely screws up the Undo / Redo of the text view.  It doesn't  
seem to be possible to use the standard shouldChangeTextInRange:  
and textDidChange pair, because my parser acts in response to an  
edit, and this would set up an infinite loop.


You need to use the should-change/did-change calls.  You can protect  
against the infinite regress by keeping track of which changes your  
code is making, and not doing any work when you are notified of  
those particular changes.  For example, you could set a flag noting  
that your change is in progress, and clear it when your change is  
done.


Douglas Davidson


Thank you for your response.

The trouble with this is that if the length of the replacement  
substring is different from what was typed, undo/redos still don't  
work as expected.  Indeed they are off by the difference in length.   
That is if I type a number that is two digits longer than the number  
that replaces it, when undoing, two extra characters are removed from  
the displayed text.


My document format has numbered lists that should be in consecutive  
order.  I'm trying to make it easier for users by having the program  
keep track of which number the user is up to when typing, and auto- 
correct for any copy and paste operations the user may perform, if  
they need to reorder the items.  My code called on each the  
notification has this loop which does the work:


NSInteger cumulativeOffset = 0;
NSUInteger index = 1;
do {
	if ([scanner scanUpToCharactersFromSet: [NSCharacterSet  
newlineCharacterSet] intoString: nil] && [scanner  
scanCharactersFromSet: [NSCharacterSet newlineCharacterSet]  
inotString: nil]) {

scanLocation = [scanner scanLocation];
		if ([scanner scanCharactersFromSet: [NSCharacterSet  
decimalDigitCharacterSet] intoString: &oldNumber] && [scanner  
scanString: @":" intoString: nil]) {
			if (index != [[NSDecimalNumber decimalNumberWithString: oldNumber]  
integerValue]) {

newNumber = [NSString stringWithFormat: @"%d", 
index];
range = NSMakeRange(scanLocation + cumulativeOffset, [oldNumber  
length]);
if ([textView shouldChangeTextInRange: range replacementString:  
newNumber]) {

[textView replaceCharactersInRange: 
range withString: newNumber];

// Do something here to adjust position 
for undos?

[textView didChangeText];
cumulativeOffset += ([newNumber length] 
- [oldNumber length]);
}
}
}
index++;
}
} while (![scanner isAtEnd]);
___

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

Please do not post 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: Code signing and verification

2008-11-26 Thread Chris Hanson

On Nov 26, 2008, at 7:32 PM, Donnie Lee wrote:


There is currently no public API for code signing. You can use the
codesign command line tool. See the man page for how to use it and  
all

of the various options available.



That is really sad :(
Thank you for the answer, Michael!


As always, if this is something you'd like to see API for, please file  
a feature request at http://bugreport.apple.com/ and describe what  
you'd like to be able to do and why.


Thanks!

  -- Chris

___

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

Please do not post 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: NSImage/NSImageView/GIF Saving an Animated GIF from NSImageView

2008-11-26 Thread Michael Robinson

I was wondering if anyone had any ideas on how to do this?

Thanks

Michael Robinson wrote:

Hi list,

I'd like to be able to use an NSImageView to display a default 
animated GIF image.  The image may be replaced by the user.


I have been using the code below to save / load images from / into the 
image view.  I would like to know how, if it is possible, one saves an 
animated gif, preserving the animation.


Also, the animation is lost when the program saves then reloads the 
image - is it possible to save (using aCoder) with animation preserved?


Thanks!

To save image to file:

   if([lbLoading image] != nil){
   NSData  * tiffData = [[lbLoading image] 
TIFFRepresentation];  NSBitmapImageRep *bits =  
[NSBitmapImageRep imageRepWithData:tiffData]; // get a rep from your 
image, or grab from a view

   NSData *data;
   [bits is]
   NSString *fullPath = [NSString 
stringWithFormat:@"%@/[EMAIL PROTECTED]@.gif",path,@"loading",[self uniqueID]];
   data = [bits representationUsingType: NSGIFFileType 
properties: nil];

   [data writeToFile: fullPath atomically: NO];
   [files addObject:fullPath];
   }


When the program saves its data:

   [aCoder encodeObject:[lbLoading image] forKey:@"lbLoading"];


And at load:

   [lbLoading setImage:[aDecoder decodeObjectForKey:@"lbLoading"]];





___

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

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

2008-11-26 Thread Matt Long
Core Animation using layers would make this simpler for you, I think.  
You can still get the click from the layer backed view, but then add  
your image to the view's layer tree as a layer. Animating a layer is  
trivial in CA.


I did a blog post on how to animate a layer to the clicked point in  
the view. Shows you how to get the current location on the view while  
in-flight as well. http://www.cimgf.com/2008/11/05/core-animation-tutorial-interrupting-animation-progress/ 
 . The layer that I animate in the post demo project doesn't have an  
image in it, but just look at setting the contents field in the layer  
(CALayer docs) and you'll have what you need.


This probably won't help you if you need to stick with NSAnimation,  
but et me know if you have CA questions.


-Matt



On Nov 26, 2008, at 7:51 AM, Hrishikesh Muruk wrote:

I have a basic question about using NSAnimation.  Here is what I am  
trying to do: My program shows a custom view and I want to animate  
an NSImage within that custom view. When the mouse is clicked within  
the program I want to move (animate) the image to a new point in the  
window.



I have subclassed NSAnimation  into MyAnim and I have overloaded the  
method "-(void)setCurrentProgress:(NSAnimationProgress)progress". My  
program is organized in this fashion.


I have a custom view class MyView which has pointers to my data  
objects (an NSImage in this case) and my animation object myAnim. It  
also has a pointer to my custom view object MyView.


On a mouse click I send the message
[myAnim startAnimation];

@interface MyView : NSView {

NSImage *myObj;
MyAnim *myAnim;
}


I want the animation to begin when the mouse is clicked so I have  
overloaded the "-mouseDown" method to call [myAnim startAnimation];.  
I plan to animate my image by changing its position from within - 
setCurrentProgress. My problem - how do I access myObj from within  
the method -setCurrentProgress (which is inside MyAnim). I could do  
something like:


(in file MyAnim.m)
-(void)setCurrentProgress:(NSAnimationProgress)progress {
NSImage * tmpImg = [super valueForKey:@"myObj"];
}

But it looks a little bit like a hack.

My questions:
1. Is there a better way to access myObj from MyAnim?
2. Once I change the position of myObj how do I get the view to  
redraw the image?


Hrishi


___

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

Please do not post 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 get handle to "File/1.jpg"

2008-11-26 Thread Stefan Werner


On Nov 26, 2008, at 6:44 PM, Scott Ribe wrote:

Actually, it's probably not, because HFS can't store a file with a  
":" in
it, but can store a file with a "/" in it. But the UNIX stuff means  
much of
the OS can't handle a file with a "/" in it, so it gets mapped to  
":" for
the OS. But some Mac APIs can't handle the ":" so that gets mapped  
back to

"/".


Ideally, code should not even be aware of what the path separator is.  
Always use the system provided methods to concatenate and split paths  
(NSURL, CFURL, NSString, FSRefs), then your code couldn't care less if  
10.7 should introduce HFS++Extreme with 'e' as path separator.


-Stefan
___

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

Please do not post 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: Live editing an NSTextView

2008-11-26 Thread Douglas Davidson


On Nov 26, 2008, at 4:14 AM, Arved von Brasch wrote:

I have this working almost perfectly by listening for the  
NSTextDidChangeNotification and searching the text for the special  
sequence.  I've found this to be the best place to handle it, so  
that cut and paste operations containing the special sequence are  
converted properly as well.  The only problem with this is that it  
completely screws up the Undo / Redo of the text view.  It doesn't  
seem to be possible to use the standard shouldChangeTextInRange: and  
textDidChange pair, because my parser acts in response to an edit,  
and this would set up an infinite loop.


You need to use the should-change/did-change calls.  You can protect  
against the infinite regress by keeping track of which changes your  
code is making, and not doing any work when you are notified of those  
particular changes.  For example, you could set a flag noting that  
your change is in progress, and clear it when your change is done.


Douglas Davidson

___

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

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

2008-11-26 Thread Hrishikesh Muruk
I have a basic question about using NSAnimation.  Here is what I am  
trying to do: My program shows a custom view and I want to animate an  
NSImage within that custom view. When the mouse is clicked within the  
program I want to move (animate) the image to a new point in the window.



I have subclassed NSAnimation  into MyAnim and I have overloaded the  
method "-(void)setCurrentProgress:(NSAnimationProgress)progress". My  
program is organized in this fashion.


I have a custom view class MyView which has pointers to my data  
objects (an NSImage in this case) and my animation object myAnim. It  
also has a pointer to my custom view object MyView.


On a mouse click I send the message
[myAnim startAnimation];

@interface MyView : NSView {

NSImage *myObj;
MyAnim *myAnim;
}


I want the animation to begin when the mouse is clicked so I have  
overloaded the "-mouseDown" method to call [myAnim startAnimation];.  
I plan to animate my image by changing its position from within - 
setCurrentProgress. My problem - how do I access myObj from within  
the method -setCurrentProgress (which is inside MyAnim). I could do  
something like:


(in file MyAnim.m)
-(void)setCurrentProgress:(NSAnimationProgress)progress {
NSImage * tmpImg = [super valueForKey:@"myObj"];
}

But it looks a little bit like a hack.

My questions:
1. Is there a better way to access myObj from MyAnim?
2. Once I change the position of myObj how do I get the view to  
redraw the image?


Hrishi

___

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

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


Live editing an NSTextView

2008-11-26 Thread Arved von Brasch

Dear Cocoa Dev List,

I am attempting to add live editing to a NSTextView.  This means that  
when the user types some specific text, the text view notices and  
converts it into a different substring, with possibly a different  
length.  The idea is similar to an auto-correcting spell checker.   
When a new character completes a special character sequence,  
replaceCharactersInRange:withString: is called to make the change, and  
I adjust the selection range to compensate for the change in length.


I have this working almost perfectly by listening for the  
NSTextDidChangeNotification and searching the text for the special  
sequence.  I've found this to be the best place to handle it, so that  
cut and paste operations containing the special sequence are converted  
properly as well.  The only problem with this is that it completely  
screws up the Undo / Redo of the text view.  It doesn't seem to be  
possible to use the standard shouldChangeTextInRange: and  
textDidChange pair, because my parser acts in response to an edit, and  
this would set up an infinite loop.


I found I could manually add my changes to the undoManager, and that  
would allow undos to function as expected, but redos won't work. ('As  
expected' means restoring the modified substring with the originally  
typed sequence minus the final character that triggered the change.   
Redo should restore the modified string.)  I don't have much  
experience with the NSUndoManager, but I understand I could possibly  
put the reciprocal action in a NSTextView subclass for  
replaceCharactersInRange:, but as this is a special case, I don't see  
any way to tell that the particular undo operation is in response to  
my modification, and not something more generic.


I'm hoping someone has done something similar, and has an elegant  
solution, or at least a different direction I could take.


Thanks,
Arved von Brasch
___

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

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


Scheduling and launchd

2008-11-26 Thread Per Ohlson
I'm trying to schedule multiple events that are supposed to trigger an
application at different hours on different days. My current idea is to use
launchd with each event as plist in Library/LaunchAgents. However, is it a
bad idea to spam the LaunchAgents-folder? 
Can I use multiple dates in the same plist or do I have to create one plist
for each date, if the hours are different each day?
Any inputs on this?

/Per

___

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

Please do not post 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 use IB to create a viewcontroller which actually linking to another nib file?

2008-11-26 Thread 李瑞

Hi,

   To be honest,  i can't catch what your question are. Maybe this could help 
you 

loadNibFile:externalNameTable:withZone:
Unarchives the contents of the nib file and links them to objects in your 
program.

+ (BOOL)loadNibFile:(NSString *)fileName externalNameTable:(NSDictionary 
*)context withZone:(NSZone *)zone

Parameters
fileName
The location of the nib file specified as an absolute path in the file system.

context
A name table whose keys identify objects associated with your program or the 
nib file. The newly unarchived objects from the nib file use this table to 
connect to objects in your program. For example, the nib file uses the object 
associated with the NSNibOwner constant as the nib file's owning object. If you 
associate an empty NSMutableArray object with the NSNibTopLevelObjects 
constant, on output, the array contains the top level objects from the nib 
file. For descriptions of these constants, see NSNib Class Reference.

zone
The memory zone in which to allocate the nib file objects.

Return Value
YES if the nib file was loaded successfully; otherwise, NO.

Discussion
This method is declared in NSNibLoading.h.

> Date: Wed, 26 Nov 2008 15:39:35 +0800
> From: [EMAIL PROTECTED]
> To: Cocoa-dev@lists.apple.com
> CC: 
> Subject: How to use IB to create a viewcontroller which actually linking to   
> another nib file?
> 
> Hi All,
> 
> I'm a newbie here. And i'm not sure if I can send questions directly to this
> mail list. If not, please kindly tell me how to ask questions. Thanks!
> 
> When I create a new prj using "viewbased app" template, it will create 2 nib
> file. And in MainWindow.xib, thre is a viewcontroller, when I open it, it
> says loaded from "another viewcontroller.nib".
> 
> Question is how do I mimic this behaviour and create a new viewcontroller
> which suppose to load from a new xib file.
> 
> 
> He Xiao
> 2008-11-26
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/imlerry%40live.cn
> 
> This email sent to [EMAIL PROTECTED]

_
新版手机MSN,新功能,新体验!满足您的多彩需求!
http://mobile.msn.com.cn
___

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

Please do not post 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: Chapters in Hillegass to skip on first reading?

2008-11-26 Thread 李瑞

Hi,

I am also a beginner, and I am confused about how to skip the chapters of 
this book.

> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Date: Wed, 26 Nov 2008 08:05:50 +0100
> CC: cocoa-dev@lists.apple.com
> Subject: Re: Chapters in Hillegass to skip on first reading?
> 
> HEllo,
> Well Im following the book as well and the chapters you mention are  
> really interesting and short, the problem is that some chapter  are  
> related so it happened to me that I skipped one and I saw that it was  
> related with the  prior project.
> 
> 
> 
> Gus
> 
> On 26.11.2008, at 0:30, Ulai Beekam wrote:
> 
> >
> > Hi,
> > Let's say I have a plan for a simple app. Nothing too fancy, in a  
> > way. To name an example, it could be one like ShoveBox or Things.  
> > Mine is probably simpler than those. (It will be a good looking UI  
> > and icon that will be more trickier part for me.)
> > I've already read more than half of Hillegass (3rd edition) and now  
> > I need to know what chapters I can safely skip.
> > These are the chapters I'm considering skipping:
> > --23. Drag and Drop (skip until I actually  
> > need any dragging and dropping)
> > 24. NSTimer (I doubt I will need any delaying)
> > 27. Web service (This one I'm not as sure about. For example, do  
> > auto-update mechanisms in Cocoa apps rely on web services, and  
> > hence, the info in this very chapter?)
> > 30. Core data (because I'm not using CoreData. Not NSArrayController  
> > either. I'm going to code without them to start with.)
> > 31. Garbage Collection (because I'm not using garbage collection)
> >
> > 32. Core Animation (don't see why I would need that)
> > 33. A Simple Cocoa/OpenGL Application (again, don't see the need atm)
> > 34. NSTask (again, no need apparent)--
> > So I just wanted to make sure you all agree with the chapters I am  
> > planning on skipping. Please consider especially the chapter 27 on  
> > web service, because if that update mechanism all Cocoa apps out  
> > there seem to have rely on the info in this chapter I will need to  
> > read it.
> > Thanks, U
> > _
> > Invite your mail contacts to join your friends list with Windows  
> > Live Spaces. It's easy!
> > http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us___
> >
> > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> >
> > Please do not post 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/gustavxcodepicora%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/imlerry%40live.cn
> 
> This email sent to [EMAIL PROTECTED]

_
超炫人气榜给您所有偶像的最新资讯和排名,快来支持自己的偶像!
http://cnweb.search.live.com/xrank/results.aspx?q=%e5%91%a8%e6%9d%b0%e4%bc%a6&FORM=MSNH
___

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

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


Multiple NSTableViews in one NSScrollView

2008-11-26 Thread Thomas Engelmeier

Hi,

I have an UI where a bunch of NSTableViews plus extra title views are  
stacked in one NSScrollView.
Currently each table is loaded from a subview NIB, populated, resized- 
to-fit and placed in a master documentview.


That is working fine except IB generated TableViews reside already in  
a IB generated NSScrollView (unused, scrollview frame = table+header  
frame) which leads to a bunch of scrolling related artifacts  
(ScrollWheel etc..). How much is a NSTableView interacting with the  
enclosing scroll view? Can I get rid of the scrollview by  
programmatically creating the table view? Ar attach the shared parent  
scroll view to all tableviews?


TIA,
Tom_E



___

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

Please do not post 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: NSTrackingArea strange requirement

2008-11-26 Thread Quincey Morris

On Nov 26, 2008, at 06:30, rajesh wrote:

I have Custom NSView with set of boxes arranged in some pattern  
( boxes with some extra UI elements like , text fields and stuff).
I am using the gaps between the boxes a.k.a the visible custom  
NSView to add the NStrackingAreas for cursor updates and as well for  
resizing the subviews (i.e the NSBox)


As an obvious fact , when ever I try to resize the subviews I need  
to as well set the frame for the NSTrackingArea elements and here I  
is no such thing as setFrame


I googled around and found that , everybody is alloc-init ' ng and  
then set the tracking area to 'nil' or release and create a new  
NSTrackingArea then – initWithRect:options:owner:userInfo:  and use  
it.
I don't have fixed number of subviews or as a fact no fixed gaps ,  
hence the tracking areas count might shoot up to anything.


I think following the general approach will have a serious affect on  
efficiency , memory and other factors .
I can't use SplitView to manage the resizing of subviews ( I  
iterate, no fixed subview , and I need to collapse or expand a  
particular subview )


Assuming you have a custom NSView and the NSBox views are its  
subviews, you can set *one* tracking area on the custom view, and one  
tracking area on each of the subviews. (Use the  
"NSTrackingInVisibleRect" option on all the tracking areas, if you  
can. Then you don't even have to update the tracking areas yourself  
when the views change size or position.)


It's not a problem that the tracking areas of the subviews overlap the  
tracking area of the parent custom view. For cursor updates, a  
tracking area doesn't send the cursorUpdate event to its owner, or  
even to its view. Instead, it sends the event to the view under the  
mouse (that is, the view that would respond to hitTest: at the current  
mouse location). So, only one view gets the event, and it's the  
"right" view -- if the mouse just entered a NSBox, the subview would  
get it; if the mouse just exited the NSBox, the parent view would get  
it.


If you need different cursors depending on which "gap" the mouse is in  
(e.g. sometimes a horizontal-resize cursor, sometimes a vertical- 
resize cursor), I'd suggest doing it by having your cursorUpdate:  
method work out which gap the mouse location is in, and not try to use  
multiple tracking areas.



___

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

Please do not post 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 get handle to "File/1.jpg"

2008-11-26 Thread Michael Ash
On Wed, Nov 26, 2008 at 11:41 AM, Gregory Weston <[EMAIL PROTECTED]> wrote:
> Michael Ash wrote:
>
>>> Hi,
>>> How do I obtain a NSFileHandle to this file which has a forward slash in
>>> the
>>> name to be able to write to this file.
>>> Supplying the path to NSFileHandle with filename in quotes also fails.
>>
>> Filenames cannot have slashes in them. If you think that your file has
>> one, then you are wrong. Very likely you think that it does because
>> Finder or other GUI apps are showing it to you that way. This is a
>> lie. A file which they display as having a / actually has a :, and the
>> character has been swapped dynamically. The slash is reserved as the
>> path separator and cannot be used as part of a filename.
>
> Nonsense. What's "actually" there depends on the underlying file system. If
> the file is on an HFS-variant volume there can be a slash in the name (but
> can't be a colon). If that wasn't the case it would be impossible to share
> media meaningfully with pre-X Mac OS and other software that reads HFS. The
> various file system APIs do the translation as necessary between colon and
> slash. The OP's issue is not that the name doesn't really have a slash in
> it; it's that he's using an API that expects POSIX style paths.

>From the perspective of userland Mac OS X code, what I said was
correct. The kernel presents a uniform file API with the
characteristics stated. That the HFS+ filesystem driver happens to
perform additional translations underneath is an irrelevant
implementation detail. Note that the colon/slash translation for
Carbon file APIs happens in userland no matter what filesystem you're
on, whether it's something like HFS+ which can store / but not :, or
whether it's something like UFS which can store : directly.

More to the point, from the perspective of both the Cocoa APIs and the
low-level POSIX APIs that every other userland API goes through,
filenames can contain : but they cannot ever contain /.

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: to get handle to "File/1.jpg"

2008-11-26 Thread Scott Ribe
> At the  
> filesystem level, that '/' is really a ':' (to avoid clashing with the
> '/' directory seperator character).  Just replace the '/' with a ':'
> and you'll be set.

Actually, it's probably not, because HFS can't store a file with a ":" in
it, but can store a file with a "/" in it. But the UNIX stuff means much of
the OS can't handle a file with a "/" in it, so it gets mapped to ":" for
the OS. But some Mac APIs can't handle the ":" so that gets mapped back to
"/".

Probably doesn't matter for the original question, but sometimes useful to
know what is actually happening when trying to figure out how to refer to a
file using a particular access method...

Now if only the Cocoa team would figure this all out...


-- 
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: Killing a Thread

2008-11-26 Thread Scott Ribe
It occurs to me that maybe you do not know about or understand the use of
the pause button in the debugger.

Get your application to the state where it's hung up. Then hit the pause
button in the debugger. Then use the thread popup to examine the stack of
each thread. Once you know where each thread is locked up, you should have a
much better chance of figuring out the problem.

Note that there may be threads you don't expect--this is normal as the
frameworks sometimes create their own threads for their own background
processing. You should at first ignore threads not running any of your code.

-- 
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: Need some advice on multithreading

2008-11-26 Thread David Phillip Oster

At 11:42 AM -0800 11/24/08, [EMAIL PROTECTED] wrote:

No, it's not a general consensus. It's something I discovered on my
own, and posted about it here. I haven't received any overall
confirmation that it's broken, but my simple test project was able to
reliably crash on perhaps half a dozen different hardware
configurations. (And fail to crash on quite a few more.)

If you like, you can go through the original thread here and come to
your own conclusions:

http://www.cocoabuilder.com/archive/message/cocoa/2008/10/30/221452

If you want to know more about it, please feel free to ask me.


Michael, I read that original thread. The reason you are having 
problems is that you are misusing the NSOperation & NSOperationQueue 
system. Your test program crashes for me, reliably, just as you say, 
on a 4-Core Mac.


However, if instead of using 10 NSOperationQueues, you use a single 
global NSOperationQueue, the program stops crashing and becomes 
reliable.


If you want serialization, then use -[NSOperation addDependency:] 
that is what addDependency: is for.


Since the whole point of NSOperationQueue is to balance the mapping 
from cores to threads over the whole machine to get the best 
throughput for the end-user, for the end-user's mix of processes, it 
makes sense that Apple intended you to have a single NSOperationQueue 
per process.


___

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

Please do not post 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 get handle to "File/1.jpg"

2008-11-26 Thread Gregory Weston

Michael Ash wrote:


Hi,
How do I obtain a NSFileHandle to this file which has a forward  
slash in the

name to be able to write to this file.
Supplying the path to NSFileHandle with filename in quotes also  
fails.


Filenames cannot have slashes in them. If you think that your file has
one, then you are wrong. Very likely you think that it does because
Finder or other GUI apps are showing it to you that way. This is a
lie. A file which they display as having a / actually has a :, and the
character has been swapped dynamically. The slash is reserved as the
path separator and cannot be used as part of a filename.


Nonsense. What's "actually" there depends on the underlying file  
system. If the file is on an HFS-variant volume there can be a slash  
in the name (but can't be a colon). If that wasn't the case it would  
be impossible to share media meaningfully with pre-X Mac OS and other  
software that reads HFS. The various file system APIs do the  
translation as necessary between colon and slash. The OP's issue is  
not that the name doesn't really have a slash in it; it's that he's  
using an API that expects POSIX style paths.

___

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

Please do not post 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: [Reposted] Document based resource strategy

2008-11-26 Thread Keary Suska


On Nov 25, 2008, at 5:29 PM, Carlos Eduardo Mello wrote:

Guess I wasn't clear again... I'm not talking about the fact that  
the NSDocument subclass owns the document window nib, as in  
'iSpend'. What I mean is this: if you check the tableview in iSpend,  
it has its datasource outlet connect to a TransactionsControler   
object which was instantiated in the nib itself, while its delegate  
outlet is wired to the File's Owner  icon. Some document based  
examples, instead of connecting its interface items to the FIle's  
Owner icon, instantiate an object of the document subclass in the  
nib and connect to it. My question is: how do the two types of  
connection differ as far as the kinds of things you can do with them?



I am not sure what you mean to ask here. Do you mean whether the  
NSDocument is a nib owner, as opposed to being instantiated in the  
nib? I imagine it depends on what the author was trying to accomplish,  
and since there are numerous ways a problem can be solved, there may  
not be a specific reason why a certain approach was used (other than  
it is what first came to mind). IMHO, NSDocument should not be  
instantiated in a nib that contains the document-specific GUI. Again,  
IMHO, I think NSDocument or it's NSWindowController should always own  
the document GUI nib.


HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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

Please do not post 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: Code signing and verification

2008-11-26 Thread Donnie Lee
>> I'd like to sign my Application and check this signature from another
>> my Application. I've found how to sign an app, but I can't find how to
>> check already signed app from objective-c/cocoa. Also I need to verify
>> that the program was signed with my certificate, not with any other
>> certificate. Can you tell me what class/functions I should to use?
>
> There is currently no public API for code signing. You can use the
> codesign command line tool. See the man page for how to use it and all
> of the various options available.
>

That is really sad :(
Thank you for the answer, Michael!

Donnie.
___

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

Please do not post 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 multiple contexts or coordinators?

2008-11-26 Thread Jim Correia

On Nov 26, 2008, at 5:02 AM, Chris Idou wrote:


The core-data documentation seems very vague about whether multiple  
threads should use different NSManagedObjectContexts but one  
NSPersistentStoreCoordinator, or multiple coordinators.


I've got an app where one thread needs to write, and one (or maybe  
more) threads need to read. One or more coordinators, what are the  
pros and cons?


Previous thread discussing this topic:

http://www.cocoabuilder.com/archive/message/cocoa/2008/10/15/220219

Jim
___

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

Please do not post 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: NSTrackingArea strange requirement

2008-11-26 Thread rajesh

hi all

Sorry , I completely overlooked the part  "updateTrackingAreas" may be  
I can override and reduce some over head.

If any one has better solution , do let me know.

Thanks in advance
Rajesh

On Nov 26, 2008, at 3:30 PM, rajesh wrote:


Hi all,

I have Custom NSView with set of boxes arranged in some pattern  
( boxes with some extra UI elements like , text fields and stuff).
I am using the gaps between the boxes a.k.a the visible custom  
NSView to add the NStrackingAreas for cursor updates and as well for  
resizing the subviews (i.e the NSBox)


As an obvious fact , when ever I try to resize the subviews I need  
to as well set the frame for the NSTrackingArea elements and here I  
is no such thing as setFrame


I googled around and found that , everybody is alloc-init ' ng and  
then set the tracking area to 'nil' or release and create a new  
NSTrackingArea then – initWithRect:options:owner:userInfo:  and use  
it.
I don't have fixed number of subviews or as a fact no fixed gaps ,  
hence the tracking areas count might shoot up to anything.


I think following the general approach will have a serious affect on  
efficiency , memory and other factors .
I can't use SplitView to manage the resizing of subviews ( I  
iterate, no fixed subview , and I need to collapse or expand a  
particular subview )


am I missing any obvious approach or is that I got off on wrong foot

Any help is appreciated

regards
Rajesh___

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

Please do not post 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/rajesh%40vangennep.nl

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: to get handle to "File/1.jpg"

2008-11-26 Thread James Montgomerie

On 26 Nov 2008, at 15:28, Jean-Daniel Dupas wrote:


Le 26 nov. 08 à 16:19, James Montgomerie a écrit :


On 26 Nov 2008, at 14:56, Nick Rogers wrote:

Hi,
How do I obtain a NSFileHandle to this file which has a forward  
slash in the name to be able to write to this file.
Supplying the path to NSFileHandle with filename in quotes also  
fails.

If not possible is there any other way to write to such a file.
I can't use open(), as the file name could contain chars from  
other language.



This file is only presented as having a '/' in the Finder UI (and  
hopefully other places that present filenames on-screen).  At the  
filesystem level, that '/' is really a ':' (to avoid clashing with  
the '/' directory seperator character).  Just replace the '/' with  
a ':' and you'll be set.




In fact, this is the contrary. It is presented as having a colon at  
the UNIX level, but really have a slash at the FS level.


http://www.macgeekery.com/gspot/2006-09/when_a_colons_a_slash_and_a_slashs_a_colon


True (on HFS and HFS-derived systems).  I'd call that more of an  
implementation detail though - It's not as if the filenames are stored  
on disk as UTF-8 strings either, but I'd still way that 'at the  
filesystem level', from an API-user's perspective, that's true.


Anyway, for someone who just wants to open a file, this is a bit  
academic.  The API's require UTF-8, and accept ':' characters, but not  
'/' characters.  '/' characters displayed in the Finder must be  
translated to ':' characters for interaction with the filesystem APIs,  
and vice-versa.


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: Killing a Thread

2008-11-26 Thread Scott Ribe
> The application is not crashing, but the thread is not exiting. From UI I'm
> giving a time interval say 10sec is set for the time interval between emails
> to be send. At the first time when I'm clicking the button to send email,
> the thread is getting called and is working fine and sends email to all
> email id's with a time interval of 10Sec. After that the thread is not exit
> and invokes the thread in every 10Sec. So when I'm button second time, the
> application get hanged, all windows and buttons get disabled and I can quit
> the application from debugger only.

1) If the thread is not exiting, then your function that you call on that
thread never completes, and you need to figure out why it doesn't.

Or 2) Or maybe it does complete, but without releasing a lock that it took.
You see, even if the thread didn't exit, that by itself would not cause a
hang when you try to create a new thread for the same function. In the
absence of locking in your code, you could create many many threads all
running the same function.

Or 3) You don't have explicit locking code of your own, but you're calling
code that does, and as in 1, the function you're calling never completes and
returns, thus holding a lock on some shared resource.

Impossible to say which without more information, but the solution is
absolutely NOT a "kill_thread" function.

-- 
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: to get handle to "File/1.jpg"

2008-11-26 Thread Jean-Daniel Dupas


Le 26 nov. 08 à 16:19, James Montgomerie a écrit :


On 26 Nov 2008, at 14:56, Nick Rogers wrote:

Hi,
How do I obtain a NSFileHandle to this file which has a forward  
slash in the name to be able to write to this file.
Supplying the path to NSFileHandle with filename in quotes also  
fails.

If not possible is there any other way to write to such a file.
I can't use open(), as the file name could contain chars from other  
language.



This file is only presented as having a '/' in the Finder UI (and  
hopefully other places that present filenames on-screen).  At the  
filesystem level, that '/' is really a ':' (to avoid clashing with  
the '/' directory seperator character).  Just replace the '/' with a  
':' and you'll be set.




In fact, this is the contrary. It is presented as having a colon at  
the UNIX level, but really have a slash at the FS level.


http://www.macgeekery.com/gspot/2006-09/when_a_colons_a_slash_and_a_slashs_a_colon


___

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

Please do not post 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: Number of Files on Volume

2008-11-26 Thread Joe Turner

Thanks :)

As long as I know it will not be deprecated anytime soon, I will use  
it :)


Cheers!
On Nov 26, 2008, at 9:19 AM, Jean-Daniel Dupas wrote:



Only the HIToolbox will be discontinued. All others API are already  
available in 64 bits app.


IMHO Apple is neither going to remove the CoreServices File Manager  
nor even mark it deprecated (before at least Mac OS 11 or 12).

There is no Cocoa API to efficiently access the File System.

And if you want do not want to use the File Manager, you will have  
to use the Darwin way, which is far more complex (and use under the  
hood by the File Manager).
Have a look at getattrlist() and the ATTR_VOL_FILECOUNT attribute  
(the man page provide a sample that show how to retreive the file  
count).



Le 26 nov. 08 à 15:53, Joe Turner a écrit :

I'm just worried that it will be deprecated soon with the release  
of Snow Leopard; it is Carbon.
Second, I just wanted to see if there was an easy Cocoa way; the  
CoreServices way works fine.

On Nov 26, 2008, at 8:51 AM, Jean-Daniel Dupas wrote:

Just a question, what was wrong with the CoreServices way ? (ie  
using FSGetVolumeInfo).


Le 26 nov. 08 à 15:19, Joe Turner a écrit :

Okay, maybe I spoke too soon... It worked twice. To get the  
number of files, I am doing this now:


- (NSNumber *)fileCount
{
	NSDictionary *attributes = [[NSFileManager defaultManager]  
fileSystemAttributesAtPath:path];

return [NSNumber numberWithDouble:
([[attributes objectForKey:NSFileSystemNodes]
			  doubleValue] - [[attributes  
objectForKey:NSFileSystemFreeNodes]

   doubleValue])];
}


The first two times I got the right number (752339), but now I am  
getting 18749375. Is this way even supposed to work?


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]


Re: to get handle to "File/1.jpg"

2008-11-26 Thread Michael Ash
On Wed, Nov 26, 2008 at 9:56 AM, Nick Rogers <[EMAIL PROTECTED]> wrote:
> Hi,
> How do I obtain a NSFileHandle to this file which has a forward slash in the
> name to be able to write to this file.
> Supplying the path to NSFileHandle with filename in quotes also fails.

Filenames cannot have slashes in them. If you think that your file has
one, then you are wrong. Very likely you think that it does because
Finder or other GUI apps are showing it to you that way. This is a
lie. A file which they display as having a / actually has a :, and the
character has been swapped dynamically. The slash is reserved as the
path separator and cannot be used as part of a filename. So try using
: instead.

> If not possible is there any other way to write to such a file.
> I can't use open(), as the file name could contain chars from other
> language.

This does not make sense. *Everything* uses open() in the end. It
handles other languages just fine as long as you use the correct
encoding, which on Mac OS X is UTF-8.

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: Code signing and verification

2008-11-26 Thread Michael Ash
On Wed, Nov 26, 2008 at 7:14 AM, Donnie Lee <[EMAIL PROTECTED]> wrote:
> Hello.
>
> I'd like to sign my Application and check this signature from another
> my Application. I've found how to sign an app, but I can't find how to
> check already signed app from objective-c/cocoa. Also I need to verify
> that the program was signed with my certificate, not with any other
> certificate. Can you tell me what class/functions I should to use?

There is currently no public API for code signing. You can use the
codesign command line tool. See the man page for how to use it and all
of the various options available.

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: Number of Files on Volume

2008-11-26 Thread Jean-Daniel Dupas


Only the HIToolbox will be discontinued. All others API are already  
available in 64 bits app.


IMHO Apple is neither going to remove the CoreServices File Manager  
nor even mark it deprecated (before at least Mac OS 11 or 12).

There is no Cocoa API to efficiently access the File System.

And if you want do not want to use the File Manager, you will have to  
use the Darwin way, which is far more complex (and use under the hood  
by the File Manager).
Have a look at getattrlist() and the ATTR_VOL_FILECOUNT attribute (the  
man page provide a sample that show how to retreive the file count).



Le 26 nov. 08 à 15:53, Joe Turner a écrit :

I'm just worried that it will be deprecated soon with the release of  
Snow Leopard; it is Carbon.
Second, I just wanted to see if there was an easy Cocoa way; the  
CoreServices way works fine.

On Nov 26, 2008, at 8:51 AM, Jean-Daniel Dupas wrote:

Just a question, what was wrong with the CoreServices way ? (ie  
using FSGetVolumeInfo).


Le 26 nov. 08 à 15:19, Joe Turner a écrit :

Okay, maybe I spoke too soon... It worked twice. To get the number  
of files, I am doing this now:


- (NSNumber *)fileCount
{
	NSDictionary *attributes = [[NSFileManager defaultManager]  
fileSystemAttributesAtPath:path];

return [NSNumber numberWithDouble:
([[attributes objectForKey:NSFileSystemNodes]
  doubleValue] - [[attributes 
objectForKey:NSFileSystemFreeNodes]
   doubleValue])];
}


The first two times I got the right number (752339), but now I am  
getting 18749375. Is this way even supposed to work?


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]


Re: to get handle to "File/1.jpg"

2008-11-26 Thread James Montgomerie

On 26 Nov 2008, at 14:56, Nick Rogers wrote:

Hi,
How do I obtain a NSFileHandle to this file which has a forward  
slash in the name to be able to write to this file.

Supplying the path to NSFileHandle with filename in quotes also fails.
If not possible is there any other way to write to such a file.
I can't use open(), as the file name could contain chars from other  
language.



This file is only presented as having a '/' in the Finder UI (and  
hopefully other places that present filenames on-screen).  At the  
filesystem level, that '/' is really a ':' (to avoid clashing with the  
'/' directory seperator character).  Just replace the '/' with a ':'  
and you'll be set.


As an aside, there's no reason you can't use open with files that have  
non-ASCII characters in their filenames.  All the BSD-level filesystem  
APIs accept UTF-8.  If you have an NSString containing the non-ASCII  
filename, you can just call '[myString fileSystemRepresentation]' to  
get an appropriate char * for use with the BSD level APIs (you'll  
still need to replace your '/'s with ':'s first though).


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: set position of alert panel

2008-11-26 Thread Michael Ash
On Tue, Nov 25, 2008 at 6:49 AM, Nishad Kumar <[EMAIL PROTECTED]> wrote:
>
> Hi all,i want to set the position of alert panel at centre of my 
> application's main window rather than screen centre. I developing my 
> application with Cocoa - Objective C. how can i do it. With thanks & 
> regards,Nishad.

Sounds like you want to use a sheet rather than an application-modal
panel. Have a look at NSAlert's
beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:
method for this.

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]


to get handle to "File/1.jpg"

2008-11-26 Thread Nick Rogers

Hi,
How do I obtain a NSFileHandle to this file which has a forward slash  
in the name to be able to write to this file.

Supplying the path to NSFileHandle with filename in quotes also fails.
If not possible is there any other way to write to such a file.
I can't use open(), as the file name could contain chars from other  
language.


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: Number of Files on Volume

2008-11-26 Thread Joe Turner
I'm just worried that it will be deprecated soon with the release of  
Snow Leopard; it is Carbon.
Second, I just wanted to see if there was an easy Cocoa way; the  
CoreServices way works fine.

On Nov 26, 2008, at 8:51 AM, Jean-Daniel Dupas wrote:

Just a question, what was wrong with the CoreServices way ? (ie  
using FSGetVolumeInfo).


Le 26 nov. 08 à 15:19, Joe Turner a écrit :

Okay, maybe I spoke too soon... It worked twice. To get the number  
of files, I am doing this now:


- (NSNumber *)fileCount
{
	NSDictionary *attributes = [[NSFileManager defaultManager]  
fileSystemAttributesAtPath:path];

return [NSNumber numberWithDouble:
([[attributes objectForKey:NSFileSystemNodes]
  doubleValue] - [[attributes 
objectForKey:NSFileSystemFreeNodes]
   doubleValue])];
}


The first two times I got the right number (752339), but now I am  
getting 18749375. Is this way even supposed to work?


Thanks!
On Nov 26, 2008, at 5:53 AM, Graham Lee wrote:


On 26/11/2008 08:28, "Andrew Farmer" <[EMAIL PROTECTED]> wrote:


On 25 Nov 08, at 16:44, Joe Turner wrote:

I have ben trying to find a good way to get an accurate count of
files on a Volume. Using a NSDirectoryEnumerator takes way too  
long

(a couples minutes), so, I figured out how to do it on the old
Carbon FileManager using [FSGetVolumeInfo...]

Is there a better way of doing it? Maybe with Cocoa tools?


If you want a non-Carbon way of doing this, take a look at  
statfs64().
It's not technically Cocoa, but it's not Carbon and it works just  
fine.


An equivalent to your code would simply be:

self.count = [NSNumber numberWithUnsignedLongLong:fsbuf.f_files];


In fact, f_files (when it works) reports the total number of nodes  
on the
filesystem, so you need to subtract f_ffree to find the number of  
nodes
which are occupied. Also, you need to test that neither of these  
numbers is

-1, as some filesystems don't support telling you that stuff.

Cheers,
Graham.
--
Graham Lee
Senior Macintosh Software Engineer, Sophos Plc.
+44 1235 540266
http://www.sophos.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/devlists%40shadowlab.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: Number of Files on Volume

2008-11-26 Thread Jean-Daniel Dupas
Just a question, what was wrong with the CoreServices way ? (ie using  
FSGetVolumeInfo).


Le 26 nov. 08 à 15:19, Joe Turner a écrit :

Okay, maybe I spoke too soon... It worked twice. To get the number  
of files, I am doing this now:


- (NSNumber *)fileCount
{
	NSDictionary *attributes = [[NSFileManager defaultManager]  
fileSystemAttributesAtPath:path];

return [NSNumber numberWithDouble:
([[attributes objectForKey:NSFileSystemNodes]
  doubleValue] - [[attributes 
objectForKey:NSFileSystemFreeNodes]
   doubleValue])];
}


The first two times I got the right number (752339), but now I am  
getting 18749375. Is this way even supposed to work?


Thanks!
On Nov 26, 2008, at 5:53 AM, Graham Lee wrote:


On 26/11/2008 08:28, "Andrew Farmer" <[EMAIL PROTECTED]> wrote:


On 25 Nov 08, at 16:44, Joe Turner wrote:

I have ben trying to find a good way to get an accurate count of
files on a Volume. Using a NSDirectoryEnumerator takes way too long
(a couples minutes), so, I figured out how to do it on the old
Carbon FileManager using [FSGetVolumeInfo...]

Is there a better way of doing it? Maybe with Cocoa tools?


If you want a non-Carbon way of doing this, take a look at  
statfs64().
It's not technically Cocoa, but it's not Carbon and it works just  
fine.


An equivalent to your code would simply be:

 self.count = [NSNumber numberWithUnsignedLongLong:fsbuf.f_files];


In fact, f_files (when it works) reports the total number of nodes  
on the
filesystem, so you need to subtract f_ffree to find the number of  
nodes
which are occupied. Also, you need to test that neither of these  
numbers is

-1, as some filesystems don't support telling you that stuff.

Cheers,
Graham.
--
Graham Lee
Senior Macintosh Software Engineer, Sophos Plc.
+44 1235 540266
http://www.sophos.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/devlists%40shadowlab.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]


NSTrackingArea strange requirement

2008-11-26 Thread rajesh

Hi all,

I have Custom NSView with set of boxes arranged in some pattern  
( boxes with some extra UI elements like , text fields and stuff).
I am using the gaps between the boxes a.k.a the visible custom NSView  
to add the NStrackingAreas for cursor updates and as well for resizing  
the subviews (i.e the NSBox)


As an obvious fact , when ever I try to resize the subviews I need to  
as well set the frame for the NSTrackingArea elements and here I is no  
such thing as setFrame


I googled around and found that , everybody is alloc-init ' ng and  
then set the tracking area to 'nil' or release and create a new  
NSTrackingArea then – initWithRect:options:owner:userInfo:  and use it.
I don't have fixed number of subviews or as a fact no fixed gaps ,  
hence the tracking areas count might shoot up to anything.


 I think following the general approach will have a serious affect on  
efficiency , memory and other factors .
I can't use SplitView to manage the resizing of subviews ( I iterate,  
no fixed subview , and I need to collapse or expand a particular  
subview )


am I missing any obvious approach or is that I got off on wrong foot

Any help is appreciated

regards
Rajesh___

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

Please do not post 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 get notification of rerun application

2008-11-26 Thread Macarov Anatoli
Example: http://www.cocoabuilder.com/archive/message/cocoa/2001/7/8/41850

- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender 
hasVisibleWindows:(BOOL)flag

{
     NSBeep();
     NSLog(@"Hi");

     return YES;
}

And in awakeFromNib in the same class

[NSApp setDelegate:self];



  
Вы уже с Yahoo!? 
Испытайте обновленную и улучшенную. Yahoo! Почту! http://ru.mail.yahoo.com
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Number of Files on Volume

2008-11-26 Thread Joe Turner
Okay, maybe I spoke too soon... It worked twice. To get the number of  
files, I am doing this now:


- (NSNumber *)fileCount
{
	NSDictionary *attributes = [[NSFileManager defaultManager]  
fileSystemAttributesAtPath:path];

return [NSNumber numberWithDouble:
([[attributes objectForKey:NSFileSystemNodes]
  doubleValue] - [[attributes 
objectForKey:NSFileSystemFreeNodes]
   doubleValue])];
}


The first two times I got the right number (752339), but now I am  
getting 18749375. Is this way even supposed to work?


Thanks!
On Nov 26, 2008, at 5:53 AM, Graham Lee wrote:


On 26/11/2008 08:28, "Andrew Farmer" <[EMAIL PROTECTED]> wrote:


On 25 Nov 08, at 16:44, Joe Turner wrote:

I have ben trying to find a good way to get an accurate count of
files on a Volume. Using a NSDirectoryEnumerator takes way too long
(a couples minutes), so, I figured out how to do it on the old
Carbon FileManager using [FSGetVolumeInfo...]

Is there a better way of doing it? Maybe with Cocoa tools?


If you want a non-Carbon way of doing this, take a look at  
statfs64().
It's not technically Cocoa, but it's not Carbon and it works just  
fine.


An equivalent to your code would simply be:

  self.count = [NSNumber numberWithUnsignedLongLong:fsbuf.f_files];


In fact, f_files (when it works) reports the total number of nodes  
on the
filesystem, so you need to subtract f_ffree to find the number of  
nodes
which are occupied. Also, you need to test that neither of these  
numbers is

-1, as some filesystems don't support telling you that stuff.

Cheers,
Graham.
--
Graham Lee
Senior Macintosh Software Engineer, Sophos Plc.
+44 1235 540266
http://www.sophos.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: Number of Files on Volume

2008-11-26 Thread Joe Turner

Thanks you!

I remembered that there was a NSFileSystemNodes and  
NSFileSystemFreeNodes in the filesystem attribute dictionary of the  
Cocoa FileManager, so, I did what you told me and subtracted free  
nodes from total nodes :)



On Nov 26, 2008, at 5:53 AM, Graham Lee wrote:


On 26/11/2008 08:28, "Andrew Farmer" <[EMAIL PROTECTED]> wrote:


On 25 Nov 08, at 16:44, Joe Turner wrote:

I have ben trying to find a good way to get an accurate count of
files on a Volume. Using a NSDirectoryEnumerator takes way too long
(a couples minutes), so, I figured out how to do it on the old
Carbon FileManager using [FSGetVolumeInfo...]

Is there a better way of doing it? Maybe with Cocoa tools?


If you want a non-Carbon way of doing this, take a look at  
statfs64().
It's not technically Cocoa, but it's not Carbon and it works just  
fine.


An equivalent to your code would simply be:

  self.count = [NSNumber numberWithUnsignedLongLong:fsbuf.f_files];


In fact, f_files (when it works) reports the total number of nodes  
on the
filesystem, so you need to subtract f_ffree to find the number of  
nodes
which are occupied. Also, you need to test that neither of these  
numbers is

-1, as some filesystems don't support telling you that stuff.

Cheers,
Graham.
--
Graham Lee
Senior Macintosh Software Engineer, Sophos Plc.
+44 1235 540266
http://www.sophos.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: Preventing a user from moving a window

2008-11-26 Thread Gregory Weston

Damien Cooke wrote:


Hi all,
I have an arrangement of windows that I do not want the user to move.
What is the best way of doing this.  There are several ways I thought
of but they are not very elegant.  Can someone point me in the right
direction?


The right direction is *probably* to rethink your design. If the user  
sees what looks like a normal window they're going to expect to be  
able to move it like a normal window and they're going to fill your  
days with support requests when they find they can't. Actually most  
of them will just curse under their breath and delete your software  
at first opportunity.


If you don't want a window moved, don't make it look like a window  
that can be moved. And that sentence alone gets you almost all the  
way to your goal.

___

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

Please do not post 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: Testing apps on 10.*

2008-11-26 Thread Gregory Weston


On Nov 25, 2008, at 9:03 PM, Gerriet M. Denkmann wrote:



On 26 Nov 2008, at 02:28, Gregory Weston <[EMAIL PROTECTED]> wrote:



macdev wrote:


I was wondering what the common ways are to test my application on
OSX 10.*
versions. Besides having a separate machine each having a different
version,
is there any other way you guys are using to test your apps?
Coming from
windows development, there you can test your apps using VMware on a
different flavor of windows.

How is this achieved on the Mac?


Keeping in mind that there *are* reasons to test on various hardware
configurations as well, if you're concerned about just testing
various OS versions I've found that it's sufficient to keep around a
FireWire HD with a different OS version on each partition and just
boot from the one I want to test.


It seems that newer hardware refuses to boot from older OS versions.
E.g. my white MacBook (2 weeks old) absolutely refuses to boot from  
Tiger.


Generally true. On the other hand, I should hope that when people are  
formulating their system requirements they're actually testing on the  
low-end of what they claim to support, and that would tend to be a  
machine that *is* capable of running the oldest OS they support as well.

___

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

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


Code signing and verification

2008-11-26 Thread Donnie Lee
Hello.

I'd like to sign my Application and check this signature from another
my Application. I've found how to sign an app, but I can't find how to
check already signed app from objective-c/cocoa. Also I need to verify
that the program was signed with my certificate, not with any other
certificate. Can you tell me what class/functions I should to use?

Donnie.
___

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

Please do not post 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 tell if app launched via login item (versus manual launch)

2008-11-26 Thread Mark Aufflick
Perfect thanks!

The only minor tweak is that the AE doesn't coerce into an int32Value
(you always get 0), instead I used the enumCodeValue method and it
works as advertised.

For the question about why I want to know - I have a preference option
to say don't open a default window if the application was opened at
login. This is different to choosing hidden in the login item because
the application can pop up windows on other events (which do not
override hiding on purpose).

That doesn't read very clearly - I hope it makes sense to anyone who cares :)

Mark.

On Wed, Nov 26, 2008 at 6:33 PM, Ken Thomases <[EMAIL PROTECTED]> wrote:
> On Nov 26, 2008, at 12:38 AM, Mark Aufflick wrote:
>
>> I'm wondering if it's possible to tell if my application was launched
>> normally by the user, or if it was launched by virtue of being in the
>> login items.
>
> You need to look up the Apple Event that is current at the time of your
> application's launch.  Use [[NSAppleEventManager sharedAppleEventManager]
> currentAppleEvent].
>
> If you're in applicationWill/DidFinishLaunching:, then it should be an "open
> application" (kAEOpenApplication, a.k.a. 'oapp') event.  Then, check the
> keyAEPropData parameter to see if it matches keyAELaunchedAsLogInItem:
>
>if ([[event paramDescriptorForKeyword:keyAEPropData] int32Value] ==
> keyAELaunchedAsLogInItem)
>// ...
>
> (Note that the parameter may not be present, in which case messaging to nil
> will cause the above 'if' condition to evaluate to false.  That's probably
> what you'd want, but just wanted to be clear.)
>
> See here:
>
> http://developer.apple.com/documentation/Carbon/Reference/Apple_Event_Manager/Reference/reference.html#//apple_ref/doc/uid/TP3134-CH4g-SW1
>
>
> Cheers,
> Ken
>
>



-- 
Mark Aufflick
  contact info at http://mark.aufflick.com/about/contact
___

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

Please do not post 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: Number of Files on Volume

2008-11-26 Thread Graham Lee
On 26/11/2008 08:28, "Andrew Farmer" <[EMAIL PROTECTED]> wrote:

> On 25 Nov 08, at 16:44, Joe Turner wrote:
>> I have ben trying to find a good way to get an accurate count of
>> files on a Volume. Using a NSDirectoryEnumerator takes way too long
>> (a couples minutes), so, I figured out how to do it on the old
>> Carbon FileManager using [FSGetVolumeInfo...]
>>
>> Is there a better way of doing it? Maybe with Cocoa tools?
>
> If you want a non-Carbon way of doing this, take a look at statfs64().
> It's not technically Cocoa, but it's not Carbon and it works just fine.
>
> An equivalent to your code would simply be:
>
>self.count = [NSNumber numberWithUnsignedLongLong:fsbuf.f_files];

In fact, f_files (when it works) reports the total number of nodes on the
filesystem, so you need to subtract f_ffree to find the number of nodes
which are occupied. Also, you need to test that neither of these numbers is
-1, as some filesystems don't support telling you that stuff.

Cheers,
Graham.
--
Graham Lee
Senior Macintosh Software Engineer, Sophos Plc.
+44 1235 540266
http://www.sophos.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: Programatically Triggering an NSSearchField Search

2008-11-26 Thread Steve Steinitz

Hi Frédéric

I determined that a single method will propagate a 
programatically-set  NSSearchFieldCell value to its NSArrayController:


[searchfield setStringValue: aSearchString];
[searchfield performClick: self];

Ta-Dum.

Thanks again Frédéric and all the best,

Steve

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Preventing a user from moving a window

2008-11-26 Thread Benjamin Dobson

On 26 Nov 2008, at 03:28:11, Damien Cooke wrote:


Hi all,
I have an arrangement of windows that I do not want the user to  
move.  What is the best way of doing this.  There are several ways I  
thought of but they are not very elegant.  Can someone point me in  
the right direction?


Regards
Damien


You could use the windowWillMove: delegate method, and reset the  
position of the window while the user is trying to move it. It's not  
ideal, but it should work (I haven't tested 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: NSTableView Drag-Drop re-ordering...

2008-11-26 Thread Chris Idou
--- On Wed, 26/11/08, Michael Robinson <[EMAIL PROTECTED]> wrote:

> I too had a horrible time implementing this.
> 
> Below I've pasted the code that handles dnd re-ordering
> in my table.
> 
> Basically it just makes a copy of the dragged row, deletes
> it, then rebuilds the array, inserting the dragged row at
> its new index.

This approach probably wouldn't work if you allow dragging of multiple rows at 
once.

This is what I did: Iterate the indexes, making a list of dragged items, and 
setting the old array items to be NSNull. Then insert the items at the 
designated index. Lastly remove all the NSNulls from the array.


NSMutableArray *allItemsArray = [NSMutableArray 
arrayWithArray:[fileArrayController arrangedObjects]];

NSMutableArray *draggedItemsArray = [NSMutableArray 
arrayWithCapacity:[rowIndexes count]];

NSUInteger currentItemIndex;
NSRange range = NSMakeRange( 0, [rowIndexes lastIndex] + 1 );
while([rowIndexes getIndexes:¤tItemIndex maxCount:1 inIndexRange:&range] 
> 0) {
NSManagedObject *thisItem = [allItemsArray 
objectAtIndex:currentItemIndex];
[draggedItemsArray addObject:thisItem];
[allItemsArray replaceObjectAtIndex:currentItemIndex withObject:[NSNull 
null]];
}
for (NSInteger i = [draggedItemsArray count]-1; 0 <= i; i--) {
NSString *file = [draggedItemsArray objectAtIndex:i];
[allItemsArray insertObject:file atIndex:row];
}
[allItemsArray removeObject:[NSNull null]];
[fileArrayController setContent:allItemsArray];

> 
> As I'm still new to ObjC, so I can't really go into
> details on how it works - but if you're like me then all
> you need is a working example!
> 
> #define MyPrivateTableViewDataType
> @"NSMutableDictionary"
> 
> - (void)awakeFromNib {
>  [table registerForDraggedTypes:[NSArray
> arrayWithObject:MyPrivateTableViewDataType]];
> }
> 
> //I'm not actually sure if this method is required...
> Like I said, I'm new to ObjC!
> - (BOOL)tableView:(NSTableView *)tv
> writeRowsWithIndexes:(NSIndexSet *)rowIndexes
> toPasteboard:(NSPasteboard*)pboard
> {
>  // Copy the row numbers to the pasteboard.
>  NSData *data = [NSKeyedArchiver
> archivedDataWithRootObject:rowIndexes];
>  [pboard declareTypes:[NSArray
> arrayWithObject:MyPrivateTableViewDataType]
> owner:controller];
>  [pboard setData:data forType:MyPrivateTableViewDataType];
>  return YES;
> }
> 
> - (NSDragOperation)tableView:(NSTableView*)tv
> validateDrop:(id )info
> proposedRow:(int)row
> proposedDropOperation:(NSTableViewDropOperation)op
> {
>  // Add code here to validate the drop
>  NSLog(@"validate Drop");
>  return NSDragOperationEvery;
> }
> 
> - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id
> )info row:(int)to
> dropOperation:(NSTableViewDropOperation)operation
> {
>  //this is the code that handles dnd ordering - my table
> doesn't need to accept drops from outside!  Hooray!
>  NSPasteboard* pboard = [info draggingPasteboard];
>  NSData* rowData = [pboard
> dataForType:MyPrivateTableViewDataType];
>  NSIndexSet* rowIndexes = [NSKeyedUnarchiver
> unarchiveObjectWithData:rowData];
>  int from = [rowIndexes firstIndex];
>NSMutableDictionary *traveller = [[controller
> arrangedObjects] objectAtIndex:from];
>  [traveller retain];
>int length = [[controller arrangedObjects] count];
>NSMutableArray *replacement = [NSMutableArray new];
> 
>int i;
>  for (i = 0; i <= length; i++){
>if(i == to){
>  if(from > to){
>  [controller insertObject:traveller
> atArrangedObjectIndex:to];
>  [controller
> removeObjectAtArrangedObjectIndex:from+1];
>  }
>  else{
>  [controller insertObject:traveller
> atArrangedObjectIndex:to];
>  [controller
> removeObjectAtArrangedObjectIndex:from];
>  }
>  }
>}
> }
> 
> 
> Jean-Nicolas Jolivet wrote:
> >  style="font-family: -moz-fixed">I'm pretty
> sure this has been covered before, however I can't find
> any good examples on how to implement it??
> > 
> > Right now my NSTableView is hooked to a subclass of
> NSArrayController, and it supports files getting dropped on
> it.. (basically the NSTableView displays files dropped from
> the finder)... that part works well, however, now I would
> like to implement drag/drop re-ordering of rows...
> > 
> > Any good examples on how to do that?
> > 
> > 
> > Jean-Nicolas Jolivet
> > [EMAIL PROTECTED]
> > http://www.silverscripting.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/idou747%40yahoo.com
> 
> This email sent to [EMAIL PROTECTED]


  Start your day with Yahoo!7 and win a Sony Bravia TV. Enter now 
http://au.docs.yahoo.com/homepageset/?p1=other&p2=au&p3=taglin

Re: NSTableView Drag-Drop re-ordering...

2008-11-26 Thread mmalcolm crawford


On Nov 26, 2008, at 2:02 AM, Jean-Nicolas Jolivet wrote:

Sorry for not spotting that one earlier... I thought  
WithAndWithoutBinding was basically the same example only more  
recent...!



I've updated the descriptions to try to make it more clear.

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: NSTableView Drag-Drop re-ordering...

2008-11-26 Thread Michael Robinson
(I really did intend for this to reach the list, but I hurriedly pressed 
the "reply to sender" hotkey)


Hi Jean-Nicolas

I too had a horrible time implementing this.

Below I've pasted the code that handles dnd re-ordering in my table.

Basically it just makes a copy of the dragged row, deletes it, then 
rebuilds the array, inserting the dragged row at its new index.


As I'm still new to ObjC, so I can't really go into details on how it 
works - but if you're like me then all you need is a working example!


#define MyPrivateTableViewDataType @"NSMutableDictionary"

- (void)awakeFromNib {
 [table registerForDraggedTypes:[NSArray 
arrayWithObject:MyPrivateTableViewDataType]];

}

//I'm not actually sure if this method is required... Like I said, I'm 
new to ObjC!
- (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet 
*)rowIndexes toPasteboard:(NSPasteboard*)pboard

{
 // Copy the row numbers to the pasteboard.
 NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
 [pboard declareTypes:[NSArray 
arrayWithObject:MyPrivateTableViewDataType] owner:controller];

 [pboard setData:data forType:MyPrivateTableViewDataType];
 return YES;
}

- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id 
)info proposedRow:(int)row 
proposedDropOperation:(NSTableViewDropOperation)op

{
 // Add code here to validate the drop
 NSLog(@"validate Drop");
 return NSDragOperationEvery;
}

- (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id 
)info row:(int)to 
dropOperation:(NSTableViewDropOperation)operation

{
 //this is the code that handles dnd ordering - my table doesn't need 
to accept drops from outside!  Hooray!

 NSPasteboard* pboard = [info draggingPasteboard];
 NSData* rowData = [pboard dataForType:MyPrivateTableViewDataType];
 NSIndexSet* rowIndexes = [NSKeyedUnarchiver 
unarchiveObjectWithData:rowData];

 int from = [rowIndexes firstIndex];
   NSMutableDictionary *traveller = [[controller arrangedObjects] 
objectAtIndex:from];

 [traveller retain];
   int length = [[controller arrangedObjects] count];
   NSMutableArray *replacement = [NSMutableArray new];

   int i;
 for (i = 0; i <= length; i++){
   if(i == to){
 if(from > to){
 [controller insertObject:traveller atArrangedObjectIndex:to];
 [controller removeObjectAtArrangedObjectIndex:from+1];
 }
 else{
 [controller insertObject:traveller atArrangedObjectIndex:to];
 [controller removeObjectAtArrangedObjectIndex:from];
 }
 }
   }
}


Jean-Nicolas Jolivet wrote:
I'm 
pretty sure this has been covered before, however I can't find any 
good examples on how to implement it??


Right now my NSTableView is hooked to a subclass of NSArrayController, 
and it supports files getting dropped on it.. (basically the 
NSTableView displays files dropped from the finder)... that part works 
well, however, now I would like to implement drag/drop re-ordering of 
rows...


Any good examples on how to do that?


Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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]


core-data multiple contexts or coordinators?

2008-11-26 Thread Chris Idou

The core-data documentation seems very vague about whether multiple threads 
should use different NSManagedObjectContexts but one 
NSPersistentStoreCoordinator, or multiple coordinators.

I've got an app where one thread needs to write, and one (or maybe more) 
threads need to read. One or more coordinators, what are the pros and cons?





  Start your day with Yahoo!7 and win a Sony Bravia TV. Enter now 
http://au.docs.yahoo.com/homepageset/?p1=other&p2=au&p3=tagline
___

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

Please do not post 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: NSTableView Drag-Drop re-ordering...

2008-11-26 Thread Jean-Nicolas Jolivet

Got it! thanks a lot for the code!

Sorry for not spotting that one earlier... I thought  
WithAndWithoutBinding was basically the same example only more  
recent...!


J-N

On 26-Nov-08, at 4:59 AM, mmalcolm crawford wrote:



On Nov 26, 2008, at 1:42 AM, Jean-Nicolas Jolivet wrote:

mmm interesting, I did download WithAndWithoutBindings before  
posting but it doesn't seem to implement drag and drop re- 
ordering... not in the WithBinding version at least... I'm trying  
it right now and it's definitely not working...
It seems like when they are saying "re-ordering" they mean column  
sorting, which I can do just fine... but definitely not drag and  
drop re-ordering..


WithAndWithoutBindings illustrates drop at an arbitrary location in  
the destination;
Bookmarks () provides a complete implementation of an array  
controller that supports drag and drop and reordering.


mmalc



Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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: Programatically Triggering an NSSearchField Search

2008-11-26 Thread Steve Steinitz

Hi Frédéric

Thank you for your helpful reply.

On 26/11/08, Frédéric Testuz wrote:


I'm not sure but did you try :

[searchfield validateEditing];

- (void)validateEditing


Thank you so much for pointing me to NSControl.  I found many 
goodies there.  validateEditing on its own did not solve the 
problem but I threw everything at it and now it works!


Here is what I added:

[searchfield validateEditing];
[searchfield abortEditing];
[searchfield performClick: self];
[searchfield controlTextDidEndEditing: nil];

In the morning, I'll work out the minimum required and report back.

Thanks again,

Steve

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTableView Drag-Drop re-ordering...

2008-11-26 Thread mmalcolm crawford


On Nov 26, 2008, at 1:42 AM, Jean-Nicolas Jolivet wrote:

mmm interesting, I did download WithAndWithoutBindings before  
posting but it doesn't seem to implement drag and drop re- 
ordering... not in the WithBinding version at least... I'm trying it  
right now and it's definitely not working...
It seems like when they are saying "re-ordering" they mean column  
sorting, which I can do just fine... but definitely not drag and  
drop re-ordering..


WithAndWithoutBindings illustrates drop at an arbitrary location in  
the destination;
Bookmarks () provides a complete implementation of an array  
controller that supports drag and drop and reordering.


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: [Reposted] Document based resource strategy

2008-11-26 Thread Gerriet M. Denkmann


On 26 Nov 2008, at 09:14, Jason Stephenson wrote:


Gerriet M. Denkmann wrote:

What version of Xcode do you have installed? I have 3.1.1 and  
Safari just says: "No file exists at the address “/Developer/ 
Documentation/DocSets/ 
com.apple.ADC_Reference_Library.CoreReference.docset/Contents/ 
Resources/Documents/documentation/Cocoa/Conceptual/Documents/ 
Documents.html”." So: are the conceptual documents (a.k.a Companion  
Guides) supposed to exist on my machine (implying that something  
went wrong with my installation) or have they disappeared for good  
(leaving dangling links all over  the place)?


Open Xcode and choose Documentation from the Help menu. If you don't  
have the Core Library DocSet already installed, it may be that you  
need to download it. Just click the button labeled "Subscribe" or  
"Get" next to Core Library in the left-hand frame of the  
documentation viewer window.


This was a very good advice indeed!
When I clicked on "Core Libray", Xcode informed me that "this is a  
partial documentation set. If you want more stuff to exist on your  
computer, you have to click "Subscribe"."
Which I did, and now all the companion guides are back in place, and  
finally I can start learning about the new Leopard things.


Kind regards,

Gerriet.

___

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

Please do not post 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: set position of alert panel

2008-11-26 Thread Mike Abdullah
I'd advise against this. Either accept the standardised system  
behaviour, or use a sheet instead.


That said, NSAlert has a -window method. You should be able to grab  
the window with that and place it wherever you like using - 
setFrame:display:


Mike.

On 25 Nov 2008, at 11:49, Nishad Kumar wrote:



Hi all,i want to set the position of alert panel at centre of my  
application's main window rather than screen centre. I developing my  
application with Cocoa - Objective C. how can i do it. With thanks &  
regards,Nishad.

_
Searching for the best deals on travel? Visit MSN Travel.
http://in.msn.com/coxandkings___

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

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


Re: NSTableView Drag-Drop re-ordering...

2008-11-26 Thread Jean-Nicolas Jolivet
mmm interesting, I did download WithAndWithoutBindings before posting  
but it doesn't seem to implement drag and drop re-ordering... not in  
the WithBinding version at least... I'm trying it right now and it's  
definitely not working...


It seems like when they are saying "re-ordering" they mean column  
sorting, which I can do just fine... but definitely not drag and drop  
re-ordering..


Jean-Nicolas Jolivet

On 26-Nov-08, at 4:36 AM, mmalcolm crawford wrote:



On Nov 26, 2008, at 12:37 AM, Jean-Nicolas Jolivet wrote:

Well it depends on which example you're talking about... you posted  
a google search result...
The first link (a cocoa builder link) has nothing to do with row re- 
ordering...
The second link (CocoaDev one) has a bunch of code examples but a  
bunch are from users saying they're having problems with said code...

Results 3, 4 and 5 don't seem to be related at all...
Am I missing something obvious??
Don't get me wrong, I really don't mind a "RTFM" style reply, but I  
did search google and cocoa builder for that one and couldnt find  
anything that seemed to work...


Well, the second link from the first search and the first link from  
the second search point indirectly and directly to  which contains:


With and Without Bindings
Shows a custom array controller that implements table view data  
source methods to support drag and drop, including copying objects  
from one window to another, drop of URLs, and re-ordering of the  
content array.
This example contains two implementations: the first uses  
standardNSTableView data source methods, the second uses bindings.


Bookmarks
This is the original version of "With and Without Bindings", and is  
slightly more advanced. It shows a custom array controller that  
implements table view data source methods to support drag and drop,  
including copying objects from one window to another, drop of URLs,  
and re-ordering of the content array.
This example only contains a bindings implementation, but supports  
multiple items in a drag, whereas the "With and Without Bindings"  
example does not; it also allows copying as well as moving within a  
table.




which seem to do what you want to do.



mmalc


Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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: NSTableView Drag-Drop re-ordering...

2008-11-26 Thread mmalcolm crawford


On Nov 26, 2008, at 12:37 AM, Jean-Nicolas Jolivet wrote:

Well it depends on which example you're talking about... you posted  
a google search result...
The first link (a cocoa builder link) has nothing to do with row re- 
ordering...
The second link (CocoaDev one) has a bunch of code examples but a  
bunch are from users saying they're having problems with said code...

Results 3, 4 and 5 don't seem to be related at all...
Am I missing something obvious??
Don't get me wrong, I really don't mind a "RTFM" style reply, but I  
did search google and cocoa builder for that one and couldnt find  
anything that seemed to work...


Well, the second link from the first search and the first link from  
the second search point indirectly and directly to  which contains:


With and Without Bindings
Shows a custom array controller that implements table view data source  
methods to support drag and drop, including copying objects from one  
window to another, drop of URLs, and re-ordering of the content array.
This example contains two implementations: the first uses  
standardNSTableView data source methods, the second uses bindings.


Bookmarks
This is the original version of "With and Without Bindings", and is  
slightly more advanced. It shows a custom array controller that  
implements table view data source methods to support drag and drop,  
including copying objects from one window to another, drop of URLs,  
and re-ordering of the content array.
This example only contains a bindings implementation, but supports  
multiple items in a drag, whereas the "With and Without Bindings"  
example does not; it also allows copying as well as moving within a  
table.




which seem to do what you want to do.



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: How to use IB to create a viewcontroller which actually linking to another nib file?

2008-11-26 Thread Jonathan Hess

Hey Hu -

You can drag a view controller into your document from the library,  
and then set the NIB name in the attributes inspector (command + 1).  
When the outer NIB is loaded, the view controller will be immediately  
created but will lazily load its view from the specified NIB/XIB.


Good luck -
Jon Hess

On Nov 26, 2008, at 3:39 PM, Hu Shaw wrote:


Hi All,

I'm a newbie here. And i'm not sure if I can send questions directly  
to this

mail list. If not, please kindly tell me how to ask questions. Thanks!

When I create a new prj using "viewbased app" template, it will  
create 2 nib
file. And in MainWindow.xib, thre is a viewcontroller, when I open  
it, it

says loaded from "another viewcontroller.nib".

Question is how do I mimic this behaviour and create a new  
viewcontroller

which suppose to load from a new xib file.


He Xiao
2008-11-26
___

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

Please do not post 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/jhess%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: NSTableView Drag-Drop re-ordering...

2008-11-26 Thread Jean-Nicolas Jolivet

Thanks a lot Chaitanya... exactly the kind of info i was looking for! :)


On 26-Nov-08, at 3:41 AM, chaitanya pandit wrote:

To re-order the items in the tableView, you will have to implement a  
custom drag type.

Say for example you name your custom drag type as @"myDragType"
then
1] Register your table view to accept this drag type using  
"registerForDraggedTypes:" and passing an array containing  
@"myDragType" along with super's drag types
2] In your tableView's data source, implement this method  
"tableView:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes 
:" and return an array containing @"myDragType".
3] Implement "tableView:writeRowsWithIndexes:toPasteboard:" in your  
data source and write any dummy data in the given pasteboard for  
type @"myDragType", this can be the data representing the items/ 
indexes being dragged
4] Check for a valid drop with  
"tableView:validateDrop:proposedRow:proposedDropOperation:"
5] Finally set the new indexes for the dragged items in   
"tableView:acceptDrop:row:dropOperation:"

HTH,
Chaitanya

On 26-Nov-08, at 1:36 PM, Jean-Nicolas Jolivet wrote:

As I said... I have no problems with dragging files on the data  
table... my table is already a drag destination and its working  
well...with the bindings in place etc...


What I can't find is good info about re-ordering the table row with  
drag and drop, and I did search google for the obvious key words  
(NSTableView drag drop order, NSTableView re-order etc etc..)


But thanks anyway...


On 26-Nov-08, at 2:58 AM, mmalcolm crawford wrote:



On Nov 25, 2008, at 11:26 PM, Jean-Nicolas Jolivet wrote:

I'm pretty sure this has been covered before, however I can't  
find any good examples on how to implement it??






mmalc




Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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/chaitanya%40expersis.com

This email sent to [EMAIL PROTECTED]




Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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: NSTableView Drag-Drop re-ordering...

2008-11-26 Thread chaitanya pandit
To re-order the items in the tableView, you will have to implement a  
custom drag type.

Say for example you name your custom drag type as @"myDragType"
then
1] Register your table view to accept this drag type using  
"registerForDraggedTypes:" and passing an array containing  
@"myDragType" along with super's drag types
2] In your tableView's data source, implement this method  
"tableView:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes 
:" and return an array containing @"myDragType".
3] Implement "tableView:writeRowsWithIndexes:toPasteboard:" in your  
data source and write any dummy data in the given pasteboard for type  
@"myDragType", this can be the data representing the items/indexes  
being dragged
4] Check for a valid drop with  
"tableView:validateDrop:proposedRow:proposedDropOperation:"
5] Finally set the new indexes for the dragged items in   
"tableView:acceptDrop:row:dropOperation:"

HTH,
Chaitanya

On 26-Nov-08, at 1:36 PM, Jean-Nicolas Jolivet wrote:

As I said... I have no problems with dragging files on the data  
table... my table is already a drag destination and its working  
well...with the bindings in place etc...


What I can't find is good info about re-ordering the table row with  
drag and drop, and I did search google for the obvious key words  
(NSTableView drag drop order, NSTableView re-order etc etc..)


But thanks anyway...


On 26-Nov-08, at 2:58 AM, mmalcolm crawford wrote:



On Nov 25, 2008, at 11:26 PM, Jean-Nicolas Jolivet wrote:

I'm pretty sure this has been covered before, however I can't find  
any good examples on how to implement it??






mmalc




Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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/chaitanya%40expersis.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: NSTableView Drag-Drop re-ordering...

2008-11-26 Thread Jean-Nicolas Jolivet
Well it depends on which example you're talking about... you posted a  
google search result...


The first link (a cocoa builder link) has nothing to do with row re- 
ordering...
The second link (CocoaDev one) has a bunch of code examples but a  
bunch are from users saying they're having problems with said code...

Results 3, 4 and 5 don't seem to be related at all...

Am I missing something obvious??

Don't get me wrong, I really don't mind a "RTFM" style reply, but I  
did search google and cocoa builder for that one and couldnt find  
anything that seemed to work...


Anyway... someone did reply to my email address saying he had a hard  
time implementing it, but he did provide some code samples/concrete  
info so I'll try to work from there...


Thanks for your time


On 26-Nov-08, at 3:29 AM, mmalcolm crawford wrote:



On Nov 26, 2008, at 12:06 AM, Jean-Nicolas Jolivet wrote:

What I can't find is good info about re-ordering the table row with  
drag and drop, and I did search google for the obvious key words  
(NSTableView drag drop order, NSTableView re-order etc etc..)



Did you look at the example?

mmalc



Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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: Programatically Triggering an NSSearchField Search

2008-11-26 Thread Frédéric Testuz

Le 26 nov. 08 à 04:57, Steve Steinitz a écrit :


Hello,

I use NSSearchFields bound to NSArrayControllers to allow my client  
to search their Core Data database.  Pretty standard.  My search  
predicate bindings are lengthy, giving my client lots of options to  
find what they want.


Occasionally I would like to programmatically specify a search for  
them.  For example, I was able to programmatically clear their  
search fields like this:


   [searchfield setStringValue: @""];
   [arrayController setFilterPredicate: nil];

However I can't work out how to set the correct non-nil predicate.   
Actually, I don't want to set the  predicate -- that's already done  
nicely in the bindings and I don't want to duplicate it in the code,  
for maintenance reasons.  ** I just want to put something in the  
search field and make it 'do it' **


I've tried increasingly desperate ideas to 'do' the search string.   
Here is my most recent defeat - sad, perhaps comical:


   [searchfield setStringValue: @"10471"];
   [arrayController setFilterPredicate: [arrayController  
filterPredicate]]; // :)


(How) can I just trigger the search after setting the  
NSSearchField's value?


I'm not sure but did you try :

[searchfield validateEditing];

- (void)validateEditing

Discussion
Validation sets the object value of the cell to the current contents  
of the cell’s editor (the NSTextobject used for editing), storing it  
as a simple NSString or an attributed string object based on the  
attributes of the editor.


Frédéric___

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

Please do not post 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: NSTableView Drag-Drop re-ordering...

2008-11-26 Thread mmalcolm crawford


On Nov 26, 2008, at 12:06 AM, Jean-Nicolas Jolivet wrote:

What I can't find is good info about re-ordering the table row with  
drag and drop, and I did search google for the obvious key words  
(NSTableView drag drop order, NSTableView re-order etc etc..)



Did you look at the example?

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: Number of Files on Volume

2008-11-26 Thread Andrew Farmer

On 25 Nov 08, at 16:44, Joe Turner wrote:
I have ben trying to find a good way to get an accurate count of  
files on a Volume. Using a NSDirectoryEnumerator takes way too long  
(a couples minutes), so, I figured out how to do it on the old  
Carbon FileManager using [FSGetVolumeInfo...]


Is there a better way of doing it? Maybe with Cocoa tools?


If you want a non-Carbon way of doing this, take a look at statfs64().  
It's not technically Cocoa, but it's not Carbon and it works just fine.


An equivalent to your code would simply be:

#include 
#include 

// ...

struct statfs64 fsbuf;
if(!statfs([volumePath fileSystemRepresentation], &fsbuf)) {
  self.count = [NSNumber numberWithUnsignedLongLong:fsbuf.f_files];
} else {
  // handle an error...
}


PS: Any reason why you're using a NSNumber as the property? It'll be a  
lot easier to just use an integral type unless there's some pressing  
need for an object.

___

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

Please do not post 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: NSTableView Drag-Drop re-ordering...

2008-11-26 Thread Jean-Nicolas Jolivet
As I said... I have no problems with dragging files on the data  
table... my table is already a drag destination and its working  
well...with the bindings in place etc...


What I can't find is good info about re-ordering the table row with  
drag and drop, and I did search google for the obvious key words  
(NSTableView drag drop order, NSTableView re-order etc etc..)


But thanks anyway...


On 26-Nov-08, at 2:58 AM, mmalcolm crawford wrote:



On Nov 25, 2008, at 11:26 PM, Jean-Nicolas Jolivet wrote:

I'm pretty sure this has been covered before, however I can't find  
any good examples on how to implement it??






mmalc




Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.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]


How to use IB to create a viewcontroller which actually linking to another nib file?

2008-11-26 Thread Hu Shaw
Hi All,

I'm a newbie here. And i'm not sure if I can send questions directly to this
mail list. If not, please kindly tell me how to ask questions. Thanks!

When I create a new prj using "viewbased app" template, it will create 2 nib
file. And in MainWindow.xib, thre is a viewcontroller, when I open it, it
says loaded from "another viewcontroller.nib".

Question is how do I mimic this behaviour and create a new viewcontroller
which suppose to load from a new xib file.


He Xiao
2008-11-26
___

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

Please do not post 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: Chapters in Hillegass to skip on first reading?

2008-11-26 Thread Gustavo Pizano

HEllo,
Well Im following the book as well and the chapters you mention are  
really interesting and short, the problem is that some chapter  are  
related so it happened to me that I skipped one and I saw that it was  
related with the  prior project.




Gus

On 26.11.2008, at 0:30, Ulai Beekam wrote:



Hi,
Let's say I have a plan for a simple app. Nothing too fancy, in a  
way. To name an example, it could be one like ShoveBox or Things.  
Mine is probably simpler than those. (It will be a good looking UI  
and icon that will be more trickier part for me.)
I've already read more than half of Hillegass (3rd edition) and now  
I need to know what chapters I can safely skip.

These are the chapters I'm considering skipping:
--23. Drag and Drop (skip until I actually  
need any dragging and dropping)

24. NSTimer (I doubt I will need any delaying)
27. Web service (This one I'm not as sure about. For example, do  
auto-update mechanisms in Cocoa apps rely on web services, and  
hence, the info in this very chapter?)
30. Core data (because I'm not using CoreData. Not NSArrayController  
either. I'm going to code without them to start with.)

31. Garbage Collection (because I'm not using garbage collection)

32. Core Animation (don't see why I would need that)
33. A Simple Cocoa/OpenGL Application (again, don't see the need atm)
34. NSTask (again, no need apparent)--
So I just wanted to make sure you all agree with the chapters I am  
planning on skipping. Please consider especially the chapter 27 on  
web service, because if that update mechanism all Cocoa apps out  
there seem to have rely on the info in this chapter I will need to  
read it.

Thanks, U
_
Invite your mail contacts to join your friends list with Windows  
Live Spaces. It's easy!

http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us___

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

Please do not post 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/gustavxcodepicora%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: Chapters in Hillegass to skip on first reading?

2008-11-26 Thread Michael Grant
I'd reconsider skipping the Core Data chapter. You can save yourself a
LOT of coding with Core Data.

Michael

On Tue, Nov 25, 2008 at 5:30 PM, Ulai Beekam <[EMAIL PROTECTED]> wrote:
>
> Hi,
> Let's say I have a plan for a simple app. Nothing too fancy, in a way. To 
> name an example, it could be one like ShoveBox or Things. Mine is probably 
> simpler than those. (It will be a good looking UI and icon that will be more 
> trickier part for me.)
> I've already read more than half of Hillegass (3rd edition) and now I need to 
> know what chapters I can safely skip.
> These are the chapters I'm considering skipping:
> --23. Drag and Drop (skip until I actually need any 
> dragging and dropping)
> 24. NSTimer (I doubt I will need any delaying)
> 27. Web service (This one I'm not as sure about. For example, do auto-update 
> mechanisms in Cocoa apps rely on web services, and hence, the info in this 
> very chapter?)
> 30. Core data (because I'm not using CoreData. Not NSArrayController either. 
> I'm going to code without them to start with.)
> 31. Garbage Collection (because I'm not using garbage collection)
>
> 32. Core Animation (don't see why I would need that)
> 33. A Simple Cocoa/OpenGL Application (again, don't see the need atm)
> 34. NSTask (again, no need apparent)--
> So I just wanted to make sure you all agree with the chapters I am planning 
> on skipping. Please consider especially the chapter 27 on web service, 
> because if that update mechanism all Cocoa apps out there seem to have rely 
> on the info in this chapter I will need to read it.
> Thanks, U
> _
> Invite your mail contacts to join your friends list with Windows Live Spaces. 
> It's easy!
> http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post 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/mgrant%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>



-- 
You have to be happy with what you have to be happy with what you have
to be happy with.
___

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

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


Number of Files on Volume

2008-11-26 Thread Joe Turner
I have ben trying to find a good way to get an accurate count of files  
on a Volume. Using a NSDirectoryEnumerator takes way too long (a  
couples minutes), so, I figured out how to do it on the old Carbon  
FileManager using:


FSVolumeInfo info;
FSRef pathRef;
FSCatalogInfo catInfo;
const char *inPath = [volumePath  
cStringUsingEncoding:NSUTF8StringEncoding];


FSPathMakeRef((UInt8 *)inPath, &pathRef, NULL);

FSGetCatalogInfo(&pathRef, kFSCatInfoGettableInfo, &catInfo, NULL,  
NULL, NULL);


FSGetVolumeInfo(catInfo.volume, 0, NULL, kFSVolInfoGettableInfo,  
&info, NULL, NULL);


self.count = [NSNumber numberWithInt:info.fileCount];

Is there a better way of doing it? Maybe with Cocoa tools?

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]


Do I need Custom View inside a hud panel to drag-n-drop images ??

2008-11-26 Thread Gustavo Pizano
Hello, well Im new to cocoa programing, but eager to learn, Im doing a  
small project, a naval battle game,  I have a HUD panel which contains  
5 NSImageView, one per Ship,(Carrier, frigate,...etc), and I wish to  
drag-ndrop those images which actually represents my objects in my  
model, into the gameboard(which is a custom view) inside the main  
window.


I think I know how to make the drag and drop, and the methods I must  
implement to achieve that, the problem I have is that those methods  
are from NSView,
like dragginExited:, prepareForDragOperation, and others, so I see  
that the NSImageView is a subclass of  NSControl;:NSView,  I thought,  
"Hey so let's put those methods mentioned above into the..."  and  
that was all, I tough then maybe lets make a category for NSImageView?  
with those methods? but then I realize  there could be problems with  
the NSView methods,
SO Im wondering if I need a custom view inside the HUD panel, who will  
contain the NSImageViews, and there implements the methods,  
draggingEntered:, dragginExited:,preparedForDragginOperation: etc.


.. Or there is another way I could achieve this?

Thanks

Gus


___

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

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


set position of alert panel

2008-11-26 Thread Nishad Kumar

Hi all,i want to set the position of alert panel at centre of my application's 
main window rather than screen centre. I developing my application with Cocoa - 
Objective C. how can i do it. With thanks & regards,Nishad.
_
Searching for the best deals on travel? Visit MSN Travel.
http://in.msn.com/coxandkings___

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

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