Storing NSDocument data in packages/bundles

2008-12-31 Thread Markus Spoettl

Hello List,

  I'm thinking of switching from a single-file based document file  
storage to a package document with various files in it, I have a  
little problem with that though:


My app stores a lot of data in a document, potentially hundreds of  
megabytes. The problem with using single files and NSKeyedArchiver is  
that one has to write everything, even if only a tiny part of the  
structure changed. My data is clustered into handy little pieces which  
could be saved into their own separate files within the package.


The problem is that - if I understand it correctly - when using file  
wrapper -fileWrapperOfType: of NSDocument, I always have to provide  
the complete wrapper, including all contained wrappers. That of course  
is exactly what I hoped to avoid because it means I'd have to write  
all data (this time into separate files/wrappers).


The NSBundle guide mentions another technique of using traditional  
file system methods for loading and saving when you have special  
needs. It's rather vague beyond that and I was hoping to get some  
hints as to how to tackle this problem.


I wouldn't mind loading all the data at once. What I'm after is a  
mechanism that would allow me to update only parts of the package  
(adding, changing or deleting files as needed). Is there any chance I  
can use -fileWrapperOfType: for that?


Looking at the NSDocument file saving message flow, it seems rather  
difficult to come up with something completely different. The document  
location you're saving to is not the final location of the real  
document on the disk. That of course prevents you from only writing  
parts of the document because the other stuff would be lost when your  
new version is moved to its final destination.


So the question is, can I use NSDocument with an update-relevant- 
parts-of-a-package-only saving mechanism? Thanks for any pointers!


Regards
Markus
--
__
Markus Spoettl

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Reversing a String

2008-12-31 Thread Martin Wierschin
Unfortunately, this is not correct; -[NSString characterAtIndex:]  
returns a unichar, which is not a char.  In addition, it will give  
odd results for composed characters.  Depending on what you want,  
you might be able to use rangeOfComposedCharacterAtIndex:.


I'd also use NSMutableString instead of a stack buffer of chars,  
since this looks like a buffer overflow (unless I'm missing  
something):


I think this is definitely the way to go. Something like this  
(untested, typed into Mail):


- (NSString*) reversedString
{
unsigned len = [self length];
NSMutableString* reversed = [NSMutableString stringWithCapacity:len];

unsigned charIdx = len;
while( charIdx  0 ) {
		NSRange charRng = [self rangeOfComposedCharacterSequenceAtIndex: 
(charIdx - 1)];

[reversed appendString:[self substringWithRange:charRng]];
charIdx = charRng.location;
}

return reversed;
}

Naturally this will be horribly inefficient, as it creates a new  
object for every composed character sequence, but the logic is likely  
what an end-user would expect a reversed string to look like.


If you ever actually needed to optimize the string reversal you could  
drop down to using a reasonably sized unichar buffer and  
getCharacters:inRange: to do it in batches. I'm not sure how one  
would best optimize the composed character sequences calculations,  
but probably checking against +[NSCharacterSet nonBaseCharacterSet]  
would be good enough.


~Martin
___

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

Please do not post 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 arch...@mail-archive.com


Re: Storing NSDocument data in packages/bundles

2008-12-31 Thread Kyle Sluder
On Wed, Dec 31, 2008 at 3:51 AM, Markus Spoettl
msappleli...@toolsfactory.com wrote:
 My app stores a lot of data in a document, potentially hundreds of
 megabytes. The problem with using single files and NSKeyedArchiver is that
 one has to write everything, even if only a tiny part of the structure
 changed. My data is clustered into handy little pieces which could be saved
 into their own separate files within the package.

Have you thought of using Core Data instead?  This is what the SQLite
store is designed to address.

 The problem is that - if I understand it correctly - when using file wrapper
 -fileWrapperOfType: of NSDocument, I always have to provide the complete
 wrapper, including all contained wrappers. That of course is exactly what I
 hoped to avoid because it means I'd have to write all data (this time into
 separate files/wrappers).

That is correct.  You have to implement -readFromURL:ofType:error: and
-writeToURL:ofType:forSaveOperation:originalContentsURL:error: if you
want to go the document-package route and not wind up with wholesale
writing.  This means, of course, that you need to be able to tell what
has changed in the document, and then be able to determine which
fragments need to be updated on disk.

--Kyle Sluder
___

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

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

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

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


NSColorWell with NSTextView-------need help

2008-12-31 Thread rethish
Hi all,


In my application I use two instance of nscolorwell, one for foreground
color (which is a default one) and second one for setting the background
color.
For setting the background color I used the code:

[textview setBackgroundColor:[colorwel color]];

This works upto some extend,the background color is changed ,if the
nscolorwell is clicked without selecting a range from the nstextview.

The problem is ,when we select a range of text from the nstextview and click
the nscolorwell (background instance) the text color also is changed .(ie
the text color and background color become same )

I want to set background color alone upto some range.


Please help

Happy New Year


Thanks in advance



___

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

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

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

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


Re: Storing NSDocument data in packages/bundles

2008-12-31 Thread Markus Spoettl

On Dec 31, 2008, at 12:57 AM, Kyle Sluder wrote:

On Wed, Dec 31, 2008 at 3:51 AM, Markus Spoettl
msappleli...@toolsfactory.com wrote:

My app stores a lot of data in a document, potentially hundreds of
megabytes. The problem with using single files and NSKeyedArchiver  
is that
one has to write everything, even if only a tiny part of the  
structure
changed. My data is clustered into handy little pieces which could  
be saved

into their own separate files within the package.


Have you thought of using Core Data instead?  This is what the SQLite
store is designed to address.


No I have not, but I have a feeling that it wouldn't be suitable. The  
data I store contains (when the document is big) millions of double  
values (amongst other things) spread across hundreds of thousands of  
objects. If the performance of NSKeyedArchiver is any indication the  
system wouldn't scale very well. It is an assumption and it might be  
totally wrong but I guess the overhead of keyed archiving is  
significantly less than that of Core Data.


The problem is that - if I understand it correctly - when using  
file wrapper
-fileWrapperOfType: of NSDocument, I always have to provide the  
complete
wrapper, including all contained wrappers. That of course is  
exactly what I
hoped to avoid because it means I'd have to write all data (this  
time into

separate files/wrappers).


That is correct.  You have to implement -readFromURL:ofType:error: and
-writeToURL:ofType:forSaveOperation:originalContentsURL:error: if you
want to go the document-package route and not wind up with wholesale
writing.  This means, of course, that you need to be able to tell what
has changed in the document, and then be able to determine which
fragments need to be updated on disk.



That's no problem, that information is available. The documentation  
for -writeToURL:ofType:forSaveOperation:originalContentsURL:error:  
states:


--
The value of absoluteURL is often not the same as [self fileURL].  
Other times it is not the same as the URL for the final save  
destination. Likewise, absoluteOriginalContentsURL is often not the  
same value as [self fileURL].

--

which is a little problem because to update my packages I need to  
original location. Do you have any insights as to what often not the  
same in this context might mean? To write the diff into the package  
I'd have to have access to the package. It doesn't sounds as it that's  
guaranteed.


Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Reversing a String (Gabe Shahbazian)

2008-12-31 Thread Peter Hudson
I have been using the following for a while across a number of  
languages without problems.



NSString *s = @Hello;
unsigned int length  = [s  length];
unsigned int index = length - 1;

NSMutableArray *ma = [NSMutableArray  array];

while( index  UINT_MAX )
{
NSRange rng = NSMakeRange( index, 1 );
[ma  addObject:[s  substringWithRange:rng]];
--index;
}

NSString *reversed = [ma  componentsJoinedByString:@];
NSLog(@reversed : %@,reversed);


PGJH

___

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

Please do not post 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 arch...@mail-archive.com


Re: Storing NSDocument data in packages/bundles

2008-12-31 Thread Kyle Sluder
On Wed, Dec 31, 2008 at 4:16 AM, Markus Spoettl
msappleli...@toolsfactory.com wrote:
 No I have not, but I have a feeling that it wouldn't be suitable. The data I
 store contains (when the document is big) millions of double values (amongst
 other things) spread across hundreds of thousands of objects. If the
 performance of NSKeyedArchiver is any indication the system wouldn't scale
 very well. It is an assumption and it might be totally wrong but I guess the
 overhead of keyed archiving is significantly less than that of Core Data.

Quite the contrary, I'm afraid.  Although without actually testing it,
you can't know for sure.

 That's no problem, that information is available. The documentation for
 -writeToURL:ofType:forSaveOperation:originalContentsURL:error: states:

 --
 The value of absoluteURL is often not the same as [self fileURL]. Other
 times it is not the same as the URL for the final save destination.
 Likewise, absoluteOriginalContentsURL is often not the same value as [self
 fileURL].
 --

 which is a little problem because to update my packages I need to original
 location. Do you have any insights as to what often not the same in this
 context might mean? To write the diff into the package I'd have to have
 access to the package. It doesn't sounds as it that's guaranteed.

For safe save operations, AppKit writes the data to a temporary file
on the same volume, and then swaps the old file with the new, which is
an atomic operation.  If it can't do that, it will rename the original
file and write the new one with the old name.  This is why absoluteURL
or absoluteOriginalContentsURL won't necessarily jive with -fileURL
(see the comment header for -[NSDocument
writeSafelyToURL:ofType:forSaveOperation:error:] for more details).
The upshot is that absoluteOriginalContentsURL will be a URL which you
can use to access your existing on-disk data, whether or not AppKit
has temporarily renamed it.

--Kyle Sluder
___

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

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

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

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


Re: Storing NSDocument data in packages/bundles

2008-12-31 Thread Kyle Sluder
By the way, this means that you can't just write out a diff to the
existing file on disk.  You must replace the entire file inside your
document package.  This is what I had thought you would originally
want to do; you are still performing wholesale writes, but not of the
entire document, just the shards within the package whose contents are
affected.
___

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

Please do not post 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 arch...@mail-archive.com


Automatically filling an app with test data

2008-12-31 Thread Matteo Manferdini
Hi everyone.
I've finally come to the end of my app and now I need to test it with
data. The test with some data generated manually goes weel, but now I
have to fill the app with lots of data, to see how it behaves. Is
there a common approach to doing this?

I came across the Cocoa scripting guide, and it seems the way to go,
but I wonder if it would not be better to write some code that fills
automatically the app instead of going through the guide to learn how
to make my app scriptable.

I'm using core data to store all application data, so maybe there is a
way I'm not considering.
Thank you very much.
Cheers.

Matteo Manferdini.
Pawn Software
www.pawn-soft.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 arch...@mail-archive.com


AW: AW: NSColorWell shows no color

2008-12-31 Thread tobias assmann
Hello,

I had a look in my nib file again and checked the following things:

no bindings are enabled
awake from nib is being called (can`t use debugger cause it is no app, but a 
gui of a audio unit, but printf told me)
I have exactly four instances of color well in my view

And here is the cause of my problem: 

The view is overlapping my whole gui and its visibility should be toggled by a 
button of its superview:

// 'Show / Hide Preferences' Button has been pressed
- (IBAction)iaShowPreferences:(id)sender{

if([splitView isHidden])
[splitView setHidden:NO];
else
[splitView setHidden:YES];

if([prefView isHidden])
[prefView setHidden:NO];
else
[prefView setHidden:YES];

}

In IB the hidden checkbox of the preference gui was checked. It always seemed 
to work, exept the wells of course ;-)

If I uncheck 'hidden' the wells draw like they should, but I can`t see me other 
gui anymore. Everything works fine if I fire up the gui with my splitview 
having a [self setHidden:YES]; in awakeFromNib, exept I would like to see the 
splitView on startup :-(

The wells seem to get the white color, by setting there view to hidden in IB or 
awakeFromNib. But it`s is no problem to hide the view after it has been drawed 
once?! Seems a strange behaviour to me

But many thanks for your answers up to hereand a nubby yoo yea ;-) of course

Tobias





Von: Andy Lee ag...@mac.com
An: tobias assmann bool_p...@yahoo.de
CC: cocoa-dev@lists.apple.com
Gesendet: Mittwoch, den 31. Dezember 2008, 05:04:26 Uhr
Betreff: Re: AW: NSColorWell shows no color

On Dec 30, 2008, at 2:22 PM, tobias assmann wrote:
 I have built the stuff in IB. And looking into the nib file again, I have 
 seen the should really show blue. But they are white, no matter if I set a 
 color or not..

I wonder if this could be caused by inadvertently setting a binding?  
*Something* is changing the color well's color from the default provided by IB. 
 If you select the color well in IB and select the Bindings inspector, is the 
Bind to check box unchecked?

 Unfortunately there is no more code related with the wells except having 
 actions handling if a color gets choosen:
 
 //  InActiveBeatColor has been selected
 - (IBAction)iaSelectInactiveBeatColor:(id)sender{
[topv.colors setColor:[sender color] forKey:@inactiveBeat];
 }
 
 I am working on a cocoa gui of a audio unit. Because of this I don`t know how 
 to do further debugging. It is my first experience in cocoa and osx 
 programming :-(

My general approach when stumped is to question my simplest assumptions.

How sure are you that your awakeFromNib is being called?  If you add a 
breakpoint at the beginning of awakeFromNib and run the debugger, do you break 
there?  If not, maybe you misspelled or miscapitalized awakeFromNib?  And while 
you're in the debugger, can you confirm that your four NSColorWell outlets are 
non-nil and all different?

Every once in a while someone realizes they accidentally made two instances of 
a subview, one exactly overlapping the other.  In IB, if you go into list view, 
can you confirm that you have exactly four instances of NSColorWell in your 
window?

As an experiment, what if you create an entirely new color well and another 
outlet, and add a line to awakeFromNib that sets *that* color well's color?  
That should absolutely, positively work since nothing about the rest of your 
code could possibly be screwing it up.

--Andy


 Is there a way to have a closer look at the code produced by IB?? Maybe 
 something is happening there..
 
 TIA!!!
 
 Tobias
 
 
 
 
 
 Von: Graham Cox graham@bigpond.com
 An: tobias assmann bool_p...@yahoo.de
 CC: cocoa-dev@lists.apple.com
 Gesendet: Dienstag, den 30. Dezember 2008, 12:22:11 Uhr
 Betreff: Re: NSColorWell shows no color
 
 
 On 30 Dec 2008, at 10:09 pm, tobias assmann wrote:
 
 I changed the place of the initialization now. Still no difference.. The 
 colors are valid. I checked this and also tried with predefined colors like 
 [NSColor greenColor]. It seems a very strange problem to me. So am I right 
 if I think, the colors should be drawn after they are set? Would make sense 
 I my opinion.
 
 
 Yes, they should immediately show the set colour with no further work on your 
 part.
 
 Clearly something else is wrong. Did you set up the interface in code or in 
 IB? Usually when colour wells are created in IB they default to blue. If 
 yours are white then it looks as if something is setting them, and white is 
 suspicious because it's all 1's.
 
 You need to post more code or go through it closely in the debugger.
 
 --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 

Re: Odd EXEC_BAD_ACCESS after executing URLRequest

2008-12-31 Thread marc hoffman

Jacob,

Are you sure you are not accidentally triggering two  'send message'  
calls concurrently. One of the most common causes of this problem is  
that your second request is over-writing the variables of an already  
in progress request. Check that done is not set to yes when you call  
your 'send message' function.


i'm pretty sure that's not the case, but i'll add a check, just to be  
sure, thanx.


marc
___

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

Please do not post 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 arch...@mail-archive.com


Re: Storing NSDocument data in packages/bundles

2008-12-31 Thread Quincey Morris

On Dec 31, 2008, at 01:32, Kyle Sluder wrote:


For safe save operations, AppKit writes the data to a temporary file
on the same volume, and then swaps the old file with the new, which is
an atomic operation.  If it can't do that, it will rename the original
file and write the new one with the old name.  This is why absoluteURL
or absoluteOriginalContentsURL won't necessarily jive with -fileURL
(see the comment header for -[NSDocument
writeSafelyToURL:ofType:forSaveOperation:error:] for more details).
The upshot is that absoluteOriginalContentsURL will be a URL which you
can use to access your existing on-disk data, whether or not AppKit
has temporarily renamed it.


I don't see how trying to do this in - 
writeToURL:ofType:forSaveOperation:originalContentsURL:error: is ever  
going to work.


If you are given (basically) an old and new package location, then  
you're forced to copy everything:


-- Trying to write changed files in the old location would be a really  
bad idea.


-- Moving the unchanged files from the old location to the new  
location would probably work (if the save operation is a pure save,  
not a save-as or save-to), but would be a really bad idea if there was  
an error during the save (because the contents of the new location  
would presumably get thrown away).


The *real* question here is: what's a *safe* strategy for saving a  
package by changing parts of it? You really need a single atomic  
operation to commit the changes, and most file systems don't provide  
this for an arbitrary set of files. NSDocument's answer is that there  
isn't a safe strategy, so it always saves by creating a copy. (And  
even that's not perfectly safe if the file system doesn't provide the  
equivalent of FSSwapFiles.)


Using Core Data as the storage mechanism for blobs of data is a  
possibility, but it's also a PITA because:


-- you likely need to turn off NSPersistentDocument's undo handling  
and provide your own


-- Core Data doesn't have save-to, and its save-as sucks (does a store  
migration)


-- if you have a lot of data, Core Data is going to keep copies of  
much of it in internal caches


My suggestion would be to go ahead and use a package document format,  
and to copy the unchanged files, and see how long it takes. If the  
save times are unacceptable, then a database solution (not Core Data)  
is probably the next step.


FWIW


___

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

Please do not post 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 arch...@mail-archive.com


Re: NSColorWell with NSTextView-------need help

2008-12-31 Thread Ross Carter
The problem is ,when we select a range of text from the nstextview  
and click
the nscolorwell (background instance) the text color also is  
changed .(ie

the text color and background color become same )


Search the archives for NSTextView and changeColor. You probably want  
to override changeColor: in your NSTextView subclass.

___

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

Please do not post 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 arch...@mail-archive.com


Re: Reversing a String (Gabe Shahbazian)

2008-12-31 Thread Michael Ash
On Wed, Dec 31, 2008 at 4:28 AM, Peter Hudson peter.hud...@mac.com wrote:
 I have been using the following for a while across a number of languages
 without problems.


 NSString *s = @Hello;
 unsigned int length  = [s  length];
 unsigned int index = length - 1;

 NSMutableArray *ma = [NSMutableArray  array];

 while( index  UINT_MAX )
 {
NSRange rng = NSMakeRange( index, 1 );
[ma  addObject:[s  substringWithRange:rng]];
--index;
 }

 NSString *reversed = [ma  componentsJoinedByString:@];
 NSLog(@reversed : %@,reversed);

I'm rather surprised, as this will fail on something as simple as an
accented e using a separate combining character, let alone more
complex constructs.

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 arch...@mail-archive.com


Re: Reversing a String

2008-12-31 Thread Dave DeLong
Ironic... This question came up in a job interview I had a couple  
weeks ago.  The following NSString category will work to reverse a  
string, and in my limited tests, it works with accents, mathematical  
symbols, and Korean characters:


- (NSString *) stringByReversingSelf {
NSMutableString * r = [NSMutableString stringWithString:self];
NSUInteger len = [r length];
NSUInteger mid = floor(len/2);
for(int i = 0; i  mid; i++) {
NSRange fr = NSMakeRange(i,1);
NSRange lr = NSMakeRange(len-i-1,1);
NSString * f = [r substringWithRange:fr];
NSString * l = [r substringWithRange:lr];
[r replaceCharactersInRange:fr withString:l];
[r replaceCharactersInRange:lr withString:f];
}
return r;
}

Here's the output of my extremely limited tests: (attached as a .png  
screenshot so that the encoding doesn't get messed up)




Cheers,

Dave

On Dec 31, 2008, at 8:51 AM, Michael Ash wrote:

On Wed, Dec 31, 2008 at 4:28 AM, Peter Hudson peter.hud...@mac.com  
wrote:
I have been using the following for a while across a number of  
languages

without problems.


NSString *s = @Hello;
unsigned int length  = [s  length];
unsigned int index = length - 1;

NSMutableArray *ma = [NSMutableArray  array];

while( index  UINT_MAX )
{
  NSRange rng = NSMakeRange( index, 1 );
  [ma  addObject:[s  substringWithRange:rng]];
  --index;
}

NSString *reversed = [ma  componentsJoinedByString:@];
NSLog(@reversed : %@,reversed);


I'm rather surprised, as this will fail on something as simple as an
accented e using a separate combining character, let alone more
complex constructs.

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 arch...@mail-archive.com


Re: Reversing a String

2008-12-31 Thread Dave DeLong

Looks like the attachment didn't come along.  It's up here:  
http://davedelong.com/stuff/stringreverse.png

Dave

On Dec 31, 2008, at 9:29 AM, Dave DeLong wrote:

Ironic... This question came up in a job interview I had a couple  
weeks ago.  The following NSString category will work to reverse a  
string, and in my limited tests, it works with accents, mathematical  
symbols, and Korean characters:


- (NSString *) stringByReversingSelf {
NSMutableString * r = [NSMutableString stringWithString:self];
NSUInteger len = [r length];
NSUInteger mid = floor(len/2);
for(int i = 0; i  mid; i++) {
NSRange fr = NSMakeRange(i,1);
NSRange lr = NSMakeRange(len-i-1,1);
NSString * f = [r substringWithRange:fr];
NSString * l = [r substringWithRange:lr];
[r replaceCharactersInRange:fr withString:l];
[r replaceCharactersInRange:lr withString:f];
}
return r;
}

Here's the output of my extremely limited tests: (attached as a .png  
screenshot so that the encoding doesn't get messed up)




Cheers,

Dave

___

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

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

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

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


Re: Reversing a String

2008-12-31 Thread Michael Ash
On Wed, Dec 31, 2008 at 11:29 AM, Dave DeLong davedel...@me.com wrote:
 Ironic... This question came up in a job interview I had a couple weeks ago.
  The following NSString category will work to reverse a string, and in my
 limited tests, it works with accents, mathematical symbols, and Korean
 characters:

 - (NSString *) stringByReversingSelf {
NSMutableString * r = [NSMutableString stringWithString:self];
NSUInteger len = [r length];
NSUInteger mid = floor(len/2);
for(int i = 0; i  mid; i++) {
NSRange fr = NSMakeRange(i,1);
NSRange lr = NSMakeRange(len-i-1,1);
NSString * f = [r substringWithRange:fr];
NSString * l = [r substringWithRange:lr];
[r replaceCharactersInRange:fr withString:l];
[r replaceCharactersInRange:lr withString:f];
}
return r;
 }

 Here's the output of my extremely limited tests: (attached as a .png
 screenshot so that the encoding doesn't get messed up)

Nope, doesn't work. It works on your test data because your test data
doesn't contain any multi-character units.

The fundamental error that everyone is making here is in assuming that
a unichar is a single indivisible unit that can be tossed around at
will. But it doesn't work that way. Sometimes you have multiple
unichars next to each other in a grouping which must be preserved.

Try your method on a string which contains abcde\u0301f where the
\u0301 is actually unicode code point 0301 COMBINING ACUTE ACCENT. It
starts out with abcdef with an acute accent on the e. After passing
through your method, it ends up with the accent on the f!

Or try it with a string that contains 1D11E MUSICAL SYMBOL G CLEF.
This is a single code point which requires two unichars to represent,
because unichar is only 16-bits and so NSString is implicitly UTF-16.
After passing through your method, the two unichars which make up this
single character get reversed which produces an invalid sequence, and
the resulting string can't be printed.

Here's code which works properly with those problems:

- (NSString *)stringByReversingSelf {
NSMutableString *me = [NSMutableString stringWithString:self];
NSMutableString *result = [NSMutableString string];

while([me length]) {
NSRange range = [me rangeOfComposedCharacterSequenceAtIndex:0];
[result insertString:[me substringWithRange:range] atIndex:0];
[me deleteCharactersInRange:range];
}

return result;
}

The key is the usage of -rangeOfComposedCharacterSequenceAtIndex:.
Without calling this method or doing the equivalent to what it does,
your code will suffer the problems I described above.

I tested that code with the string @abcdéf턞g (that's an accented e
using a combining diacritical before the f, and the aforementioned
musical note at the end) and it worked as expected.

I don't guarantee that my code will work on everything. Unicode is
weird enough and covers enough weird languages that there are probably
situations where this will still fail. But it covers most of the
tricky bits, and at least will always produce valid unicode output.

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 arch...@mail-archive.com

Re: Pull Down Toolbar Item

2008-12-31 Thread Sean McBride
Carmen Cerino Jr. (ccerin...@gmail.com) on 2008-12-29 10:00 AM said:

I would like to create a pull down toolbar item similar to what Xcode
has for a few of its toolbar items.

BTW, the HIG talks about these a little:

http://developer.apple.com/documentation/userexperience/conceptual/
applehiguidelines/XHIGControls/chapter_19_section_4.html#//apple_ref/doc/
uid/TP3359-BAADHEBI

Sean


___

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

Please do not post 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 arch...@mail-archive.com


Re: A Mac App helper NSStatusItem - how to share preferences

2008-12-31 Thread Sean McBride
Steve Cronin (steve_cro...@mac.com) on 2008-12-28 8:41 PM said:

I have an application which will have an optional helper NSStatusItem.
The statusItem is a stand-alone application which can be installed as
a LoginItem.

I want this status item to be able to read the preferences file from
the application.

No need to drop to CFPreferences.  Let's say your 2 bundle identifiers
are com.cronin.mainapp and com.cronin.helper.

In your helper app, just do this:

NSUserDefaults* sud = [NSUserDefaults standardUserDefaults];
[sud addSuiteNamed:@com.cronin.mainapp];

Sean


___

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

Please do not post 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 arch...@mail-archive.com


Re: A Mac App helper NSStatusItem - how to share preferences

2008-12-31 Thread Michael Ash
On Tue, Dec 30, 2008 at 8:18 PM, Steve Cronin steve_cro...@mac.com wrote:
 Michael;

 OK to really perhaps beat the poor horse,  is the following kosher?

  (NSDictionary *) prefDictionary {
return [(NSDictionary *)CFPreferencesCopyMultiple(NULL,  appBundleID,
  kCFPreferencesCurrentUser,  kCFPreferencesCurrentHost) autorelease];
 }

Yep, that's fine (as long as you're not using garbage collection) and
also pretty. Well, as pretty as CF code gets, anyway.

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 arch...@mail-archive.com


Re: Making an object release itself?

2008-12-31 Thread Matt Neuburg
On Wed, 31 Dec 2008 14:28:44 +1100, Jacob Rhoden li...@jacobrhoden.com
said:
I'm thinking PostReader class could have a static function that
initialises a new PostReader object, tells it to start the work, and
then do a [self release] after it has called the callback function
'postsRead';

There is certainly nothing wrong, on the face of it, with an object telling
itself to release. This is quite common for singleton and temporary objects
(just what you're dealing with). m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide - Second Edition!
http://www.amazon.com/gp/product/0596102119



___

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

Please do not post 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 arch...@mail-archive.com


Re: Initial Prefs Setting Of Checkbox?

2008-12-31 Thread Matt Neuburg
On Tue, 30 Dec 2008 23:25:03 -0500, Chunk 1978 chunk1...@gmail.com said:
i have a few checkboxes in my prefs window which are bound... however,
i was under the impression that i could easily set the very first load
state of these boxes in IB by checking Selected (Inspector 
Attributes  Visual  Selected) before the userdefaults are written...

There are two misunderstandings here, and the most important of them is the
second one, before the user defaults are written. There should be NO SUCH
TIME. It is up to you register the default defaults (that is, the initial
value for user defaults before the user has had any chance to express an
opinion) before the app even finishes loading for the first time. That is
exactly what registerDefaults is for. In some cases, finding a
sufficiently early entry point can be a challenge; I typically resort to
+initialize.

m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide - Second Edition!
http://www.amazon.com/gp/product/0596102119



___

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

Please do not post 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 arch...@mail-archive.com


Re: modifier key query

2008-12-31 Thread Sean McBride
Wesley Smith (wesley.h...@gmail.com) on 2008-12-26 3:04 AM said:

Is there a way to know if a modifier key (shift, ctrl, option, cmd,
etc) is pressed?  Obviously, there's this:
NSUInteger modifierFlags = [theEvent modifierFlags];

but what if you need to know this information independent of an
NSEvent?  Anyway to get it?  So far I haven't seen anything
encouraging in the docs.

There's GetCurrentKeyModifiers(), which is superbly documented in
CarbonEventsCore.h.  But sticking with NSEvent, if you can, if probably
better.

Sean


___

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

Please do not post 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 arch...@mail-archive.com


Re: Making an object release itself?

2008-12-31 Thread Jean-Daniel Dupas


Le 31 déc. 08 à 18:28, Matt Neuburg a écrit :

On Wed, 31 Dec 2008 14:28:44 +1100, Jacob Rhoden li...@jacobrhoden.com 


said:

I'm thinking PostReader class could have a static function that
initialises a new PostReader object, tells it to start the work, and
then do a [self release] after it has called the callback function
'postsRead';


There is certainly nothing wrong, on the face of it, with an object  
telling
itself to release. This is quite common for singleton and temporary  
objects

(just what you're dealing with). m.


Just take care to call release at the very end. Once release is  
called, accessing an ivar may crash your app.


___

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

Please do not post 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 arch...@mail-archive.com


Re: Storing NSDocument data in packages/bundles

2008-12-31 Thread Markus Spoettl

On Dec 31, 2008, at 1:32 AM, Kyle Sluder wrote:

On Wed, Dec 31, 2008 at 4:16 AM, Markus Spoettl
msappleli...@toolsfactory.com wrote:
No I have not, but I have a feeling that it wouldn't be suitable.  
The data I
store contains (when the document is big) millions of double values  
(amongst

other things) spread across hundreds of thousands of objects. If the
performance of NSKeyedArchiver is any indication the system  
wouldn't scale
very well. It is an assumption and it might be totally wrong but I  
guess the
overhead of keyed archiving is significantly less than that of Core  
Data.


Quite the contrary, I'm afraid.  Although without actually testing it,
you can't know for sure.


OK, I wouldn't have expected that. The question is rather academic for  
me anyway as the application is existing and using non-Core Data  
objects already. Changing all the innards of the application is not an  
option at this point. Unless of course this is a lot less painfull  
than it sounds.


That's no problem, that information is available. The documentation  
for
-writeToURL:ofType:forSaveOperation:originalContentsURL:error:  
states:


--
The value of absoluteURL is often not the same as [self fileURL].  
Other

times it is not the same as the URL for the final save destination.
Likewise, absoluteOriginalContentsURL is often not the same value  
as [self

fileURL].
--

which is a little problem because to update my packages I need to  
original
location. Do you have any insights as to what often not the same  
in this
context might mean? To write the diff into the package I'd have to  
have

access to the package. It doesn't sounds as it that's guaranteed.


For safe save operations, AppKit writes the data to a temporary file
on the same volume, and then swaps the old file with the new, which is
an atomic operation.  If it can't do that, it will rename the original
file and write the new one with the old name.  This is why absoluteURL
or absoluteOriginalContentsURL won't necessarily jive with -fileURL
(see the comment header for -[NSDocument
writeSafelyToURL:ofType:forSaveOperation:error:] for more details).
The upshot is that absoluteOriginalContentsURL will be a URL which you
can use to access your existing on-disk data, whether or not AppKit
has temporarily renamed it.



That would not help a lot because I'd have to copy the unchanged parts  
or the old package into the new package. The whole idea was not to re- 
write data that hasn't changed.


Thanks for the ideas though, I'll definitely investigate this further.

Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Reversing a String

2008-12-31 Thread Ricky Sharp


On Dec 31, 2008, at 10:52 AM, Michael Ash wrote:


The key is the usage of -rangeOfComposedCharacterSequenceAtIndex:.
Without calling this method or doing the equivalent to what it does,
your code will suffer the problems I described above.

I tested that code with the string @abcdéf턞g (that's an  
accented e

using a combining diacritical before the f, and the aforementioned
musical note at the end) and it worked as expected.

I don't guarantee that my code will work on everything. Unicode is
weird enough and covers enough weird languages that there are probably
situations where this will still fail. But it covers most of the
tricky bits, and at least will always produce valid unicode output.



Reversing a string only really makes sense for certain languages  
anyhow.  Perhaps even just English.  The rendering of reversed strings  
may also get a bit weird for text involving positional variants.


Anyhow, attempting to construct a universal solution will either be  
too difficult or perhaps not possible.  The original poster should  
provide some extra clues as to what the output will be used for.


I'm all for 100% Unicode support by applications, but there are some  
situations where working with plain 'ol ASCII still makes sense.  In  
that specific case, reversing a string becomes trivial.


___
Ricky A. Sharp mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.com



___

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

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

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

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


Re: Storing NSDocument data in packages/bundles

2008-12-31 Thread Kyle Sluder
On Wed, Dec 31, 2008 at 1:08 PM, Markus Spoettl
msappleli...@toolsfactory.com wrote:
 That would not help a lot because I'd have to copy the unchanged parts or
 the old package into the new package. The whole idea was not to re-write
 data that hasn't changed.

I wasn't thinking completely straight last night... you'll want to
override -writeSafelyToURL: to perform the atomic writes of your
individual components.

--Kyle Sluder
___

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

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

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

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


Re: Storing NSDocument data in packages/bundles

2008-12-31 Thread Markus Spoettl

On Dec 31, 2008, at 4:46 AM, Quincey Morris wrote:
I don't see how trying to do this in - 
writeToURL:ofType:forSaveOperation:originalContentsURL:error: is  
ever going to work.


If you are given (basically) an old and new package location, then  
you're forced to copy everything:


-- Trying to write changed files in the old location would be a  
really bad idea.


-- Moving the unchanged files from the old location to the new  
location would probably work (if the save operation is a pure save,  
not a save-as or save-to), but would be a really bad idea if there  
was an error during the save (because the contents of the new  
location would presumably get thrown away).


The *real* question here is: what's a *safe* strategy for saving a  
package by changing parts of it? You really need a single atomic  
operation to commit the changes, and most file systems don't provide  
this for an arbitrary set of files. NSDocument's answer is that  
there isn't a safe strategy, so it always saves by creating a copy.  
(And even that's not perfectly safe if the file system doesn't  
provide the equivalent of FSSwapFiles.)


Using Core Data as the storage mechanism for blobs of data is a  
possibility, but it's also a PITA because:


-- you likely need to turn off NSPersistentDocument's undo handling  
and provide your own


-- Core Data doesn't have save-to, and its save-as sucks (does a  
store migration)


-- if you have a lot of data, Core Data is going to keep copies of  
much of it in internal caches


My suggestion would be to go ahead and use a package document  
format, and to copy the unchanged files, and see how long it takes.  
If the save times are unacceptable, then a database solution (not  
Core Data) is probably the next step.



Thanks for the pointers, I'll think about that. It's rather surprising  
that NSDocument's save-as-copy-and-move strategy that works so well  
for single files backfires so heavily in my case.


Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: modifier key query

2008-12-31 Thread Ricky Sharp


On Dec 31, 2008, at 11:36 AM, Sean McBride wrote:


Wesley Smith (wesley.h...@gmail.com) on 2008-12-26 3:04 AM said:


Is there a way to know if a modifier key (shift, ctrl, option, cmd,
etc) is pressed?  Obviously, there's this:
NSUInteger modifierFlags = [theEvent modifierFlags];

but what if you need to know this information independent of an
NSEvent?  Anyway to get it?  So far I haven't seen anything
encouraging in the docs.


There's GetCurrentKeyModifiers(), which is superbly documented in
CarbonEventsCore.h.  But sticking with NSEvent, if you can, if  
probably

better.



There's really nothing wrong with relying upon certain Carbon APIs.   
If or when Apple ever removes Carbon, I foresee APIs moving to new  
homes.


It's not like the current system has two shared libraries (Carbon/ 
Cocoa) and when Carbon goes, all APIs go with it.  In many cases,  
Carbon APIs are just wrappers over lower-level code.


If there are key pieces of functionality that you can do in Carbon,  
but not Cocoa, definitely file enhancement requests to add those APIs  
to Cocoa.

___
Ricky A. Sharp mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.com



___

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

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

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

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


Re: modifier key query

2008-12-31 Thread Sean McBride
Ricky Sharp (rsh...@mac.com) on 2008-12-31 1:21 PM said:

 Is there a way to know if a modifier key (shift, ctrl, option, cmd,
 etc) is pressed?  Obviously, there's this:
 NSUInteger modifierFlags = [theEvent modifierFlags];

 but what if you need to know this information independent of an
 NSEvent?  Anyway to get it?  So far I haven't seen anything
 encouraging in the docs.

 There's GetCurrentKeyModifiers(), which is superbly documented in
 CarbonEventsCore.h.  But sticking with NSEvent, if you can, if
 probably
 better.

There's really nothing wrong with relying upon certain Carbon APIs.
If or when Apple ever removes Carbon, I foresee APIs moving to new
homes.

Sticking with NSEvent is better not because GetCurrentKeyModifiers() is
Carbon, but because of the nature of GetCurrentKeyModifiers().  Please
read the excellent comments in the header that I mentioned.  The OP was
vague on his goals/needs, so GetCurrentKeyModifiers() maybe appropriate.

Sean


___

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

Please do not post 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 arch...@mail-archive.com


Re: modal sheet with validation logic

2008-12-31 Thread Nathan Kinsinger

On Dec 30, 2008, at 11:09 AM, Ronnie B wrote:


Hi All and Happy New Year ,

I am trying to do something not usual with the modal sheet.  I have  
a field
and a submit button on a sheet, and I want to implement some  
validation

behavior.


I'd say this is completely usual.



Two things I am trying to achieve are:
1. If the field's data fails my validation, I want to have the  
colored red

border around the field
2. I would like not to have the sheet dismissed until validation  
passes.


So, the sheet is displayed, user enters an invalid data, OK pressed,  
sheet
remains open, red border appears around the field.   User enters a  
valid

data, OK pressed, sheet is dismissed.


In my UI I turn both the label and the text in the text field red,  
show a (previously hidden) text label under the field that describes  
why the data is invalid, and place the cursor in the field with the  
error.


So, if I have Password and Confirm Password fields and the user does  
not enter the confirm password correctly I do:


BOOL foundError = NO;
if ([password isEqualToString:confirmPassword]) {
[confirmPasswordErrorLabel setHidden:YES];
[confirmPasswordField setTextColor:[NSColor blackColor]];
[confirmPasswordLabel setTextColor:[NSColor blackColor]];
} else {
foundError = YES;
[confirmPasswordErrorLabel setHidden:NO];
[confirmPasswordField setTextColor:[NSColor redColor]];
[confirmPasswordLabel setTextColor:[NSColor redColor]];
[[self window] makeFirstResponder:confirmPasswordField];
}

If there are multiple fields that need this sort of validation then I  
start from the bottom one and test each one going up the sheet. This  
way the cursor is in the topmost field with an error when done.


Put your version of this code in the IBAction method called by the OK  
button, if foundError is NO then close the sheet normally and go on  
your merry way, if not then do nothing and the sheet will remain open.



From what I understand about the modal sheets, they need to be  
dismissed (to

avoid messing up with the main event loop).


The sheet can remain open for as long as you need it.

Keep in mind the user can open the sheet then go do something else for  
a couple minutes/hours/days/eons before coming back and hitting OK. So  
any background work you are doing needs to keep that in mind.



Can anyone advise on the two questions above, or at least inform if  
that is

possible to begin with.

If keeping a sheet open is not an option, I will go with the  
scenario of
closing it and re-opening it again. In this case, how to implement  
the point

1 above - to have a red border around the text field.


Thanks,

Ron


--Nathan


___

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

Please do not post 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 arch...@mail-archive.com


mydoc.myext/QuickLook/Preview.html and full screen

2008-12-31 Thread Gerd Knops
I am looking to add QuickLook functionality to a fairly complex  
document. A static html file, using some javascript to interact with  
the document contents would be ideal for a number of reasons. So I  
experimented by adding a QuickLook/Preview.html file to my document  
bundle.


That works fine, and in 'normal' QuickLook mode that html can be  
resized to cover most of the screen.


But in full screen mode the html always appears to be sized to cover  
only about 1/4 of the available space. Is there some trick to allow  
the html document to use the entire screen?


Thanks

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 arch...@mail-archive.com


Re: Storing NSDocument data in packages/bundles

2008-12-31 Thread Quincey Morris

On Dec 31, 2008, at 10:12, Markus Spoettl wrote:

It's rather surprising that NSDocument's save-as-copy-and-move  
strategy that works so well for single files backfires so heavily in  
my case.


Well, to be accurate, it's not a NSDocument issue, it's a problem with  
updating in place more than single file vs file package.


Incidentally, there's a fairly simple safe strategy for file packages:

-- Use a single index file that lists all the files that make up the  
current version of the document.


-- When saving, first write all the changed data to new files with new  
names.


-- Then update the index file atomically.

-- Then delete all the out of date files.

But that has a few drawbacks:

-- The individual file names are potentially different every time you  
save (which may or may not matter to you).


-- You need periodic housekeeping to detect orphaned files (due to  
saves that failed for some reason) and delete them.


-- Differences in file name encodings/naming rules might cause  
problems if the whole package is manually copied from one file system  
to another.


If you can come up with any acceptable safe strategy, then it's still  
an issue how to integrate it into NSDocument. writeSafelyToURL: seems  
like the obvious place, but its documentation says must call super  
if overridden, and calling super is probably going to mess up your  
strategy.


BTW, before you decide that long save times are unacceptable, take a  
look at how Amadeus behaves when saving large sound files. It has the  
best slow save (from a usability point of view) of any app I've seen.



___

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

Please do not post 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 arch...@mail-archive.com


NSPersistent Document but probably a Bindings Noobie Cry for Help

2008-12-31 Thread Richard Ashwell

Ok,

First this is cry for help.  Second I suck at the cocoa dev thing so I  
anticipate that I won't even describe this very well, please forgive  
my lack of skill in Cocoa Dev, but here goes:


I have built a relatively complex application, but have dug a whole I  
can't fix or dig out of.  I built the app on the Document Core Data  
model, but this isn't really a core data issue (As in I haven't gotten  
that deep into that part). My app was a little different (I think) in  
that I wanted a controlling Main Window to be able to select / open  
documents from rather than just the New/Open mechanisms provided by  
the template.


To facilitate this

1) I overrode: applicationShouldOpenUntitledFile:  to return NO so  
that an untitled document wouldn't pop up.
2) Then I added a Window to the MainMenu Nib and added lots of code /  
bindings etc to have a table of documents to choose from etc, the idea  
here is there that the application overall is really a database of  
individual documents.
3) I was pretty pleased to get all of this working, and the New/Open  
still functions for opening or creating individual documents, so I  
haven't broken anything there yet.
4) The next task was based on a selection in the database table, I  
wanted to programatically open a document and pre populate it from the  
data.


Here I ran into the issue that the document from the template was tied  
to Nib via the Overridden windowNibName: method, which made it  
difficult to programmatically get the Controller Window when creating  
a new document from elsewhere in the code.  The solution I have here  
is to comment out the windowNibName method and instead implement:


- (void)makeWindowControllers
{
	NSWindowController *mainWindowController = [[NSWindowController  
alloc] initWithWindowNibName:@MyDocument owner:self];


[mainWindowController setShouldCloseDocument:YES];
[self addWindowController:mainWindowController];
[mainWindowController showWindow:self];
}

This worked and I could instantiate an instance of my Document Class  
programatically when ever I want and call method makeWindowControllers  
on it and the document would come up, more importantly I could then  
setup the instantiated Document to have its data loaded.  This all is  
working with one exception:


Problem:

One view in my document nib is an NSTextView that I have A) Subclassed  
and in IB set it to the Subclass, and B) IBOutleted to the main  
document class for a variable there.  Note this works when creating  
new/open documents from the templates (I assume because the Nib  
basically instantiates an instance of the sub class, and binds it for  
me via the IBOutlet).  Nice and dandy, however:


When I create the new document programatically (and I think/guess this  
is my issue) perhaps I am getting two instantiations of the Subclassed  
NSTextView or somehow when I create programatically my document class  
isn't getting bound via the IBOutlet.  I am only guessing and I don't  
know how to troubleshoot here, which is why I am begging for help.


More details:
At this point I removed ALL functionality from the NSTextView subclass  
leaving only a single method that is passed an  
NSMutableAttributedString and all the method does is set the text  
storage of itself and increases the font size etc, and again this  
method is called and works via the new/open document stuff, but fails  
when called programatically, I have traced to see that the string  
passed in both cases is occurring, but since nothing shows up in the  
view when I do it programatically, my only guess is that it is some  
how a different instance of the subclass?


Any and all help is appreciated, I will happily code pieces etc, but  
the application is a little large to link the whole thing here, but If  
someone has any ideas please please, help me trouble shoot this.


Regards,
Richard Ashwell




___

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

Please do not post 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 arch...@mail-archive.com


Re: Initial Prefs Setting Of Checkbox?

2008-12-31 Thread Chunk 1978
ok i get that... however, what if a developer intends to leave all
checkboxes in preferences unchecked as the initial defaults, and there
are only checkboxes or radio buttons, no colors, no numbers, etc... is
it considered bad practice to not register these defaults if they are
bound?  or is it better to keep code to a minimum and not register the
defaults... are there any problems that can arise from not having
defaults registered if their initial settings of the checkboxes is
desired?

On Wed, Dec 31, 2008 at 12:34 PM, Matt Neuburg m...@tidbits.com wrote:
 On Tue, 30 Dec 2008 23:25:03 -0500, Chunk 1978 chunk1...@gmail.com said:
i have a few checkboxes in my prefs window which are bound... however,
i was under the impression that i could easily set the very first load
state of these boxes in IB by checking Selected (Inspector 
Attributes  Visual  Selected) before the userdefaults are written...

 There are two misunderstandings here, and the most important of them is the
 second one, before the user defaults are written. There should be NO SUCH
 TIME. It is up to you register the default defaults (that is, the initial
 value for user defaults before the user has had any chance to express an
 opinion) before the app even finishes loading for the first time. That is
 exactly what registerDefaults is for. In some cases, finding a
 sufficiently early entry point can be a challenge; I typically resort to
 +initialize.

 m.

 --
 matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
 A fool + a tool + an autorelease pool = cool!
 One of the 2007 MacTech Top 25: http://tinyurl.com/2rh4pf
 AppleScript: the Definitive Guide - Second Edition!
 http://www.amazon.com/gp/product/0596102119




___

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

Please do not post 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 arch...@mail-archive.com


Display sleep vs. enterFullScreenMode

2008-12-31 Thread Shayne Wissler
Hello,

I have an application that uses NSView's
enterFullScreenMode/exitFullScreenModeWithOptions in order to toggle
between fullscreen and normal display mode. Evidently, the default
behavior while in full screen mode is to disable OSX's display sleep
timer. How can I re-enable it? I do not want my application to
interfere with the user's default sleep settings (unless my
application explicitly needs to when it's in a given mode--but that
doesn't depend on whether it's in fullscreen or normal mode).

Thank you for any help.


Shayne Wissler
___

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

Please do not post 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 arch...@mail-archive.com


Re: Storing NSDocument data in packages/bundles

2008-12-31 Thread Markus Spoettl

On Dec 31, 2008, at 11:29 AM, Quincey Morris wrote:
It's rather surprising that NSDocument's save-as-copy-and-move  
strategy that works so well for single files backfires so heavily  
in my case.


Well, to be accurate, it's not a NSDocument issue, it's a problem  
with updating in place more than single file vs file package.


Incidentally, there's a fairly simple safe strategy for file packages:

-- Use a single index file that lists all the files that make up  
the current version of the document.


-- When saving, first write all the changed data to new files with  
new names.


-- Then update the index file atomically.

-- Then delete all the out of date files.

But that has a few drawbacks:

-- The individual file names are potentially different every time  
you save (which may or may not matter to you).


-- You need periodic housekeeping to detect orphaned files (due to  
saves that failed for some reason) and delete them.


-- Differences in file name encodings/naming rules might cause  
problems if the whole package is manually copied from one file  
system to another.


Sounds like it should be doable quite easily in my case. Thanks very  
much for the verbosity.


If you can come up with any acceptable safe strategy, then it's  
still an issue how to integrate it into NSDocument.  
writeSafelyToURL: seems like the obvious place, but its  
documentation says must call super if overridden, and calling  
super is probably going to mess up your strategy.


That's what I thought too. What's the point of implementing a  
different way to safely save things when at the end you have to use  
the built-in behavior. It really doesn't make any sense, I believe  
this must be a documentation inaccuracy which really meant to say be  
sure to call super unless you're doing you completely home-grown  
saving stuff on your own. Pure speculation of course.


BTW, before you decide that long save times are unacceptable, take a  
look at how Amadeus behaves when saving large sound files. It has  
the best slow save (from a usability point of view) of any app  
I've seen.



Which brings me to something else. How does one do that, meaning how  
can I provide a save progress. I can't use a second thread to save the  
document because (I think) AppKit expects that -writeSafelyToURL:  
returns when it's done. Starting a thread and off-loading the work  
there so that I can update the UI while the operation is going on  
isn't going to work. An asynchronous mechanism where I can tell the  
document what is has been saved similar to NSApplications - 
applicationShouldTerminate: and -replyToApplicationShouldTerminate:  
would be what I'd need for that. Currently the only way of doing a  
save progress with user interaction is rolling my own save operation  
altogether, which has lots of implications (for example the behavior  
when saving in the process of app termination). Am I overlooking  
something obvious here?


Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: NSPersistent Document but probably a Bindings Noobie Cry for Help

2008-12-31 Thread Quincey Morris

On Dec 31, 2008, at 11:58, Richard Ashwell wrote:

4) The next task was based on a selection in the database table, I  
wanted to programatically open a document and pre populate it from  
the data.


It's not clear what you mean by programmatically open a document.  
Are you invoking the same action method that the Open menu item uses?  
Telling the NSDocumentController to open a document? Trying to use  
[[NSDocument alloc] init...]?


It also sounds like perhaps this programmatic open actually has the  
semantics of new. That is, you're creating a new (untitled) document  
with some data from your database, which is (eventually) going to get  
saved in a file separate from your database. If so, calling this  
open is going to confuse us.


Here I ran into the issue that the document from the template was  
tied to Nib via the Overridden windowNibName: method, which made it  
difficult to programmatically get the Controller Window when  
creating a new document from elsewhere in the code.  The solution I  
have here is to comment out the windowNibName method and instead  
implement:


- (void)makeWindowControllers
{
	NSWindowController *mainWindowController = [[NSWindowController  
alloc] initWithWindowNibName:@MyDocument owner:self];


[mainWindowController setShouldCloseDocument:YES];
[self addWindowController:mainWindowController];
[mainWindowController showWindow:self];
}


It's not clear how this makes it easier to get the Controller  
Window, since the reference to the controller is local to this  
method. Anyway, once the controller is created, you can always get it  
as [[document windowControllers] objectAtIndex: 0].


This worked and I could instantiate an instance of my Document Class  
programatically when ever I want and call method  
makeWindowControllers on it and the document would come up, more  
importantly I could then setup the instantiated Document to have its  
data loaded.


If you really are invoking makeWindowControllers yourself, you  
probably shouldn't be, since it's normally invoked automatically.  
Invoking your implementation manually would create a second window  
controller, which isn't what you want.


To create a new document programmatically, you should probably be  
invoking [NSDocumentController openUntitledDocumentAndDisplay:error:].  
Are you using something else?



___

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

Please do not post 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 arch...@mail-archive.com


Re: NSPersistent Document but probably a Bindings Noobie Cry for Help

2008-12-31 Thread Richard Ashwell

Ok some more details:

I removed the subclassing of NSTextView entirely just to eliminate  
that as any sort of source for the problem so now:


In my document nib I have a regular NSTextView, bound via IBOutlet to  
a variable in the document class.  However still the NSTextView only  
responds to updating its content when the document is instantiated via  
new/open rather than when created programatically.  Is there some  
binding I need to do instead of IBOutlet NIB binding to get that view  
to respond?  Does new/open somehow alloc init the variable  
differently?  IE am I supposed to alloc init the NSTextView in the  
Document init, or was this supposed to be handled by IB?


Puzzling on..

Richard

On Dec 31, 2008, at 1:58 PM, Richard Ashwell wrote:


Ok,

First this is cry for help.  Second I suck at the cocoa dev thing so  
I anticipate that I won't even describe this very well, please  
forgive my lack of skill in Cocoa Dev, but here goes:


I have built a relatively complex application, but have dug a whole  
I can't fix or dig out of.  I built the app on the Document Core  
Data model, but this isn't really a core data issue (As in I haven't  
gotten that deep into that part). My app was a little different (I  
think) in that I wanted a controlling Main Window to be able to  
select / open documents from rather than just the New/Open  
mechanisms provided by the template.


To facilitate this

1) I overrode: applicationShouldOpenUntitledFile:  to return NO so  
that an untitled document wouldn't pop up.
2) Then I added a Window to the MainMenu Nib and added lots of  
code / bindings etc to have a table of documents to choose from etc,  
the idea here is there that the application overall is really a  
database of individual documents.
3) I was pretty pleased to get all of this working, and the New/ 
Open still functions for opening or creating individual documents,  
so I haven't broken anything there yet.
4) The next task was based on a selection in the database table, I  
wanted to programatically open a document and pre populate it from  
the data.


Here I ran into the issue that the document from the template was  
tied to Nib via the Overridden windowNibName: method, which made it  
difficult to programmatically get the Controller Window when  
creating a new document from elsewhere in the code.  The solution I  
have here is to comment out the windowNibName method and instead  
implement:


- (void)makeWindowControllers
{
	NSWindowController *mainWindowController = [[NSWindowController  
alloc] initWithWindowNibName:@MyDocument owner:self];


[mainWindowController setShouldCloseDocument:YES];
[self addWindowController:mainWindowController];
[mainWindowController showWindow:self];
}

This worked and I could instantiate an instance of my Document Class  
programatically when ever I want and call method  
makeWindowControllers on it and the document would come up, more  
importantly I could then setup the instantiated Document to have its  
data loaded.  This all is working with one exception:


Problem:

One view in my document nib is an NSTextView that I have A)  
Subclassed and in IB set it to the Subclass, and B) IBOutleted to  
the main document class for a variable there.  Note this works when  
creating new/open documents from the templates (I assume because the  
Nib basically instantiates an instance of the sub class, and binds  
it for me via the IBOutlet).  Nice and dandy, however:


When I create the new document programatically (and I think/guess  
this is my issue) perhaps I am getting two instantiations of the  
Subclassed NSTextView or somehow when I create programatically my  
document class isn't getting bound via the IBOutlet.  I am only  
guessing and I don't know how to troubleshoot here, which is why I  
am begging for help.


More details:
At this point I removed ALL functionality from the NSTextView  
subclass leaving only a single method that is passed an  
NSMutableAttributedString and all the method does is set the text  
storage of itself and increases the font size etc, and again this  
method is called and works via the new/open document stuff, but  
fails when called programatically, I have traced to see that the  
string passed in both cases is occurring, but since nothing shows up  
in the view when I do it programatically, my only guess is that it  
is some how a different instance of the subclass?


Any and all help is appreciated, I will happily code pieces etc, but  
the application is a little large to link the whole thing here, but  
If someone has any ideas please please, help me trouble shoot this.


Regards,
Richard Ashwell




___

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

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

Help/Unsubscribe/Update your Subscription:

Re: mydoc.myext/QuickLook/Preview.html and full screen

2008-12-31 Thread Gerd Knops


On Dec 31, 2008, at 1:22 PM, Gerd Knops wrote:

I am looking to add QuickLook functionality to a fairly complex  
document. A static html file, using some javascript to interact with  
the document contents would be ideal for a number of reasons. So I  
experimented by adding a QuickLook/Preview.html file to my document  
bundle.


That works fine, and in 'normal' QuickLook mode that html can be  
resized to cover most of the screen.


But in full screen mode the html always appears to be sized to cover  
only about 1/4 of the available space. Is there some trick to allow  
the html document to use the entire screen?


Closer examination shows that apparently javascript is not supported  
inside QuickLook. Seemingly arbitrary limitation, when according to  
the documentation Java applets and Flash are supported.


Would have been nice to have some client-side javascript to produce a  
nice functional QuickLook document, instead of being limited to 'no  
nib allowed' C code. Why no full Objective-C support for Quicklook  
seems rather odd.


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 arch...@mail-archive.com


Re: Storing NSDocument data in packages/bundles

2008-12-31 Thread Quincey Morris

On Dec 31, 2008, at 12:11, Markus Spoettl wrote:


On Dec 31, 2008, at 11:29 AM, Quincey Morris wrote:
It's rather surprising that NSDocument's save-as-copy-and-move  
strategy that works so well for single files backfires so heavily  
in my case.

...
-- You need periodic housekeeping to detect orphaned files (due to  
saves that failed for some reason) and delete them.

...


It didn't occur to me when I wrote this that it might need an  
exclusive lock on the package to do this (and possibly other steps)  
safely.


If you can come up with any acceptable safe strategy, then it's  
still an issue how to integrate it into NSDocument.  
writeSafelyToURL: seems like the obvious place, but its  
documentation says must call super if overridden, and calling  
super is probably going to mess up your strategy.


That's what I thought too. What's the point of implementing a  
different way to safely save things when at the end you have to use  
the built-in behavior. It really doesn't make any sense, I believe  
this must be a documentation inaccuracy which really meant to say  
be sure to call super unless you're doing you completely home-grown  
saving stuff on your own. Pure speculation of course.


Reading the comments in NSDocument.h is instructive. If it was just a  
case of replacing the built-in file-handling strategy with your own,  
I'd say go ahead and override without calling super. But the comments  
refer to mysterious other things that need to be done, so even if  
failing to call super works now it might break things in the future.


Which brings me to something else. How does one do that, meaning how  
can I provide a save progress. I can't use a second thread to save  
the document because (I think) AppKit expects that - 
writeSafelyToURL: returns when it's done. Starting a thread and off- 
loading the work there so that I can update the UI while the  
operation is going on isn't going to work. An asynchronous mechanism  
where I can tell the document what is has been saved similar to  
NSApplications -applicationShouldTerminate: and - 
replyToApplicationShouldTerminate: would be what I'd need for that.  
Currently the only way of doing a save progress with user  
interaction is rolling my own save operation altogether, which has  
lots of implications (for example the behavior when saving in the  
process of app termination). Am I overlooking something obvious here?


To do the save synchronously in the main thread with a progress sheet,  
I've had reasonable success sprinkling 'isCancelled' checks throughout  
the save code, and implementing 'isCancelled' like this:


- (BOOL) isCancelled {
NSEvent *event;
	while (event = [NSApp nextEventMatchingMask: NSAnyEventMask  
untilDate: nil inMode: NSEventTrackingRunLoopMode dequeue: YES])

[NSApp sendEvent: event];
return isOperationCancelled;
}

(The progress sheet's cancel button's action routine is responsible  
for setting isOperationCancelled to YES.) It's not elegant but it  
seems to work fine so long as it's called often enough.


Doing it asynchronously is more of a puzzle.
___

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

Please do not post 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 arch...@mail-archive.com


Re: NSPersistent Document but probably a Bindings Noobie Cry for Help

2008-12-31 Thread Richard Ashwell
Quincy thanks for your reply, ok I was going to start sending you tons  
of little snipits from my code, and I had the whole email, typed but  
decided to reread your comments carefully.


In a nutshell:

1) I am/was creating my document  class programatically like:  (Note  
Typed in email, and in my project MyDocument is actually named  
something else)


MyDocument *newDoc = [[MyDocument alloc] init];
[newDoc importData:data];

By itself this wouldn't pop up a document because of the overridden  
applicationShouldOpenUntitledFile: method


So I added:

[newDoc makeWindowControllers];  and the method mentioned below.

Reading your notes carefully though it looks like I maybe should be  
using openUntitledDocumentAndDisplay:error instead of the  
makeWindowController thing that got my document to popup perhaps only  
because I added the showWindow:self to the end of that method.  And  
you are probably right that I am getting two instantiations, but only  
seeing one.


I will test your suggestion first, though It might take me a few  
because the template doesn't generate a NSDocumentController, only the  
NSPersistentDocument class itself so I first have to figure out how to  
add the Controller to my AppController class and stuff without  
breaking everything,  I should be able to  get  
openUntitledDocumentAndDisplay:error to work (I bet it does, so here  
is a pre thank you!!!),


If not I think perhaps I should first deconstruct into a separate  
clean project so that I can share better examples.


Regards,
Richard






On Dec 31, 2008, at 2:42 PM, Quincey Morris wrote:


On Dec 31, 2008, at 11:58, Richard Ashwell wrote:

4) The next task was based on a selection in the database table, I  
wanted to programatically open a document and pre populate it from  
the data.


It's not clear what you mean by programmatically open a document.  
Are you invoking the same action method that the Open menu item  
uses? Telling the NSDocumentController to open a document? Trying to  
use [[NSDocument alloc] init...]?


It also sounds like perhaps this programmatic open actually has  
the semantics of new. That is, you're creating a new (untitled)  
document with some data from your database, which is (eventually)  
going to get saved in a file separate from your database. If so,  
calling this open is going to confuse us.


Here I ran into the issue that the document from the template was  
tied to Nib via the Overridden windowNibName: method, which made it  
difficult to programmatically get the Controller Window when  
creating a new document from elsewhere in the code.  The solution I  
have here is to comment out the windowNibName method and instead  
implement:


- (void)makeWindowControllers
{
	NSWindowController *mainWindowController = [[NSWindowController  
alloc] initWithWindowNibName:@MyDocument owner:self];


[mainWindowController setShouldCloseDocument:YES];
[self addWindowController:mainWindowController];
[mainWindowController showWindow:self];
}


It's not clear how this makes it easier to get the Controller  
Window, since the reference to the controller is local to this  
method. Anyway, once the controller is created, you can always get  
it as [[document windowControllers] objectAtIndex: 0].


This worked and I could instantiate an instance of my Document  
Class programatically when ever I want and call method  
makeWindowControllers on it and the document would come up, more  
importantly I could then setup the instantiated Document to have  
its data loaded.


If you really are invoking makeWindowControllers yourself, you  
probably shouldn't be, since it's normally invoked automatically.  
Invoking your implementation manually would create a second window  
controller, which isn't what you want.


To create a new document programmatically, you should probably be  
invoking [NSDocumentController  
openUntitledDocumentAndDisplay:error:]. Are you using something else?



___

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

Please do not post 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/rashwell%40me.com

This email sent to rashw...@me.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 arch...@mail-archive.com


Re: NSPersistent Document but probably a Bindings Noobie Cry for Help

2008-12-31 Thread Richard Ashwell

More details:

Ok I, I think I have a lot to learn before I can call  
[NSDocumentController openUntitledDocumentAndDisplay:error], in the  
mean time I pulled out the extra call to makeWindowControllers and  
traced, When the document gets create via the New menu item the  
makeWindowControllers gets called automatically like you described,  
but just instantiating the document with MyDocument *newDoc =  
[[MyDocument alloc] init]; doesn't call makeWindowControllers.   
Perhaps that is what the NSDocumentController is supposed to do for me?


Richard



On Dec 31, 2008, at 3:49 PM, Richard Ashwell wrote:

Quincy thanks for your reply, ok I was going to start sending you  
tons of little snipits from my code, and I had the whole email,  
typed but decided to reread your comments carefully.


In a nutshell:

1) I am/was creating my document  class programatically like:   
(Note Typed in email, and in my project MyDocument is actually named  
something else)


MyDocument *newDoc = [[MyDocument alloc] init];
[newDoc importData:data];

By itself this wouldn't pop up a document because of the overridden  
applicationShouldOpenUntitledFile: method


So I added:

[newDoc makeWindowControllers];  and the method mentioned below.

Reading your notes carefully though it looks like I maybe should be  
using openUntitledDocumentAndDisplay:error instead of the  
makeWindowController thing that got my document to popup perhaps  
only because I added the showWindow:self to the end of that method.   
And you are probably right that I am getting two instantiations, but  
only seeing one.


I will test your suggestion first, though It might take me a few  
because the template doesn't generate a NSDocumentController, only  
the NSPersistentDocument class itself so I first have to figure out  
how to add the Controller to my AppController class and stuff  
without breaking everything,  I should be able to  get  
openUntitledDocumentAndDisplay:error to work (I bet it does, so here  
is a pre thank you!!!),


If not I think perhaps I should first deconstruct into a separate  
clean project so that I can share better examples.


Regards,
Richard






On Dec 31, 2008, at 2:42 PM, Quincey Morris wrote:


On Dec 31, 2008, at 11:58, Richard Ashwell wrote:

4) The next task was based on a selection in the database table, I  
wanted to programatically open a document and pre populate it from  
the data.


It's not clear what you mean by programmatically open a document.  
Are you invoking the same action method that the Open menu item  
uses? Telling the NSDocumentController to open a document? Trying  
to use [[NSDocument alloc] init...]?


It also sounds like perhaps this programmatic open actually has  
the semantics of new. That is, you're creating a new (untitled)  
document with some data from your database, which is (eventually)  
going to get saved in a file separate from your database. If so,  
calling this open is going to confuse us.


Here I ran into the issue that the document from the template was  
tied to Nib via the Overridden windowNibName: method, which made  
it difficult to programmatically get the Controller Window when  
creating a new document from elsewhere in the code.  The solution  
I have here is to comment out the windowNibName method and instead  
implement:


- (void)makeWindowControllers
{
	NSWindowController *mainWindowController = [[NSWindowController  
alloc] initWithWindowNibName:@MyDocument owner:self];


[mainWindowController setShouldCloseDocument:YES];
[self addWindowController:mainWindowController];
[mainWindowController showWindow:self];
}


It's not clear how this makes it easier to get the Controller  
Window, since the reference to the controller is local to this  
method. Anyway, once the controller is created, you can always get  
it as [[document windowControllers] objectAtIndex: 0].


This worked and I could instantiate an instance of my Document  
Class programatically when ever I want and call method  
makeWindowControllers on it and the document would come up, more  
importantly I could then setup the instantiated Document to have  
its data loaded.


If you really are invoking makeWindowControllers yourself, you  
probably shouldn't be, since it's normally invoked automatically.  
Invoking your implementation manually would create a second window  
controller, which isn't what you want.


To create a new document programmatically, you should probably be  
invoking [NSDocumentController  
openUntitledDocumentAndDisplay:error:]. Are you using something else?



___

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

Please do not post 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/rashwell%40me.com

This email sent to rashw...@me.com



Re: NSPersistent Document but probably a Bindings Noobie Cry for Help

2008-12-31 Thread Quincey Morris

On Dec 31, 2008, at 13:49, Richard Ashwell wrote:

1) I am/was creating my document  class programatically like:   
(Note Typed in email, and in my project MyDocument is actually named  
something else)


MyDocument *newDoc = [[MyDocument alloc] init];
[newDoc importData:data];


Not so good. When creating or opening a document, there's more to do  
than just creating the NSDocument instance.  
openUntitledDocumentAndDisplay:error: is the way to go.


By itself this wouldn't pop up a document because of the overridden  
applicationShouldOpenUntitledFile: method


No, that had nothing to do with it. By creating the NSDocument  
instance directly, you simply weren't getting the document window shown.



So I added:

[newDoc makeWindowControllers];  and the method mentioned below.

Reading your notes carefully though it looks like I maybe should be  
using openUntitledDocumentAndDisplay:error instead of the  
makeWindowController thing that got my document to popup perhaps  
only because I added the showWindow:self to the end of that method.


Exactly.

And you are probably right that I am getting two instantiations, but  
only seeing one.


I will test your suggestion first, though It might take me a few  
because the template doesn't generate a NSDocumentController, only  
the NSPersistentDocument class itself so I first have to figure out  
how to add the Controller to my AppController class and stuff  
without breaking everything,  I should be able to  get  
openUntitledDocumentAndDisplay:error to work (I bet it does, so here  
is a pre thank you!!!),


No need to stress! NSDocumentController is a singleton object that  
every AppKit application gets for free. So instead of:


MyDocument *newDoc = [[MyDocument alloc] init];

just write this:

NSError *error;
	MyDocument *newDoc = [[NSDocumentController sharedDocumentController]  
openUntitledDocumentAndDisplay: YES error: error];

if (!newDoc)
... // report the problem described in 'error'

... I pulled out the extra call to makeWindowControllers and traced,  
When the document gets create via the New menu item the  
makeWindowControllers gets called automatically like you described,  
but just instantiating the document with MyDocument *newDoc =  
[[MyDocument alloc] init]; doesn't call makeWindowControllers.   
Perhaps that is what the NSDocumentController is supposed to do for  
me?


Yup. It also causes the document to appear on the Window menu for you,  
and populates the Open Recent menu.



___

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

Please do not post 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 arch...@mail-archive.com


NSSplitView

2008-12-31 Thread David Blanton
How does one make a connected horiz-vert split view like in Xcode,  
you know,  one control point to size in both directions?


HNY cocoa heads!




David Blanton




___

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

Please do not post 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 arch...@mail-archive.com


Re: NSPersistent Document but probably a Bindings Noobie Cry for Help

2008-12-31 Thread Brandon Walkin
If you're looking at the same split view as I am (main window), it  
appears that they're just using a horizontal split view as the right  
subview in a vertical split view. There doesn't seem to be a resize  
handle that adjusts both directions.


On 31-Dec-08, at 5:27 PM, Quincey Morris wrote:


On Dec 31, 2008, at 13:49, Richard Ashwell wrote:

1) I am/was creating my document  class programatically like:   
(Note Typed in email, and in my project MyDocument is actually  
named something else)


MyDocument *newDoc = [[MyDocument alloc] init];
[newDoc importData:data];


Not so good. When creating or opening a document, there's more to do  
than just creating the NSDocument instance.  
openUntitledDocumentAndDisplay:error: is the way to go.


By itself this wouldn't pop up a document because of the overridden  
applicationShouldOpenUntitledFile: method


No, that had nothing to do with it. By creating the NSDocument  
instance directly, you simply weren't getting the document window  
shown.



So I added:

[newDoc makeWindowControllers];  and the method mentioned below.

Reading your notes carefully though it looks like I maybe should be  
using openUntitledDocumentAndDisplay:error instead of the  
makeWindowController thing that got my document to popup perhaps  
only because I added the showWindow:self to the end of that method.


Exactly.

And you are probably right that I am getting two instantiations,  
but only seeing one.


I will test your suggestion first, though It might take me a few  
because the template doesn't generate a NSDocumentController, only  
the NSPersistentDocument class itself so I first have to figure out  
how to add the Controller to my AppController class and stuff  
without breaking everything,  I should be able to  get  
openUntitledDocumentAndDisplay:error to work (I bet it does, so  
here is a pre thank you!!!),


No need to stress! NSDocumentController is a singleton object that  
every AppKit application gets for free. So instead of:


  MyDocument *newDoc = [[MyDocument alloc] init];

just write this:

  NSError *error;
  MyDocument *newDoc = [[NSDocumentController  
sharedDocumentController] openUntitledDocumentAndDisplay: YES error:  
error];

  if (!newDoc)
  ... // report the problem described in 'error'

... I pulled out the extra call to makeWindowControllers and  
traced, When the document gets create via the New menu item the  
makeWindowControllers gets called automatically like you described,  
but just instantiating the document with MyDocument *newDoc =  
[[MyDocument alloc] init]; doesn't call makeWindowControllers.   
Perhaps that is what the NSDocumentController is supposed to do for  
me?


Yup. It also causes the document to appear on the Window menu for  
you, and populates the Open Recent menu.



___

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

Please do not post 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/bwalkin%40gmail.com

This email sent to bwal...@gmail.com


___

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

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

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

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


Re: NSSplitView

2008-12-31 Thread Brandon Walkin
If you're looking at the same split view as I am (main window), it  
appears that they're just using a horizontal split view as the right  
subview in a vertical split view. There doesn't seem to be a resize  
handle that adjusts both directions.


On 31-Dec-08, at 5:22 PM, David Blanton wrote:

How does one make a connected horiz-vert split view like in Xcode,  
you know,  one control point to size in both directions?


HNY cocoa heads!




David Blanton




___

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

Please do not post 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/bwalkin%40gmail.com

This email sent to bwal...@gmail.com


___

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

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

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

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


Re: NSSplitView

2008-12-31 Thread David Blanton
In Xcode 2.4.1 , debug view, all in one, the stack and vars are  
split, and below is source and there is one control point that moves  
the vert and horiz splitters


Some Apple magic perhaps?

On Dec 31, 2008, at 3:49 PM, Brandon Walkin wrote:

If you're looking at the same split view as I am (main window), it  
appears that they're just using a horizontal split view as the  
right subview in a vertical split view. There doesn't seem to be a  
resize handle that adjusts both directions.


On 31-Dec-08, at 5:22 PM, David Blanton wrote:

How does one make a connected horiz-vert split view like in Xcode,  
you know,  one control point to size in both directions?


HNY cocoa heads!




David Blanton




___

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

Please do not post 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/bwalkin%40gmail.com

This email sent to bwal...@gmail.com






David Blanton




___

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

Please do not post 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 arch...@mail-archive.com


agc error for object ... Deallocating a non-block

2008-12-31 Thread Michael Link

When I see an error on the console that looks like this:

Test(22389,0xb0103000) malloc: *** free() called with 0x1f29ba00 with  
refcount 0
Test(22389,0xb0103000) malloc: *** auto malloc[22389]: agc error for  
object 0x1f29ba00: Deallocating a non-block


What exactly does 'Deallocating a non-block' mean?

I was running with malloc history on and the last 2 stack traces for  
0x1f29ba00 are:


Stack - pthread: 0xa0580720 number of frames: 28
0: 0x951e482d in malloc_zone_calloc
1: 0x951e4782 in calloc
2: 0x902158cc in CGImageSourceGetTypeWithData
3: 0x90215712 in CGImageSourceGetTypeWithData
4: 0x901e61be in CGImageSourceCreateImageAtIndex
5: 0x901ebb1c in CGImageSourceGetPropertiesAtIndex
6: 0x901eba76 in CGImageSourceCopyPropertiesAtIndex
7: 0x91e6be8b in +[NSBitmapImageRep  
_imagesWithData:hfsFileType:extension:zone:expandImageContentNow:includeAllReps 
:]

8: 0x91e6fc71 in +[NSBitmapImageRep imageRepsWithData:]
9: 0x91e6f50e in -[NSImage initWithData:]
   10: 0x7375d in -[SPCaptchaImageView connectionDidFinishLoading:]  
at /Users/mlink/Code/code-cocoa/Test/trunk/Test/SPCaptchaImageView.m:259

   11: 0x95739a3d in __invoking___
   12: 0x95739428 in -[NSInvocation invoke]
   13: 0xf0a0b in -[MLHTTPConnection _didFinishLoading] at /Users/ 
mlink/Code/code-cocoa/Test/trunk/Test/MLHTTPConnection.m:204

   14: 0x95739a3d in __invoking___
   15: 0x95739428 in -[NSInvocation invoke]
   16: 0x94f3039c in __NSThreadPerformPerform
   17: 0x956ba5f5 in CFRunLoopRunSpecific
   18: 0x956bacd8 in CFRunLoopRunInMode
   19: 0x927392c0 in RunCurrentEventLoopInMode
   20: 0x927390d9 in ReceiveNextEventCommon
   21: 0x92738f4d in BlockUntilNextEventMatchingListInMode
   22: 0x91d80d7d in _DPSNextEvent
   23: 0x91d80630 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:]

   24: 0x91d7966b in -[NSApplication run]
   25: 0x91d468a4 in NSApplicationMain
   26: 0xc884 in main at /Users/mlink/Code/code-cocoa/Test/trunk/Test/ 
main.m:25

   27: 0x2e52 in start
Stack - pthread: 0xa0580720 number of frames: 28
0: 0x951e2323 in malloc_zone_free
1: 0x951e22cd in free
2: 0x90256516 in CGImagePluginSetClipPath
3: 0x949f43c8 in CGDataProviderCreateWithFaultDataCallback
4: 0x94809f17 in CGDataProviderGetBytePtr
5: 0x901e9e70 in CGImagePluginSetBandProc
6: 0x91e6e168 in -[NSBitmapImageRep _loadData]
7: 0x91e6bf27 in +[NSBitmapImageRep  
_imagesWithData:hfsFileType:extension:zone:expandImageContentNow:includeAllReps 
:]

8: 0x91e6fc71 in +[NSBitmapImageRep imageRepsWithData:]
9: 0x91e6f50e in -[NSImage initWithData:]
   10: 0x7375d in -[SPCaptchaImageView connectionDidFinishLoading:]  
at /Users/mlink/Code/code-cocoa/Test/trunk/Test/SPCaptchaImageView.m:259

   11: 0x95739a3d in __invoking___
   12: 0x95739428 in -[NSInvocation invoke]
   13: 0xf0a0b in -[MLHTTPConnection _didFinishLoading] at /Users/ 
mlink/Code/code-cocoa/Test/trunk/Test/MLHTTPConnection.m:204

   14: 0x95739a3d in __invoking___
   15: 0x95739428 in -[NSInvocation invoke]
   16: 0x94f3039c in __NSThreadPerformPerform
   17: 0x956ba5f5 in CFRunLoopRunSpecific
   18: 0x956bacd8 in CFRunLoopRunInMode
   19: 0x927392c0 in RunCurrentEventLoopInMode
   20: 0x927390d9 in ReceiveNextEventCommon
   21: 0x92738f4d in BlockUntilNextEventMatchingListInMode
   22: 0x91d80d7d in _DPSNextEvent
   23: 0x91d80630 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:]

   24: 0x91d7966b in -[NSApplication run]
   25: 0x91d468a4 in NSApplicationMain
   26: 0xc884 in main at /Users/mlink/Code/code-cocoa/Test/trunk/Test/ 
main.m:25

   27: 0x2e52 in start

--
Michael
___

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

Please do not post 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 arch...@mail-archive.com


Re: NSPersistent Document but probably a Bindings Noobie Cry for Help

2008-12-31 Thread Richard Ashwell

Sweet Sweet!!! Magic!!!  the :


NSError *error;
	MyDocument *newDoc = [[NSDocumentController  
sharedDocumentController] openUntitledDocumentAndDisplay: YES error:  
error];


was the key, thank you so much Quincey!!!  This both instantiates and  
lets me controll what is created!


Yeah!! What a great end to the year, i'll actually go into the new  
year with working code :)


Regards,
Richard




On Dec 31, 2008, at 4:27 PM, Quincey Morris wrote:


On Dec 31, 2008, at 13:49, Richard Ashwell wrote:

1) I am/was creating my document  class programatically like:   
(Note Typed in email, and in my project MyDocument is actually  
named something else)


MyDocument *newDoc = [[MyDocument alloc] init];
[newDoc importData:data];


Not so good. When creating or opening a document, there's more to do  
than just creating the NSDocument instance.  
openUntitledDocumentAndDisplay:error: is the way to go.


By itself this wouldn't pop up a document because of the overridden  
applicationShouldOpenUntitledFile: method


No, that had nothing to do with it. By creating the NSDocument  
instance directly, you simply weren't getting the document window  
shown.



So I added:

[newDoc makeWindowControllers];  and the method mentioned below.

Reading your notes carefully though it looks like I maybe should be  
using openUntitledDocumentAndDisplay:error instead of the  
makeWindowController thing that got my document to popup perhaps  
only because I added the showWindow:self to the end of that method.


Exactly.

And you are probably right that I am getting two instantiations,  
but only seeing one.


I will test your suggestion first, though It might take me a few  
because the template doesn't generate a NSDocumentController, only  
the NSPersistentDocument class itself so I first have to figure out  
how to add the Controller to my AppController class and stuff  
without breaking everything,  I should be able to  get  
openUntitledDocumentAndDisplay:error to work (I bet it does, so  
here is a pre thank you!!!),


No need to stress! NSDocumentController is a singleton object that  
every AppKit application gets for free. So instead of:


MyDocument *newDoc = [[MyDocument alloc] init];

just write this:

NSError *error;
	MyDocument *newDoc = [[NSDocumentController  
sharedDocumentController] openUntitledDocumentAndDisplay: YES error:  
error];

if (!newDoc)
... // report the problem described in 'error'

... I pulled out the extra call to makeWindowControllers and  
traced, When the document gets create via the New menu item the  
makeWindowControllers gets called automatically like you described,  
but just instantiating the document with MyDocument *newDoc =  
[[MyDocument alloc] init]; doesn't call makeWindowControllers.   
Perhaps that is what the NSDocumentController is supposed to do for  
me?


Yup. It also causes the document to appear on the Window menu for  
you, and populates the Open Recent menu.



___

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

Please do not post 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/rashwell%40me.com

This email sent to rashw...@me.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 arch...@mail-archive.com


Re: Display sleep vs. enterFullScreenMode

2008-12-31 Thread Sean McBride
Shayne Wissler (wiss...@gmail.com) on 2008-12-31 3:11 PM said:

I have an application that uses NSView's
enterFullScreenMode/exitFullScreenModeWithOptions in order to toggle
between fullscreen and normal display mode. Evidently, the default
behavior while in full screen mode is to disable OSX's display sleep
timer. How can I re-enable it? I do not want my application to
interfere with the user's default sleep settings (unless my
application explicitly needs to when it's in a given mode--but that
doesn't depend on whether it's in fullscreen or normal mode).

I can confirm your results.  enterFullScreenMode is not documented to
have that effect.  It ends up calling CGDisplayCapture(), perhaps it is
responsible for that.

Sigh.  Another reason to avoid enterFullScreenMode I'm afraid.  Here's
my list of why:

- prevents display sleep
- does not allow menubar to autoshow/hide
- does not allow dock to autoshow/hide
- does not allow cmd-tabbing between apps
- does not allow exposé to be invoked
- invoking force quit kills the app instead of showing force quit dialog
- documentation says you can choose the window level
(NSFullScreenModeWindowLevel), but implementation does not honour it,
instead always uses kCGMaximumWindowLevel-1.
- using SetSystemUIMode() does not work with enterFullScreenMode
- other apps are not notified when your app goes fullscreen
(kEventAppSystemUIModeChanged Carbon event)
- going fullscreen invokes -(void)viewWillMoveToSuperview:
(NSView*)newSuperview with a nil newSuperview.  This is the condition
that one generally uses to call unbind: on one's view.
http://homepage.mac.com/mmalc/CocoaExamples/controllers.html#unbinding

Hopefully in 10.6 this API will become usable.

Sean


___

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

Please do not post 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 arch...@mail-archive.com


Re: Initial Prefs Setting Of Checkbox?

2008-12-31 Thread Graham Cox


On 1 Jan 2009, at 6:59 am, Chunk 1978 wrote:


ok i get that... however, what if a developer intends to leave all
checkboxes in preferences unchecked as the initial defaults, and there
are only checkboxes or radio buttons, no colors, no numbers, etc... is
it considered bad practice to not register these defaults if they are
bound?  or is it better to keep code to a minimum and not register the
defaults... are there any problems that can arise from not having
defaults registered if their initial settings of the checkboxes is
desired?



Basically if your defaults are 0, NO or NULL/nil for any setting, you  
can safely just not bother with registering them. That's because these  
are the values returned for a missing key.


You only need to register the defaults that have to be set to a value  
other than these. I typically design my defaults so that an absence of  
a value is the default default (aside: why preferences got changed  
to defaults is a mystery - it leads to confusion when discussing the  
defaults for preferences). For things like colours, you can substitute  
the default colour at runtime if you get a nil value back from the  
default - that is another way to avoid the need to use  
registerDefaults, but often it's useful to just use a plist with  
registerDefaults: so you can quickly edit the settings without  
hardwiring them into your code.


--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 arch...@mail-archive.com


Re: NSSplitView

2008-12-31 Thread Benjamin Dobson


On 31 Dec 2008, at 22:53:46, David Blanton wrote:

In Xcode 2.4.1 , debug view, all in one, the stack and vars are  
split, and below is source and there is one control point that moves  
the vert and horiz splitters


Some Apple magic perhaps?


I think posting a screenshot on the web would help those of us who do  
not have access to Xcode 2.4.1 right now.

___

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

Please do not post 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 arch...@mail-archive.com


Re: mydoc.myext/QuickLook/Preview.html and full screen

2008-12-31 Thread Julien Jalon
On Wed, Dec 31, 2008 at 10:37 PM, Gerd Knops gerti-cocoa...@bitart.comwrote:


 On Dec 31, 2008, at 1:22 PM, Gerd Knops wrote:

  I am looking to add QuickLook functionality to a fairly complex document.
 A static html file, using some javascript to interact with the document
 contents would be ideal for a number of reasons. So I experimented by adding
 a QuickLook/Preview.html file to my document bundle.

 That works fine, and in 'normal' QuickLook mode that html can be resized
 to cover most of the screen.

 But in full screen mode the html always appears to be sized to cover only
 about 1/4 of the available space. Is there some trick to allow the html
 document to use the entire screen?

  Closer examination shows that apparently javascript is not supported
 inside QuickLook.


Security reasons. In particular, QL is a little more paranoid if it gets the
preview directly from the disk (e.g. in
MyDoc.docextension/QuickLook/Preview.html)


 Seemingly arbitrary limitation, when according to the documentation Java
 applets and Flash are supported.


Web Plug-ins are not supported (if this is in QL documentation, it is a
bug).


 Would have been nice to have some client-side javascript to produce a nice
 functional QuickLook document, instead of being limited to 'no nib allowed'
 C code. Why no full Objective-C support for Quicklook seems rather odd.


Security, stability and other reasons.

QL is not meant to fully replace an application. It's not meant to be some
sort of Active X or OpenDoc either. Its goal is much more limited (but in
the end much more useful ;-) ).

-- 
Julien
___

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

Please do not post 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 arch...@mail-archive.com


Re: NSSplitView

2008-12-31 Thread Sherm Pendley

On Dec 31, 2008, at 9:07 PM, Benjamin Dobson wrote:


On 31 Dec 2008, at 22:53:46, David Blanton wrote:

In Xcode 2.4.1 , debug view, all in one, the stack and vars are  
split, and below is source and there is one control point that  
moves the vert and horiz splitters


Some Apple magic perhaps?


I think posting a screenshot on the web would help those of us who  
do not have access to Xcode 2.4.1 right now.


3.1.2 behaves the same way, so I'd assume the in-between versions  
(2.5, 3.0, etc.) do also.


I doubt that it's some undocumented magic in the standard  
NSSplitView though - more likely just a custom control that was  
created by the Xcode dev team. Oddly, it's only used in the Debug  
view. Not in the Project view, nor in the docs viewer, despite both of  
those windows having similar three-pane arrangements.


sherm--

___

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

Please do not post 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 arch...@mail-archive.com


Re: NSOutlineView

2008-12-31 Thread Mahaboob

Data is stored in a database and I¹m retrieving it by using QuickLite
database.

On 12/31/08 6:31 PM, Timothy Larkin t...@cornell.edu wrote:

 Where are the data coming from? A core data store? Or do you load them
 explicitly?
 
  
 --
  
 
 Timothy Larkin
  
 
 Abstract Tools
  
 
 Caroline, NY
  
  
 
 On Dec 30, 2008, at 11:53 PM, Mahaboob wrote:
 
  I used awakeFromNib method. When I¹m running the program in debugger,
 outlineView get instantiated and shows its value ³0x14c260² and also its
 variables(_numberOfRows ,...) shows the value ³0² and opens the main window.
 From the main window when I¹m clicking the button, that opens the window
 containing outlineView, then outlineView shows its value as ³0x99d6938b² and
 also its variables shows nothing, thus opens the window without outline data.
 Then I selected a table from the popup button (which calls the method for
 loading outline data) then outlineView shows its value ³0x14c260² and
 displays outline data.
  
  
  On 12/30/08 6:33 PM, Timothy Larkin t...@cornell.edu wrote:
  
  
 I am assuming that the objects in question are loaded from a nib. In that
 case, you cannot assume that all the nib objects have been created until the
 nib loader send those objects an awakeFromNib message. Try writing an awake
 from nib method for one of the nib classes. If you then put a breakpoint, I
 think you will find that the outline view has been instantiated, and from
 there you can call your method that loads the outline data.
  
  
  
   
  --
   
  
  Timothy Larkin
   
  
  Abstract Tools
   
  
  Caroline, NY
   
   
  
  
  
 
   
   
 
 


___

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

Please do not post 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 arch...@mail-archive.com


Re: iTunes Scripting Bridge examples?

2008-12-31 Thread Scott Anguish
heh, no. This is a personal project I'm messing with. Nothing work  
related.



On 30-Dec-08, at 1:41 PM, Kyle Sluder wrote:


On Tue, Dec 30, 2008 at 11:53 AM, has hengist.p...@virgin.net wrote:
which you can then clean up or rewrite into whatever form you need.  
Won't
help you with SB specifically, of course, but I think my views on  
SB are

sufficently recorded by now.


Uh, Scott Anguish probably has very good reason to want a Scripting
Bridge-specific example: http://www.linkedin.com/pub/a/149/167

;-)

--Kyle Sluder


___

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

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

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

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


Re: Automatically filling an app with test data

2008-12-31 Thread Kyle Sluder
On Wed, Dec 31, 2008 at 5:01 AM, Matteo Manferdini
mat.maili...@gmail.com wrote:
 I've finally come to the end of my app and now I need to test it with
 data. The test with some data generated manually goes weel, but now I
 have to fill the app with lots of data, to see how it behaves. Is
 there a common approach to doing this?

You mean you have written an application and haven't been testing it
throughout?  What do you plan to do when you have a rat's nest of
interrelated issues that you can't address without going back and
revamping your app's design?

 I came across the Cocoa scripting guide, and it seems the way to go,
 but I wonder if it would not be better to write some code that fills
 automatically the app instead of going through the guide to learn how
 to make my app scriptable.

If you want to get data into your app, you might want to look at
writing code to extract data from other sources, rather than starting
with that data and trying to get it into your app.  After all, you're
already writing your app's source code, you needn't treat it as a
black box.

 I'm using core data to store all application data, so maybe there is a
 way I'm not considering.

That would be an awfully generic problem to solve, wouldn't it?
Given a program P, which we know uses Core Data in some capacity but
can do anything else beyond that, and an arbitrary set of test data T,
import T into P in a useful manner.  Smells like the Halting Problem.
 ;-)

--Kyle Sluder
___

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

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

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

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


Re: NSOutlineView

2008-12-31 Thread Mahaboob

When I¹m calling this method from toolbar in the main window,
first the outlineView shows the value ³0x0² then it call another method,
that queries the database retrieves all the data needed, and then control
goes to [OutlineView reloadData]; .then also outlineView shows the value
³0x0². Then it fires the event numberOfChildrenOfItem and it returns 0. Thus
opens the window without any outline data.

When I¹m calling this method from a button in main window,
OutlineView shows the value ³0x34890c24² then queries the database and opens
the window containing outline data.

On 1/1/09 11:18 AM, Timothy Larkin t...@cornell.edu wrote:

 Perhaps the data have not yet been loaded when you try to populate the table
 the first time.
 
  
 --
  
 
 Timothy Larkin
  
 
 Abstract Tools
  
 
 Caroline, NY
  
  
 
 On Dec 31, 2008, at 10:53 PM, Mahaboob wrote:
 
  
  Data is stored in a database and I¹m retrieving it by using QuickLite
 database.
  
  On 12/31/08 6:31 PM, Timothy Larkin t...@cornell.edu wrote:
  
  
 Where are the data coming from? A core data store? Or do you load them
 explicitly?
 
 


___

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

Please do not post 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 arch...@mail-archive.com


Re: iTunes Scripting Bridge examples?

2008-12-31 Thread Charles Steinman
On Mon, Dec 29, 2008 at 9:15 PM, Scott Anguish sc...@cocoadoc.com wrote:
 Does anyone have any examples of using the Scripting Bridge with iTunes?
  Specifically how you get the currently selected tracks returned as an array
 of iTunesTrack items.

Should be something like:

iTunesApplication *iTunes = [SBApplication
applicationWithBundleIdentifier:@com.apple.iTunes];
NSArray *tracks = [[iTunes selection] get];

I just did the equivalent in Ruby and it worked like a charm.
___

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

Please do not post 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 arch...@mail-archive.com


Enable repeated Keyboard Event when key stays down

2008-12-31 Thread Simon Vanesse

Hello,

I am currently improving the Wiiji source code (Wiiji is a open source  
software that allows the use of a wiimote as a Joystick + keyboard  
input on a mac).
I have checked everywhere in the forums / google and haven't found a  
solution to have the keyboard repeat a keystroke when a key on the  
wiimote stays down.


Here is the code executed when a keystroke up/down event is received.  
Currently the key is not repeated but just outputted once :


// hid_key : key's number
// isPressed : True when key is down, false otherwise

static CGKeyCode hid_key;
static CGEventRef event = NULL;

CFRelease(CGEventCreate(NULL)); // Tiger's bug. see: 
http://www.cocoabuilder.com/archive/message/cocoa/2006/10/4/172206

event = CGEventCreateKeyboardEvent(NULL, hid_key, isPressed);
if(isPressed)   {
	CGEventSetType(event,kCGEventKeyDown); // Don't know if this is  
necessary, the api tells it is a prerequisite before calling  
CGEventSetIntegerValueField
	CGEventSetIntegerValueField(event, kCGKeyboardEventAutorepeat,  
(int64_t)1); // This should allow autorepeat, but doesn't work right now

}
CGEventPost(kCGHIDEventTap, event);
CFRelease(event);


Does anyone got this fixed before ?

Thanks for your answers,

Best,

Simon
___

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

Please do not post 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 arch...@mail-archive.com


Problem adding an entity to a to-many relationship

2008-12-31 Thread Keith Lander
I am trying to get my head round Core Data and Bindings. I have  
created a simple core data model consisting of two entities called  
Course and Student. There is a to-many relationship from Course to  
Student. I have created a view with one table for Courses and another  
for students. There is a button for adding courses. That works fine. I  
also have a button which when clicked gets a CSV file containing  
student details. For each student in the file I want to create a new  
entity and have the following code in my NSPersistentDocument subclass:


NSManagedObjectContext *context = [self managedObjectContext];
	Student *student = [NSEntityDescription  
insertNewObjectForEntityForName:@Student  
inManagedObjectContext:context];


This seems to work OK. I then update the fields with data from the CSV  
file.


The problem comes when I try to add the student to its owning course.

I get the course from the array controller using:

Course *course = [[coursesController selectedObjects] objectAtIndex:0];

This seems to return the correct entity.

Then I then add the student using the predefined accessor:

[course addStudentsObject:student];

This fails in the call [NSBinder  
_invokeSelector:withAguments:onKeyPath:ofObject:mode:raisesForNotApplicableKeys 
:]


I'm using the latest version of XCode and have got garbage collection  
switched on.


I hope someone can sort me out.

Cheers
Keith
___

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

Please do not post 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 arch...@mail-archive.com


Need Xcode/Cocoa template for screensaver interactive OpenGL app

2008-12-31 Thread Greg Edwards
Hi folks,
I'm looking for an Xcode/Cocoa template that can build a screensaver, and
also a normal interactive OpenGL app with the same gfx, in a bordered window
or full-screen, with keystroke and gui control. This is for OpenGL and
shader experimentation, to run only on Mac OS X 10.4/5.  I've got the
Standard Apple Templates / Screensaver going fine, thanks to the folks at
http://cocoadevcentral.com  for their ScreenSaver tutorials I and II. My env
is Macbook, 10.5.5, Xcode 3.1.2

Thanks in advance,
GE.
___

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

Please do not post 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 arch...@mail-archive.com


Which language to get started with cocoa development?

2008-12-31 Thread Achim Domma

Hi,

I develop software for a living and want to get started with cocoa  
development just for fun. I'm good at python, C, C++ and C# and have  
some Ruby knowledge. Now I'm asking myself, which language I should  
use to get started with cocoa development:


- ObjC looks interesing, but would be a new language to learn. I like  
to learn new languages, but I also prefer to do one step after  
another. So learning Cocoa and Obj-C toghether could be frustrating.
- I like dynamic scripting languages like python and ruby, but I would  
like to ship my apps to other users. And they should not care about  
the language I have used. Can pyObjC or RubyCoca be bundled with my  
app, so that the enduser will not recognize that python/ruby is  
shipped with my app?
- As far as I understand, GUIs are usually build with the interface  
builder of XCode. That tools is tuned to be used with ObjC. How good  
is the integration with scripting languages?
- How up to date are bindings to non ObjC languages usually? If I  
will like cocoa development, I want to have a look at core data and  
core animations. Are these also available for ruby and python?
- What about Mono/Cocoa#? Looks like Mono is not an good option, if I  
want to distribute my app as small download via the web. Or am I wrong?


I would be very happy to hear some opinions of experienced cocoa  
developers about these topics. Any feedback would be very appreciated.


cheers,
Achim
___

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

Please do not post 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 arch...@mail-archive.com