Swap NSBox content without user seeing it when animation is involved

2013-04-01 Thread Brad Stone
Desired action: 
1) An NSBox (dstBox) with View A in it's content animates out to the left
2) NSBox's content is replaced with View B
3) NSBox with View B in it's content animates in from the right. 

Actual action:
1) An NSBox (dstBox) with View A in it's content animates out to the left
2) NSBox with View A in it's content animates in from the right. 
3) NSBox's content is replaced with View B

2 and 3 are swapped which is the problem.

The motion of the animation works fine.   The problem is the NSBox's content  
(dstBox) doesn't change on the screen until the animation is stopped.  I'd like 
it to be switched somewhere off screen so view B comes in from the right and 
the user doesn't see the switch happen.

Does someone have any suggestions I can try out?

Thanks



//Move out
[settings setObject:dstBox forKey:NSViewAnimationTargetKey];
[settings setObject:[NSValue valueWithRect:startingFrame] 
forKey:NSViewAnimationStartFrameKey];
if (toRight) {
destFrame.origin.x += destFrame.size.width+1;
} else {
destFrame.origin.x -= destFrame.size.width-1;
}
[settings setObject:[NSValue valueWithRect:destFrame] 
forKey:NSViewAnimationEndFrameKey];
// Animate
NSAnimation *theAnim = [[NSViewAnimation alloc] 
initWithViewAnimations:[NSArray arrayWithObject:settings]];
[theAnim setDuration:animationDuration];
[theAnim setAnimationBlockingMode:NSAnimationBlocking];
[theAnim startAnimation];




// Update the View
[dstBox setContentView:newView];




// Move in
if (toRight) {
destFrame.origin.x -= (destFrame.size.width-1)*2;
} else {
destFrame.origin.x += (destFrame.size.width+1)*2;
}
[settings setObject:[NSValue valueWithRect:destFrame] 
forKey:NSViewAnimationStartFrameKey];
[settings setObject:[NSValue valueWithRect:startingFrame] 
forKey:NSViewAnimationEndFrameKey];
// Animate
theAnim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray 
arrayWithObject:settings]];
[theAnim setDuration:animationDuration];
[theAnim setAnimationBlockingMode:NSAnimationBlocking];
[theAnim startAnimation];  
___

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

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

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

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


Re: Swap NSBox content without user seeing it when animation is involved

2013-04-01 Thread Brad Stone
I was using an NSBox for my convenience to make view swapping easy.  The super 
view has two boxes (dstBox is one of them) and there are three different views 
that get swapped into and out of the bottom box.  Using an NSBox makes this 
pretty easy.  That's why it's designed that way.

 
On Apr 1, 2013, at 1:30 PM, Fritz Anderson fri...@manoverboard.org wrote:

 On 1 Apr 2013, at 11:11 AM, Brad Stone cocoa-...@softraph.com wrote:
 
 Desired action: 
 1) An NSBox (dstBox) with View A in it's content animates out to the left
 2) NSBox's content is replaced with View B
 3) NSBox with View B in it's content animates in from the right. 
 
 Actual action:
 1) An NSBox (dstBox) with View A in it's content animates out to the left
 2) NSBox with View A in it's content animates in from the right. 
 3) NSBox's content is replaced with View B
 
 2 and 3 are swapped which is the problem.
 
 The motion of the animation works fine.   The problem is the NSBox's content 
  (dstBox) doesn't change on the screen until the animation is stopped.  I'd 
 like it to be switched somewhere off screen so view B comes in from the 
 right and the user doesn't see the switch happen.
 
 Does someone have any suggestions I can try out?
 
 It is possible that during a single animation, a view's contents are reduced 
 to an OpenGL texture, and won't update until the animation completes. Or this 
 is an effect of the animationBlockingMode you've chosen.
 
 You have two completely different instances of visible content. There's no 
 reason to be stingy. Use two views. Initialize both before use, and track 
 which is current. The performance hit is small, and is complete before the 
 views are visible; barring a pathological case, the memory hit is negligible 
 on a modern computer. (You may be able to remove the (instance?) variable 
 toRight, which you'd otherwise have to keep in sync, and replace it with 
 _activeBox == _rightBox.)
 
 (I'm curious: Do you need the decoration of an NSBox? Would an NSView do as 
 well?)
 
   — F
 
 -- 
 Fritz Anderson
 Xcode 4 Unleashed: 4.5 supplement for free!
 http://www.informit.com/store/xcode-4-unleashed-9780672333279
 


___

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

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

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

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

How to: NSPopover Refuse First Responder?

2013-03-20 Thread Brad Stone
I'm trying to replicate the NSPopover functionality that the new iTunes has and 
I'm 99% there.  The las problem I'm facing is when the NSPopover appears it 
steals the firstResponder status from the NSSearchField so the user's typing 
gets interrupted when the popover appears.  I tried giving the firstResponser 
status back after the popover appear but all that does is mess up the user's 
typing.  

How can I have a popover appear but have the NSSearchField never relinquish 
it's firstResponder status or have the NSPopover refuse firstResponder?

Thanks
___

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

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

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

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


Syncing w/o iCloud

2012-12-20 Thread Brad Stone
I have an app in OS X that shares files with an app in iOS.  Because of 
security restrictions some information cannot be shared with iCloud.  I'd like 
to do it over a wire.  What are my alternatives?  If someone could point me in 
the right direction I'd appreciate it.

Thanks
___

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

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

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

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


Is it possible to read a file icon from iOS file system?

2012-12-10 Thread Brad Stone
In iOS is there a way I can get access a file's icon?  

I use [NSWorkspace iconForFile] in OS X.  I looked a lot yesterday and I don't 
**think** there is a way in iOS.  My OS X app has an iOS client and the files 
will be synced using iCloud.  My app's document structure is a file package 
with a core data database and user files in it (Excel, for example).  When they 
open the package with my client in iOS they see a table view with the file 
names and I want them to see the icons.

I'm trying to read the icon from the file as a work-around because the icon is 
stored as an NSImage in the core data database.  I thought if I could avoid 
modifying my core data model by reading the image from the file and I'll just 
remove the attribute form the iOS model.  To make the image work in iOS will 
require me to change all the thousands of NSImages in the OS X world which is 
where I'll probably end up.

Thanks
___

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

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

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

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


Re: Is it possible to read a file icon from iOS file system?

2012-12-10 Thread Brad Stone
Answered my own question.

UIDocumentInteractionController 
@property(nonatomic,readonly) NSArray *icons
Discussion
This property contains an array of UIImage objects containing the available 
icons for the given file. The images in the array are sorted from smallest to 
largest, with the smallest image located at index 0. The returned array always 
contains at least one image.
The images themselves are provided by the system and determined by the UTI of 
the file. Apps can register custom icons for their associated files by 
including the appropriate meta information in their Info.plist file. If no 
custom icon exists, the images in this property represent the generic document 
icon.


On Dec 10, 2012, at 5:34 PM, Brad Stone cocoa-...@softraph.com wrote:

 In iOS is there a way I can get access a file's icon?  
 
 I use [NSWorkspace iconForFile] in OS X.  I looked a lot yesterday and I 
 don't **think** there is a way in iOS.  My OS X app has an iOS client and the 
 files will be synced using iCloud.  My app's document structure is a file 
 package with a core data database and user files in it (Excel, for example).  
 When they open the package with my client in iOS they see a table view with 
 the file names and I want them to see the icons.
 
 I'm trying to read the icon from the file as a work-around because the icon 
 is stored as an NSImage in the core data database.  I thought if I could 
 avoid modifying my core data model by reading the image from the file and 
 I'll just remove the attribute form the iOS model.  To make the image work in 
 iOS will require me to change all the thousands of NSImages in the OS X world 
 which is where I'll probably end up.
 
 Thanks
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.com

___

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

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

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

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


Re: FileWrapper iCloud

2012-11-21 Thread Brad Stone
The wrapper functionality is a remnant of NSPersistentDocument but I don't use 
it anymore.  Thanks for your answers, this was helpful.

On Nov 10, 2012, at 1:28 PM, Sean McBride s...@rogue-research.com wrote:

 On Sat, 10 Nov 2012 18:09:58 +, Luke Hiesterman said:
 
 File wrappers don't make it inherently easier or harder to deal with
 iCloud. File packages (which you would use file wrappers to represent)
 can be elegant means of wrapping up document data because it allows for
 easy separation of distinct components, and are usually recommended if
 they at all make sense for your application.
 
 Unless you use NSPersistentDocument, which still, after all these years, and 
 even after the addition of 'external storage' support in 10.7, doesn't 
 support file wrappers. :(
 
 Cheers,
 
 --
 
 Sean McBride, B. Eng s...@rogue-research.com
 Rogue Researchwww.rogue-research.com
 Mac Software Developer  Montréal, Québec, Canada
 
 


___

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

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

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

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

FileWrapper iCloud

2012-11-10 Thread Brad Stone
Does fileWrapper functionality make it easier or harder or is completely 
irrelevant for iCloud document functionality?  My app used to need the 
fileWrapper functionality and it's still in there but I don't need it anymore 
and I want to remove it all.  Would it help me keep it?

Thanks
___

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

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

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

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


Simple question driving me CRAZY

2012-06-16 Thread Brad Stone
I have a subclass of a NSViewController.  In fact, I created on just as a test 
with no custom code.  I then throw an NSTextView in the NSView that comes with 
it and then drag from the NSTextView to the .h file to create an outlet.  Why 
why why is it making it unsafe_unretained?  I'm using ARC.  Why it's it weak 
like every other subview?  The NSTextView is in a NSScrollView which is in the 
controllers NSView.  The NSScrollView is coming in as weak.


It's been diving me insane all day.

Thanks
___

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

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

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

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


Re: Convert to Objective-C ARC Syntax Error

2012-04-12 Thread Brad Stone
Dave - I am not linking directly to any of the files causing the errors listed 
in my original email.  I did a search on #import  and got:
#import Cocoa/Cocoa.h
#import Security/Security.h
#import Carbon/Carbon.h
#import Security/SFKeychainSavePanel.h
#import Foundation/Foundation.h
#import CoreData/CoreData.h
#import CommonCrypto/CommonCryptor.h /
#import Security/Security.h
#import CoreFoundation/CoreFoundation.h
#import CoreFoundation/CFPlugInCOM.h
#import CoreServices/CoreServices.h
#import QuickLook/QuickLook.h
#import Quartz/Quartz.h

On Apr 1, 2012, at 7:16 PM, Dave Zarzycki wrote:

 Brad,
 
 This looks similar to Radar 10434539. Let me know if this works: simplify the 
 header includes in your code to just #import Quartz/Quartz.h and just link 
 against Quartz. If your code is already doing this, then let us know.
 
 Thanks!
 
 davez
 
 


___

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

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

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

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


Convert to Objective-C ARC Syntax Error

2012-03-31 Thread Brad Stone
I used Edit-Refactor-Convert to Objective-C ARC  My app works fine but 
I'm getting a syntax error in Apple's header files.  They're all in the same 
place: @private. 

There error is '__strong' only applies to objective-c object or block pointer 
types; type here is 'void *'

Here's an example:

/* Quartz Composer Composition Renderer */
@interface QCRenderer : NSObject QCCompositionRenderer
{
@private
__strong void*  _QCRendererPrivate;
}


I'm thinking I should remove the __strong from these but I'm wondering why 
__strong was added here anyway and I'm wary about touching Apple's code.

I'm at a loss. 

Thanks

The same things happens in QCPlugIn.h, QCRendered.h, QCCompositionLayer.h, 
QCView.h, QCCompositionParameterView.h, QCCompositionPickerView.h, 
QCCompositionPickerPanel.h, QCPLugInViewController.h, IKImageBrowserView.h, 
IKImageBrowswerCell.h, IKImageBrowserView.h
___

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

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

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

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


Proper Way to use the Sandbox

2012-02-18 Thread Brad Stone
I modified my Mac shoebox app for sandboxing.  My application stores the user 
info as a series of file packages in a series of directories all rolling up 
into a Documents folder.  It works fine but now I noticed the sandbox directory 
structure doesn't get backed up with Time Machine.  Obviously, when it was in 
the regular documents folder it got backed up.  Now that it's in the app 
sandbox it seems like it does not. 
 
What is the recommended approach to make sure the user data gets backed up by 
Time Machine?  
___

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

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

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

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


Re: Recently Opened in Doc

2012-02-04 Thread Brad Stone
Thanks everyone.  In the end, since this is a shoebox app like iPhoto where the 
user doesn't access their data via File-Open and the file name doesn't 
necessarily make sense to the user I suppressed the Open Recently menu (the 
user has a History menu like Safari for that purpose).  For the dock menu I 
made my own which allowed me to give the user menu item titles that would mean 
something to them.  I did it two parts.  First I did this to suppress the 
default functionality:

- (NSUInteger)maximumRecentDocumentCount {
return 0;
}

and then I provide my own using - (NSMenu *)applicationDockMenu:(NSApplication 
*)sender.  I'm not doing a lot of calculations here so it comes up quickly for 
the user.

On Jan 28, 2012, at 5:58 PM, James Merkel wrote:

 On 28 Jan 2012 08:46:48 -0800 Quincey Morris wrote:
 
 On Jan 28, 2012, at 08:19 , Brad Stone wrote:
 
 I have a shoebox app like iPhoto where the actual filename is irrelevant to 
 the user.   I control the file name.  
 
 What I'd like to do is just capture the menu items before they're displayed 
 and change the menu titles into something relevant to the user.  In the 
 scheme of things it's a minor way to access the info in my app so if I 
 could eliminate them that would be OK too.  Changing the filename is not an 
 option at this point.
 
 It seems to me you can subclass NSDocumentController, then override 
 'noteNewRecentDocument:' to do nothing. Presumably this will keep your 
 filename off the Open Recent submenu, the Recent Items item on the Apple 
 menu, and the dock menu. Then you should be able to delete the Open Recent 
 item itself, and be left with no traces of recent items from your app.
 
 If you wanted to go the extra mile, you could create your own recent-items 
 implementation, driven from your 'noteNewRecentDocument:' override, and 
 using the 'applicationDockMenu:' application delegate method, with whatever 
 document identifiers you want.
 
 
 My app is not document based so I call noteNewRecentDocumentURL: directly to 
 add the filename to the Open Recent submenu list.
 If I comment that line of code out then the document is not added to the list 
 as expected. Also, the Dock menu Show Recents shows nothing and the 
 filename is not added to  the Dock menu list. 
 
 So yes, noteNewRecentDocument; (which calls noteNewRecentDocumentURL: ) is 
 the key to the whole thing.
 
 Jim Merkel

___

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

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

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

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


Re: Recently Opened in Doc

2012-01-28 Thread Brad Stone
I have a shoebox app like iPhoto where the actual filename is irrelevant to the 
user.   I control the file name.  

What I'd like to do is just capture the menu items before they're displayed and 
change the menu titles into something relevant to the user.  In the scheme of 
things it's a minor way to access the info in my app so if I could eliminate 
them that would be OK too.  Changing the filename is not an option at this 
point.


On Jan 27, 2012, at 11:19 PM, James Merkel wrote:

 On 27 Jan 2012 10:20:37 Brad Stone wrote:
 I'd like to 
 1) change the menu titles of the recently opened documents listed in the 
 dock menu
 
 if I can't do that I'd like to 
 
 2) remove the list of recently opened documents all together.
 
 I haven't been able to find a way to do this.  Can someone provide guidance?
 
 Thanks
 
 I don't  have an answer to your question -- but something I didn't notice 
 before.
 If you rename a file, the new filename appears in the recently opened files 
 menu (replacing the old filename).
 However the old filename stays in the doc menu.
 Seems like that's a bug.
 
 Jim Merkel


___

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

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

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

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


Re: Recently Opened in Doc

2012-01-28 Thread Brad Stone
Thanks Quincey, I've already subclassed my NSDocumentController and I use 
noteNewRecentDocument to prevent my index file from showing up in the list.   
The code never gets past the continue call because every time this method is 
called the only menu item  in [openRecentMenu itemArray] is Clear Menu 
(except when I quit out).

- (void)noteNewRecentDocument:(NSDocument *)aDocument {
if ([aDocument isKindOfClass:[PNDocument class]]) {
[super noteNewRecentDocument:aDocument];
}

NSMenu *fileMenu = [[[NSApp mainMenu] itemWithTitle:@File] submenu];
if (!fileMenu) {
return;
}
NSMenu *openRecentMenu = [[fileMenu itemWithTitle:@Open Recent] submenu];
if (!openRecentMenu) {
return;
}
 
for (NSMenuItem *openRecentMenuItem in [openRecentMenu itemArray]) {
NSString *title = [openRecentMenuItem title];
if ([title isEqualToString:@Clear Menu]) {
continue;
}
   // code to change the menuItem title

}
}





On Jan 28, 2012, at 11:46 AM, Quincey Morris wrote:

 On Jan 28, 2012, at 08:19 , Brad Stone wrote:
 
 I have a shoebox app like iPhoto where the actual filename is irrelevant to 
 the user.   I control the file name.  
 
 What I'd like to do is just capture the menu items before they're displayed 
 and change the menu titles into something relevant to the user.  In the 
 scheme of things it's a minor way to access the info in my app so if I could 
 eliminate them that would be OK too.  Changing the filename is not an option 
 at this point.
 
 It seems to me you can subclass NSDocumentController, then override 
 'noteNewRecentDocument:' to do nothing. Presumably this will keep your 
 filename off the Open Recent submenu, the Recent Items item on the Apple 
 menu, and the dock menu. Then you should be able to delete the Open Recent 
 item itself, and be left with no traces of recent items from your app.
 
 If you wanted to go the extra mile, you could create your own recent-items 
 implementation, driven from your 'noteNewRecentDocument:' override, and using 
 the 'applicationDockMenu:' application delegate method, with whatever 
 document identifiers you want.
 
 

___

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

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

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

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


Recently Opened in Doc

2012-01-27 Thread Brad Stone
I'd like to 
1) change the menu titles of the recently opened documents listed in the dock 
menu

if I can't do that I'd like to 

2) remove the list of recently opened documents all together.
 
I haven't been able to find a way to do this.  Can someone provide guidance?

Thanks
___

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

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

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

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


Core Animation + Focus Ring

2011-10-28 Thread Brad Stone
I understand there's an issue with focus rings not appearing in an editable 
cell if, like I do, you have an NSOutlineView sitting on a view that has Core 
Animation turned on.  Since it's not working and I'm using the latest XCode I'm 
assuming it's not fixed.  I'd be interested in any work-arounds.  The best one 
for me would be for me to programmatically turn on and off the Core Animation 
checkbox (the equivalent to that in code) on the fly in my code.  Any 
suggestions?___

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

Please do not post admin requests or moderator comments to the list.
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


Confused with block completionHandler

2011-08-24 Thread Brad Stone
I need to call this method manually but I'm confused how to format the 
completionHandler.  I don't understand what I'm reading.  Can anyone give me an 
example of how to define the completionHandler or point me to some 
documentation?

 [self saveToURL:[self fileURL] ofType:@myDocType 
forSaveOperation:NSAutosaveInPlaceOperation completionHandler:^(I'm 
confused!!!)];

This is the method definition
- (void)saveToURL:(NSURL *)url ofType:(NSString *)typeName 
forSaveOperation:(NSSaveOperationType)saveOperation completionHandler:(void 
(^)(NSError *errorOrNil))completionHandler

I've used blocks before like below but I don't understand the syntax above and 
I couldn't find an example on the internet or the documentation.  Any help 
would be appreciated.
[openPanel beginSheetModalForWindow:[NSApp keyWindow] 
completionHandler:^(NSInteger theResult) {
 if (theResult) {
   // some code here
}

Thanks___

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

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

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

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


Re: Confused with block completionHandler

2011-08-24 Thread Brad Stone
All these answers are great.   Thanks

On Aug 24, 2011, at 9:01 PM, Graham Cox wrote:

 
 On 25/08/2011, at 10:46 AM, Brad Stone wrote:
 
 I need to call this method manually but I'm confused how to format the 
 completionHandler.  I don't understand what I'm reading.  Can anyone give me 
 an example of how to define the completionHandler or point me to some 
 documentation?
 
 [self saveToURL:[self fileURL] ofType:@myDocType 
 forSaveOperation:NSAutosaveInPlaceOperation completionHandler:^(I'm 
 confused!!!)];
 
 This is the method definition
 - (void)saveToURL:(NSURL *)url ofType:(NSString *)typeName 
 forSaveOperation:(NSSaveOperationType)saveOperation completionHandler:(void 
 (^)(NSError *errorOrNil))completionHandler
 
 I've used blocks before like below but I don't understand the syntax above 
 and I couldn't find an example on the internet or the documentation.  Any 
 help would be appreciated.
 [openPanel beginSheetModalForWindow:[NSApp keyWindow] 
 completionHandler:^(NSInteger theResult) {
 if (theResult) {
  // some code here
 }
 
 
 Separate the block definition from the calling method to make it clearer:
 
 
 void (^completionHandler)(NSError*) = ^(NSError* error)
 {
   // here, write the code that makes up the body of the completion handler
 
 
 }
 
 [self saveToURL:[self fileURL] ofType:@myDoc forSaveOperation:saveOp 
 completionHandler:completionHandler];
 
 
 Here we just named the block 'completionHandler', but it could be anything, 
 such as 'fred' - it's just a variable identifier.
 
 
 
 --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


Lion's Auto Save Versions

2011-07-05 Thread Brad Stone
I'm testing my app in Lion with 4.1 and I'd like to play around with Auto Save 
and Versions (http://developer.apple.com/technologies/mac/whats-new.html).  
I've been through the documentation and I can't find anything new about how 
this works.  

Is there any documentation how we implement Auto Save and Versions?  Is the the 
same old autosave functionality that's been around for a while?

Second question, I have a Core Data document-based app so I've been running 
under the assumption that it's not recommended use Auto Save.  This may be 
urban legend.  If it's real does it still apply?

Thanks, Brad___

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

Please do not post admin requests or moderator comments to the list.
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: Help with relationship objects

2011-06-29 Thread Brad Stone
Quincey, that helps.  Thanks

On Jun 28, 2011, at 1:36 PM, Quincey Morris wrote:

 On Jun 28, 2011, at 08:40, Brad Stone wrote:
 
 I get the below.  Notice the new SRTodoEntity is properly in the todos 
 relationship but there's also a reference to it outside of the SRNoteEntity. 
  Intuitively, I would think there should be only one reference to it inside 
 SRNoteEntity.This is my confusion.  Why is it reference twice?  How can 
 I prevent that from happening if this isn't normal?
 
 po [[self managedObjectContext] registeredObjects]
 {(
 Note uid:330961758011065
  creationDate:2009-09-05 13:21:54 -0400
  modificationDate:2009-09-06 12:41:02 -0400
  todos:Relationship objects for {(
  SRTodoEntity: 0x200483d80 (entity: SRTodoEntity; id: 0x2004121e0 
 x-coredata://614245CF-F03E-4F43-9D7F-98CDCB2899FA/SRTodoEntity/p1 ; data: {
  note = 0x2002c4e60 
 x-coredata://614245CF-F03E-4F43-9D7F-98CDCB2899FA/SRNoteEntity/p1;
  todoViewData = nil;
  })
  )} on 0x200448360
 noteData:538
 
 SRTodoEntity: 0x200483d80 (entity: SRTodoEntity; id: 0x2004121e0 
 x-coredata://614245CF-F03E-4F43-9D7F-98CDCB2899FA/SRTodoEntity/p1 ; data: {
  note = 0x2002c4e60 
 x-coredata://614245CF-F03E-4F43-9D7F-98CDCB2899FA/SRNoteEntity/p1;
  todoViewData = nil;
 })
 )}
 
 You've kinda got hold of the wrong end of this. Core Data is an object graph, 
 certainly, and any pointer to a managed object is a reference to the 
 object. There are references to these objects all over your code -- every 
 stack variable pointer is a reference. In the above example, a reference to 
 the Todo object exists inside the set of references that represents Note's 
 relationship to its Todo's. That makes it a really important reference, but 
 it's certainly never the only one.
 
 By sending a 'registeredObjects' message to the managedObjectContext (which 
 is *not* an object in the object graph), you've asked it to construct a 
 collection (a set, as it happens) of references to Core Data objects it knows 
 about. There's no *relationship* from the MOC to the managed objects, it's 
 just the MOC's job to know what managed objects are currently in memory.
 
 

___

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

Please do not post admin requests or moderator comments to the list.
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


Help with relationship objects

2011-06-28 Thread Brad Stone
I need a little guidance.  Did I properly add a relationship object?  I don't 
know what's normal in this scenario.

I referred to here: 
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdUsingMOs.html

I have an entity called SRNoteEntity which has a to-many relationship with 
SRTodoEntity in a mutableSet called todos.  When I do the following:

[thisNote addTodosObject:todoItem];

I get the below.  Notice the new SRTodoEntity is properly in the todos 
relationship but there's also a reference to it outside of the SRNoteEntity.  
Intuitively, I would think there should be only one reference to it inside 
SRNoteEntity.This is my confusion.  Why is it reference twice?  How can I 
prevent that from happening if this isn't normal?

po [[self managedObjectContext] registeredObjects]
{(
 Note uid:330961758011065
creationDate:2009-09-05 13:21:54 -0400
modificationDate:2009-09-06 12:41:02 -0400
todos:Relationship objects for {(
SRTodoEntity: 0x200483d80 (entity: SRTodoEntity; id: 0x2004121e0 
x-coredata://614245CF-F03E-4F43-9D7F-98CDCB2899FA/SRTodoEntity/p1 ; data: {
note = 0x2002c4e60 
x-coredata://614245CF-F03E-4F43-9D7F-98CDCB2899FA/SRNoteEntity/p1;
todoViewData = nil;
})
)} on 0x200448360
 noteData:538

 SRTodoEntity: 0x200483d80 (entity: SRTodoEntity; id: 0x2004121e0 
x-coredata://614245CF-F03E-4F43-9D7F-98CDCB2899FA/SRTodoEntity/p1 ; data: {
note = 0x2002c4e60 
x-coredata://614245CF-F03E-4F43-9D7F-98CDCB2899FA/SRNoteEntity/p1;
todoViewData = nil;
})
)}

___

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

Please do not post admin requests or moderator comments to the list.
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: Quick Looking big files crash

2011-05-24 Thread Brad Stone
So it looks like the QuickLook framework has some bugs with Garbage Collection 
required.  

I contacted Apple tech support and they confirmed this is likely a bug in the 
Quick Look framework and asked me to file a bug report.  Too bad this cost me 
one of my free tech support chits.

In the mean time I'm incorporating QL this way:

NSString *paths = @;
for (NSString *thisPath in srcPathArray) {

NSString *s = @;
if ([paths length] == 0) {
s = [NSString stringWithFormat:@(quoted form of (POSIX 
path of \%@\)), thisPath];
} else {
s = [NSString stringWithFormat:@  \ \  (quoted 
form of (POSIX path of \%@\)), thisPath];
}
paths = [paths stringByAppendingString:s];
}


NSAppleScript *quickLook = nil;
// do shell script (qlmanage -p   (quoted form of (POSIX path of 
srcPath)))
NSString *command = [NSString stringWithFormat:@do shell script 
(\qlmanage -p \  %@),paths];
quickLook = [[NSAppleScript alloc] initWithSource:command];
[quickLook executeAndReturnError:nil];


On May 3, 2011, at 9:09 PM, Brad Stone wrote:

 Interesting, OK, now remember, t this is new to me.
 
 To begin the QL panel I run this required method:
 - (void)beginPreviewPanelControl:(QLPreviewPanel *)panel
 {
previewPanel = [panel retain];
panel.delegate = self;
panel.dataSource = self;
 }
 
 and then it ends with 
 
 - (void)endPreviewPanelControl:(QLPreviewPanel *)panel
 {
[previewPanel release];
previewPanel = nil;
 }
 
 Where QLPreviewPanel* previewPanel; is defined in my header file.
 
 The crash happens after the begin and never gets to the end.  
 
 I see here 
 http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcCoreFoundation.html
  that to ensure the longevity of Objective-C objects, you should use 
 CFRetain instead of retain.  
 
 I haven't been able to find the correct syntax to replace the retain/release 
 with CFRetain/CFRelease
 
 On May 3, 2011, at 7:51 PM, Wim Lewis wrote:
 
 
 On 3 May 2011, at 4:03 PM, Brad Stone wrote:
 I have a symbolic breakpoint set and it stops on 
 auto_refcount_underflow_error, even the small files.  If I continue the doc 
 shows in QL.
 
 Presumably, a few stack frames up, there will be a call to CFRelease() which 
 is causing the underflow (what would be an over-released zombie in a non-GC 
 app).
 
 The first thing I'd look for is using CFRelease() when you should call 
 -release (or vise versa, and the same for retain): code written pre-GC would 
 treat those as equivalent, but in a GC or optional-GC world they need to be 
 treated as operating on distinct kinds of refcount.
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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


selectionIndexesForProposedSelection on mouse Up or mouse Down

2011-05-12 Thread Brad Stone
For my NSTableView (NSIndexSet *)tableView:(NSTableView *)tableView 
selectionIndexesForProposedSelection:(NSIndexSet *)proposedSelectionIndexes 
fires on mouseDown and (void)tableViewSelectionDidChange:(NSNotification 
*)aNotification fires on mouseUp.

For my NSOutlineView (NSIndexSet *)outlineView:(NSOutlineView *)outlineView 
selectionIndexesForProposedSelection:(NSIndexSet *)proposedSelectionIndexes and 
(void)outlineViewSelectionDidChange:(NSNotification *)notification fire only on 
mouseUp.  

Is this normal behavior?

I would prefer the NSOutlineView fire on mouseDown like the NSTableView.  Is 
there a way to change that?

(In Mail.app, if you organize by thread selection happens on mouseUp but in 
iTunes, the podcast outlineView selects on 
mouseDown).___

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

Please do not post admin requests or moderator comments to the list.
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: selectionIndexesForProposedSelection on mouse Up or mouse Down

2011-05-12 Thread Brad Stone
I'm thinking about the perception of the user.  When I'm in Mail.app, for 
example, clicking in the outlineView (organized by thread) and I click on a row 
it feels less responsive because there's a pause before the row highlights (a 
pause until I release the mouse button).  When I'm in iTunes and the row 
highlights as soon as the mouse button is down is just feels more responsive.

I put in NSLog calls to show me when proposed and didChange get called.  
NSTableView's delegate gets called on mouseDown while NSOutlineView on mouseUp.

On May 12, 2011, at 2:06 PM, Quincey Morris wrote:

 On May 12, 2011, at 10:05, Brad Stone wrote:
 
 For my NSTableView (NSIndexSet *)tableView:(NSTableView *)tableView 
 selectionIndexesForProposedSelection:(NSIndexSet *)proposedSelectionIndexes 
 fires on mouseDown and (void)tableViewSelectionDidChange:(NSNotification 
 *)aNotification fires on mouseUp.
 
 For my NSOutlineView (NSIndexSet *)outlineView:(NSOutlineView *)outlineView 
 selectionIndexesForProposedSelection:(NSIndexSet *)proposedSelectionIndexes 
 and (void)outlineViewSelectionDidChange:(NSNotification *)notification fire 
 only on mouseUp.  
 
 This can't be true.
 
 For a start, thinking of the delegate methods as firing on mouse events 
 seems like a way to lead yourself astray. There are *various* ways to change 
 a selection, only some of which start at a mouse down event, and the delegate 
 methods are invoked at *various* points in the procedure depending on 
 circumstances, no matter how it starts. (Well, ...DidChange presumably gets 
 invoked only at the end, but what constitutes the end may vary.)
 
 Specifically, if NSOutlineView's 'selectionIndexesForProposedSelection:...' 
 method wasn't ever called until a mouse up event (after an initial mouse 
 down, I mean), it wouldn't be possible to prevent rows from getting selected 
 while the mouse is being dragged, and it *is* possible to do so.
 
 There may be specific scenarios where the view decides not to invoke the 
 delegate until mouse up, but that fact just demonstrates the pointlessness of 
 trying to parse the mouse event behavior.
 
 

___

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

Please do not post admin requests or moderator comments to the list.
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


Quick Looking big files crash

2011-05-03 Thread Brad Stone
I added Quartz and QuickLook frameworks to my garbage-collection-required app 
and then added simple Quick Look functionally.  

The bigger the file the more errors I get.  Small pdfs show no errors, large 
ppts, xl or zip files show a bunch of errors and eventually crash.  I'm not 
familiar with non-garbage collection memory management.  I wouldn't even be 
able to determine if these errors are telling me I should be.  Please help.

Here's what I get when I QL a large file.

proNotes(52698,0x1196fd000) malloc: reference count underflow for 0x201afc920, 
break on auto_refcount_underflow_error to debug. (17 times)
proNotes(52698,0x1196fd000) malloc: resurrection error for object 0x201f0a380 
while assigning {conservative-block}[352](0x20189fc40)[304] = 
CFRunLoopSource[128](0x201f0a380)
garbage pointer stored into reachable memory, break on 
auto_zone_resurrection_error to debug (13 times)
 

Then crash.  What should I look for?  How should I approach debugging this?

Thanks___

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

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

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

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


Re: Quick Looking big files crash

2011-05-03 Thread Brad Stone
I have a symbolic breakpoint set and it stops on auto_refcount_underflow_error, 
even the small files.  If I continue the doc shows in QL.

On May 3, 2011, at 6:52 PM, Wim Lewis wrote:

 
 On 3 May 2011, at 3:45 PM, Brad Stone wrote:
 Here's what I get when I QL a large file.
 
 proNotes(52698,0x1196fd000) malloc: reference count underflow for 
 0x201afc920, break on auto_refcount_underflow_error to debug. (17 times)
 proNotes(52698,0x1196fd000) malloc: resurrection error for object 
 0x201f0a380 while assigning {conservative-block}[352](0x20189fc40)[304] = 
 CFRunLoopSource[128](0x201f0a380)
 garbage pointer stored into reachable memory, break on 
 auto_zone_resurrection_error to debug (13 times)
 
 
 Then crash.  What should I look for?  How should I approach debugging this?
 
 Have you tried breaking on auto_refcount_underflow_error and 
 auto_zone_resurrection_error?
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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: Quick Looking big files crash

2011-05-03 Thread Brad Stone
My app stores an NSURL to a file.  All I'm doing is acting as the data source 
and delegate for QL and giving it access to an NSArray with the URL.  I'm not 
creating a plugin (or am I misunderstanding you). 

On May 3, 2011, at 6:59 PM, Nick Zitzmann wrote:

 
 On May 3, 2011, at 4:45 PM, Brad Stone wrote:
 
 Here's what I get when I QL a large file.
 
 proNotes(52698,0x1196fd000) malloc: reference count underflow for 
 0x201afc920, break on auto_refcount_underflow_error to debug. (17 times)
 proNotes(52698,0x1196fd000) malloc: resurrection error for object 
 0x201f0a380 while assigning {conservative-block}[352](0x20189fc40)[304] = 
 CFRunLoopSource[128](0x201f0a380)
 garbage pointer stored into reachable memory, break on 
 auto_zone_resurrection_error to debug (13 times)
 
 
 Then crash.  What should I look for?  How should I approach debugging this?
 
 
 Do this:
 
 1. In your project, add an executable for /usr/bin/qlmanage
 2. Give it an argument that points to a file that your importer handles, plus 
 any flags you need to pass to the task
 3. If you haven't done so already, make a symbolic link pointing to your 
 built importer product, and place it where you normally place your QuickLook 
 generators (so it loads the built product instead of a copy of the built 
 product)
 4. Make a symbolic breakpoint for auto_zone_resurrection_error
 5. Build and debug
 
 If you set up everything correctly, then Xcode's debugger will launch 
 qlmanage, which will load your plugin, and trigger the problem, and cause the 
 debugger to break. Good luck; debugging plugins isn't always easy.
 
 Nick Zitzmann
 http://www.chronosnet.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: Quick Looking big files crash

2011-05-03 Thread Brad Stone
Interesting, OK, now remember, t this is new to me.

To begin the QL panel I run this required method:
- (void)beginPreviewPanelControl:(QLPreviewPanel *)panel
{
previewPanel = [panel retain];
panel.delegate = self;
panel.dataSource = self;
}
 
and then it ends with 

- (void)endPreviewPanelControl:(QLPreviewPanel *)panel
{
[previewPanel release];
previewPanel = nil;
}

Where QLPreviewPanel* previewPanel; is defined in my header file.

The crash happens after the begin and never gets to the end.  

I see here 
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcCoreFoundation.html
 that to ensure the longevity of Objective-C objects, you should use CFRetain 
instead of retain.  

I haven't been able to find the correct syntax to replace the retain/release 
with CFRetain/CFRelease

On May 3, 2011, at 7:51 PM, Wim Lewis wrote:

 
 On 3 May 2011, at 4:03 PM, Brad Stone wrote:
 I have a symbolic breakpoint set and it stops on 
 auto_refcount_underflow_error, even the small files.  If I continue the doc 
 shows in QL.
 
 Presumably, a few stack frames up, there will be a call to CFRelease() which 
 is causing the underflow (what would be an over-released zombie in a non-GC 
 app).
 
 The first thing I'd look for is using CFRelease() when you should call 
 -release (or vise versa, and the same for retain): code written pre-GC would 
 treat those as equivalent, but in a GC or optional-GC world they need to be 
 treated as operating on distinct kinds of refcount.
 
 

___

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

Please do not post admin requests or moderator comments to the list.
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: Is a file open in another application?

2011-03-20 Thread Brad Stone
After sleeping on it my choices are to remove the encryption feature or make a 
big ugly dialog box warning the user if they encrypt a file that's open they 
will lose their changes.  Neither of these approaches are optimum.

On Mar 19, 2011, at 11:04 PM, Brad Stone wrote:

 I do need it to work for any app, not just Word or XL.
 
 I guess a poor workaround would be since it's not possible to reliably check 
 if the file is open I can force the user to quit the file's default app 
 before allowing them to encrypt.  It's just kind of heavy-handed.
 
 On Mar 19, 2011, at 6:20 PM, Charles Srstka wrote:
 
 On Mar 19, 2011, at 1:40 PM, Conrad Shultz wrote:
 
 On 3/19/11 11:10 AM, Kyle Sluder wrote:
 On Sat, Mar 19, 2011 at 9:13 AM, Conrad Shultz
 con...@synthetiqsolutions.com wrote:
 Note that this will only capture files that are properly opened (i.e.
 fopen()'d), so you won't catch every apparently open file.  For example,
 if you open a file in vi(m), it creates a hidden scratch file in the
 same directory and closes the original file.  You then edit the scratch
 file, which is only written out to the original file on save.  In this
 way, the original file is protected from damage due to a crash, but lsof
 will almost never show it as being open.
 
 This is also how Cocoa apps work. They only keep the file open to read
 its contents.
 
 I'm afraid that what Brad wants to do is not possible yet.
 
 Are you certain that is a general behavior?
 
 Just looking at NSDocument’s default hooks for opening/saving files will 
 show you the answer to that. The ones the user is encouraged to use in the 
 general case read the file into an NSData object on open, and write an 
 NSData out to the file on save.
 
 Charles___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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: Is a file open in another application?

2011-03-20 Thread Brad Stone
Actually, the users are shown files in a NSTableView and they select a menu to 
encrypt/decrypt.  That's where I'll warn them.  Thanks for your suggestion.

On Mar 20, 2011, at 10:10 AM, Robert Martin wrote:

 Given all the problems I've seen raised in this thread, I was just thinking 
 that you might just implement the encryption in a droplet, or a drop window - 
 so users can choose when to encrypt rather than having the encryption 'done' 
 to them.
 
 I just kept thinking about it, so thought I would mention it!
 
 Rob
 
 
 On Mar 19, 2011, at 9:34 AM, Brad Stone wrote:
 
 Is there a way for me to tell if a particular file is open in another 
 application?
 
 I have a feature I'd like to provide to my users that involves encrypting 
 files that belong to other apps (i.e. my application can encrypt/decrypt a 
 Word or Excel file).  I want to prevent the user from encrypting or 
 decrypting the file if it's open (i.e. the file is open in Word).  I would 
 like to display a dialog box that says something like myWord Doc.docx is 
 open.  Please close it and continue.  I've found the ability to find 
 running applications and I've found commentary that says what I'm asking for 
 is not possible.  I couldn't find anything in NSWorkspace or NSFileManager 
 to help unless there's a file attribute I don't know about that can tell me. 
  Any ideas?
 
 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/robmartin%40frontiernet.net
 
 This email sent to robmar...@frontiernet.net
 

___

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

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

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

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


Is a file open in another application?

2011-03-19 Thread Brad Stone
Is there a way for me to tell if a particular file is open in another 
application?

I have a feature I'd like to provide to my users that involves encrypting files 
that belong to other apps (i.e. my application can encrypt/decrypt a Word or 
Excel file).  I want to prevent the user from encrypting or decrypting the file 
if it's open (i.e. the file is open in Word).  I would like to display a dialog 
box that says something like myWord Doc.docx is open.  Please close it and 
continue.  I've found the ability to find running applications and I've found 
commentary that says what I'm asking for is not possible.  I couldn't find 
anything in NSWorkspace or NSFileManager to help unless there's a file 
attribute I don't know about that can tell me.  Any ideas?

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: Is a file open in another application?

2011-03-19 Thread Brad Stone
I do need it to work for any app, not just Word or XL.

I guess a poor workaround would be since it's not possible to reliably check if 
the file is open I can force the user to quit the file's default app before 
allowing them to encrypt.  It's just kind of heavy-handed.

On Mar 19, 2011, at 6:20 PM, Charles Srstka wrote:

 On Mar 19, 2011, at 1:40 PM, Conrad Shultz wrote:
 
 On 3/19/11 11:10 AM, Kyle Sluder wrote:
 On Sat, Mar 19, 2011 at 9:13 AM, Conrad Shultz
 con...@synthetiqsolutions.com wrote:
 Note that this will only capture files that are properly opened (i.e.
 fopen()'d), so you won't catch every apparently open file.  For example,
 if you open a file in vi(m), it creates a hidden scratch file in the
 same directory and closes the original file.  You then edit the scratch
 file, which is only written out to the original file on save.  In this
 way, the original file is protected from damage due to a crash, but lsof
 will almost never show it as being open.
 
 This is also how Cocoa apps work. They only keep the file open to read
 its contents.
 
 I'm afraid that what Brad wants to do is not possible yet.
 
 Are you certain that is a general behavior?
 
 Just looking at NSDocument’s default hooks for opening/saving files will show 
 you the answer to that. The ones the user is encouraged to use in the general 
 case read the file into an NSData object on open, and write an NSData out to 
 the file on save.
 
 Charles___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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: Accessing a managedObject property from within an accessor of another property

2011-02-23 Thread Brad Stone
[A]nd then it occurred to me that a computer is a stupid machine with the 
ability to do incredibly smart things, while computer programmers are smart 
people with the ability to do incredibly stupid things.  They are, in short, a 
perfect match.  ~Bill Bryson

On Feb 22, 2011, at 11:42 PM, Quincey Morris wrote:

 That's a lot of information you posted. :)
 
 Unfortunately, *based on the posted information* there's nothing obviously 
 wrong except that you've shot yourself in the foot using the debugger. Let's 
 look, for example,  at what one of the backtraces is telling you. You 
 triggered this by typing 'po self' in the debugger:
 
 On Feb 22, 2011, at 19:34, Brad Stone wrote:
 
 Breakpoint 28, -[SRMainWindowController toggleLock:] (self=0x2000df5e0, 
 _cmd=0x1000a9239, sender=0x2000df5e0) at SRMainWindowController.m:2897
 2897 [note setIsEncrypted:[NSNumber numberWithBool:YES]];
 The program being debugged stopped while in a function called from GDB.
 When the function (_NSPrintForDebugger) is done executing, GDB will silently
 stop (instead of continuing to evaluate the expression containing
 the function call).
 
 A function called from the debugger as a result of 'po self' failed. What 
 function? It's not clear yet, but it *is* clear what failed -- that function 
 directly or indirectly called 'toggleLock:' *again* -- the method you were in 
 when you started all this debugging activity. Why did it stop? It hit the 
 breakpoint that you put in that code.
 
 This backtrace is enlightening, unlike the earlier ones, because it shows 
 what the debugger was trying to do:
 
 Here's a backtrace right after po #3 before I'm out of setIsEncrypted
 backtrace
 #0  -[SRMainWindowController toggleLock:] (self=0x2000df5e0, 
 _cmd=0x1000a9239, sender=0x2000df5e0) at SRMainWindowController.m:2897
 #1  0x00010002dae9 in -[SRMainWindowController getEncryptionKey] 
 (self=0x2000df5e0, _cmd=0x1000a7210) at SRMainWindowController.m:2948
 #2  0x000198d2 in -[Note category] (self=0x20027bda0, 
 _cmd=0x7fff85450184) at Note.m:257
 #3  0x000189c8 in -[Note description] (self=0x20027bda0, 
 _cmd=0x7fff83c821e8) at Note.m:56
 
 The debugger was trying to execute [note description], which is what it does 
 to get a description to display as a result of 'po note'. Normally, the 
 standard 'description' in NSObject is called, which just prints the address 
 of the object and its class. You, apparently have overridden 'description' in 
 the Note class, and it apparently invokes 'category', which invokes 
 '-[SRMainWindowController getEncryptionKey]', which invokes 'toggleLock:', 
 which is why it hits the breakpoint again.
 
 Note that (apparently) if isEncrypted is NO, then 'getEncryptionKey' isn't 
 invoked, and so 'toggleLock' isn't invoked either. That's why setting 
 isFlagged instead didn't crap out in the debugger.
 
 Other than indicating an inappropriate design of your 'description' override, 
 there's absolutely no indication of anything wrong here at all. It looks like 
 you've been chasing a chimera. :)
 
 Obviously I may be overlooking something, but step 1 is to fix your 
 'description' method so that it doesn't cause Core Data fetches. 
 
 #4  0x7fff868a386b in _NSPrintForDebugger ()
 #5  function called from gdb
 #6  -[Note setIsEncrypted:] (self=0x20027bda0, _cmd=0x1000a6eb8, 
 value=0x7fff70886280) at Note.m:206
 #7  0x00010002d5c9 in -[SRMainWindowController toggleLock:] 
 (self=0x2000df5e0, _cmd=0x1000a9239, sender=0x2000867e0) at 
 SRMainWindowController.m:2897
 #8  0x7fff83b2afbf in -[NSToolbarButton sendAction:to:] ()
 #9  0x7fff8379c135 in -[NSToolbarItemViewer mouseDown:] ()
 #10 0x7fff8368934f in -[NSWindow sendEvent:] ()
 #11 0x7fff835bea86 in -[NSApplication sendEvent:] ()
 #12 0x7fff835554da in -[NSApplication run] ()
 #13 0x7fff8354e1a8 in NSApplicationMain ()
 #14 0x00016b60 in main (argc=1, argv=0x7fff5fbff628) at main.m:13
 

___

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

Please do not post admin requests or moderator comments to the list.
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


Accessing a managedObject property from within an accessor of another property

2011-02-22 Thread Brad Stone
I've been trying for days to determine why I get EXC_BAD_ACCESS when I try to 
access a managedObject property from within an accessor of another property?

this code in main.m
[[self note] setValue:@HELLO WORLD forKey:@category];
NSNumber *tmpVal = [NSNumber numberWithBool:![[[self note] 
valueForKey:@isEncrypted] boolValue]]; // if I type po [self note] I see the 
note description
[[self note] setValue:tmpVal forKey:@isEncrypted]; // if I type po [self 
note] after this I get EXEC_BAD_ACCESS

The if statement in the accessor is causing the problem:
- (NSString *)category {
NSString * tmpValue;

[self willAccessValueForKey:@category];
tmpValue = [self primitiveCategory];
[self didAccessValueForKey:@category];

if ([[self valueForKey:@isEncrypted] boolValue]) {  // THIS IS CAUSING 
THE PROBLEM
// code to decrypt tmpValue
}

return tmpValue;
}

When I replace: if ([[self valueForKey:@isEncrypted] boolValue]) with if (1 
== 2 ) or if (1 == 1 ) it works

FYI: in my .h file @property (nonatomic, retain) NSNumber * isEncrypted; and 
@dynamic isEncrypted; in .m___

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

Please do not post admin requests or moderator comments to the list.
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


Fwd: Accessing a managedObject property from within an accessor of another property

2011-02-22 Thread Brad Stone
FYI - my managedObject is defined as such:

@interface Note :  NSManagedObject  
{
}

@property (nonatomic, retain) NSNumber * uid;
@property (nonatomic, retain) NSString * category;
@property (nonatomic, retain) NSNumber * isEncrypted;

@interface Note (CoreDataGeneratedPrimitiveAccessors)

- (NSString *)primitiveCategory;
- (void)setPrimitiveCategory:(NSString *)value;

@end


@implementation Note 

@dynamic uid;
@dynamic category;
@dynamic isEncrypted;

- (NSString *)category 
{


NSString * tmpValue;

[self willAccessValueForKey:@category];
tmpValue = [self primitiveCategory];   
[self didAccessValueForKey:@category];

   if ([[self valueForKey:@isEncrypted] boolValue]) {
//code to decrypt tmpValue
}
 
return tmpValue;
}

- (void)setCategory:(NSString *)value 
{   


if ([[self valueForKey:@isEncrypted] boolValue]) {
// code to encrypt tmpValue
}
 

[self willChangeValueForKey:@category];
[self setPrimitiveCategory:value];
[self didChangeValueForKey:@category];
}

- (BOOL)validateCategory:(id *)valueRef error:(NSError **)outError 
{
// Insert custom validation logic here.
return YES;
}
___

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

Please do not post admin requests or moderator comments to the list.
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: Accessing a managedObject property from within an accessor of another property

2011-02-22 Thread Brad Stone
Yes, all my other classes are prefixed with SR since this one.  I haven't 
gotten back to fixing this.

On Feb 22, 2011, at 10:22 AM, Uli Kusterer wrote:

 On 22.02.2011, at 16:13, Brad Stone wrote:
 FYI - my managedObject is defined as such:
 
 @interface Note :  NSManagedObject  
 {
 }
 
 That's probably not your problem, but just to eliminate it as a cause: You 
 should prefix your class names. Apple has been known to create internal 
 private classes with un-prefixed names (like Account). And once one class 
 with a particular name has been loaded, requests to load any other class of 
 the same name will be ignored. Anyone trying to create an instance of such a 
 class will get the first class that was loaded, which is probably something 
 completely different.
 
 So I recommend choosing your own three-character prefix (BST?), just in case 
 there's some private Apple class named Note.
 
 Cheers,
 -- Uli Kusterer
 The Witnesses of TeachText are everywhere...
 http://www.zathras.de
 
 
 

___

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

Please do not post admin requests or moderator comments to the list.
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: Accessing a managedObject property from within an accessor of another property

2011-02-22 Thread Brad Stone
Quincey,

Thanks for relying.  It's good to have another developer to talk this thru with.

1) customer accessors for isEncrypted didn't work (I have a set exactly like 
category)
2) I'm using garbage collection
3) I tried [note isEncrypted] same error
4) i tried using a local ivar i..e Note *thisNote = [self note], no change

I've been trying these variations for days.


On Feb 22, 2011, at 12:44 PM, Quincey Morris wrote:

 On Feb 22, 2011, at 06:19, Brad Stone wrote:
 
 I've been trying for days to determine why I get EXC_BAD_ACCESS when I try 
 to access a managedObject property from within an accessor of another 
 property?
 
 this code in main.m
 [[self note] setValue:@HELLO WORLD forKey:@category];
 NSNumber *tmpVal = [NSNumber numberWithBool:![[[self note] 
 valueForKey:@isEncrypted] boolValue]]; // if I type po [self note] I see 
 the note description
 [[self note] setValue:tmpVal forKey:@isEncrypted]; // if I type po [self 
 note] after this I get EXEC_BAD_ACCESS
 
 The if statement in the accessor is causing the problem:
 - (NSString *)category {
 NSString * tmpValue;
 
   [self willAccessValueForKey:@category];
   tmpValue = [self primitiveCategory];
   [self didAccessValueForKey:@category];
  
   if ([[self valueForKey:@isEncrypted] boolValue]) {  // THIS IS CAUSING 
 THE PROBLEM
   // code to decrypt tmpValue
   }
  
   return tmpValue;
 }
 
 No answer, but a couple of points:
 
 -- What happens if you write 'note.isEncrypted' (or '[note isEncrypted]') 
 instead of '[note valueForKey: @isEncrypted]'?
 
 -- What happens if you code your own custom accessors for isEncrypted, like 
 you've done for category?
 
 -- EXC_BAD_ACCESS is often a symptom of a memory management problem. Is there 
 a problem with the object being returned by '[self note]'? You didn't show 
 code for where this is implemented. It's possible that you failed to retain 
 the object, or, if you're using garbage collection, returned an object with 
 no strong references, or perhaps you returned a zombie object.
 
 What happens in the above code if you set first a local variable to '[[self 
 note] retain]' and use the local variable in place of the other references to 
 '[self note]'?
 
 

___

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

Please do not post admin requests or moderator comments to the list.
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: Accessing a managedObject property from within an accessor of another property

2011-02-22 Thread Brad Stone
In my Note entity:
self = (Note *)0x20027bda0

In my .h file have this property defined: @property (nonatomic, retain) 
NSNumber * isFlagged; and this in .m @dynamic isFlagged; and no custom accessors

New code in my Note entity:
- (void)setIsEncrypted:(NSNumber *)value {
// see po #1 which I typed here

[self willChangeValueForKey:@isFlagged];  
[self setPrimitiveValue:value forKey:@isFlagged];
[self didChangeValueForKey:@isFlagged];

// see po #2 which I typed here

[self willChangeValueForKey:@isEncrypted];
[self setPrimitiveValue:value forKey:@isEncrypted];
[self didChangeValueForKey:@isEncrypted];

// see po #3 which I typed here

}

po #1
po self
Note uid:319649395851582
 category:None
 isFlagged:0
 isEncrypted:0

po #2
po self
Note uid:319649395851582
 category:None
 isFlagged:1
 isEncrypted:0

po #3
po self

Breakpoint 28, -[SRMainWindowController toggleLock:] (self=0x2000df5e0, 
_cmd=0x1000a9239, sender=0x2000df5e0) at SRMainWindowController.m:2897
2897[note setIsEncrypted:[NSNumber numberWithBool:YES]];
The program being debugged stopped while in a function called from GDB.
When the function (_NSPrintForDebugger) is done executing, GDB will silently
stop (instead of continuing to evaluate the expression containing
the function call).

Here's a backtrace right after po #3 before I'm out of setIsEncrypted
backtrace
#0  -[SRMainWindowController toggleLock:] (self=0x2000df5e0, _cmd=0x1000a9239, 
sender=0x2000df5e0) at SRMainWindowController.m:2897
#1  0x00010002dae9 in -[SRMainWindowController getEncryptionKey] 
(self=0x2000df5e0, _cmd=0x1000a7210) at SRMainWindowController.m:2948
#2  0x000198d2 in -[Note category] (self=0x20027bda0, 
_cmd=0x7fff85450184) at Note.m:257
#3  0x000189c8 in -[Note description] (self=0x20027bda0, 
_cmd=0x7fff83c821e8) at Note.m:56
#4  0x7fff868a386b in _NSPrintForDebugger ()
#5  function called from gdb
#6  -[Note setIsEncrypted:] (self=0x20027bda0, _cmd=0x1000a6eb8, 
value=0x7fff70886280) at Note.m:206
#7  0x00010002d5c9 in -[SRMainWindowController toggleLock:] 
(self=0x2000df5e0, _cmd=0x1000a9239, sender=0x2000867e0) at 
SRMainWindowController.m:2897
#8  0x7fff83b2afbf in -[NSToolbarButton sendAction:to:] ()
#9  0x7fff8379c135 in -[NSToolbarItemViewer mouseDown:] ()
#10 0x7fff8368934f in -[NSWindow sendEvent:] ()
#11 0x7fff835bea86 in -[NSApplication sendEvent:] ()
#12 0x7fff835554da in -[NSApplication run] ()
#13 0x7fff8354e1a8 in NSApplicationMain ()
#14 0x00016b60 in main (argc=1, argv=0x7fff5fbff628) at 
main.m:13___

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

Please do not post admin requests or moderator comments to the list.
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: Accessing a managedObject property from within an accessor of another property

2011-02-22 Thread Brad Stone
SCENARIO 1:

The thread is:
0 - [SRMainWindowController toggleLock:]  //self = (SRMainWindowController *) 
0x20009d440
1-[NSToolbarButton sendAction:to:]

- (IBAction)toggleLock:(id)sender {

NSError *fetchError = nil;
NSArray *fetchResults;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

NSEntityDescription *entity = [NSEntityDescription 
entityForName:@Note inManagedObjectContext:[self managedObjectContext]];
[fetchRequest setEntity:entity];
fetchResults = [[self managedObjectContext] 
executeFetchRequest:fetchRequest error:fetchError];

Note *note = nil;
if (fetchRequest != nil  [fetchResults count] == 1)  {
note = [fetchResults objectAtIndex:index];  //note = (Note 
*)0x20027bfe0
}


if (note) {
[note setIsEncrypted:[NSNumber numberWithBool:YES]];  // see below
}
}




When I jump into  note setIsEncrypted:[NSNumber numberWithBool:YES]]; in the 
Note managedObject

self = (Note *)0x20027bfe0  // same as above
value = (NSCFBoolean *) 0x7fff70886280

po self
Note uid:319649395851582
 category:None
 isEncrypted:0
 isFlagged:0
(gdb) 

- (void)setIsEncrypted:(NSNumber *)value {
[self willChangeValueForKey:@isEncrypted];
[self setPrimitiveValue:value forKey:@isEncrypted];
[self didChangeValueForKey:@isEncrypted];
// see backtrace
}

As soon as I po after the setPrimitive I get:

Breakpoint 26, -[SRMainWindowController toggleLock:] (self=0x20009d440, 
_cmd=0x1000a92b1, sender=0x20009d440) at SRMainWindowController.m:2891
2891if (fetchRequest != nil  [fetchResults count] == 1)  {
The program being debugged stopped while in a function called from GDB.
When the function (_NSPrintForDebugger) is done executing, GDB will silently
stop (instead of continuing to evaluate the expression containing
the function call).




#0  -[Note setIsEncrypted:] (self=0x2000b7600, _cmd=0x1000a6eb8, 
value=0x7fff70886280) at Note.m:206
#1  0x00010002d5c9 in -[SRMainWindowController toggleLock:] 
(self=0x200078f80, _cmd=0x1000a9239, sender=0x2000a0c20) at 
SRMainWindowController.m:2897
#2  0x7fff83b2afbf in -[NSToolbarButton sendAction:to:] ()
#3  0x7fff8379c135 in -[NSToolbarItemViewer mouseDown:] ()
#4  0x7fff8368934f in -[NSWindow sendEvent:] ()
#5  0x7fff835bea86 in -[NSApplication sendEvent:] ()
#6  0x7fff835554da in -[NSApplication run] ()
#7  0x7fff8354e1a8 in NSApplicationMain ()
#8  0x00016b60 in main (argc=1, argv=0x7fff5fbff628) at main.m:13




SCENARIO 2:
I created a second scenario as a test to try to shed more light.  Scenario 1 
and scenario 2 are **exactly** the same but I'm setting another NSNumber, 
isFlagged to YES in the setIsEncrypted accessor and it gets set correctly 
without an exception but isEncrypted still causes one.


In SRMainWindowController:
self = (SRMainWindowController *)0x2000df5e0
note = (Note *)0x20027bda0

 see earlier email for second 
part___

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

Please do not post admin requests or moderator comments to the list.
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


exception when I try to access a managedObject property from within an accessor of another property

2011-02-21 Thread Brad Stone
I am getting an exception when I try to access a managedObject property from 
within an accessor of another property.  As ridiculous as it sounds I've been 
at this for over three days.  Hopefully someone can point out what I'm doing 
wrong.


- (NSString *)category 
{
NSString * tmpValue;

[self willAccessValueForKey:@category];
tmpValue = [self primitiveCategory];
[self didAccessValueForKey:@category];


if ([[self valueForKey:@isEncrypted] boolValue]) {  // THIS IS CAUSING 
THE PROBLEM
NSData *sData = [tmpValue dataUsingEncoding:NSUTF8StringEncoding];
sData = [sData decryptWithString:@userKey];
tmpValue = [SRGlobalVariables getStringFromData:sData];
}
 
 
return tmpValue;
}

The error I get is:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x7fff5f3ffd80
0x7fff843748d7 in _CFArrayReplaceValues ()
The program being debugged was signaled while in a function called from GDB.
GDB has restored the context to what it was before the call.
To change this behavior use set unwindonsignal off
Evaluation of the expression containing the function (_NSPrintForDebugger) will 
be abandoned.


When I replace:
if ([[self valueForKey:@isEncrypted] boolValue]) 

with 
if (1 == 2 ) or if (1 == 1 ) 


I don't get an exception. ___

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

Please do not post admin requests or moderator comments to the list.
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: Community Suggestions on Encryption

2011-02-17 Thread Brad Stone
FYI - for anyone trying to solve this problem use this NSData category which 
puts a user friendly wrapper around CCCryptor.  It works perfectly!  See this 
(scroll to the bottom) 
http://stackoverflow.com/questions/2579453/nsdata-aes-class-encryption-decryption-in-cocoa
 and here for the source code: 
https://github.com/nicerobot/objc/tree/master/NSData/NSData%2BAES/

Cheers to the author for sharing.


On Feb 16, 2011, at 10:48 AM, Brad Stone wrote:

 Jean - thanks to your tip I was able to find this code at 
 http://pastie.org/966473.  It works very well (I tried to paste it below but 
 it was too big) for NSString ivars.  
 
 What I'm working on now is to try to figure out how to encrypt/decrypt an 
 NSData iVar. 
 
 I have an NSData ivar which is binded to an NSTextView.  The text view is 
 rich text, the user can drag in jpgs, changes fonts, styles, etc..  If I send 
 it to this code, encrypt it and decrypt it, I get back chinese characters.  I 
 don't think the approach is to store the text separately from the rest of the 
 rich text data so I'm investigating how I can write similar code for NSData.
 
 On Feb 15, 2011, at 10:52 AM, Jean-Daniel Dupas wrote:
 
 
 Le 15 févr. 2011 à 16:35, Brad Stone a écrit :
 
 I've been doing a lot of hunting to find a simple way for me to encrypt an 
 NSString and NSData.  I've found a bunch of useful blogs like Cocoa Nut 
 (http://cocoa-nut.de/?tag=encryption, Deusty:Using OpenSSL in Cocoa 
 (http://deusty.blogspot.com/2007/01/using-openssl-in-cocoa.html) and the 
 SSCrypto site (http://septicus.com/products/opensource/).  The thing is 
 however that these, among others I've found (like cocoa-aes from 2009), 
 are dated.  The SSCrypto files haven't been updated since 2006 and these 
 blogs are of similar age.
 
 My question is simple: can I get this done without having to dive deep into 
 the world of OpenSSL?  If so, how?
 
 I have about four NSString iVars and one NSData iVar I want to encrypt.  I 
 wrote my own test code to encrypt/decrypt an NSString on the fly and have 
 it work with core data transparently to the user.  I'm at the point now 
 where I need to replace that test code with something real.  From all I've 
 read, OpenSSL is the way to go but I've also read it's very difficult to 
 implement.  I know nothing about it.  What initially attracted me to 
 SSCrypto is that it's simple (i.e. NSData *decryptedText = [crypto 
 decrypt:@aes256]) but I'm worried about using something relatively old 
 and using a third party framework.
 
 
 For AES (and SHA, and HMAC), use CommonCrypto API which is part of libSystem.
 
 man CCCryptor for details. (or search in Xcode doc).
 
 -- Jean-Daniel
 
 
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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: Community Suggestions on Encryption

2011-02-16 Thread Brad Stone
Jean - thanks to your tip I was able to find this code at 
http://pastie.org/966473.  It works very well (I tried to paste it below but it 
was too big) for NSString ivars.  

What I'm working on now is to try to figure out how to encrypt/decrypt an 
NSData iVar. 

I have an NSData ivar which is binded to an NSTextView.  The text view is rich 
text, the user can drag in jpgs, changes fonts, styles, etc..  If I send it to 
this code, encrypt it and decrypt it, I get back chinese characters.  I don't 
think the approach is to store the text separately from the rest of the rich 
text data so I'm investigating how I can write similar code for NSData.

On Feb 15, 2011, at 10:52 AM, Jean-Daniel Dupas wrote:

 
 Le 15 févr. 2011 à 16:35, Brad Stone a écrit :
 
 I've been doing a lot of hunting to find a simple way for me to encrypt an 
 NSString and NSData.  I've found a bunch of useful blogs like Cocoa Nut 
 (http://cocoa-nut.de/?tag=encryption, Deusty:Using OpenSSL in Cocoa 
 (http://deusty.blogspot.com/2007/01/using-openssl-in-cocoa.html) and the 
 SSCrypto site (http://septicus.com/products/opensource/).  The thing is 
 however that these, among others I've found (like cocoa-aes from 2009), 
 are dated.  The SSCrypto files haven't been updated since 2006 and these 
 blogs are of similar age.
 
 My question is simple: can I get this done without having to dive deep into 
 the world of OpenSSL?  If so, how?
 
 I have about four NSString iVars and one NSData iVar I want to encrypt.  I 
 wrote my own test code to encrypt/decrypt an NSString on the fly and have it 
 work with core data transparently to the user.  I'm at the point now where I 
 need to replace that test code with something real.  From all I've read, 
 OpenSSL is the way to go but I've also read it's very difficult to 
 implement.  I know nothing about it.  What initially attracted me to 
 SSCrypto is that it's simple (i.e. NSData *decryptedText = [crypto 
 decrypt:@aes256]) but I'm worried about using something relatively old and 
 using a third party framework.
 
 
 For AES (and SHA, and HMAC), use CommonCrypto API which is part of libSystem.
 
 man CCCryptor for details. (or search in Xcode doc).
 
 -- Jean-Daniel
 
 
 
 

___

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

Please do not post admin requests or moderator comments to the list.
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


Community Suggestions on Encryption

2011-02-15 Thread Brad Stone
I've been doing a lot of hunting to find a simple way for me to encrypt an 
NSString and NSData.  I've found a bunch of useful blogs like Cocoa Nut 
(http://cocoa-nut.de/?tag=encryption, Deusty:Using OpenSSL in Cocoa 
(http://deusty.blogspot.com/2007/01/using-openssl-in-cocoa.html) and the 
SSCrypto site (http://septicus.com/products/opensource/).  The thing is however 
that these, among others I've found (like cocoa-aes from 2009), are dated.  
The SSCrypto files haven't been updated since 2006 and these blogs are of 
similar age.

My question is simple: can I get this done without having to dive deep into the 
world of OpenSSL?  If so, how?

I have about four NSString iVars and one NSData iVar I want to encrypt.  I 
wrote my own test code to encrypt/decrypt an NSString on the fly and have it 
work with core data transparently to the user.  I'm at the point now where I 
need to replace that test code with something real.  From all I've read, 
OpenSSL is the way to go but I've also read it's very difficult to implement.  
I know nothing about it.  What initially attracted me to SSCrypto is that it's 
simple (i.e. NSData *decryptedText = [crypto decrypt:@aes256]) but I'm 
worried about using something relatively old and using a third party framework.

What suggestions does the community have on the best approach?

Thanks
Brad___

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

Please do not post admin requests or moderator comments to the list.
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: Abstract Text Example and Question

2011-02-10 Thread Brad Stone
Matt and Graham - I knew there was a better approach.  I'll look into the 
things you suggest.

On Feb 10, 2011, at 10:19 AM, Matt Neuburg wrote:

 On Wed, 9 Feb 2011 22:04:58 -0500, Brad Stone cocoa-...@softraph.com said:
 I made this code to remove any duplicate words from a large group of text. 
 
 if ([resultArray indexOfObject:s] == NSNotFound)
 
 There's the problem. Who knows how this is implemented? You could be 
 searching the entire array one entry at a time all the way to the end for 
 every single word (if the text goes, say, fee fi fo fum fum fum fum 
 fum...). That's why the usual algorithm for this sort of thing involves a 
 dictionary, not an array; access to a key in a dictionary is guaranteed fast 
 because of hashing. Basically you're making a histogram, which is a 
 well-solved problem. If order matters, use both the dictionary *and* some 
 other storage to keep track of the words in the order in which they actually 
 appear. m.
 
 --
 matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
 A fool + a tool + an autorelease pool = cool!
 AppleScript: the Definitive Guide - Second Edition!
 http://www.apeth.net/matt/default.html#applescriptthings

___

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

Please do not post admin requests or moderator comments to the list.
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


Abstract Text Example and Question

2011-02-09 Thread Brad Stone
I made this code to remove any duplicate words from a large group of text.  The 
result is stored in an index file so the text doesn't need to make sense.  I'm 
removing the duplicates to save space in the index file.  I was wondering if 
anyone had a suggestion for a more efficient way to accomplishing this.  I'm 
guessing the separations and joins are taking up memory and slowing things down 
(even though I'm not positive about that).  Using this code reduced the index 
file size form 4.7MB to 2.7MB.

Thanks

- (NSString *)abstractText:(NSString *)srcString {
NSMutableArray *resultArray = [[NSMutableArray alloc] init];
NSArray *textArray = [srcString componentsSeparatedByString:@ ];
for (NSString *s in textArray) {

s = [s stringByTrimmingCharactersInSet:[NSCharacterSet 
alphanumericCharacterSet]];
s = [s lowercaseString];

if ([resultArray indexOfObject:s] == NSNotFound) {
[resultArray addObject:s];
}
}

NSString *resultString = nil;
if ([resultArray count]  0) {
resultString = [resultArray componentsJoinedByString:@ ];
} else {
resultString = srcString;
}
return resultString;
}___

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

Please do not post admin requests or moderator comments to the list.
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


Predicate Help

2011-01-12 Thread Brad Stone
I'm been trying for two days to get this to work.  I've googled, read the 
Predicate Programming Guide - I guess I just don't get it.

I'm trying to develop a predicate to populate a mutable array .  I have an 
array that contains SRIndexObjects.

@interface SRIndexObject : NSObject NSCoding {
NSNumber *uid;
NSArray * todos; // this is an array of SRIndexTodo objects
}

@interface SRIndexTodo : NSObject {
NSDate * todoCompletedDate;
}



My goal is to find all the SRIndexObjects that have at least one todo where the 
completed date is greater than or equal to a particular date.  

this is the  code:

NSPredicate *hasTodosPredicate = [NSPredicate predicateWithFormat:@todos[SIZE] 
 0];  // this works fine if I use this as the only predicate
NSPredicate *compDatePredicate = [NSPredicate predicateWithFormat:@ANY 
todos.todoCompletedDate = %@, targetDate];
NSPredicate *predicate = [NSCompoundPredicate 
andPredicateWithSubpredicates:[NSArray arrayWithObjects:hasTodosPredicate, 
compDatePredicate, nil]];

NSLog(@%@, predicate);   
[currentFoundArray addObjectsFromArray:[tempArray 
filteredArrayUsingPredicate:predicate]];  // tempArray has 2000 SRIndexObjects, 
currentFoundArray is mutable and empty  

This is the result:
2011-01-12 18:43:43.090 testApp[37874:a0f] todos[SIZE]  0 AND ANY 
todos.todoCompletedDate = CAST(316328400.00, NSDate)
2011-01-12 18:44:24.957 testApp[37874:a0f] -[NSNull compare:]: unrecognized 
selector sent to instance 0xa036f6a0

What I think is happening is since todos.todoCompletedDate can be nil it's 
causing the failure (the NSNull compare).  I just don't know how to build a 
predicate to deal with that since I want to add the object to currentFoundArray 
if at least one is not nil and the date is = targetDate.

Help would be greatly appreciated.

Thanks - Brad___

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

Please do not post admin requests or moderator comments to the list.
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: Predicate Help

2011-01-12 Thread Brad Stone
So cool!

On Jan 12, 2011, at 7:05 PM, Dave DeLong wrote:

 SUBQUERY! :)
 
 NSArray *objects = ...; //your array of SRIndexObjects
 
 NSPredicate * f = [NSPredicate predicateWithFormat:@SUBQUERY(todos, $t, 
 $t.todoCompletedDate = %@)@count  0, aParticularDate];
 NSArray *filteredObjects = [objects filteredArrayUsingPredicate:f];
 
 Explanation:
 
 SUBQUERY() is kind of like a second level of filtering.  The first parameter 
 is a collection (or keypath to one, etc), the second parameter is a variable 
 name (that iteratively represents each item in the collection), and the third 
 parameter is a predicate.  
 
 So:
 
 SUBQUERY(todos, $t, $t.todoCompletedDate = %@)
 
 This has the same effect as:
 
 NSArray * filtered = [todos filteredArrayUsingPredicate:[NSPredicate 
 predicateWithFormat:@todoCompletedDate = %@, aParticularDate]];
 
 Notice that it returns a collection, which means we can use the results in a 
 larger expression.  In this case, we're going to invoke the @count keyPath on 
 it, which returns the number of items in the collection, which we'll compare 
 against 0.
 
 In a nutshell, that's a predicate that will find all objects in the source 
 array that have at least one todo object, where that todo object's 
 todoCompletedDate is on or after aParticularDate.
 
 Sweet, huh?
 
 Dave
 
 On Jan 12, 2011, at 3:58 PM, Brad Stone wrote:
 
 I'm been trying for two days to get this to work.  I've googled, read the 
 Predicate Programming Guide - I guess I just don't get it.
 
 I'm trying to develop a predicate to populate a mutable array .  I have an 
 array that contains SRIndexObjects.
 
 @interface SRIndexObject : NSObject NSCoding {
   NSNumber *uid;
   NSArray * todos; // this is an array of SRIndexTodo objects
 }
 
 @interface SRIndexTodo : NSObject {
   NSDate * todoCompletedDate;
 }
 
 
 
 My goal is to find all the SRIndexObjects that have at least one todo where 
 the completed date is greater than or equal to a particular date.  
 
 this is the  code:
 
 NSPredicate *hasTodosPredicate = [NSPredicate 
 predicateWithFormat:@todos[SIZE]  0];  // this works fine if I use this 
 as the only predicate
 NSPredicate *compDatePredicate = [NSPredicate predicateWithFormat:@ANY 
 todos.todoCompletedDate = %@, targetDate];
 NSPredicate *predicate = [NSCompoundPredicate 
 andPredicateWithSubpredicates:[NSArray arrayWithObjects:hasTodosPredicate, 
 compDatePredicate, nil]];
 
 NSLog(@%@, predicate);   
 [currentFoundArray addObjectsFromArray:[tempArray 
 filteredArrayUsingPredicate:predicate]];  // tempArray has 2000 
 SRIndexObjects, currentFoundArray is mutable and empty  
 
 This is the result:
 2011-01-12 18:43:43.090 testApp[37874:a0f] todos[SIZE]  0 AND ANY 
 todos.todoCompletedDate = CAST(316328400.00, NSDate)
 2011-01-12 18:44:24.957 testApp[37874:a0f] -[NSNull compare:]: unrecognized 
 selector sent to instance 0xa036f6a0
 
 What I think is happening is since todos.todoCompletedDate can be nil it's 
 causing the failure (the NSNull compare).  I just don't know how to build a 
 predicate to deal with that since I want to add the object to 
 currentFoundArray if at least one is not nil and the date is = targetDate.
 
 Help would be greatly appreciated.
 
 Thanks - Brad___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com
 
 This email sent to davedel...@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


A Quick Look contribution and a question

2011-01-03 Thread Brad Stone
I'm submitting this code for anyone who needs a quick hack to get Quick Look 
working.  It's a hack because it's using AppleScript and the Quick Look Server 
debug and management tool.  If you send an array of paths this will bring them 
up in a Quick Look window.

I don't think the Quick Look documentation is as robust as it can be, I'm still 
trying to figure out how to do the same thing the right way. 

- (void)quickLook:(NSArray *)srcPathArray {

//build the paths string
NSString *paths = @;
for (NSString *thisPath in srcPathArray) {

NSString *s = @;
if ([paths length] == 0) {
s = [NSString stringWithFormat:@(quoted form of (POSIX 
path of \%...@\)), thisPath];
} else {
s = [NSString stringWithFormat:@  \ \  (quoted 
form of (POSIX path of \%...@\)), thisPath];
}
paths = [paths stringByAppendingString:s];
}


NSAppleScript *quickLook = nil;
// do shell script (qlmanage -p   (quoted form of (POSIX path of 
srcPath)))
NSString *command = [NSString stringWithFormat:@do shell script 
(\qlmanage -p \  %@),paths];
quickLook = [[NSAppleScript alloc] initWithSource:command];
[quickLook executeAndReturnError:nil];
}___

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

Please do not post admin requests or moderator comments to the list.
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: Strange error solved by turning off Non-contiguous Layout

2010-12-27 Thread Brad Stone
Yeah, that was it.  I get by the place where the it used to deadlock.  I'm make 
a note of that!  Thanks

On Dec 26, 2010, at 10:57 PM, Nick Zitzmann wrote:

 
 On Dec 26, 2010, at 5:00 PM, Brad Stone wrote:
 
 Ken - I never knew how to take a sample of the processes.  It's given me 
 some visibility into the spinning beach ball.  I still get the deadlock in 
 the commitEditing which is in saveDocumentWithDelegate only on some 
 documents when I edit text that requires me to scroll an NSTextView.  Does 
 anything jump out at you in this call graph?  What is NSOperation waiting 
 for?
 
 Did you turn on the can draw concurrently option on the text view or its 
 scroll view? If so, then turn that off. That option will not work, except in 
 views that specifically support threaded drawing. IIRC, none of the AppKit's 
 views support this (except for NSButton and NSProgressIndicator, but they 
 have separate APIs for this for historical reasons).
 
 Nick Zitzmann
 http://www.chronosnet.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: Strange error solved by turning off Non-contiguous Layout

2010-12-26 Thread Brad Stone
Ken - I never knew how to take a sample of the processes.  It's given me some 
visibility into the spinning beach ball.  I still get the deadlock in the 
commitEditing which is in saveDocumentWithDelegate only on some documents when 
I edit text that requires me to scroll an NSTextView.  Does anything jump out 
at you in this call graph?  What is NSOperation waiting for?

Call graph:
2761 Thread_118   DispatchQueue_1: com.apple.main-thread  (serial)
  2761 start
2761 main
  2761 NSApplicationMain
2761 -[NSApplication run]
  2761 -[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:]
2761 _DPSNextEvent
  2761 BlockUntilNextEventMatchingListInMode
2761 ReceiveNextEventCommon
  2761 RunCurrentEventLoopInMode
2761 CFRunLoopRunSpecific
  2761 __CFRunLoopRun
2761 __NSFireTimer
  2761 -[SRMainWindowController 
checkToSaveDirtyDoc:]
2761 -[PNDocument 
saveDocumentWithDelegate:didSaveSelector:contextInfo:]
  2761 
-[NSManagedObjectContext(NSEditorAndEditorRegistration) commitEditing]
2761 -[NSController commitEditing]
  2761 -[NSValueBinder commitEditing]
2761 -[NSValueBinder discardEditing]
  2761 -[_NSTextPlugin 
showValue:inObject:]
2761 -[NSTextStorage endEditing]
  2761 -[NSTextStorage 
processEditing]
2761 -[NSTextStorage 
_notifyEdited:range:changeInLength:invalidatedRange:]
  2761 -[NSLayoutManager 
textStorage:edited:range:changeInLength:invalidatedRange:]
2761 
-[NSLayoutManager(NSPrivate) _resizeTextViewForTextContainer:]
  2761 
-[NSTextView(NSPrivate) _setFrameSize:forceScroll:]
2761 -[NSView 
setFrameSize:]
  2761 -[NSView 
_postFrameChangeNotification]
2761 -[NSClipView 
_reflectDocumentViewFrameChange]
  2761 -[NSClipView 
_scrollTo:animate:]
2761 
-[NSScrollView scrollClipView:toPoint:]
  2761 
-[NSClipView scrollToPoint:]
2761 
-[NSClipView _immediateScrollToPoint:]
  2761 
-[NSView displayIfNeeded]
2761 
-[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
  2761 
-[NSOperationQueue waitUntilAllOperationsAreFinished]

2761 -[NSOperation waitUntilFinished]
  
2761 -[__NSOperationInternal waitUntilFinished]

2761 _pthread_cond_wait

  2761 __semwait_signal
2761 Thread_1166672   DispatchQueue_2: com.apple.libdispatch-manager  
(serial)
  2761 start_wqthread
2761 _pthread_wqthread
  2761 _dispatch_worker_thread2
2761 _dispatch_queue_invoke
  2761 _dispatch_mgr_invoke
2761 kevent
2761 Thread_1166673   DispatchQueue_6: com.apple.root.default-priority  
(serial)
  2761 start_wqthread
2761 _pthread_wqthread
  2761 _dispatch_worker_thread2
2761 _dispatch_call_block_and_release
  2761 __doStart2
2761 -[__NSOperationInternal start]
  2761 -[_NSViewDrawOperation main]
2761 -[NSTextView _drawRect:clip:]
  2761 -[NSTextView drawRect:]
2761 -[NSConcreteTextStorage _lockForReading]
  2761 -[NSViewHierarchyLock 
lockForReadingWithExceptionHandler:]
2761 _pthread_cond_wait
  2761 __semwait_signal



On Dec 22, 2010, at 12:37 AM, Ken Thomases wrote:

 On Dec 21, 2010, at 10:08 PM, Brad Stone wrote:
 
 I have an NSTextView that has about 1,900

Re: Strange error solved by turning off Non-contiguous Layout

2010-12-22 Thread Brad Stone
I don't have a lot of experiencing debugging deadlocks.  The commitEditing call 
never returns, just spinning beach ball, so that makes it difficult to debug.

I did notice that edits before a certain number of characters commits fine 
after that - deadlock.  Weird.

On Dec 22, 2010, at 12:27 PM, Douglas Davidson wrote:

 
 On Dec 21, 2010, at 8:08 PM, Brad Stone wrote:
 
 I have an NSTextView that has about 1,900 characters in it.  Just regular 
 text.  If I edit the text and save my app hangs at  [[self 
 managedObjectContext] commitEditing];  I found setting nonContinuousLayout 
 to NO in the NSTextView prevents the hang but that's not really solving the 
 problem.
 
 Here's what's strange.  If I expand the window so the all the text shows 
 without the scroll bar it doesn't hang.  If I edit the same text but scroll 
 down the get it I get a hang.  If I set nonContiguousLayout to NO it doesn't 
 hang in either scenario.
 
 What advice can anyone give as to how I can address this problem?
 
 The obvious workaround to try would be to call [layoutManager 
 ensureLayoutForCharacterRange:NSMakeRange(0, textLength)] at some point 
 before you save.  That will cause the entire text to be laid out, as it would 
 be if the window showed all of it.  It would also be helpful if you could 
 file a bug with enough information to reproduce this.
 
 Douglas Davidson
 

___

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

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

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

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


Strange error solved by turning off Non-contiguous Layout

2010-12-21 Thread Brad Stone
I have an NSTextView that has about 1,900 characters in it.  Just regular text. 
 If I edit the text and save my app hangs at  [[self managedObjectContext] 
commitEditing];  I found setting nonContinuousLayout to NO in the NSTextView 
prevents the hang but that's not really solving the problem.

Here's what's strange.  If I expand the window so the all the text shows 
without the scroll bar it doesn't hang.  If I edit the same text but scroll 
down the get it I get a hang.  If I set nonContiguousLayout to NO it doesn't 
hang in either scenario.

What advice can anyone give as to how I can address this problem?

Thanks, Brad___

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

Please do not post admin requests or moderator comments to the list.
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


Converting an AttributedString into NSData for an NSTextView

2010-09-25 Thread Brad Stone
I have an NSMutableString that I want to set as the NSData source for an 
NSTextView.  I'm stuck and don't know how to do it.   I'm importing about 4,000 
XML files and I have to programmatically create the attributedString for each 
one, there's no way around it.

How do I convert an NSMutableString to NSData so it can be the data source for 
an NSTextView?

Thanks___

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

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

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

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


Re: Converting an AttributedString into NSData for an NSTextView

2010-09-25 Thread Brad Stone
I've been programming in Cocoa for 12 months now so I may not understand the 
subject fully but my NSTextView Data binding is connected to a Core Data 
attribute of type Binary Data (NSData) and this works when I manually type in 
text, set some attributes like underline or font, save it and reopen it.  

Since I have 4,000 files to cycle through I want to do this all 
programatically.  To simplify things I tried to do this with an NSString 
instead of an NSAttributableString.  I wrote a test app that creates a new 
document, pulls the entity newNote and uses the following code to set the 
NSData object:

NSData *noteData = [s dataUsingEncoding:NSUnicodeStringEncoding]; 
[newNote setValue:noteData forKey:@noteData];

I then save the document and loop around again.  This works fine with the 
NSString.  After the 4,000 are loaded in, if I open one of the documents in my 
interface and look in the textView I see the string.  I guess don't fully 
understand how to repeat this process with an AttributedString.  I don't see 
how NSTextStorage applies in this scenario.  Maybe I'm skipping a step.



On Sep 25, 2010, at 11:28 AM, Keary Suska wrote:

 
 On Sep 25, 2010, at 9:12 AM, Brad Stone wrote:
 
 I have an NSMutableString that I want to set as the NSData source for an 
 NSTextView.  I'm stuck and don't know how to do it.   I'm importing about 
 4,000 XML files and I have to programmatically create the attributedString 
 for each one, there's no way around it.
 
 How do I convert an NSMutableString to NSData so it can be the data source 
 for an NSTextView?
 
 NSTextView doesn't use NSData as its data source--it uses NSTextStorage. 
 You can get its content as a mutable string using -mutableString and 
 manipulate it.
 
 Keary Suska
 Esoteritech, Inc.
 Demystifying technology for your home or business
 

___

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

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

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

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


Re: One last try: how do you make a bookmark bar like Safari?

2010-09-21 Thread Brad Stone
These are all great resources.  Thanks

On Sep 20, 2010, at 6:08 PM, John Nairn wrote:

 On Sep 20, 2010, at 12:02 PM, cocoa-dev-requ...@lists.apple.com wrote:
 
 I sent this out last week and go no replies.  Please excuse me for sending 
 it out again but I want to try one more time in case someone has an answer.
 
 I've been spending some time searching and thinking about how I can make a 
 bookmark bar like in Safari or Firefox.  It has some of the characteristics 
 of a toolbar especially when the window is small it puts the remaining 
 toolbar items in a drop-down menu but it also has some of the properties of 
 a collectionView with editable views, reordering and dragging.  I've seen 
 some threads here but haven't found anything definitive.
 
 How have any of you implemented one?
 
 
 You need a custom control. I found this one
 
 http://www.positivespinmedia.com/dev/PSMTabBarControl.html
 
 which is freely available under BSD license. It looks good, but I have not 
 gotten as far yet as implementing it in any of my applications.
 
 ---
 John Nairn
 GEDitCOM - Genealogy Software for the Macintosh
 http://www.geditcom.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


One last try: how do you make a bookmark bar like Safari?

2010-09-20 Thread Brad Stone
I sent this out last week and go no replies.  Please excuse me for sending it 
out again but I want to try one more time in case someone has an answer.

I've been spending some time searching and thinking about how I can make a 
bookmark bar like in Safari or Firefox.  It has some of the characteristics of 
a toolbar especially when the window is small it puts the remaining toolbar 
items in a drop-down menu but it also has some of the properties of a 
collectionView with editable views, reordering and dragging.  I've seen some 
threads here but haven't found anything definitive.

How have any of you implemented one?

Thanks___

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

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

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

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


How to: Bookmark bar like Safari?

2010-09-15 Thread Brad Stone
I've been spending some time searching and thinking about how I can make a 
bookmark bar like in Safari or Firefox.  It has some of the characteristics of 
a toolbar especially when the window is small it puts the remaining toolbar 
items in a drop-down menu but it also has some of the properties of a 
collectionView with editable views, reordering and dragging.  I've seen some 
threads here but haven't found anything definitive.

How have any of you implemented one?

Thanks___

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

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

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

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


Re: Highlight Text like with FIne

2010-09-07 Thread Brad Stone
Ross - That looks like a good solution, basically, I'm highlighting the 
background versus the actual text.  Very clever.   This approach has the added 
advantage of preventing the user from accidentally deleting text because it's 
not a real highligh.  I'll try this out tonight.

Using this code I was able to highlight text in an textView but again, it's 
highlighting the text, not the background:

NSString *s = [textView string];
NSMutableArray *selRangeArray = [[NSMutableArray alloc] init];
if ([s length]  0) {
NSRange r = [s rangeOfString:searchText 
options:NSCaseInsensitiveSearch range:NSMakeRange(0, [s length])];
while (r.location != NSNotFound) {
[selRangeArray addObject:[NSValue 
valueWithRange:r]];
NSUInteger newStart = r.location + r.length;
r = [s rangeOfString:searchText 
options:NSCaseInsensitiveSearch range:NSMakeRange(newStart, [s length] - 
newStart)];
}
if ([selRangeArray count]  0) {
[textView setSelectedRanges:selRangeArray];
}
}


On Sep 6, 2010, at 1:19 PM, Ross Carter wrote:

 On Sep 5, 2010, at 7:33 PM, Brad Stone wrote:
 
 I want to highlight different substrings contained in controls in a window 
 (two different comboBoxes for example) programmatically when the user is 
 searching for a subString.  I can do this for one comboBox but not both 
 simultaneously.  Here's one.
 
 NSString *s = [titleComboBox stringValue];
 NSRange r = [s rangeOfString:searchText options:NSCaseInsensitiveSearch 
 range:NSMakeRange(0, [s length])];
 [titleComboBox selectText:w];
 if (r.location != NSNotFound) {
 // this is needed to select the substring
  NSText *textEditor = [w fieldEditor:YES forObject:titleComboBox];
  [textEditor setSelectedRange:r];
 }
 
 But this only highlights the text in the titleComboBox.  If I then repeat 
 this to highlight the  text in the categoryComboBox by repeating the code, 
 titleComboBox gets deselected and categoryComboBox gets selected.  I want to 
 highlight them both simultaneously.  I'd also rather use the big yellow 
 highlight like with the find panel (but that's later).
 
 Is this possible? 
 
 Your code will not work because there can be only one active field editor at 
 a time, and you are controlling the text by manipulating the selectedRange 
 property of the field editor.
 
 I would be inclined to try using attributed strings to show the selection. 
 Maybe something like this:
 
 if (r.location != NSNotFound) {
   NSMutableAttributedString *stringWithSelection = 
 [[NSMutableAttributedString alloc] initWithString:s];
   [stringWithSelection addAttribute: NSBackgroundColorAttributeName 
 value:[NSColor yellowColor] range:r];
   // set control value to stringWithSelection, using whatever technique 
 is appropriate
   [stringWithSelection release];
 }
 
 To deselect, just set the control value to [[control attributedStringValue] 
 string].
 
 There are other ways to do what you need. This might be the most 
 straightforward.
 
 -Ross
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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


Highlight Text like with FIne

2010-09-05 Thread Brad Stone
I want to highlight different substrings contained in controls in a window (two 
different comboBoxes for example) programmatically when the user is searching 
for a subString.  I can do this for one comboBox but not both simultaneously.  
Here's one.

NSString *s = [titleComboBox stringValue];
NSRange r = [s rangeOfString:searchText options:NSCaseInsensitiveSearch 
range:NSMakeRange(0, [s length])];
[titleComboBox selectText:w];   
if (r.location != NSNotFound) {
// this is needed to select the substring
NSText *textEditor = [w fieldEditor:YES forObject:titleComboBox];
[textEditor setSelectedRange:r];
}

But this only highlights the text in the titleComboBox.  If I then repeat this 
to highlight the  text in the categoryComboBox by repeating the code, 
titleComboBox gets deselected and categoryComboBox gets selected.  I want to 
highlight them both simultaneously.  I'd also rather use the big yellow 
highlight like with the find panel (but that's later).

Is this possible? 

Thanks___

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

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

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

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


Re: stringWithQuotedPrintableString almost perfect

2010-08-20 Thread Brad Stone
You know, sometimes it just helps getting other developers perspectives to help 
you look at a bug from a different angle (even though you think you're doing 
this by yourself).  The code works fine for me too!  My problem is I had the 
WRONG ENCODING when I use the converted string to create the data object of my 
NSTextView.  DUH!

s = [dict objectForKey:@Note]; 
NSData *noteData = [s dataUsingEncoding: NSUnicodeStringEncoding]; // I had 
NSASCIIStringEncoding for some unknown reason!
[newNote setValue:noteData forKey:@noteData];

Stephen - thanks for your mods.  I'll study what you did and fix my code.



On Aug 20, 2010, at 12:28 AM, Quincey Morris wrote:

 On Aug 19, 2010, at 19:27, Brad Stone wrote:
 
 Can someone help me figure out why (brackets not included)  [•   m]  
 (which is, on the Mac, an option-8 character, a tab character and a 
 lowercase m) converts to (brackets not included [• m] ?
 
 The source text  is quoted-printable UTF-8 text I created and saved in an 
 XML file in a different application.  All the other characters and line 
 returns translate perfectly but this option-8 tab combination does not.
 
 Here is my source code.
 
 Thanks
 
 - (NSString *)stringWithQuotedPrintableString:(const char *)qpString {
  
   const char *p = qpString;
   char *ep, *utf8_string = malloc(strlen(qpString) * sizeof(char));
   NSParameterAssert( utf8_string );
   ep = utf8_string;
  
  
  
   while( *p ) {
  
   switch( *p ) {
  case '=':
  
  NSAssert1( *(p + 1) != 0  *(p + 2) != 0, 
 @Malformed QP String: %s, qpString);
  if( *(p + 1) != '\r' ) {
  int i, byte[2];
  for( i = 0; i  2; i++ ) {
  byte[i] = *(p + i + 1);
  if( isdigit(byte[i]) )
  byte[i] -= 0x30;
  else
  byte[i] -= 0x37;
  
  if (byte[i] = 0  byte[i]  
 16) {
  continue;
  }
  
  NSAssert( byte[i] = 0  
 byte[i]  16, @bad encoded character);
  }
  *(ep++) = (char) (byte[0]  4) | 
 byte[1];
  }
  p += 3;
  continue;
  default:
  *(ep++) = *(p++);
  continue;
   }
   }
  return [[NSString alloc] initWithBytesNoCopy:utf8_string 
 length:strlen(utf8_string) encoding:NSUTF8StringEncoding freeWhenDone:YES];
 }
 
 It would be a help if you could show the hex bytes actually being passed to 
 'initWithBytesNoCopy...'.
 
 I note, however, that if your input contains the sequence =\r, your code 
 above will eat the character following the '\r'. That sort of looks like a 
 bug.
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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


stringWithQuotedPrintableString almost perfect

2010-08-19 Thread Brad Stone
Can someone help me figure out why (brackets not included)  [•  m]  (which is, 
on the Mac, an option-8 character, a tab character and a lowercase m) converts 
to (brackets not included [• m] ?

The source text  is quoted-printable UTF-8 text I created and saved in an XML 
file in a different application.  All the other characters and line returns 
translate perfectly but this option-8 tab combination does not.

Here is my source code.

Thanks

- (NSString *)stringWithQuotedPrintableString:(const char *)qpString {

const char *p = qpString;
char *ep, *utf8_string = malloc(strlen(qpString) * sizeof(char));
NSParameterAssert( utf8_string );
ep = utf8_string;



while( *p ) {

switch( *p ) {
case '=':

NSAssert1( *(p + 1) != 0  *(p + 2) != 0, 
@Malformed QP String: %s, qpString);
if( *(p + 1) != '\r' ) {
int i, byte[2];
for( i = 0; i  2; i++ ) {
byte[i] = *(p + i + 1);
if( isdigit(byte[i]) )
byte[i] -= 0x30;
else
byte[i] -= 0x37;

if (byte[i] = 0  byte[i]  
16) {
continue;
}

NSAssert( byte[i] = 0  
byte[i]  16, @bad encoded character);
}
*(ep++) = (char) (byte[0]  4) | 
byte[1];
}
p += 3;
continue;
default:
*(ep++) = *(p++);
continue;
}
}
return [[NSString alloc] initWithBytesNoCopy:utf8_string 
length:strlen(utf8_string) encoding:NSUTF8StringEncoding freeWhenDone:YES];
}





___

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

Please do not post admin requests or moderator comments to the list.
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: Reading in UTF-8 to Data

2010-07-16 Thread Brad Stone
The XML file is from an app I wrote a long time ago and contains thousands of 
documents similar to this one.  Once Nick mentioned quotable-printable I 
remembered I used that.  It was so long ago I had forgotten.  There are many 
users that use the app and each of them have hundreds, if not thousands, of 
individual XML files and they need this functionality.  My last resort would be 
to send out update for the old app to all the users to reprocess their XML 
files w/o the quoted-printable but you know how that will go.  If I could only 
get Cocoa to do it I'd be done.

On Jul 15, 2010, at 9:20 PM, Greg Guerin wrote:

 Brad Stone wrote:
 
 Yes, quoted-printable.  That's precisely it but in doing my research in the 
 documentation and on the internet it doesn't seem like it's a simple process 
 especially for someone like me with 9 months of Cocoa development experience.
 
 
 There is nothing apparent in your code that would cause quoted-printable to 
 magically appear.  If it's not your code, the next most obvious candidate is 
 your data.
 
 Exactly where is your data coming from, and exactly how did it get there?  
 Maybe you have a glitch somewhere along your data-production pathway, that's 
 unexpectedly producing quoted-printable.
 
 That pathway includes all uploads, file-transfers, file copies, etc.  It even 
 includes any editor you used the last time you looked at the original XML 
 file.  If the editor is helping you by interpreting quoted-printable, then 
 you might want to try something simpler, like the 'cat' command in 
 Terminal.app, or even the 'hexdump -C' command.  If you're not a Terminal 
 person, HexFiend is your friend (google it).
 
  -- GG
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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: Reading in UTF-8 to Data

2010-07-16 Thread Brad Stone
Kyle - I have my legacy file format perfectly parsed into an NSDictionary and 
my code works fine from the NSOpenPanel to select the legacy document to 
creating the new document in Cocoa, adding it to the managedObjectContext, 
inserting the data in all the right places and saving the new document.  The 
process would be perfect if I could decode the quoted-printable text in Cocoa.  
That's the only thing that's still incomplete.  What I meant when I said Cocoa 
to do it was that I would like to decode in Cocoa versus having to create 
additional code in the legacy app to create a new file format w/o the 
quoted-printable encoding.  Hopefully that's a clearer explanation.

Does anyone have any code snippets they can share that will decode 
quoted-printable?


On Jul 16, 2010, at 11:31 AM, Kyle Sluder wrote:

 On Fri, Jul 16, 2010 at 5:58 AM, Brad Stone cocoa-...@softraph.com wrote:
 The XML file is from an app I wrote a long time ago and contains thousands 
 of documents similar to this one.  Once Nick mentioned quotable-printable I 
 remembered I used that.  It was so long ago I had forgotten.  There are many 
 users that use the app and each of them have hundreds, if not thousands, of 
 individual XML files and they need this functionality.  My last resort would 
 be to send out update for the old app to all the users to reprocess their 
 XML files w/o the quoted-printable but you know how that will go.  If I 
 could only get Cocoa to do it I'd be done.
 
 The framework knows nothing about your file format, so you can't get
 Cocoa to do it. You'll simply need to perform the conversion yourself
 when you read the file in from 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


Re: Reading in UTF-8 to Data

2010-07-16 Thread Brad Stone
Agreed Thomas but code snippets have been elusive. 

On Jul 16, 2010, at 1:00 PM, Thomas Engelmeier wrote:

 
 Am 16.07.2010 um 14:58 schrieb Brad Stone:
 
 The XML file is from an app I wrote a long time ago and contains thousands 
 of documents similar to this one.  Once Nick mentioned quotable-printable I 
 remembered I used that.  It was so long ago I had forgotten.  There are many 
 users that use the app and each of them have hundreds, if not thousands, of 
 individual XML files and they need this functionality.  My last resort would 
 be to send out update for the old app to all the users to reprocess their 
 XML files w/o the quoted-printable but you know how that will go.  If I 
 could only get Cocoa to do it I'd be done.
 
 Run, don't walk, and find some code snippet that removes the bizarre QP 
 reencoding from the data you get reading your XML, and don't reapply it 
 saving (except in a backward compatibility mode for non-upgrading users).
 
 The whole idea of UTF-8 is to be able to represent about any glyph imaginable 
 without requiring reencoding, and UTF8-encoded XML deals pretty well with it 
 besides the requirement to escape ' under certain 
 circumstances.___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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: Reading in UTF-8 to Data

2010-07-16 Thread Brad Stone
I was all over the internet last night including Stack Overflow, Coco Dev, this 
mailing list.  I can' t believe I missed this.  Thanks!

On Jul 16, 2010, at 2:58 PM, Kirk Kerekes wrote:

 In the first page of Google hits for nsstring quoted-printable
 
 http://stackoverflow.com/questions/491678/can-you-translate-php-function-quoted-printable-decode-to-an-nsstring-based-ob
 
 This is at least a starting point.
 
 

___

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

Please do not post admin requests or moderator comments to the list.
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


Reading in UTF-8 to Data

2010-07-15 Thread Brad Stone
I'm having trouble getting text to appear properly in an NSTextView which is 
binded to an NSData attribute in core data.  I've been all over the internet 
but I'm still stumped.

The original text looks like this:
There is a period at the end of this sentence.
You should have also just seen a line return and here • is a option-8 bullet 
character.

This text is saved in an XML file that starts with ?xml version=1.0 
encoding=UTF-8?

My goal is to write code to read this XML file and create an NSData object for 
the text.  This is what I've written:
NSString *s = [childNode stringValue];  //assume this child is the correct text 
NSData *noteData = [s dataUsingEncoding:NSUnicodeStringEncoding 
allowLossyConversion:YES];  // I also tried NSUTF8StringEncoding

This results in the following appearing in my NSTextView
There is a period at the end of this sentence=2E=0DYou should have also jus= t 
seen a line return and here =E2=80=A2 is a option-8 bullet character= =2E


I'd like to do the correct encoding but there's something wrong and I don't 
want to resort to the find and replace method. (i.e. find =2E and replace with 
.) 

The actual text in the XML file is:
NoteThere is a period at the end of this sentence=2E=0DYou should have also 
jus=
t seen a line return and here =E2=80=A2 is a option-8 bullet character=
=2E/Note

(why there's an = between the s and t in the word just is confusing).

Can anyone help?  

Thank you

___

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

Please do not post admin requests or moderator comments to the list.
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: Reading in UTF-8 to Data

2010-07-15 Thread Brad Stone
Yes, quoted-printable.  That's precisely it but in doing my research in the 
documentation and on the internet it doesn't seem like it's a simple process 
especially for someone like me with 9 months of Cocoa development experience.

Does anyone have a utility or sample code?

On Jul 15, 2010, at 6:19 PM, Nick Zitzmann wrote:

 
 On Jul 15, 2010, at 4:03 PM, Brad Stone wrote:
 
 I'm having trouble getting text to appear properly in an NSTextView which is 
 binded to an NSData attribute in core data.  I've been all over the internet 
 but I'm still stumped.
 
 The original text looks like this:
 There is a period at the end of this sentence.
 You should have also just seen a line return and here • is a option-8 bullet 
 character.
 
 This text is saved in an XML file that starts with ?xml version=1.0 
 encoding=UTF-8?
 
 My goal is to write code to read this XML file and create an NSData object 
 for the text.  This is what I've written:
 NSString *s = [childNode stringValue];  //assume this child is the correct 
 text 
 NSData *noteData = [s dataUsingEncoding:NSUnicodeStringEncoding 
 allowLossyConversion:YES];  // I also tried NSUTF8StringEncoding
 
 This results in the following appearing in my NSTextView
 There is a period at the end of this sentence=2E=0DYou should have also jus= 
 t seen a line return and here =E2=80=A2 is a option-8 bullet character= =2E
 
 
 I'd like to do the correct encoding but there's something wrong and I don't 
 want to resort to the find and replace method. (i.e. find =2E and replace 
 with .) 
 
 The actual text in the XML file is:
 NoteThere is a period at the end of this sentence=2E=0DYou should have 
 also jus=
 t seen a line return and here =E2=80=A2 is a option-8 bullet character=
 =2E/Note
 
 (why there's an = between the s and t in the word just is confusing).
 
 Can anyone help?  
 
 Looks like you need to translate the text in the XML file using a MIME 
 quoted-printable decoder, and then run the results through a UTF-8 decoder. 
 Quoted-printable sequences start with a = and the next two characters 
 indicate the hex value of the character. For example, 0xe280a2 is the bullet 
 character (U+2022) in UTF-8. See RFC 2045 for more details.
 
 Nick Zitzmann
 http://www.chronosnet.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: How to revert to an unedited document window?

2010-06-30 Thread Brad Stone
That was the suggestion I needed.  Thank you.  Here's what I did in the 
windowControler:

[doc removeWindowController:self];
[[self managedObjectContext] rollback];
[doc close];

and then I use my normal routine to reload the document. 

On Jun 29, 2010, at 12:23 PM, Jerry Krinock wrote:

 
 On 2010 Jun 29, at 05:23, Brad Stone wrote:
 
 Using [NSPersistentDocument revertToContentsOfURL:(NSURL 
 *)inAbsoluteURLofType:(NSString *)inTypeName error:(NSError**)outError] 
 works except the window closes and opens.  If that didn't happen I'd be fine.
 
 Reverting a Core Data document is tricky.  Apple's recommended methods are 
 given here:
 
 http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/NSPersistentDocumentTutorial/04_Department/department.html#//apple_ref/doc/uid/TP40002832-SW6
 
 But you should also read these:
 
 http://www.cocoabuilder.com/archive/cocoa/161579-bug-in-nspersistentdocument-tutorial.html#161579
 http://www.cocoabuilder.com/archive/cocoa/174292-bug-nspersistentdocument-core-data-tutorial.html#174292
 http://www.cocoabuilder.com/archive/cocoa/177523-bug-nspersistentdocument-core-data-tutorial.html#177523
 
 Since Revert is not a major advertised feature of the app I was working on, 
 after trying unsuccessfully to make it work for an hour or so,  I gave up and 
 implemented Revert to simply close and re-open the document.  It's a little 
 slow and ugly, but it works, and eliminates a branch of regression 
 possibilities.
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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


How to revert to an unedited document window?

2010-06-29 Thread Brad Stone
I have a subclassed windowController that has an associated core data 
managedObject called note, a managedObjectContext and a NSPersistendDocument. 
 Sometimes I need to reset everything back to the last time the doc was saved 
and make the doc clean (isDocumentEdited == NO) so that when I close it the 
documentController doesn't ask me if I want to save changes.

managedObjectContext rollback does restore everything to the last save but I 
can't get the document to be unEdited.  Using [window setDocumentEdited:NO] or 
[windowController setDocumentEdited:NO} (which I know I shouldn't call) both 
don't work.

Do I have to reset the persistendDocument somehow?

Using [NSPersistentDocument revertToContentsOfURL:(NSURL 
*)inAbsoluteURLofType:(NSString *)inTypeName error:(NSError**)outError] works 
except the window closes and opens.  If that didn't happen I'd be fine.

Thanks___

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

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

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

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


applicationShouldTerminate gets called on with no edited documents

2010-06-11 Thread Brad Stone
I have (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication 
*)sender in my app delegate and it gets called when the user quits if **no** 
documents have been edited (I'm using Core Data). If one of my documents **is** 
edited it doesn't get called.  It goes right to - 
(void)closeAllDocumentsWithDelegate:(id)delegate 
didCloseAllSelector:(SEL)didCloseAllSelector contextInfo:(void *)contextInfo in 
my subclassed NSDocumentController.  

I set up a breakpoint in my subclassed NSDocumentController at 
closeAllDocuments and I see this when I quit (assuming there's an edited 
document):
0 -[SRDocumentController 
closeAllDocumentsWithDelegate:didCloseAllSelector:contextInfo:]
1 
-[NSDocumentController(NSInternal)_shouldTerminateWithDelegate:shouldTerminateSelector:]
2 -[NSApplication _shouldTerminate]
3 -[NSApplication terminate:]



I want to have an opportunity to send an NSApplicationTerminateReply before 
closeAllDocumentsWithDelegate is called. If applicationShouldTerminate would 
get called like it does with no edited documents I would be in great shape.

Can anyone help me?___

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

Please do not post admin requests or moderator comments to the list.
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


Newbie Question re: callback signatures

2010-06-04 Thread Brad Stone
How do I create the callback method?  I don't understand what the signature is 
telling me.  I have 
canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo: in my NSDocument 
and I want to set up the callback method.  When I create a method as below it 
never fires.  I must just not be reading it correctly.  

- (void)document:(NSDocument *)doc shouldClose:(BOOL)shouldClose 
contextInfo:(void *)contextInfo {
NSLog(@hey, it finally worked!);
}

What exactly should the method be in my NSDocument?


Thanks in advance.


canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo:
If the receiver is not dirty, this method immediately calls the 
shouldCloseSelector callback on the specified delegate with YES.

- 
(void)canCloseDocumentWithDelegate:(id)delegateshouldCloseSelector:(SEL)shouldCloseSelector
 contextInfo:(void *)contextInfo

Parameters
delegate
The delegate to which the selector message is sent.
shouldCloseSelector
The selector of the message sent to the delegate.
contextInfo
Object passed with the callback to provide any additional context information.
Discussion
If the receiver is dirty, an alert is presented giving the user a chance to 
save, not save, or cancel. If the user chooses to save, this method saves the 
document. If the save completes successfully, this method calls the callback 
with YES. If the save is canceled or otherwise unsuccessful, this method calls 
the callback with NO. This method may be called 
byshouldCloseWindowController:delegate:shouldCloseSelector:contextInfo:. It is 
also called by the NSDocumentController method closeAllDocuments. You should 
call it before you call closeif you are closing the document and want to give 
the user a chance to save any edits. Pass thecontextInfo object with the 
callback.
The shouldCloseSelector callback method should have the following signature:
- (void)document:(NSDocument *)doc shouldClose:(BOOL)shouldClose  
contextInfo:(void  *)contextInfo
Availability
Available in Mac OS X v10.0 and later.
Declared In
NSDocument.h

___

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

Please do not post admin requests or moderator comments to the list.
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


Loading PersistentDocuments into the same window

2010-04-30 Thread Brad Stone
I want to open NSPersistentDocuments and load them into the same window one at 
a time.  I'm almost there but missing some steps.  Hopefully someone can help 
me.

I have a few saved documents on the hard drive.  On launch my app opens to an 
untitled NSPersistentDocument and creates a separate NSWindowController.  When 
I press the button to load file 1 off the hard drive the data appears in the 
fields but two things are wrong that I can see:

1) changing the data doesn't make the document dirty
2) choosing save updates the persistentstore (I know this because when I open 
the file again I see the changes) but I get an error: +entityForName: could not 
locate an NSManagedObjectModel for entity name 'Book'

Here's my code which is in the WindowController that was launched initially 
with the untitled document.  This code isn't perfect.  For example, I know I 
should processPendingChanges and save the current doc before I load the new 
one.  This is test code to try to get over this hurdle.

- (IBAction)newBookTwo:(id)sender {
NSDocumentController *dc = [NSDocumentController 
sharedDocumentController];
NSURL *url = [NSURL fileURLWithPath:[@~/Desktop/File 2.binary 
stringByExpandingTildeInPath]];

NSError *error;
MainWindowDocument *thisDoc = [dc openDocumentWithContentsOfURL:url 
display:NO error:error];

[self setDocument:thisDoc]; 
[self setManagedObjectContext:[thisDoc managedObjectContext]];
}


Thanks!___

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

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

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

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


Re: Loading PersistentDocuments into the same window

2010-04-30 Thread Brad Stone
Think about the Finder.  You click on a file, get a preview.  If you like it 
you can open it.  That's what I'm driving at.  You click on a row in a 
tableView, you get a preview (the opening is in code, I'm storing an index of 
file references in a different NSDocument) and if you like it you open up in a 
new window.  The difference here is you can edit the file in preview.

I'll try your code.  Thanks for the reply.

On Apr 30, 2010, at 1:17 PM, Quincey Morris wrote:

 On Apr 30, 2010, at 08:56, Brad Stone wrote:
 
 I want to open NSPersistentDocuments and load them into the same window one 
 at a time.
 
 Excuse the soapbox, but you do realize that from the outside looking in, this 
 *seems* like a terrible idea? If your documents really are documents in the 
 user interface sense, then what's the reason for inventing a new 
 document-handling metaphor for users? If they're not really documents, then 
 why try to shoehorn them into the NSDocument metaphor?
 
 Keep in mind that Core Data persistent stores don't really fit the standard 
 document metaphor very well, so that NSPersistentDocument is already a little 
 bit broken. (Ask the people who've had trouble with Save As, for example.) 
 Piling on another layer of metaphorical abuse seems like a prescription for 
 great pain. But anyway ...
 
 - (IBAction)newBookTwo:(id)sender {
  NSDocumentController *dc = [NSDocumentController 
 sharedDocumentController];
  NSURL *url = [NSURL fileURLWithPath:[@~/Desktop/File 2.binary 
 stringByExpandingTildeInPath]];
 
  NSError *error;
  MainWindowDocument *thisDoc = [dc openDocumentWithContentsOfURL:url 
 display:NO error:error];
 
  [self setDocument:thisDoc]; 
  [self setManagedObjectContext:[thisDoc managedObjectContext]];
 }
 
 Here's what I'd try (apologies if you've tried this already; all typed in 
 mail):
 
 1. Create a global variable:
 
   MyWindowController* recycledWindowController = nil;
 
 2. In the window controller:
 
 - (IBAction)newBookTwo:(id)sender {
   NSDocumentController *dc = [NSDocumentController 
 sharedDocumentController];
   NSURL *url = [NSURL fileURLWithPath:[@~/Desktop/File 2.binary 
 stringByExpandingTildeInPath]];
 
   recycledWindowController = self;
   [self.document removeWindowController: self];
 
   NSError *error;
   MainWindowDocument *thisDoc = [dc openDocumentWithContentsOfURL:url 
 display:NO error:error];
 }
 
 3. In the document:
 
 - (void) makeWindowControllers {
   if (! recycledWindowController) {
   recycledWindowController = ... // create a new window controller
   recycledWindowController.shouldCloseDocument = YES;
   }
   [self addWindowController: recycledWindowController];
   [recycledWindowController noteChangedDocument]; // or send a 
 notification, or have the window controller KVO-observe its own 'document' 
 property
   recycledWindowController = nil;
 }
 
 Something like that.
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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: Loading PersistentDocuments into the same window

2010-04-30 Thread Brad Stone
Yes, I haven't gotten to the second part yet.

So, let me see if I understand what you're doing in your first example.

You're putting the initial window controller in a global that both the doc and 
the windowController can get to.  When it's time to open a new doc you're 
saving the current windowController to the global variable, removing it from 
the dc list and calling [dc openDocument...].  This will reuse the saved global 
windowController (the code in the document subclass).

 [dc openDocumentWith...] is opening the new doc and it'll be associated with 
the same windowController in the makeWindowControllers method. I see how you're 
doing that.  What I don't understand is the documentation for 
openDocumentWIthCOntentsOfURL doesn't mention anything about setting up the 
managedObjectContext or creating an undoManager and liking the MOC to a 
persistentStore.  This could just be me because I've been doing cocoa for 6 
months (programming in other languages for many years) but are you assuming all 
the stuff happens because openDocument... is called?

Regarding the second part, yes I'm planning on setting up another 
windowController and when I show the second window moving the 
managedObjectContext over to it.  Both windows will have the same moc.  I had a 
similar problem with that: no undo and the saving didn't work but I put that on 
hold until I got the first part done.  I figure if it works in the preview 
window making it work in it's own window should be straightforward.



On Apr 30, 2010, at 3:36 PM, Quincey Morris wrote:

 On Apr 30, 2010, at 10:55, Brad Stone wrote:
 
 Think about the Finder.  You click on a file, get a preview.  If you like it 
 you can open it.  That's what I'm driving at.  You click on a row in a 
 tableView, you get a preview (the opening is in code, I'm storing an index 
 of file references in a different NSDocument) and if you like it you open up 
 in a new window.  The difference here is you can edit the file in preview.
 
 After letting this percolate for a while ...
 
 It's a bit more involved than I thought, because it looks like you actually 
 need 2 window controller classes -- one for the preview, and another for the 
 independently opened documents (assuming those windows don't themselves 
 function as preview windows).
 
 In any case, I think I'd keep the initial preview window as a singleton, and 
 always let the document create its own window controller (of a different 
 class, I'd assume), when a file is chosen for preview, but just not show the 
 document's own window yet.
 
 Then, I'd attach the singleton controller to the document with 
 addWindowController: (after removing it from another document, if it was 
 previously attached elsewhere). It could could then configure itself to 
 display the document contents. (That would eliminate the global variable and 
 the makeWindowControllers override that I suggested earlier.)
 
 That would make it easy to open an independent document window from the 
 preview -- just show its already existing window.
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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: Loading PersistentDocuments into the same window

2010-04-30 Thread Brad Stone
Quincey - you were right.  The undo wasn't working because the windowController 
wasn't in the document's windowController array.   I used your concept of 
reusing the same windowController and it works.  

Thanks!



On Apr 30, 2010, at 4:12 PM, Quincey Morris wrote:

 On Apr 30, 2010, at 12:44, Brad Stone wrote:
 
 [dc openDocumentWith...] is opening the new doc and it'll be associated with 
 the same windowController in the makeWindowControllers method. I see how 
 you're doing that.  What I don't understand is the documentation for 
 openDocumentWIthCOntentsOfURL doesn't mention anything about setting up the 
 managedObjectContext or creating an undoManager and liking the MOC to a 
 persistentStore.  This could just be me because I've been doing cocoa for 6 
 months (programming in other languages for many years) but are you assuming 
 all the stuff happens because openDocument... is called?
 
 It happens in the NSPersistentDocument initialization -- the 
 NSDocumentController isn't involved beyond triggering the creation of the 
 document.
 
 Regarding the second part, yes I'm planning on setting up another 
 windowController and when I show the second window moving the 
 managedObjectContext over to it.  Both windows will have the same moc.  I 
 had a similar problem with that: no undo and the saving didn't work but I 
 put that on hold until I got the first part done.  I figure if it works in 
 the preview window making it work in it's own window should be 
 straightforward.
 
 I believe that undo etc weren't working because your window controller wasn't 
 in the document's windowControllers array.
 
 Note that if you're planning on allowing editing in both places, you have a 
 whole other set of issues to do with, to keep the two views of the document 
 contents in sync.
 
 I'm back to thinking this might be a bit misguided from the UI point of view. 
 Presumably you have something in the preview window that lets you select 
 which document to preview. Why not just leave that much in the preview window 
 and just let that window open and close real document windows to do the 
 preview? What's the payoff from integrating both into a single window (and 
 is it big enough to justify the development time)?
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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


XCode 3.2.2 Hangs after Clean All but Previous Version Doesn't

2010-04-26 Thread Brad Stone
The same code builds fine after a clean all in 3.2.1 and 3.2.  In the new 
version, 3.2.2, it hangs during the build.  Here's the sequence:

1) I open the code
2) clean all
3) I build and it hangs (still says Clean succeeded in the bottom right of 
the window)
4) I force quit and reopen code
5) clean all
6) I build and it goes fine (it says precompiling, building, running)
7) I quit my app
8) clean all
9) back to 3


Has anyone else experienced this?  It only happens with this code.

___

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

Please do not post admin requests or moderator comments to the list.
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: XCode 3.2.2 Hangs after Clean All but Previous Version Doesn't

2010-04-26 Thread Brad Stone
Nope, just this project.  I loaded it on a different Mac, same problem and it's 
OK in 3.2.  The thing is I can't even debug it. 

On Apr 26, 2010, at 9:14 AM, Rui Pacheco wrote:

 Does it happen with all projects or always the same?
 
 If its always the same project try deleting the project folder and checking 
 it out again.
 
 On 26 April 2010 14:06, Brad Stone cocoa-...@softraph.com wrote:
 The same code builds fine after a clean all in 3.2.1 and 3.2.  In the new 
 version, 3.2.2, it hangs during the build.  Here's the sequence:
 
 1) I open the code
 2) clean all
 3) I build and it hangs (still says Clean succeeded in the bottom right of 
 the window)
 4) I force quit and reopen code
 5) clean all
 6) I build and it goes fine (it says precompiling, building, running)
 7) I quit my app
 8) clean all
 9) back to 3
 
 
 Has anyone else experienced this?  It only happens with this code.
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/rui.pacheco%40gmail.com
 
 This email sent to rui.pach...@gmail.com
 
 
 
 -- 
 Best regards,
 Rui Pacheco

___

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

Please do not post admin requests or moderator comments to the list.
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: How do I get a file reference w/o relying on the path?

2010-04-25 Thread Brad Stone
SOLVED

This works just as it should.  For reasons that I thought were valid at the 
time (I no longer think so) I had this code in writeSafelyToURL: right after 
the writeTofile: command.  What was strange was the url was valid because I was 
storing the bookmark after the file was successfully written to the hard drive 
but I guess there wasn't enough information in the file yet to make a valid 
reference (bookmark).  I moved it farther down the line with the exact same 
code and everything worked fine.

Thank you for all your help.


On Apr 18, 2010, at 10:43 PM, Noah Desch wrote:

 
 Are you sure the data is being stored into your note dictionary correctly? 
 Here is my bookmark resolution code, it looks almost exactly like yours. I'm 
 running on 10.6.3 and building for 10.6 with GC off.
 
 
 - (NSURL *)resolveBookmarkData:(NSData *)bookmark 
 withOptions:(NSURLBookmarkResolutionOptions)options needsUpdate:(BOOL *)stale
 {
   NSURL *url;
   NSError *error;
   NSMutableDictionary *userInfo;
   
   error = Nil;
   *stale = NO;
   url = [NSURL URLByResolvingBookmarkData:bookmark options:options 
 relativeToURL:Nil bookmarkDataIsStale:stale error:error];
   if ( url ) {
   return url;
   }
   
   if ( error  [[error domain] isEqualTo:NSCocoaErrorDomain]  [error 
 code] == NSFileNoSuchFileError ) {
   // error presentation and resolution code follows...
 
 
 
 
 -Noah
 
 
 
 On Apr 18, 2010, at 10:08 PM, Brad Stone wrote:
 
 The error comes back file does not exist and the NSLog statement shows 
 url = (null) after I change the name of the file in the Finder.  If I 
 change the file name back to what it was when the bookmark was saved the 
 file opens fine.  I changed my creation option to 0.  No difference.
 
 NSData *bookmarkData = [note valueForKey:@bookmarkData];
  NSError *error = nil;
  BOOL isStale;
  NSURL *url = [NSURL URLByResolvingBookmarkData:bookmarkData 
 options:0 relativeToURL:nil bookmarkDataIsStale:isStale error:error];
  NSLog(@url = %@, [url description]);
  
  if (error != nil) {
  [NSApp presentError:error];
  }
 
 
 On Apr 18, 2010, at 11:45 AM, Noah Desch wrote:
 
 
 On Apr 18, 2010, at 10:43 AM, Brad Stone wrote:
 
 I'm storing the bookmark data in an array displayed in a table:
 NSData *bookmarkData = [inAbsoluteURL 
 bookmarkDataWithOptions:NSURLBookmarkCreationSuitableForBookmarkFile 

 includingResourceValuesForKeys:nil

 relativeToURL:nil
error:error];
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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: How do I get a file reference w/o relying on the path?

2010-04-18 Thread Brad Stone
I'm storing the bookmark data in an array displayed in a table:
NSData *bookmarkData = [inAbsoluteURL 
bookmarkDataWithOptions:NSURLBookmarkCreationSuitableForBookmarkFile 

includingResourceValuesForKeys:nil

relativeToURL:nil
error:error];




When the user double clicks on the row in the table I want to open the file.  I 
use this:
NSError *error;
BOOL isStale;
NSURL *url = [NSURL URLByResolvingBookmarkData:bookmarkData 
options:NSURLBookmarkResolutionWithoutUI relativeToURL:nil 
bookmarkDataIsStale:isStale error:error];

When the file's name or directory changes on my hard drive the resolved url == 
nil.   I'd like it to resolve to the actual file even if my app is closed and 
opened again (I'm saving the bookmarkData to repopulate the table the next time 
the user opens my app).  I thought that's what bookmarks did in 10.6 - I could 
be wrong.  An ugly workaround would be when the user double-clicks for me to 
create an actual alias file in a temp folder from the bookmark data and store 
that in my array, recreate it in a temp folder and launch that.  I'm sure 
that's wrong - there has got to be a better way.


On Apr 3, 2010, at 6:55 PM, Ken Thomases wrote:

 On Apr 3, 2010, at 5:20 PM, Brad Stone wrote:
 
 I want to store a reference to a file in an ivar that will allow the user to 
 change the file's name and/or the directory (i.e. the path) and still allow 
 me to access it.  I don't want to create a file (like an ailas).  I need to 
 store the file reference in a variable so I can open the file no matter 
 where the user moves it or renames it.
 
 FSRefs have the property you desire.  As of Snow Leopard, though, the new 
 recommended technique is to use a file reference NSURL.  Check the NSURL 
 documentation and also:
 
 http://developer.apple.com/mac/library/documentation/cocoa/conceptual/LowLevelFileMgmt/Articles/FileManagementNSURL.html
 
 
 Note that an alias _record_ is different from an alias _file_.  An alias 
 record is data in memory and is suitable for this purpose, but perhaps 
 overkill.
 
 As of Snow Leopard, alias records are deprecated in favor of bookmark data, 
 but, again, it's probably overkill.  (Both alias records and bookmark data 
 are more suitable if the reference is to be persisted for use by a later 
 process.  Also, both can apply more robust searching heuristics to find an 
 appropriate file even if it isn't the original.  For example, if the original 
 is deleted and replaced with a new file of the same name.)
 
 Cheers,
 Ken
 

___

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

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

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

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


Re: How do I get a file reference w/o relying on the path?

2010-04-18 Thread Brad Stone
The error comes back file does not exist and the NSLog statement shows url = 
(null) after I change the name of the file in the Finder.  If I change the 
file name back to what it was when the bookmark was saved the file opens fine.  
I changed my creation option to 0.  No difference.

NSData *bookmarkData = [note valueForKey:@bookmarkData];
NSError *error = nil;
BOOL isStale;
NSURL *url = [NSURL URLByResolvingBookmarkData:bookmarkData 
options:0 relativeToURL:nil bookmarkDataIsStale:isStale error:error];
NSLog(@url = %@, [url description]);

if (error != nil) {
[NSApp presentError:error];
}


On Apr 18, 2010, at 11:45 AM, Noah Desch wrote:

 
 On Apr 18, 2010, at 10:43 AM, Brad Stone wrote:
 
 I'm storing the bookmark data in an array displayed in a table:
 NSData *bookmarkData = [inAbsoluteURL 
 bookmarkDataWithOptions:NSURLBookmarkCreationSuitableForBookmarkFile 
  
 includingResourceValuesForKeys:nil
  
 relativeToURL:nil
  error:error];
 
 
 I am doing the same thing and it is still able to resolve the bookmarks when 
 the file moves or its name changes. The only real difference I can see 
 between our two approaches is that I am passing 0 for both the creation 
 options and the resolution options.
 
 What are the properties of the error object are you getting when the bookmark 
 resolution fails?
 
 -Noah
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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: NSInvocation error when closing a dirty document

2010-04-12 Thread Brad Stone
The view that has the combo box, for example, has a Object Controller (called 
NoteObjectController) binded to my file's owner (MyDocument : NSDocument) with 
the Model Key Path to the MOC and the object controller is an entity of my 
model I created in Core Data.  The combo box is binded to the attribute 
category (which is in the entity Note).  All of it is just like you said and 
pretty plain vanilla.  Remember, all this binding works fine with a normal 
save.  Just not when I close a dirty document.  When I do, the first time I get 
the invocation error.  I don't know **why** I just know it's because the cursor 
is still in the text fields (any one of them).  When I close again it works 
because the editing ended when the error came up.  I'm using 
saveDocumentWithDelegate to check to see if the user is closing a document 
that needs to be saved so I can end editing before the save begins to head off 
the error.

I agree with you 100%.  I'm learning in Cocoa that if you're doing too much 
coding you're doing something wrong but I don't know how else to fix it.  I'm 
an experience programmer but only 6-months with Cocoa.



On Apr 12, 2010, at 1:04 AM, Jerry Krinock wrote:

 Brad, you're overriding a method for a strange purpose, and it looks like 
 you're examining an argument to see if it is a certain Apple private 
 selector, and all this is done to achieve something which is quite ordinary, 
 namely binding your data model to a combo box and a text view.
 
 When you find yourself doing something extraordinary to achieve a result 
 which is ordinary, it means that you took a wrong turn somewhere.  Anyone 
 else with a similar problem should instead try the object controller I 
 suggested.
 
 
 On 2010 Apr 11, at 14:42, Brad Stone wrote:
 
 - (void)saveDocumentWithDelegate:(id)delegate 
 didSaveSelector:(SEL)didSaveSelector contextInfo:(void *)contextInfo {
  
  if (didSaveSelector == @selector(_document:shouldClose:contextInfo:)) { 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.com
On Apr 12, 2010, at 1:04 AM, Jerry Krinock wrote:

 Brad, you're overriding a method for a strange purpose, and it looks like 
 you're examining an argument to see if it is a certain Apple private 
 selector, and all this is done to achieve something which is quite ordinary, 
 namely binding your data model to a combo box and a text view.
 
 When you find yourself doing something extraordinary to achieve a result 
 which is ordinary, it means that you took a wrong turn somewhere.  Anyone 
 else with a similar problem should instead try the object controller I 
 suggested.
 
 
 On 2010 Apr 11, at 14:42, Brad Stone wrote:
 
 - (void)saveDocumentWithDelegate:(id)delegate 
 didSaveSelector:(SEL)didSaveSelector contextInfo:(void *)contextInfo {
  
if (didSaveSelector == @selector(_document:shouldClose:contextInfo:)) {   
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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: NSInvocation error when closing a dirty document

2010-04-11 Thread Brad Stone
For future reference, I needed to end editing in the textView or the combo 
boxes to prevent the NSInvocation error.  I did this by making the window the 
firstResponder in my NSDocument class with the saveDocumentWithDelegate method 
only when the window is being closed.  This is not necessary when the document 
is just being saved.

Here's the code

- (void)saveDocumentWithDelegate:(id)delegate 
didSaveSelector:(SEL)didSaveSelector contextInfo:(void *)contextInfo {

// Try to end editing

if (didSaveSelector == @selector(_document:shouldClose:contextInfo:)) { 
NSWindow *w = [headerBox window];   
BOOL ended = [w makeFirstResponder:w];
if (!ended) {
NSLog(@Could not end editing in 
MyDocument:saveDocumentWithDelegate:);
return;
}
} 



[super saveDocumentWithDelegate:(id)delegate 
didSaveSelector:didSaveSelector
contextInfo:(void 
*)contextInfo];


}  

On Apr 10, 2010, at 9:12 PM, Jerry Krinock wrote:

 
 On 2010 Apr 10, at 12:43, Brad Stone wrote:
 
 I have a strange bug that I've been tracking for a while and I'd like the 
 benefit of your experience.  It happens with I close a window that needs to 
 be saved.
 
 When closing a dirty Core Data NSPersistentDocument I get the following 
 error between the Do you want to save sheet and the save panel:
 
 [58341:a0f] +[NSInvocation invocationWithMethodSignature:]: method signature 
 argument cannot be nil
 
 If I make the document dirty by typing text into any of the combo boxes or 
 the text view I get the above error after I press the Save button on the  
 Do you want to save…  sheet
 
 Well, as usual, there are two routes to attack this.  I was going to say to 
 try either, but in this case, since you know it has something to do with the 
 combo boxes or text view, I'd try Route 2 first.
 
 Route 1 - The Scientist.  Use debugging information to try and narrow down 
 where the problem might be.  To do this, set breakpoints on the following 
 symbols.  (Some are irrelevant for this case, but you should have these handy 
 in any project):
 
 handleFailureInMethod:object:file:lineNumber:description:
 objc_exception_throw
 malloc_printf
 -[NSException raise]
 handleFailureInFunction:file:lineNumber:description:
 raise:format:arguments:
 
 Then Debug - Breakpoints On.  Reproduce your problem, and the debugger will 
 stop where the exception occurs.  Look at the call stack and think real hard. 
  To get more food for thought, in your Xcode documentation browser, search 
 for and open the Document-Based Applications Overview.  Click on the 
 chapter, Message Flow in the Document Architecture, then scroll down to and 
 feast your eyes upon Figure 6.
 
 Route 2 - The Engineer.  Figure out what you're doing that's different than 
 what everyone else is doing, and change your design toward the more 
 conventional until the problem goes away.  You didn't say much about how 
 you're binding these combo boxes and text view.  Look at Apple's 
 DepartmentAndEmployees sample code, in the MyDocument.nib, and note how the 
 DepartmentController, an NSObjectController, is interposed between the user 
 interface and the data model.  One reason to do that is so that your data 
 model will be updated when the window is closed, and then you won't need to 
 do this:
 
 have the bindings set, in IB, to Continuously Updates Value.
 
 which is definitely *not* conventional.  (Again, look at the bindings in 
 DepartmentAndEmployees MyDocument.nib.)  Other reasons may be related to your 
 current problem.
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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


NSInvocation error when closing a dirty document

2010-04-10 Thread Brad Stone
I have a strange bug that I've been tracking for a while and I'd like the 
benefit of your experience.  It happens with I close a window that needs to be 
saved.

When closing a dirty Core Data NSPersistentDocument I get the following error 
between the Do you want to save sheet and the save panel:

[58341:a0f] +[NSInvocation invocationWithMethodSignature:]: method signature 
argument cannot be nil

Yes, I know something is nil but I have not ventured into any of the methods 
that handle this behavior (I start with SaveDocument) and I don't know exactly 
what is nil.  This happens whether its a document that's never been saved or 
one that has.

I've tracked it down to an exact sequence of events.  The document's window has 
two combo boxes, a radio button matrix and a text view. 

If I make the document dirty by changing the selected radio button and then 
close the window everything works as expected (Do you want to save sheet 
comes up, I press Save and the save panel comes up. 
If I make the document dirty by typing text into any of the combo boxes or the 
text view I get the above error after I press the Save button on the  Do you 
want to save…  sheet (the sheet closes like normal but nothing happens after 
the error)
After the sheet disappears.  I press the close box again and everything works 
fine: the save panel comes up and the document saves normally. 

This made me think that maybe the edits weren't getting updated but those three 
objects have the bindings set, in IB, to Continuously Updates Value.

Thanks for the help.___

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

Please do not post admin requests or moderator comments to the list.
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


How do I get a file reference w/o relying on the path?

2010-04-03 Thread Brad Stone
I want to store a reference to a file in an ivar that will allow the user to 
change the file's name and/or the directory (i.e. the path) and still allow me 
to access it.  I don't want to create a file (like an ailas).  I need to store 
the file reference in a variable so I can open the file no matter where the 
user moves it or renames it.

For those of you who know REALbasic I can do this easily with 
FolderItem.GetSaveInfo. 

How can I do this in Cocoa?

Thanks___

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

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

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

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


Re: How do I get a file reference w/o relying on the path?

2010-04-03 Thread Brad Stone
Very interesting.  According to the documentation if I want to store the 
reference and want it to persist after a reboot I need to do a bookmark.  

You should not store or archive file reference URLs. A file’s ID may be 
different for different boots of the operating system. If you need to store a 
URL, see “Working with Bookmarks and Aliases.”
THANK YOU so much for pointing me in the correct direction.


On Apr 3, 2010, at 6:55 PM, Ken Thomases wrote:

 On Apr 3, 2010, at 5:20 PM, Brad Stone wrote:
 
 I want to store a reference to a file in an ivar that will allow the user to 
 change the file's name and/or the directory (i.e. the path) and still allow 
 me to access it.  I don't want to create a file (like an ailas).  I need to 
 store the file reference in a variable so I can open the file no matter 
 where the user moves it or renames it.
 
 FSRefs have the property you desire.  As of Snow Leopard, though, the new 
 recommended technique is to use a file reference NSURL.  Check the NSURL 
 documentation and also:
 
 http://developer.apple.com/mac/library/documentation/cocoa/conceptual/LowLevelFileMgmt/Articles/FileManagementNSURL.html
 
 
 Note that an alias _record_ is different from an alias _file_.  An alias 
 record is data in memory and is suitable for this purpose, but perhaps 
 overkill.
 
 As of Snow Leopard, alias records are deprecated in favor of bookmark data, 
 but, again, it's probably overkill.  (Both alias records and bookmark data 
 are more suitable if the reference is to be persisted for use by a later 
 process.  Also, both can apply more robust searching heuristics to find an 
 appropriate file even if it isn't the original.  For example, if the original 
 is deleted and replaced with a new file of the same name.)
 
 Cheers,
 Ken
 

___

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

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

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

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


Re: NSBrowser Question

2010-02-15 Thread Brad Stone
Thanks for your response.  That's exactly what I was doing but your response 
made me take another look (I was working on this all day yesterday).  It seems 
I was reloading the column before the wrapper was completely saved (even though 
I thought I was)!  When I put the reload code in a button and clicked it after 
the save it works fine.  Ugh - if I did this yesterday I would have saved hours 
of frustration!

On Feb 14, 2010, at 9:19 PM, Keary Suska wrote:

 On Feb 14, 2010, at 3:53 PM, Brad Stone wrote:
 
 I have an app that saves it's documents in a fileWrapper.  The document's 
 window has a NSBrowser where users can attach files.  Before the document is 
 saved for the first time the NSBrower's root is a temporary attachments 
 folder (because the filewrapper doesn't exist).  After it's saved that 
 attachment folder is moved into the wrapper.  When I save the file for the 
 first time, even though I set the root item to the attachment folder in the 
 wrapper, the Browser can't find the attachments (the items are still looking 
 in the temp folder).  If I close and reopen the document it works fine.
 
 What do I have to do to tell the NSBrowser that the root item has been 
 changed and that the items are now in the attachment folder in the wrapper?
 
 Did you call reloadColumn: after the change?
 
 Keary Suska
 Esoteritech, Inc.
 Demystifying technology for your home or business
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.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


NSBrowser Question

2010-02-14 Thread Brad Stone
I have an app that saves it's documents in a fileWrapper.  The document's 
window has a NSBrowser where users can attach files.  Before the document is 
saved for the first time the NSBrower's root is a temporary attachments folder 
(because the filewrapper doesn't exist).  After it's saved that attachment 
folder is moved into the wrapper.  When I save the file for the first time, 
even though I set the root item to the attachment folder in the wrapper, the 
Browser can't find the attachments (the items are still looking in the temp 
folder).  If I close and reopen the document it works fine.

What do I have to do to tell the NSBrowser that the root item has been changed 
and that the items are now in the attachment folder in the wrapper?

Thanks___

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

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

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

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


Re: NSTextField sendActionOn:

2010-01-17 Thread Brad Stone
Here's why I need this - I've been trying to solve this problem for 2 weeks!

This issue all revolves around a NSCollectionView.  Each CollectionViewItem has 
a view containing a NSTextField, NSDatePicker, NSButton (checkbox), and an 
NSLevelIndicator.  The selection index of my CollectionView is binded to the 
selection index of an NSArrayController.  The problem I having is if the user 
performs a mouseDown in the TextField I need to update the selectionIndex of 
the array controller so the CollectionView will show the appropriate view as 
selected. Without this, the wrong view is selected.  Here's a quick example:

1) click the add button twice to create two items in my collectionView.  Items 
with index 0 and 1.  Since item 1 was the last one created, it is selected (I 
have it showing a grey box).
2) click your mouse into the text field of the item at index 0 and start typing

The user would expect item 0 to be the selected item but it's not.  The array 
controller still thinks item 1 is selected.  It needs to be told otherwise.  If 
the user pressed the remove button item 1 would be removed.  

This is why I want to fire an action when the user inserts into the text field 
(just like I do when the user clicks the checkbox).  I want to change the 
selectedObject in the array controller.  The problem I'm having with 
subclassing the NSTextField is I can't figure out how to get the 
CollectionViewItem from the subclassed TextField.  If I could I could then 
execute my method to update the ArrayController.  I tried creating an IBOutlet 
to the CollectionView, the ArrayController and the CollectionViewItem but they 
all come back as nil.  I think I read here that IBOutlets don't work in this 
instance.  I also tried setting up my own Notification but the 
CollectionViewItem never receives it (other objects do).

This is tricky, any help you may have would be appreciated.

Brad



On Jan 17, 2010, at 6:12 AM, Graham Cox wrote:

 
 On 17/01/2010, at 3:56 PM, Brad Stone wrote:
 
 I was able to capture the mouseDown event in the field but only in a 
 subclass which is causing me problems elsewhere.
 
 
 Indeed, a mouse click is not the only reason a field might become focused - 
 the user could tab into it as well.
 
 Overriding -becomeFirstResponder should do it.
 
 Taking a step back though, WHY do you need to get notified here? What are you 
 trying to do? There might be a better way.
 
 --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: NSTextField sendActionOn:

2010-01-17 Thread Brad Stone
I finally had a breakthrough!  I'm not sure it's the best solution but it 
works and hopefully will be instructive for others trying to do the same thing 
connection views.  There's a lot of steps (which is why I think it may not be 
the best) so I'll try to be as clear as possible.

1) when a user clicks their mouse in my subclasses NSTextField I send this 
action:
 BOOL theResult = [NSApp sendAction:@selector(notifyViewOfMouseDown) to:nil 
from:nil];

2) my subclassed view has a method that executes when this action is sent:
- (void)notifyViewOfMouseDown {

NSDictionary *d = [NSDictionary dictionaryWithObject:self 
forKey:@view];

NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName:SRVIsSelectedChanged object:self userInfo:d];

}
This allows me to package up the view and send it along in a notification.  
Packaging the view is **key** here because this is the view that needs to be 
selected.  My subclassed NSCollectionView is registered as an observer of this 
notification.  When it receives this notification I execute this code to update 
the array controller with a new selectedObject

- (void)handleViewSelections:(NSNotification *)note {

View *v = [[note userInfo] objectForKey:@view];


int limit = [[self content] count];

for (int i = 0; i  limit; i++) {
NSCollectionViewItem *item = [self itemAtIndex:i];
View *thisView = [item view];

if ([thisView isEqual:v]) {
[item setSelected:YES]; //my subclassed 
NSCollectionViewItem knows how to set itself as selected and update the array 
controller
}
}


}


Boy, I'm glad I figured that out!  I'm sure there are a lot more experienced 
programmers than me out there so if anyone can think of a way I can do this 
without so many steps I'd be glad to learn from them.

Jonathan, thanks for your suggestion.  My subclassed NSTextField didn't respond 
to superview.  I wish it did, it would have saved me a step.  To adapt your 
solution I'd need to register each newly created view in my NSCollectionView 
link that back to the NSCollectionViewItem that has the code to set itself as 
selected and to update the array controller.  I had to delete your reply from 
this message to make it thru the listserve size 
limit.___

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

Please do not post admin requests or moderator comments to the list.
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


NSTextField sendActionOn:

2010-01-16 Thread Brad Stone
I have an NSTextField and an NSDatePicker on a view.  As soon as the user 
clicks into either on (and before they type anything) I want to send an action. 
 I thought I'd use sendActionOn: but I can't get it to work.

The best I can do for the NSTextField is bind an action and in, IB, in the 
TextFieldAttributes set Action to Sent on End Editing  which sends the 
action after the first character is type.  I want the action sent as soon as 
the field gains focus.

Thanks___

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

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

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

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


Re: NSTextField sendActionOn:

2010-01-16 Thread Brad Stone
I tried that (textDidBeginEditing) but it fires only after the user hits a key 
to begin typing, not when they first enter the field (i.e. the action that 
makes the focus ring show up).  I want to be notified as soon as the user 
clicks in the field to get the cursor in there.  I was able to capture the 
mouseDown event in the field but only in a subclass which is causing me 
problems elsewhere.

On Jan 16, 2010, at 3:08 PM, Matthew Lindfield Seager wrote:

 On Sunday, January 17, 2010, Brad Stone cocoa-...@softraph.com wrote:
 The best I can do for the NSTextField is bind an action and in, IB, in the 
 TextFieldAttributes set Action to Sent on End Editing  which sends the 
 action after the first character is type.  I want the action sent as soon as 
 the field gains focus.
 
 Googling nstextfield begin editing notification without the quotes
 takes one straight to the fine manual. See textDidBeginEditing in
 particular.
 
 Hope that is what you are after.
 
 Regards,
 Matt

___

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

Please do not post admin requests or moderator comments to the list.
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


How do I know when a new object is added to an NSArray or NSCollectionView?

2010-01-10 Thread Brad Stone
I'd like a viewController to be notified whenever an arrayController adds a new 
object.  Here's why:

I have an NSTextField in a view that gets added in an NSCollectionView.  
There's also an array controller and when I fire the add: selector the new 
view shows up in the collection.  The view that gets added has an NSTextField 
in it and I want the cursor to be in there and ready so the user can just start 
typing.   So I guess this is a two-part question:
1) how do I get notified if a new object is added?
2) how do I make the NSTextField in the view that just was added ready and 
waiting to be typed in?

Thanks!___

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

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

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

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