Custom NSDocument class will not save to file

2012-01-03 Thread Erik Stainsby
I'm certain this is a trivial error on my part, but my custom document class 
will not write the file to the local filesystem.  I have several other files 
which I can write, and I can write the content when I use an NSString to encode 
the text first.  But once I init my own document, setup the attributedText and 
try to writeToURL: or saveToURL: phht!  

"File could not be saved because the specified format is not supported."


This is the passage in my app delegate which drives the save operation in 
response to a web page being loaded into a webView:

NSError * error = nil;  
self.htmlText = [[NSMutableAttributedString alloc] initWithString: 
html];

WebHistoryItem * item = [[webview backForwardList] currentItem];
if( ! [history containsObject:item]) {
[history addObject:item];
}

NSString * urlString = [webview mainFrameURL];
NSString * filename = nil;

if( ! [htmlList itemWithTitle:urlString] )
{
[self configureWorkingSiteFolders:urlString];

if(nil==filename) 
{
if( [[[NSURL URLWithString:urlString] relativePath] 
isEqualToString:@"/"]) 
{
filename = [[@"" 
stringByAppendingPathComponent:@"index"]
 
stringByAppendingPathExtension:@"html"];
}
else {
filename = [urlString lastPathComponent];
}
}

// instantiate htmlDocument

RSSHTMLDocument * htmlDocument = [[RSSHTMLDocument alloc] init];
[htmlDocument readFromURL:[NSURL URLWithString:urlString] 
ofType:NSHTMLTextDocumentType error:&error];
[htmlDocument setTitle:[webview mainFrameTitle]];

NSURL * fileURL = NSUserDefaults standardUserDefaults] 
URLForKey:kRSSProjectDirectoryURL] 
URLByAppendingPathComponent:@"index" 
isDirectory:NO] 
URLByAppendingPathExtension:@"html"];

[htmlDocument saveToURL:fileURL ofType:NSHTMLTextDocumentType 
  forSaveOperation:NSSaveOperation error:&error ];
if( error ) {
[self presentError:error];
error = nil;
}
[htmlList addItemWithTitle:filename];
}


And here is the custom saveToURL:  implementation:


- (BOOL) saveToURL:(NSURL *)url ofType:(NSString *)typeName 
  forSaveOperation:(NSSaveOperationType)saveOperation 
error:(NSError **)outError {

BOOL saveSuccess = NO;
NSString * page = @"";
NSData * data = [attributedText dataFromRange:NSMakeRange(0, 
[attributedText length]) documentAttributes:nil error:outError];

if( outError ) {
[NSApp presentError:*outError];
outError = nil;
}
if(!filename) {
filename = [@"unnamed-file" 
stringByAppendingPathExtension:@"html"];
}

if(data) {
page = [[NSString alloc] initWithData:data 
encoding:NSUTF8StringEncoding];
NSLog(@"%@ [%04d] %@ %@",[self className],__LINE__, 
NSStringFromSelector(_cmd),page);
[page writeToURL:[[[NSUserDefaults standardUserDefaults]  
URLForKey:kRSSCSSDirectoryURL] 
URLByAppendingPathComponent:filename 
isDirectory:NO] 
  atomically:YES encoding:NSUTF8StringEncoding 
error:outError];

if( outError ) { 
[NSApp presentError:*outError];
outError = nil;
}
saveSuccess = YES;
}
return saveSuccess;
}


My question I suppose is how do I get saveToURL:  to write a plaintext version 
of the contents of my class? 

TIA,
Erik


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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


NSRuleEditor templates?

2012-01-27 Thread Erik Stainsby
Hello list,  

Forgive me if this has been asked and answered, but what does one do in XC4.2 
to create the requisite rule editor templates?  I find nothing useful in the 
docs on this topic, and the only example code used IB 3.0 to do this task.
Help?

Erik
___

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

Please do not post 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 NSRuleEditor worth the learning curve?

2012-01-28 Thread Erik Stainsby
Hello list folks,

I'm struggling with the abstraction and sketchy documentation that surround 
NSRuleEditor. I feel a need to know that the effort is worthwhile, versus 
cobbling together something in a table or outline view instead.

The domain I am working in really fits well within the structured rule editor 
model. I have many lists of finite scope which have an inherent hierarchy and 
each choice made implies filters for the remaining options.

But I am really confused by the highly flexible model of the rule editor. The 
toughest part right now is that I am unable to see how the NSRuleEditor 
instance populates a given row, based on having received either a stringValue, 
a menuItem or a control/view.  Where in all of this have I the opportunity to 
establish the layout and orientation of the various widgets for a given row?  

One example I have found (NibBasedSpotlightSearcher.xcodeproj - circa 2006) 
presents a window in the nib which holds clusters of related controls in a 
single view. I'm doing the gasping guppy trying to see where in the code those 
individual controls are addressed, loaded and applied. 

Has anyone got a nakedly simple example of a minimalist use of the NSRuleEditor 
they could point me to? 

Cheers,
Erik
___

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

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


Window/Controller, View/Controller, View ?

2012-01-31 Thread Erik Stainsby
Hello list,

Seeking clarity about the display hierarchy: 

I have an application for a form which would have several variant sections, the 
exact configuration of which would be established in context at run time. I'm 
thinking to setup the variants as views, then swap them in using a (?) 
ViewController. Or sh/would there be a ViewController per view, and the 
swapping being directed from the p.o.v. of the Window or a WindowController?

Clearly I have more reading to do. Would anyone care to give me a gentle shove 
in the right general direction ?

Erik
___

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

Please do not post 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: Window/Controller, View/Controller, View ?

2012-02-01 Thread Erik Stainsby
Fritz,

Where would that be introduced into the hierarchy ? As the File Owner of
the View ? Or as an ObjectController added into the View ?  Are you
suggesting substitution or addition to the tree.

Erik


On 1 February 2012 09:00, Fritz Anderson  wrote:

> On 31 Jan 2012, at 4:34 PM, Quincey Morris wrote:
>
> > It's often convenient to subclass the view controller for a particular
> view, so that the objects in the view can use the view controller as its …
> um … controller. This view controller itself may well end up using the
> window controller as its … er … controlling controller.
>
> Bindings can be your friend here. In simple cases, having an
> NSObjectController link between controls and .representedObject can do a
> lot for you.
>
>— F
>
>


-- 
--
Erik Stainsby
Time Dwarf, Experience Engineer
RoaringSky Software
___

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

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

Addressing handlers in the First Responder list of another window ?

2012-02-02 Thread Erik Stainsby
Hello list,

I have a context menu in one window (A) from which I need to dispatch to
another (B) window's First Responder list.
Do I need to bring in a reference to window B (or it's controller) into the
nib/code of window A ? This seems to go against loose coupling practices,
no?  Or should this sort of communication be handled using
NSNotificationCenter services?
Advice?

--
Erik Stainsby
Experience Engineer
RoaringSky Software
___

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

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


NSTextField recieves string but does not display it?

2012-02-04 Thread Erik Stainsby
I am perplexed.  

I have two windows. A is the source, B is the destination. A context menu 
action in A sets a string value on a message. The message arrives in window B, 
in a view which sets the stringValue of an NSTextField. I then read the 
stringValue back and echo it via NSLog() to ensure it arrived. All well and 
good.  However, for some reason the NSTextField does not display the new value. 
 

Urk?!


- (IBAction) setActionSelectorString:(NSString*)nodeSelector {
NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, nodeSelector);
if( nodeSelector != nil ) {
[[[self view] window] makeMainWindow];
[actionSelector setStringValue: nodeSelector];
[[self view] setNeedsDisplay:YES];
NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, 
[actionSelector stringValue]);
}
}

Both NSLog stmts return the expected value.
What have I done wrong/not done ? 

- Erik
___

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

Please do not post 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: NSTextField recieves string but does not display it?

2012-02-05 Thread Erik Stainsby
On 2012-02-04, at 8:38 PM, Quincey Morris wrote:

> This is all very code-smelly. 


Here is a longer and more complete explanation of the circumstances.


MainMenu.xib
web browser window  (A)
object references to App Delegate, Web Delegate and Rule Editor (WC)

The web delegate implements the following UIDelegate method:

- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary 
*)element 

 defaultMenuItems:(NSArray *)defaultMenuItems {

// - (NSString*) selectorForDOMNode:(DOMNode*)node; 
//  returns the CSS selector - not an Obj-C selector 

NSString * nodeSelector = [self selectorForDOMNode:[element 
objectForKey:WebElementDOMNodeKey]];
NSMenuItem * item1 = [[NSMenuItem alloc] initWithTitle:@"Set Action 
selector" 

action:@selector(quickSetActionSelector:) 

keyEquivalent:@""]; 
return [NSArray arrayWithObjects:item1,nil];// there will be more 
menu cases later
} 

=   


The web browser instantiates a subclassed WebView which declares & implements:

@interface RSSWebView : WebView

@property (retain) IBOutlet RSSRuleEditorController * ruleEditor;
- (IBAction) quickSetActionSelector:(id)sender;
@end

@implementation RSSWebView

@synthesize ruleEditor;

- (IBAction) quickSetActionSelector:(id)sender {
NSString * nodeSelector = [sender respresentedObject];
if( nodeSelector != nil) {
[ruleEditor setActionSelectorStringValue:nodeSelector];
}
}

@end



The Rule Editor is a WindowController initialized in the AppDelegate:
 
- (void) applicationWillFinishLaunching:(NSNotification *)notification {
NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, @"");

// this is a secondary window
editorController = [[RSSRuleEditorController alloc] init];
[[editorController window] makeKeyAndOrderFront:self];
}

The RSSWebView ruleEditor is connected to this editorController in IB.

The RUule Editor implements this method:

- (void) setActionSelectorStringValue:(NSString*)string {
// string is the nodeSelector
[[actionForms objectAtIndex:1] setActionSelectorString:string]; 
}



The class RSSRuleEditorController : NSWindowController  employs view swapping.
RSSRuleEditorController has a mutable array holding a collection of view 
controllers, 
which inherit from RSSEditorForm : NSViewController
The views which are owned by the members of the collection are input forms.
The test case is RSSActionForm : RSSEditorForm
This view currently hosts a single input field: NSTextField * actionSelector.

@interface RSSActionForm : RSSEditorForm

@property (retain) IBOutlet NSTextField * actionSelector;

- (void) setActionSelectorString:(NSString*) string;

@end

@implementation RSSActionForm

@synthesize actionSelector;

- (void) setActionSelectorString:(NSString*)nodeSelector {
NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, nodeSelector);   
// Again, this is the CSS selector, not an Obj-C selector 
if( nodeSelector != nil ) {

[[[self view] window] makeMainWindow];

[actionSelector setStringValue: nodeSelector];
[[self view] setNeedsDisplay:YES];
NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, 
[actionSelector stringValue]);
}
}

@end



To reiterate my problem, although the string which is set in this last method - 
setActionSelectorString has the correct value,
and reading it back after setting returrns that same value, the NSTextField * 
actionSelector (linked in IB) does not reflect the value in the UI.

 Until I tried having teh ActionForm view controller call [[[self view] window] 
makeMainWindow] the call to [actionSelector setStringValue:nodeSelector] had no 
effect. This is what leads me to wonder if there is still something I need to 
do vis-à-vis the window 1 / window 2 relationship that I have not yet 
understood.

I remain perplexed. 

~ Erik



___

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

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

Framework installation pain in XC4.2

2012-02-11 Thread Erik Stainsby
Is it commonplace to have to copy the compiled output of one's own framework 
into a deployment location ? I'm also not finding where to setup a search path 
for such custom framework once placed.  Is there a more appropriate list to be 
asking for this ?  And of course the documentation I can find on this topic is 
out of date and refers to all manner of XC3 features which seem not to have a 
corollary in XC4…

I'm trying to set up a lightweight custom framework against which I can hang a 
plugin architecture ~ dynamic bundle loading. Where would you place such a 
framework ?  I have been targeting ~/Library/Frameworks for the moment, but 
suspect there is a scheme which would allow this to all be contained with the 
Application Support context for my app.  Clues ? 

~ Erik
___

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

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

NSPopUpButton not accepting setMenu: from WindowController code

2012-02-18 Thread Erik Stainsby

[myPUBtn setMenu:menu] accepted in MyAppDelegate but does not accept 
setMenu:menu when relocated to an NSWindowController.  I'm thinking there is 
something I have missed about the loading sequence.

When all the code resided in MyAppDelegate I could load a list of plugins, 
build a menu item for each, and call setMenu:menu on the instance of 
NSPopUpButton connected in IB to a reference in the delegate. The appDelegate 
was getting messy so I refactored this window out to a NSWindowController, call 
-[controller initWithWindowNibName:owner:]
and remade all the connections. Several times to be sure.

The passage of code which builds out the menu items successfully executes. 
NSLog(@"%@",menu) shows the content expected.
NSLog(@"%@",[myPUBtn menu])  logs (null).

When the popup menu was being successfully populated from the AppDelegate I was 
running the code which does this work from -(void) 
applicationWillFinishLaunching;  Now that it resides in the WC I have tried 
variously: -windowDidLoad, -windowWillLoad, -awakeFromNib (not invoked), and 
even tacking it directly onto the end of initWithWindowNibName:owner:  The 
results are the same: the log shows the menu built and the setMenu: statement 
fires, but the target control does not receive the new menu.

My assumption at the moment is that it is a sequence of loading issue: that the 
popup button isn't present yet (?) when 
the menu hand off fires.

Here's the relevant selection from the code:

~ Erik




@interface RSTrixieEditor : NSWindowController

@property (retain) IBOutlet NSPopUpButton * actionMenu;

@end


@implementation RSTrixieEditor

@synthesize actionMenu; // popup button

- (id)initWithWindowNibName:(NSString *)windowNibName owner:(id)owner {
self = [super initWithWindowNibName:windowNibName owner:owner];
if (self) {
[self setActionPlugins:[self loadPluginsWithPrefix:@"Action"]]; 
}
return self;
}


- (void)windowDidLoad
{
[super windowDidLoad];
NSMenu * menu = [[NSMenu alloc] init];

for(RSTrixiePlugin * p in actionPlugins)
{
NSMenuItem * menuItem = [[NSMenuItem alloc] initWithTitle:[p 
name] action:@selector(showActionPlugin:) keyEquivalent:@""];
[menuItem setRepresentedObject:p];
[menu addItem:menuItem];
NSLog(@"%s- [%04d] added action menu item for plugin: %@", 
__PRETTY_FUNCTION__, __LINE__, [p name]);
}
[actionMenu setMenu:menu];
NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, menu);   
// shows description of populated menu
NSLog(@"%s- [%04d] %lu", __PRETTY_FUNCTION__, __LINE__, [[menu 
itemArray] count]);  // returns 2
NSLog(@"%s- [%04d] %lu", __PRETTY_FUNCTION__, __LINE__, [[[actionMenu 
menu] itemArray] count]);  // returns 2
NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, [actionMenu 
menu]);  // (null)
[actionMenu setNeedsDisplay:YES];  // on a whim
}


[…]



___

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

Please do not post 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: NSPopUpButton not accepting setMenu: from WindowController code

2012-02-18 Thread Erik Stainsby
Michael gave me the clue. I still had the window's owner as AppDelegate. When I 
corrected that to the WindowController all is well.  Details details.

~ Erik

On 2012-02-18, at 9:55 AM, Keary Suska wrote:

> On Feb 18, 2012, at 8:37 AM, Erik Stainsby wrote:
> 
>> 
>> [myPUBtn setMenu:menu] accepted in MyAppDelegate but does not accept 
>> setMenu:menu when relocated to an NSWindowController.  I'm thinking there is 
>> something I have missed about the loading sequence.
> 
> When you call this method, what object do you pass as "owner"? Is the outlet 
> connected from the File's Owner, or an object in the same xib?
> 
>> - (id)initWithWindowNibName:(NSString *)windowNibName owner:(id)owner {
>>   self = [super initWithWindowNibName:windowNibName owner:owner];
>>   if (self) {
>>  [self setActionPlugins:[self loadPluginsWithPrefix:@"Action"]]; 
>>   }
>>   return self;
>> }
>> 
>> 
>> - (void)windowDidLoad
>> {
>>   [super windowDidLoad];
>>  NSMenu * menu = [[NSMenu alloc] init];
>> 
>>  for(RSTrixiePlugin * p in actionPlugins)
>>  {
>>  NSMenuItem * menuItem = [[NSMenuItem alloc] initWithTitle:[p 
>> name] action:@selector(showActionPlugin:) keyEquivalent:@""];
>>  [menuItem setRepresentedObject:p];
>>  [menu addItem:menuItem];
>>  NSLog(@"%s- [%04d] added action menu item for plugin: %@", 
>> __PRETTY_FUNCTION__, __LINE__, [p name]);
>>  }
>>  [actionMenu setMenu:menu];
>>  NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, menu);   
>> // shows description of populated menu
>>  NSLog(@"%s- [%04d] %lu", __PRETTY_FUNCTION__, __LINE__, [[menu 
>> itemArray] count]);  // returns 2
>>  NSLog(@"%s- [%04d] %lu", __PRETTY_FUNCTION__, __LINE__, [[[actionMenu 
>> menu] itemArray] count]);  // returns 2
>>  NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, [actionMenu 
>> menu]);  // (null)
>>  [actionMenu setNeedsDisplay:YES];  // on a whim
>> }
>> 
>> 
>> […]
>> 
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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%40esoteritech.com
>> 
>> This email sent to cocoa-...@esoteritech.com
> 
> 
> 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: [Obj-C] if (self) vs. if (self != nil)

2012-02-24 Thread Erik Stainsby
And what does the list feel about the following form (which I think I picked up 
from a Wil Shipley article):

if(nil != (self = [super init]))

Myself I find it elegantly brief and imminently readable. 


Time Dwarf,
Roaring Guy

On 2012-02-24, at 9:30 AM, David Duncan  wrote:

> On Feb 24, 2012, at 6:50 AM, Oleg Krupnov wrote:
> 
>> So basically, nil is of type "void*", so the expression "self != nil"
>> compares two pointers and the result is "boolean", which is perfect
>> for testing in the "if" statement. But the "self" alone is of type
>> "pointer" and so when it is tested by the "if" statement, it's
>> implicitly cast to the type "boolean".
> 
> In C any non-zero value is 'true', as such if (self) vs if (self != nil) is a 
> pure stylistic choice, neither is more correct than the other in terms of the 
> language itself.
> --
> David Duncan
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca

___

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

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

2012-02-28 Thread Erik Stainsby
Learning a new language makes me humble.

NSTableView - I have an NSTableViewDataSource with an array holding the objects 
to be represented in the table.
I add a new object to the array, I call [table reloadData]; and I follow that 
with [table setNeedsDisplay:YES];
Bupkiss. Nada.  However, when I tap a column header to resort the view, presto. 
Content.

What am I missing ?

- (void) appendRule:(NSNotification *) note {
RSTrixieRule * rule = [note object];
[_rules addObject: rule];
[table reloadData];
[table setNeedsDisplay:YES];
}




Erik Stainsby
erik.stain...@roaringsky.ca
-
Consistently place constants on the LHS of an expression: you cannot 
accidentally assign when you meant to compare.





___

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

Please do not post 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: How to: NSTableView redisplay

2012-02-28 Thread Erik Stainsby
My code:


#import 
#import 

@interface RSTrixieTable : NSWindowController < NSTableViewDataSource >

@property (retain) IBOutlet NSMutableArray * rules;
@property (retain) IBOutlet NSTableView * table;

- (void) appendRule:(NSNotification*)note;

- (NSInteger) numberOfRowsInTableView:(NSTableView *)aTableView;

@end


#import "RSTrixieTable.h"

@interface RSTrixieTable ()

@end

@implementation RSTrixieTable

@synthesize rules = _rules;
@synthesize table;

- (id)init
{
self = [super initWithWindowNibName:@"RSTrixieTable" owner:self];
if (self) {
NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, @"");

_rules = [[NSMutableArray alloc] init];

[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(appendRule:) name:nnRSTrixieStoreNewRuleNotification 
object:nil];
}

return self;
}


- (void)windowDidLoad
{
[super windowDidLoad];
}

- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView {
NSInteger ret = 0;
if([_rules count]) ret = [_rules count];
return ret;
}


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

RSTrixieRule * rule = [note object];
[_rules addObject: rule];
[table reloadData];
[table setNeedsDisplay:YES];
}

@end





Erik Stainsby
erik.stain...@roaringsky.ca
-
Consistently place constants on the LHS of an expression: you cannot 
accidentally assign when you meant to compare.




On 2012-02-28, at 9:50 PM, Brian Lambert wrote:

> Post your code.
> 
> On Tue, Feb 28, 2012 at 8:39 PM, Erik Stainsby  
> wrote:
> Learning a new language makes me humble.
> 
> NSTableView - I have an NSTableViewDataSource with an array holding the 
> objects to be represented in the table.
> I add a new object to the array, I call [table reloadData]; and I follow that 
> with [table setNeedsDisplay:YES];
> Bupkiss. Nada.  However, when I tap a column header to resort the view, 
> presto. Content.
> 
> What am I missing ?
> 
> - (void) appendRule:(NSNotification *) note {
>RSTrixieRule * rule = [note object];
>[_rules addObject: rule];
>[table reloadData];
>[table setNeedsDisplay:YES];
> }
> 
> 
> 
> 
> Erik Stainsby
> erik.stain...@roaringsky.ca
> -
> Consistently place constants on the LHS of an expression: you cannot 
> accidentally assign when you meant to compare.
> 
> 
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/brianlambert%40gmail.com
> 
> This email sent to brianlamb...@gmail.com
> 


___

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

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

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

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


Re: How to: NSTableView redisplay

2012-02-29 Thread Erik Stainsby
The  is connected to the nib. The  is not instantiated elsewhere. 
Content does show up after the table column headers are manipulated so the 
column defs are reasonable.  I'll give Jens' suggestion a try  but I have only 
seen the form below cited.  I'll remove the extraneous setNeedsDisplay: call;


Erik Stainsby
erik.stain...@roaringsky.ca
-
Consistently place constants on the LHS of an expression: you cannot 
accidentally assign when you meant to compare.



On 2012-02-29, at 12:25 AM, Graham Cox wrote:

> 
> On 29/02/2012, at 5:47 PM, Jens Alfke wrote:
> 
>> 
>> On Feb 28, 2012, at 8:39 PM, Erik Stainsby wrote:
>> 
>>> [_rules addObject: rule];
>>> [table reloadData];
>>> [table setNeedsDisplay:YES];
>> 
>> IIRC you need to call -noteNumberOfRowsChanged instead, if you've change the 
>> number of rows. -reloadData is just for reloading the existing rows.
> 
> 
> That's news to me - I've always just called -reloadData. I believe it queries 
> the rowCount, and then marks as needing redisplay those rows that are 
> visible. This might be less optimal that reloading only the changed rows, but 
> as far as I know, this has always worked fine for me.
> 
> Erik's code looks OK, but we don't know that the outlet  is actually 
> pointing to anything, or that it's pointing to the correct thing. That's what 
> I'd check first - set a breakpoint in appendRule: and have a look at it.
> 
> --Graham
> 
> 


___

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

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

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

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


Re: How to: NSTableView redisplay

2012-02-29 Thread Erik Stainsby
Supplemental:  the table only renders once. However many objects are in the 
_rules array are presented when any column header is activated. Then the table 
freezes up.  Additionally items can be added to the array; nothing more happens 
with the table view.


Erik Stainsby
erik.stain...@roaringsky.ca
-
Consistently place constants on the LHS of an expression: you cannot 
accidentally assign when you meant to compare.




On 2012-02-29, at 12:25 AM, Graham Cox wrote:

> 
> On 29/02/2012, at 5:47 PM, Jens Alfke wrote:
> 
>> 
>> On Feb 28, 2012, at 8:39 PM, Erik Stainsby wrote:
>> 
>>> [_rules addObject: rule];
>>> [table reloadData];
>>> [table setNeedsDisplay:YES];
>> 
>> IIRC you need to call -noteNumberOfRowsChanged instead, if you've change the 
>> number of rows. -reloadData is just for reloading the existing rows.
> 
> 
> That's news to me - I've always just called -reloadData. I believe it queries 
> the rowCount, and then marks as needing redisplay those rows that are 
> visible. This might be less optimal that reloading only the changed rows, but 
> as far as I know, this has always worked fine for me.
> 
> Erik's code looks OK, but we don't know that the outlet  is actually 
> pointing to anything, or that it's pointing to the correct thing. That's what 
> I'd check first - set a breakpoint in appendRule: and have a look at it.
> 
> --Graham
> 
> 


___

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

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

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

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


Re: NSURLRequests and Firewalls

2012-03-05 Thread Erik Stainsby
I think generally a firewall ought to return an http status code of 302 
redirected which you could probably key off for a login handler. 

Time Dwarf,
Roaring Guy

On 2012-03-05, at 11:21 AM, Alex Zavatone  wrote:

> I just found out why some JSON parsing was failing, the data returned from 
> the NSURLRequest was the HTML for our firewall authentication page.
> 
> Is there an established practice or set of documents on the iOS Dev Lib that 
> shows how to handle this?  I scanned the sample code and found nothing.  
> Searching teh googles for NSURL and firewall doesn't return much either.
> 
> Thanks in advance.
> - Alex Zavatone
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca

___

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

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


NSTableView update basics

2012-03-08 Thread Erik Stainsby
I have a tableView which will accept one new row and updates to that row 
succeed. Subsequent application of the same process does add new rowData 
dictionary objects to the tableData model (NSMutableArray) but the tableView 
will not display these additions.

A button on the UI is wired up to - (IBAction) addTableItem:(id)sender; and 
pops in the first row just fine. NSLog() messages have revealed that additional 
clicks on the button add new rows to the tableData array, but the UI does not 
respond to these events.

I'm pretty sure I'm missing something pretty basic here.


@interface MyClass : NSViewController < NSTableViewDataSource, 
NSTableViewDelegate >

@property (retain) IBOutlet NSTableView * tableView;
@property (retain) IBOutlet NSMutableArray * tableData;

- (IBAction) addTableItem:(id)sender;

@end

@implementation MyClass

@synthesize tableView;
@synthesize tableData;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
tableData = [NSMutableArray array];
}
return self;
} 


- (NSInteger) numberOfRowsInTableView:(NSTableView *)tableView {
return [tableData count] || 0;
}

- (id) tableView:(NSTableView *)tableView 
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
NSDictionary * rowData = [tableData objectAtIndex:row];
return [rowData valueForKey:[tableColumn identifier]];
}

- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject 
forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex {

NSMutableDictionary * rowData = [[tableData objectAtIndex:rowIndex] 
mutableCopy];
[rowData setValue:anObject forKey:[aTableColumn identifier]];
[tableData replaceObjectAtIndex:rowIndex withObject:rowData];
[tableView reloadData];
}

- (IBAction) addTableItem:(id)sender {
[tableData addObject:[NSDictionary 
dictionaryWithObjectsAndKeys:@"prop",@"property",@"val",@"value",nil]];
    [tableView reloadData];
}

@end




Erik Stainsby
erik.stain...@roaringsky.ca
-
Consistently place constants on the LHS of an expression: you cannot 
accidentally assign when you meant to compare.





___

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

Please do not post 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: NSTableView update basics

2012-03-09 Thread Erik Stainsby
A poorly thought out attempt to return the count or zero (I was writing a lot 
of perl the day I coded this). 

I recall reading that there is a race condition when *view*-based tables are 
loaded from nib. This does not obtain in my current case: this is a cell based 
table.  

I removed the errant || 0 and the table is behaving correctly. Thanks for 
proofing my code.


Erik Stainsby
erik.stain...@roaringsky.ca
-
Consistently place constants on the LHS of an expression: you cannot 
accidentally assign when you meant to compare.




On 2012-03-09, at 1:38 AM, Graham Cox wrote:

> 
> On 09/03/2012, at 4:42 PM, Erik Stainsby wrote:
> 
>> - (NSInteger) numberOfRowsInTableView:(NSTableView *)tableView {
>>  return [tableData count] || 0;
>> }
> 
> 
> What is the intention here? You are doing a boolean OR with the value zero, 
> which will promote (in fact demote) the return type to a BOOL. Whatever the 
> number of items, it will only ever return YES, or 1.
> 
> --Graham
> 


___

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

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

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

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


Re: Uncaught Exception: NSUnknownKeyException

2012-03-09 Thread Erik Stainsby
You can specify them in IB Don.

In the tree of XIB elements (under the Objects header) locate and select the 
Table Column element. I the Identity Inspector the second heading reads User 
Interface Item Identifier. Set this to the column id you wish to use in your 
code (the variable name perhaps).


Erik Stainsby
erik.stain...@roaringsky.ca
-
Consistently place constants on the LHS of an expression: you cannot 
accidentally assign when you meant to compare.




On 2012-03-09, at 1:32 PM, Donald Hall wrote:

> Thanks to Mike and Graham for the replies.
> 
> I think I figured out where the problem was. I am putting data into an 
> NSTableView, with one ivar from the Action class in each column. My original 
> project was so old that it used nibs instead of xibs, so I redid them all. In 
> the new Xcode there doesn't seem to be a way to specify the column identifier 
> for the xib in the Attributes Inspector, and I forgot about this, so each 
> column has an identifier of nil or null. I believe this explains the error 
> message. Here is the top part of the stack trace:
> 
>   0   CoreFoundation  0x918ded87 __raiseError + 231
>   1   libobjc.A.dylib 0x9b7f1149 objc_exception_throw 
> + 155
>   2   Foundation  0x9548bd78 
> -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 285
>   3   Foundation  0x953b1b97 
> _NSGetUsingKeyValueGetter + 39
>   4   Foundation  0x953b1b68 
> -[NSObject(NSKeyValueCoding) valueForKey:] + 406
>   5   Script Timer0x00014991 -[MyDocument 
> tableView:objectValueForTableColumn:row:] + 3249
>   6   AppKit  0x907c5c71 -[NSTableView 
> _dataSourceValueForColumn:row:] + 69
>   7   AppKit  0x907c55e7 -[NSTableView 
> preparedCellAtColumn:row:] + 420
>   8   AppKit  0x907d6c6c -[NSTableView 
> _drawContentsAtRow:column:withCellFrame:] + 50
> 
> It looks like I'll either have to specify the identifiers in code or 
> implement the new way to handle table columns using bindings. I will study 
> the "NSTableViewBinding" sample project.
> 
> Thanks again, Don
> 
> On 2012-03-09, at 2:35 AM, Graham Cox wrote:
> 
>> 
>> On 09/03/2012, at 5:57 PM, Donald Hall wrote:
>> 
>>> s class is not key value coding-compliant for the key (null).
>> 
>> 
>> The key is nil (null). So the problem is where the key is coming from, not 
>> the operation of the Action class.
>> 
>> --Graham
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca


___

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

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


NSPopover subview positioning issue

2012-03-17 Thread Erik Stainsby
I've got a popover controller which loads one of several subviews ('panels' 
below) as it's content. I have properties on the controller which expose the 
current panel's height and width.  The popover resizes correctly but fails to 
place the panel correctly.  If the replaceSubview:with: is called before the 
resize (as illustrated) the panel appears shifted down by half it's height, 
leaving half of the panel content inaccessible. If the -replaceSubview:with: 
call is placed after the resize, the inserted panel is half invisible off the 
top edge of the popover.

Does anyone understand what on earth is happening? And what I can do about it?


@implementation RSPanelPopoverController

@synthesize popover = _popover;
@synthesize box = _box;
@synthesize activePanelWidth;
@synthesize activePanelHeight;

- (void) showPanelPopover:(NSView*)locator activePanel:(NSView*)panel {

[[self view] replaceSubview:[self box] with:panel];

[self setActivePanelWidth: panel.frame.size.width];
[self setActivePanelHeight: panel.frame.size.height];

[[self popover] showRelativeToRect:[locator bounds] ofView:locator 
preferredEdge:NSMinYEdge];
}


Erik Stainsby
erik.stain...@roaringsky.ca
-
Consistently place constants on the LHS of an expression: you cannot 
accidentally assign when you meant to compare.





___

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

Please do not post 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: NSPopover subview positioning issue

2012-03-17 Thread Erik Stainsby
Hi Fritz,

The popover controller is a standard NSViewController which is also acting as 
the delegate for the popovers.
I guess I ought to have included the header as well before:

#import 

@interface RSPanelPopoverController : NSViewController < NSPopoverDelegate >

@property (weak) IBOutlet NSPopover * popover;
@property (weak) IBOutlet NSBox * box;
@property (assign) NSInteger activePanelWidth;
@property (assign) NSInteger activePanelHeight;

- (void) showPanelPopover:(NSView*)locator activePanel:(NSView*)panel;

@end


I have modified the showPanelPopover: method  thus:

- (void) showPanelPopover:(NSView*)locator activePanel:(NSView*)panel {

[self setActivePanelWidth: panel.frame.size.width];
[self setActivePanelHeight: panel.frame.size.height];
[panel setFrameOrigin: self.view.bounds.origin];// new 
line
[[self view] replaceSubview:[self box] with:panel];

[[self popover] showRelativeToRect:[locator bounds] ofView:locator 
preferredEdge:NSMinYEdge];
}

with the effect that the view is correctly placed within the popover ON SECOND 
VIEWING. The initial load is still rendered off-set by half the vertical 
dimension.




Erik Stainsby
erik.stain...@roaringsky.ca
-
Consistently place constants on the LHS of an expression: you cannot 
accidentally assign when you meant to compare.




On 2012-03-17, at 1:10 PM, Fritz Anderson wrote:

> On 17 Mar 2012, at 2:48 PM, Erik Stainsby wrote:
> 
>> I've got a popover controller which loads one of several subviews ('panels' 
>> below) as it's content. I have properties on the controller which expose the 
>> current panel's height and width.  The popover resizes correctly but fails 
>> to place the panel correctly.  If the replaceSubview:with: is called before 
>> the resize (as illustrated) the panel appears shifted down by half it's 
>> height, leaving half of the panel content inaccessible. If the 
>> -replaceSubview:with: call is placed after the resize, the inserted panel is 
>> half invisible off the top edge of the popover.
>> 
>> Does anyone understand what on earth is happening? And what I can do about 
>> it?
>> 
>> 
>> @implementation RSPanelPopoverController
>> 
>> @synthesize popover = _popover;
>> @synthesize box = _box;
>> @synthesize activePanelWidth;
>> @synthesize activePanelHeight;
>> 
>> - (void) showPanelPopover:(NSView*)locator activePanel:(NSView*)panel {
>>  
>>  [[self view] replaceSubview:[self box] with:panel];
>>  
>>  [self setActivePanelWidth: panel.frame.size.width];
>>  [self setActivePanelHeight: panel.frame.size.height];
>>  
>>  [[self popover] showRelativeToRect:[locator bounds] ofView:locator 
>> preferredEdge:NSMinYEdge];
>> }
> 
> I'm not clear on a few things. It appears that the "panel" frame is offset 
> one way or the other, but I don't see the frame being set, nor the panel 
> being translated. You say that the order of setActivePanel…: matters, but you 
> don't show that the methods (odd, but not wrong, that you don't use dot 
> notation) do anything but change the value of an instance variable. If they 
> actually change view geometry, you'll have to show us.
> 
> What class does RSPanelPopoverController descend from?
> 
> What is .box? (It appears that it can be replaced only once.) Have you logged 
> the frames of .box, .view, and panel, before and after the replacement? And 
> .view.bounds?
> 
>   — F
> 


___

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

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

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

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

Re: Placing Cells in an NSMatrix

2012-04-04 Thread Erik Stainsby
Small bit if knowledge to share. The stroke of the border is drawn centred over 
the line of the border. So your described 4pt line would intrude 2pts into the 
bounded area. I'm know if that will help any with understanding the 
left-shifting you have observed.

Erik Stainsby
erik.stain...@roaringsky.ca
-
Consistently place constants on the LHS of an expression: you cannot 
accidentally assign when you meant to compare.




On 2012-04-04, at 9:04 PM, Peter Teeson wrote:

> On 2012-04-04, at 6:52 PM, Peter Teeson wrote:
>> On 2012-04-04, at 5:02 PM, Fritz Anderson wrote:
>>> On 4 Apr 2012, at 2:20 PM, Peter Teeson wrote:
>>>> Given a 3 x 3 Matrix which is a sub-class of NSMatrix with Cells 
>>>> sub-classed from NSButton 
>>>> the X origins of column 0 cells seem to be 1.0 point inside the Matrix 
>>>> bounds.
>>>> 
>>>> So if I want to stroke the Matrix bounds with a line width of e.g. 4.0 
>>>> points
>>>> it draws over the left area of the column 0 cells.
>>>> 
>>>> Hence I would like to make sure that the origins of the cells are where I 
>>>> want them to be, i.e. leave enough room to stroke the Matrix bounds.
>>>> 
>>>> I've read Matrix Programming Guide and looked at the NSMatrix and NSCell
>>>> references but I do not understand which methods to use to accomplish this.
>>>> 
>>>> Should I do this in NSCell calcDrawInfo? And then does that mean for each 
>>>> Cell?
>>>> Surely there must be simple way to provide a frame for all the Cells inset 
>>>> from the bounds of the Matrix.
>>>> 
>>>> Nor can I find a way to do this in Interface Builder.
>>>> AutoLayout is checked but Automatically Resizes Cells is not.
>>> 
>>> I read the NSMatrix class reference to say that NSMatrix enforces its frame 
>>> being the hull of the cells plus the intercell spacing. You won't 
>>> accomplish you want, in the way you propose, without fighting the framework.
>>> 
>>> Why not embed the matrix in a view of your own? You can then draw whatever 
>>> you like around it.
>> Thanks for your thought. 
>> But the strange thing is that my experiments show that there is in fact an 
>> spacing on the top, right, and bottom 
>> of the area between the cells and the matrix bounds. But not on the left 
>> side!!
>> 
>> I would expect there to be equal spacing all around. I have confirmed this 
>> by reducing the size of the cells (setCellSize) 
>> and the area between the cells and the Matrix bounds adjusts appropriately 
>> except for the left edge.
>> 
>> Something I do not understand is going on here that I do not find logical.
>> 
>> Peter
> In Lion there are new methods related to constraints (in NSLayoutConstraint.h 
> -alignmentRectForFrame and -frameForAlignmentRect) that might be applicable 
> to my query.
> Also in XCode in the xib Size inspector for the Matrix the View section it 
> shows Frame Rectangle or Layout Rectangle. But changing the X value of one 
> changes it in the other.
> Looks like I may have to override the above methods as suggested in the 
> reference. Anyone done this and used these and can point at example code or 
> more documentation?
> 
> But these were only added in Lion so how was it done previously (if at all)?
> 
> Peter
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca


___

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

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


Responder chain inclarity

2012-04-15 Thread Erik Stainsby
I'm having responder chain headaches.  Here's my stack of objects:

RSWindow with custom - sendEvent: to capture and handle with trackingRect for 
webView mouse activity.

When the user clicks I create a viewController and add the view as a subview to 
the RSWindow.
The viewController provides - deleteLocator: which invokes [[self view] 
removeFromSuperview]. 

A right click on a subview opens a context menu with two options: Edit or 
Delete. Delete should remove the subview from the RSWindow.

My issue is with wiring up the menu to the NSResponder chain. When I connect 
the Delete menu item to the FirstReponder action in IB the event never fires. 
If I connect the Delete button directly to the viewController's deleteLocator: 
action outlet the event gets hung up in the RSWindow sendEvent:  else { [super 
sendEvent:theEvent] } .

Here is a partial of the NSLog dump:

2012-04-15 12:57:59.705 Trixie[5098:503] -[RSAppDelegate init]- [0019] 
2012-04-15 12:58:04.299 Trixie[5098:503] -[NSCarbonMenuImpl deleteLocator:]: 
unrecognized selector sent to instance 0x7f837d2b22a0
2012-04-15 12:58:04.300 Trixie[5098:503] An uncaught exception was raised
2012-04-15 12:58:04.300 Trixie[5098:503] -[NSCarbonMenuImpl deleteLocator:]: 
unrecognized selector sent to instance 0x7f837d2b22a0
2012-04-15 12:58:04.302 Trixie[5098:503] (
0   CoreFoundation  0x7fff93220f56 
__exceptionPreprocess + 198
1   libobjc.A.dylib 0x7fff867d1d5e 
objc_exception_throw + 43
2   CoreFoundation  0x7fff932ad1be -[NSObject 
doesNotRecognizeSelector:] + 190
3   CoreFoundation  0x7fff9320de23 
___forwarding___ + 371
4   CoreFoundation  0x7fff9320dc38 
_CF_forwarding_prep_0 + 232
5   CoreFoundation  0x7fff9321070d -[NSObject 
performSelector:withObject:] + 61
6   AppKit  0x7fff8ae20ffa 
-[NSApplication sendAction:to:from:] + 139
7   AppKit  0x7fff8af0e323 -[NSMenuItem 
_corePerformAction] + 399
8   AppKit  0x7fff8af0e05a 
-[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 125
9   AppKit  0x7fff8b1ad4d4 -[NSMenu 
_internalPerformActionForItemAtIndex:] + 38
10  AppKit  0x7fff8b03c1bd 
-[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 138
11  AppKit  0x7fff8ae87e93 
NSSLMMenuEventHandler + 339
12  HIToolbox   0x7fff88564478 
_ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec 
+ 1263
13  HIToolbox   0x7fff88563a84 
_ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec
 + 446
14  HIToolbox   0x7fff8857a923 
SendEventToEventTarget + 76
15  HIToolbox   0x7fff885c09c5 
_ZL18SendHICommandEventjPK9HICommandjjhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef
 + 398
16  HIToolbox   0x7fff886a8035 
SendMenuCommandWithContextAndModifiers + 56
17  HIToolbox   0x7fff886ef7a9 
SendMenuItemSelectedEvent + 253



Clearly I am misunderstanding some aspect of the menu-to-Respnder chain setup.  
Any thoughts?

It occurs to me I may be trying to remove the viewController from within the 
viewController - a lifting-by-the-bootstraps problem ?  Should I make the 
RSWindow do the removal/deletion ? Or AppDelegate ?



Erik Stainsby
erik.stain...@roaringsky.ca




___

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

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


Redrawing overlay views

2012-04-24 Thread Erik Stainsby
I have a window which owns a webview over which I place buttons (in their own 
subviews) where the user has clicked.  However, because they are not part of 
the webview's hierarchy of objects, when the window is resized the webview 
content will likely reflow. I therefore need to reposition the buttons. I have 
methods which annotate the DOM and which cache references to the nodes the user 
has selected.  I am thinking to walk the cache of nodes and redraw the button's 
views at the new location of the corresponding DOM element. I am halfway 
through implementing this strategy but would be interested to hear other 
opinions of how this might be achieved.

Below is some of the code I have in the works which responds to the window's 
windowDidResizeNotification in the windowController and instructs the webView 
to walk the cache of user-selected DOM nodes.   At present I cannot seem to 
recall the DOM nodes from the dictionary in which the code caches them.


#import 
#import 
#import "RSWebView.h"

//
//  this controller is both windowController and webview frameLoadDelegate

@interface RSTrixieController : NSWindowController < NSComboBoxDataSource, 
NSComboBoxDelegate >

@property (retain) IBOutlet RSWebView * webview;

- (void) refreshWebviewOverlay:(NSNotification*)nota;

@end


@implementation

@synthesize webview;

- (void)windowDidLoad
{
[super windowDidLoad];

[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(refreshWebviewOverlay:) name:NSWindowDidResizeNotification 
object:[webview window]];
}

- (void) refreshWebviewOverlay:(NSNotification*)nota {
[[self webview] repositionLocatorViews];
}

[…]

@end



Then from the webView which responds:


@implementation

@synthesize boundingBox;// trivial view which draws it's outline
@synthesize locators;   // mutable dict - button-hosting views - 
keyed-alike to taggedNodes
@synthesize taggedNodes;// mutable dict - DOMElements adjacent - 
keyed-alike to locators


- (void) repositionLocatorViews {

// clean up
[self removeBoundingBox];

for(NSString * idtag in [taggedNodes allKeys]) 
{   
DOMElement * node = [taggedNodes objectForKey:idtag];
RSBoundingBox * bbox = [[RSBoundingBox alloc] 
initWithFrame:[node boundingBox]];
NSRect newBox = [self flipBoundingBox:[bbox frame] 
fromWebView:self];
[bbox setFrame:newBox];
RSLocatorViewController * lv = [locators objectForKey:idtag];
[[lv view]setFrame: [self frameRelativeTo:bbox]];
}
} 


- (NSRect) flipBoundingBox:(NSRect)htmlBox fromWebView:(WebView*)webView {
NSRect bounds = [[[webView window] contentView] bounds];
float newY = bounds.size.height - htmlBox.size.height - 
htmlBox.origin.y;
return NSMakeRect(htmlBox.origin.x,newY,htmlBox.size.width, 
htmlBox.size.height);
}


- (NSRect) frameRelativeTo:(RSBoundingBox*)bbox {
return NSMakeRect(bbox.frame.origin.x-20, bbox.frame.origin.y + 
bbox.frame.size.height - 20, 20, 20);
}


- (void) removeBoundingBox {
if(nil != boundingBox)
{
[boundingBox removeFromSuperview];
boundingBox = nil;
}
}

[ … ]


Any thoughts and suggestions welcomed.


Erik Stainsby
erik.stain...@roaringsky.ca

___

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

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

NSPopover ~ resize to match content?

2012-04-24 Thread Erik Stainsby

I'm trying to make a popover view resize to fit the content-of-the-moment.  
This is probably trivial and I have being over thinking myself into 
complications.

I have three classes of information to display in turn in a popover. The user 
clicks a segment control to advance and may return if she wishes.  My window 
xib contains the popover view and three differently sized 'client' views which 
are swapped in as needed. Great, works like a charm.

However I cannot for the life of me cause the popover 'host' view to resize. 
When I dump the dimensions to NSLog the outer view frame reports the correct 
(resized as I specified) dims. but the popover has not been resized. The 
numbers do not match the picture.

What am I missing?  Some code:



- (void) showPanel:(NSView*)panel {
// guard
if(!panel) panel = actionPanel; 

[self setActivePanelWidth: panel.frame.size.width];
[self setActivePanelHeight: panel.frame.size.height];

NSLog(@"%s- [%04d] %@: %0.2f", __PRETTY_FUNCTION__, __LINE__, [panel 
className], panel.frame.size.height);

NSRect newFrameSize = self.view.frame;
newFrameSize.size.height = popoverHeader.frame.size.height + 
activePanelHeight;

NSLog(@"%s- [%04d] %@: %0.2f", __PRETTY_FUNCTION__, __LINE__, 
[self.view className], self.view.frame.size.height);

[[self view] setFrame:newFrameSize];
if( currentPanel == nil) 
{
[[self view] replaceSubview:[self placeholderBox] with: panel];
}
else {

[[self view] replaceSubview:currentPanel with: panel];
}
// a custom category on NSView
[panel setFrameTopLeftPoint: popoverHeader.frame.origin];

currentPanel = panel;
[locator setCurrentPanel: panel];

[popover showRelativeToRect:[locator bounds] ofView:locator 
preferredEdge:NSMaxXEdge];
}



Any help appreciated. Thanks.


Erik Stainsby
erik.stain...@roaringsky.ca
-





___

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

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

2012-04-24 Thread Erik Stainsby
The menu portion of a combo box is just that an NSMenu so you ought to be able 
to everything you can with  a regular menu item.

Erik


On 2012-04-23, at 5:53 PM, koko wrote:

> I have been spelunking all afternoon with mixed results.  Some say I can put 
> an image and text in an NSComboBoxCell.
> 
> Can this be done … put an image and text in an NSComboBoxCell?
> 
> I can find no examples and would appreciate one if possible.
> 
> -koko
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca


___

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

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

2012-05-10 Thread Erik Stainsby
I have had this happen when I have forgotten to declare my action method in the 
public header.


Erik Stainsby
erik.stain...@roaringsky.ca
-




On 2012-05-10, at 4:24 PM, koko wrote:

> I have a menu item connected to an action in First Responder;
> 
> The action exists in an NSView subclass.
> 
> The subclass implements acceptsFirstResonder and return YES.
> 
> The subclass implements validateMenuItem and return YES;
> 
> When the menu displays the menu item is disabled (set to enabled in IB).
> 
> Is this not the proper implementation?
> 
> -koko
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca


___

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

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

2012-05-10 Thread Erik Stainsby
Could you please paste the a copy of the method in a message? It is far easier 
to help you debug code which we can see than a description of something we 
cannot see.


Erik Stainsby
erik.stain...@roaringsky.ca
-




On 2012-05-10, at 5:07 PM, koko wrote:

> 
> On May 10, 2012, at 6:05 PM, Erik Stainsby wrote:
> 
>> I have had this happen when I have forgotten to declare my action method in 
>> the public header.
> 
> The action is declared in the subclass header.
> 
> 


___

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

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

2012-06-06 Thread Erik Stainsby
I think the approach you would use is to employ -[NSWorkspace] to launch the 
other app on your behalf.



Sent from my iPad

On 2012-06-06, at 1:58 PM, koko  wrote:

> Is it possible to call a method in an app that is not running causing it to 
> load?
> 
> -koko
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca

___

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

Please do not post 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: Lion permission problems

2012-06-23 Thread Erik Stainsby
So if I understand your pattern, you are managing a single "product PDF" which 
is constructed by your app based upon metadata which describes the specific 
component PDFs etc that the user has chosen. Those component PDFs reside 
elsewhere than within your app space, correct? 



On 2012-06-23, at 1:26 PM, Matthew Weinstein  wrote:

> Unfortunately that  undoes the automation idea. The time saving here is that 
> by just re-saving the pdf, the app when the document is opened recombines it 
> based upon the rules that the user set up. Basically you're forcing the user 
> to recreate the sequence of files each time anew. 
> 
> On Jun 23, 2012, at 1:22 PM, Kyle Sluder wrote:
> 
>> On Jun 23, 2012, at 1:16 PM, Matthew Weinstein  wrote:
>> 
>>> The whole idea of the app is so that users can automate the combining of 
>>> different PDFs; users should be able to swap out different pdfs and then 
>>> the program will recombine them. The program remembers (saves in a wrapper) 
>>> the pdfs that have been combined. Sort of defeats the purpose if the users 
>>> can't substitute say this year's calendar for last year's.
>> 
>> So your app's workflow relies on the user understanding and manipulating the 
>> filesystem? Apple seem to be encouraging developers to provide interfaces 
>> that don't require specific filesystem layouts. In other words, you control 
>> the filesystem under your container (which the user should never see) and 
>> the user controls the filesystem everywhere else (the layout of which your 
>> program should not rely on).
>> 
>> Instead of requiring the user to replace the files using Finder, can they 
>> just replace the files using your app? You would keep the source PDFs and 
>> all the combined results inside your document wrapper.
>> 
>> --Kyle Sluder
>> 
>>> 
>>> On Jun 23, 2012, at 1:12 PM, Kyle Sluder wrote:
>>> 
 On Jun 23, 2012, at 12:09 PM, Matthew Weinstein  wrote:
 
> I think the temp.security thing will work, but I'm wondering what happens 
> if a user replaces a file in the directory by one with the same name; 
> does the os know it's not the original file?
 
 Security scoped bookmarks are attached to the file itself, so if the file 
 is replaced you will not be able to access the new file that exists at 
 that path.
 
 May I ask what motivated you to choose a project-oriented document 
 structure (components located outside the document itself) rather than a 
 compound document structure (PDFs copied or moved into your doc bundle)?
 
 --Kyle Sluder
 
> 
> On Jun 23, 2012, at 9:53 AM, Alex Zavatone wrote:
> 
>> From what I have read in the docs, accessing files outside of the 
>> approved areas/domains (music, photos, documents(?) ) will ALWAYS 
>> require user interaction.
>> 
>> Apple is really screwing us in this one.
>> 
>> I hope that Conrad is right with his suggestion.
>> 
>> On Jun 23, 2012, at 12:17 PM, Matthew Weinstein wrote:
>> 
>>> Dear cocoa-dev,
>>> So I'm wondering how in the maze of sandboxed apps how to get my app to 
>>> work properly. What it does is wrap around pdf files so that they can 
>>> be combined, separated; etc. It doesn't actually change the original 
>>> pdfs, just remembers their locations, reads them in and then writes to 
>>> a different pdf (as the user requests). 
>>> 
>>> In addition it opens a specific  wrapper on launch which contains 
>>> standard elements that a user might want to add to their pdf (blank 
>>> pages, etc.). The file is just a typical file that the program creates, 
>>> stored at a location provided by the user, so that they can add their 
>>> own elements to this wrapper. 
>>> 
>>> The first time the program is run, it doesn't find this special 
>>> wrapper, asks the user where they want it it, they pick a spot (home or 
>>> documents), the program creates a directory, copies the needed files 
>>> out of its bundle,  it opens the file, and all is well, the elements 
>>> from the "fixings" wrapper appear in a menu on the menu bar. 
>>> 
>>> However, the second time the program is run, i.e., once the files have 
>>> been put in place and I try to access them,  I get a "257" error on 
>>> [[NSDocumentController sharedDocumentController] 
>>> openDocumentWithContentsOfURL: myurl display: YES error: &err]; Which 
>>> seems to mean I don't have permission...
>>> 
>>> It doesn't matter where the user saves the file; I get the 257 error. I 
>>> did all of this because when I created the directory using the 
>>> NSHomeDirectoryForUser(NSUserName()) and submitted the application, 
>>> Apple complained and said I needed to ask the user where to put it; but 
>>> if I do I get a 257 subsequent times the program is run.
>>> 
>>> Any ideas on how to do this or get beyond the error code?
>>> 
>>>

Is this an incorrect use of categories ?

2012-07-05 Thread Erik Stainsby
   if([rule hasDelayField])[self.delayField
setStringValue:rule.delayField];
if([rule hasPeriodField])   [self.periodField   
setStringValue:rule.periodField];
if([rule hasOpacityField])  [self.opacityField  
setStringValue:rule.opacityField];
if([rule hasEasingField])   [self.easingField   
setStringValue:rule.easingField];
if([rule hasCallbackField]) [self.callbackField 
setStringValue:rule.callbackField];
}

@end

---

End of message.

Erik Stainsby.
___

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

Please do not post 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 this an incorrect use of categories ?

2012-07-05 Thread Erik Stainsby
Thanks for the reply Graham.

The categories are loaded in a window controller which serves as the context 
for the plugins. The plugins are loaded with a convenience method from my 
framework, which uses NSBundle loading techniques.

Is it sufficient that the categories be loaded in the windowController code? Or 
do they need to be available in the framework context in which the plugins are 
actually loaded from nib?  That is, my categories are being added in the app 
not in the framework.


RSRuleWindowController.m:

#import "RSRuleWindowController.h"
#import "NSView+RSPositionView.h"
#import "DOMElement+RSLDOMExtensions.h"

#import "RSActionRule+RSActionRuleFromPlugin.h"
#import "RSFilterRule+RSFilterRuleFromPlugin.h"
#import "RSReactionRule+RSReactionRuleFromPlugin.h"

#import "RSActionPlugin+RSActionPluginFromRule.h"
#import "RSFilterPlugin+RSFilterPluginFromRule.h"
#import "RSReactionPlugin+RSReactionPluginFromRule.h"

@implementation RSRuleWindowController 

- (id)  init {
self = [super initWithWindowNibName:@"RSRuleWindow"];
if (self) {
_rules = [NSMutableDictionary dictionary];

RSTrixieLoader *loader = [[RSTrixieLoader alloc] init];

self.actionPlugins  = [loader 
loadPluginsWithPrefix:@"Action" ofType:@"bundle"];
self.filterPlugins  = [loader 
loadPluginsWithPrefix:@"Filter" ofType:@"bundle"];
self.reactionPlugins= [loader 
loadPluginsWithPrefix:@"Reaction" ofType:@"bundle"];
    loader = nil;
}
return self;
} 

[…]

@end





On 2012-07-05, at 8:23 PM, Graham Cox  wrote:

> 
> On 06/07/2012, at 12:50 PM, Erik Stainsby wrote:
> 
>> However, I am getting an   "unrecognized selector sent to instance 
>> 0xyaddayadda" when I try to run this. I know the selector does exist, so I 
>> must have a scoping issue (?)
> 
> 
> At run-time, if the target object implements the selector (whether in a 
> category or otherwise), you won't get this message. So, the target object is 
> either not what you think it is, or the category wasn't attached.
> 
> If the selector is supplied by a category, then the category must have been 
> loaded in order to be attached to the class. If that category is implemented 
> by the plug-in, you must have loaded and linked the plug-in before calling 
> the method, so if that's the case I'd be looking at where and how you are 
> doing this - usually you use the methods of the NSBundle class to load your 
> plug-in. e.g. -loadAndReturnError:
> 
> It's not that clear from what you posted where the category is defined and 
> implemented - in your app or in the plug-in.
> 
> 
> --Graham
> 
> 


___

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

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

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

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

Re: Is this an incorrect use of categories ?

2012-07-06 Thread Erik Stainsby


On 2012-07-06, at 12:46 PM, Greg Parker  wrote:

> On Jul 5, 2012, at 7:50 PM, Erik Stainsby  wrote:
>> My project employs a framework which loads several plugins. When the user 
>> interacts with these plugins s/he generates an intermediate abstraction of 
>> the plugin contents which I refer to as a rule. The rule abstraction exists 
>> to facilitate round-tripping back to the plugin of origin or onward to the 
>> rendered product. 
>> 
>> I am currently stuck in the stage of migrating the data from the plugin to a 
>> newly created rule instance.  I hit on the notion of using categories to 
>> shuffle the values from the plugin instance to the rule instance and vice 
>> versa. Two small dedicated categories for each plugin family (I have three 
>> families at the moment). Seems a manageable scheme.  However, I am getting 
>> an   "unrecognized selector sent to instance 0xyaddayadda" when I try to run 
>> this. I know the selector does exist, so I must have a scoping issue (?)
> 
> What exactly is the unrecognized selector message you get?
> 


2012-07-04 20:43:50.180 Trixie[422:303] -[RSLocatorView requestPopover:]- 
[0098] 
2012-07-04 20:44:02.980 Trixie[422:303] 
-[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:]- [0015] 
plugin.action: addClass
2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
unrecognized selector sent to instance 0x101833fe0
2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
unrecognized selector sent to instance 0x101833fe0
2012-07-04 20:44:02.983 Trixie[422:303] (
0   CoreFoundation  0x7fff90996716 
__exceptionPreprocess + 198
1   libobjc.A.dylib 0x7fff8c97c470 
objc_exception_throw + 43
2   CoreFoundation  0x7fff90a2cd5a 
-[NSObject(NSObject) doesNotRecognizeSelector:] + 186
3   CoreFoundation  0x7fff90984c3e 
___forwarding___ + 414
4   CoreFoundation  0x7fff90984a28 
_CF_forwarding_prep_0 + 232
5   Trixie  0x0001cf81 
-[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:] + 177
6   Trixie  0x0001b6d9 
-[RSRuleWindowController addRuleToStore:] + 249
7   AppKit  0x7fff91589599 
-[NSApplication sendAction:to:from:] + 342
8   AppKit  0x7fff915893f7 -[NSControl 
sendAction:to:] + 85
9   AppKit  0x7fff9158932b -[NSCell 
_sendActionFrom:] + 138
10  AppKit  0x7fff91587813 -[NSCell 
trackMouse:inRect:ofView:untilMouseUp:] + 1855
11  AppKit  0x7fff91587061 
-[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504
12  AppKit  0x7fff915867dc -[NSControl 
mouseDown:] + 820
13  AppKit  0x7fff9157e13e -[NSWindow 
sendEvent:] + 6853
14  AppKit  0x7fff9157a274 
-[NSApplication sendEvent:] + 5761
15  AppKit  0x7fff9148feaa 
-[NSApplication run] + 636
16  AppKit  0x7fff91434886 
NSApplicationMain + 869
17  Trixie  0x00011b12 main + 34
18  libdyld.dylib   0x7fff8f9e27e1 start + 0
)



> Are there any static libraries involved in your build process? Categories 
> compiled into static libraries require special treatment.
> -- 
> Greg Parker gpar...@apple.com Runtime Wrangler
> 

I am only using the home-built loader framework as mentioned.  No other 
external-to-Cocoa libs.

I opted to use categories in this case to avoid having to directly modify my 
framework. But if there is as Graham suggested a load order issue, I might be 
better off implementing the method natively in the framework. I pretty much 
have the code already in the categories. :D

Erik



___

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

Please do not post 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 this an incorrect use of categories ?

2012-07-06 Thread Erik Stainsby
On 2012-07-06, at 5:11 PM, Greg Parker  wrote:

> On Jul 6, 2012, at 4:48 PM, Erik Stainsby  wrote:
>> 2012-07-04 20:44:02.980 Trixie[422:303] 
>> -[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:]- [0015] 
>> plugin.action: addClass
>> 2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
>> unrecognized selector sent to instance 0x101833fe0
> 
> How is -[RSReactionRule setAction:] implemented? It wasn't in your quoted 
> categories.

Actually it was part of my first post: it is declared 

@property (retain) action; 
@synthesize action=_action; 

~ as implemented in the RSReactionRule.   It is invoked in the category, as:  
[self setAction: plugin.action]; 





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


___

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

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

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

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


Re: Is this an incorrect use of categories ?

2012-07-06 Thread Erik Stainsby


On 2012-07-06, at 5:28 PM, Erik Stainsby  wrote:

> On 2012-07-06, at 5:11 PM, Greg Parker  wrote:
> 
>> On Jul 6, 2012, at 4:48 PM, Erik Stainsby  
>> wrote:
>>> 2012-07-04 20:44:02.980 Trixie[422:303] 
>>> -[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:]- [0015] 
>>> plugin.action: addClass
>>> 2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
>>> unrecognized selector sent to instance 0x101833fe0
>> 
>> How is -[RSReactionRule setAction:] implemented? It wasn't in your quoted 
>> categories.
> 
> Actually it was part of my first post: it is declared 
> 
> @property (retain) action; 

Check that:  
@property (retain) NSString * action;


> @synthesize action=_action; 
> 
> ~ as implemented in the RSReactionRule.   It is invoked in the category, as:  
> [self setAction: plugin.action]; 
> 
> 
> 
> 
> 
>> -- 
>> Greg Parker gpar...@apple.com Runtime Wrangler
>> 
>> 
> 


___

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

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

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

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


Re: Is this an incorrect use of categories ?

2012-07-06 Thread Erik Stainsby


On 2012-07-06, at 5:13 PM, Alex Zavatone  wrote:

> OK.  I'm not sure what I ran into is related, but maybe it is.  
> 
> If you can isolate the line of code before the crash, can you check and NSLog 
> the string value of the selector being sent and see if it matches the 
> selectors on the object?
> 
> GL.

The selector name is reported in the error message, and the method is declared 
as a @property/@synthesize so I have no reason to doubt that they match up.

I have in troubleshooting this hand coded the setter/getter and removed the 
property decl. With nil difference in the result. Still not recognized.   Which 
is why I started to think about scope issues.


> 
> On Jul 6, 2012, at 7:48 PM, Erik Stainsby wrote:
> 
>> 
>> 
>> On 2012-07-06, at 12:46 PM, Greg Parker  wrote:
>> 
>>> On Jul 5, 2012, at 7:50 PM, Erik Stainsby  
>>> wrote:
>>>> My project employs a framework which loads several plugins. When the user 
>>>> interacts with these plugins s/he generates an intermediate abstraction of 
>>>> the plugin contents which I refer to as a rule. The rule abstraction 
>>>> exists to facilitate round-tripping back to the plugin of origin or onward 
>>>> to the rendered product. 
>>>> 
>>>> I am currently stuck in the stage of migrating the data from the plugin to 
>>>> a newly created rule instance.  I hit on the notion of using categories to 
>>>> shuffle the values from the plugin instance to the rule instance and vice 
>>>> versa. Two small dedicated categories for each plugin family (I have three 
>>>> families at the moment). Seems a manageable scheme.  However, I am getting 
>>>> an   "unrecognized selector sent to instance 0xyaddayadda" when I try to 
>>>> run this. I know the selector does exist, so I must have a scoping issue 
>>>> (?)
>>> 
>>> What exactly is the unrecognized selector message you get?
>>> 
>> 
>> 
>> 2012-07-04 20:43:50.180 Trixie[422:303] -[RSLocatorView requestPopover:]- 
>> [0098] 
>> 2012-07-04 20:44:02.980 Trixie[422:303] 
>> -[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:]- [0015] 
>> plugin.action: addClass
>> 2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
>> unrecognized selector sent to instance 0x101833fe0
>> 2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
>> unrecognized selector sent to instance 0x101833fe0
>> 2012-07-04 20:44:02.983 Trixie[422:303] (
>>  0   CoreFoundation  0x7fff90996716 
>> __exceptionPreprocess + 198
>>  1   libobjc.A.dylib 0x7fff8c97c470 
>> objc_exception_throw + 43
>>  2   CoreFoundation  0x7fff90a2cd5a 
>> -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
>>  3   CoreFoundation  0x7fff90984c3e 
>> ___forwarding___ + 414
>>  4   CoreFoundation  0x7fff90984a28 
>> _CF_forwarding_prep_0 + 232
>>  5   Trixie  0x0001cf81 
>> -[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:] + 177
>>  6   Trixie  0x0001b6d9 
>> -[RSRuleWindowController addRuleToStore:] + 249
>>  7   AppKit  0x7fff91589599 
>> -[NSApplication sendAction:to:from:] + 342
>>  8   AppKit  0x7fff915893f7 -[NSControl 
>> sendAction:to:] + 85
>>  9   AppKit  0x7fff9158932b -[NSCell 
>> _sendActionFrom:] + 138
>>  10  AppKit  0x7fff91587813 -[NSCell 
>> trackMouse:inRect:ofView:untilMouseUp:] + 1855
>>  11  AppKit  0x7fff91587061 
>> -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504
>>  12  AppKit  0x7fff915867dc -[NSControl 
>> mouseDown:] + 820
>>  13  AppKit  0x7fff9157e13e -[NSWindow 
>> sendEvent:] + 6853
>>  14  AppKit  0x7fff9157a274 
>> -[NSApplication sendEvent:] + 5761
>>  15  AppKit  0x7fff9148feaa 
>> -[NSApplication run] + 636
>>  16  AppKit  0x7fff91434886 
>> NSApplicationMain + 869
>>  17  Trixie  0x00011b12 main + 34
>>  18  libdyld.dylib   0x7fff8f9e27e1 start + 0
>> )
>> 
>

Avoiding cyclic header imports

2012-07-10 Thread Erik Stainsby
I have two classes, and a model object - RSPlugin, RSExpression, and RSRule - 
which share the same data model.
I have thought to have the classes provide a method which can be used to 
initialize the RSRule object so:

RSRule * rule = [[RSRule alloc] init];
[rule loadFromPlugin: currentPlugin];

where -[RSRule loadFromPlugin:] copies the values to the rule. This requires 
however that RSRule #imports the RSPlugin header.

I also would like to maintain symmetry by having RSPlugin import the values of 
RSRule, for purposes of round-tripping to the UI (plugin reps the UI for a rule 
instance).  Obviously, this would require RSPlugin to #import RSRule's header.  
Xcode doesn't like this one bit.

The same sort of reciprocal data-swapping interface would be wanted for the 
RSExpression side of the chain.

I imagine this is such a commonplace sort of relationship that there must be a 
standard approach (or perhaps several approaches) to solving it.  My first stab 
at it was to try and provide the interfaces as categories but I ran into a 
similar issue with circular imports.

Anyone got a pointer to a Comp Sci 101 style description of how to avoid this?  
Thanks for your time.

~ Erik
___

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

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


Instance not responding to selector

2012-07-10 Thread Erik Stainsby
I have a set of plugins which I load via a custom framework.  The plugins load 
and behave correctly in the UI. 

I have a set of corresponding "rule" objects, one for each class of plugin. A 
plugin may load data from a rule, and a rule may load data from a plugin:  
-[RSRule loadFromPlugin:(RSPlugin*)plugin]  or -[RSPlugin 
loadFromRule:(RSRule*)rule].  I have moved away from using categories to do 
this and the classes implement these methods internally.  The header files list 
the methods correctly.

However, after a clean and build, attempting to invoke any of these 
-[loadFrom..:] methods causes a crash reporting "unrecognized selector".

A typical error message:

2012-07-10 20:42:39.791 Trixie[41453:303] -[RSReactionRule loadFromPlugin:]: 
unrecognized selector sent to instance 0x1018961b0
2012-07-10 20:42:39.792 Trixie[41453:303] -[RSReactionRule loadFromPlugin:]: 
unrecognized selector sent to instance 0x1018961b0
2012-07-10 20:42:39.794 Trixie[41453:303] (
0   CoreFoundation  0x7fff898bf716 
__exceptionPreprocess + 198
1   libobjc.A.dylib 0x7fff858a5470 
objc_exception_throw + 43
2   CoreFoundation  0x7fff89955d5a 
-[NSObject(NSObject) doesNotRecognizeSelector:] + 186
3   CoreFoundation  0x7fff898adc3e 
___forwarding___ + 414
4   CoreFoundation  0x7fff898ada28 
_CF_forwarding_prep_0 + 232
5   Trixie  0x0001adf3 
-[RSRuleWindowController addRuleToStore:] + 131
6   AppKit  0x7fff8a4b2599 
-[NSApplication sendAction:to:from:] + 342
7   AppKit  0x7fff8a4b23f7 -[NSControl 
sendAction:to:] + 85
8   AppKit  0x7fff8a4b232b -[NSCell 
_sendActionFrom:] + 138
9   AppKit  0x7fff8a4b0813 -[NSCell 
trackMouse:inRect:ofView:untilMouseUp:] + 1855
10  AppKit  0x7fff8a4b0061 
-[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504
11  AppKit  0x7fff8a4af7dc -[NSControl 
mouseDown:] + 820
12  AppKit  0x7fff8a4a713e -[NSWindow 
sendEvent:] + 6853
13  AppKit  0x7fff8a4a3274 
-[NSApplication sendEvent:] + 5761
14  AppKit  0x7fff8a3b8eaa 
-[NSApplication run] + 636
15  AppKit  0x7fff8a35d886 
NSApplicationMain + 869
16  Trixie  0x000112a2 main + 34
17  libdyld.dylib   0x7fff8890b7e1 start + 0
)

Any advice on how I could narrow down what is causing this? I have tried using 
repondsToSelector: but this doesn't do anything but confirm what the error 
message states, that the selector is not recognized. 

~ Erik

___

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

Please do not post 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: Instance not responding to selector

2012-07-10 Thread Erik Stainsby


On 2012-07-10, at 9:44 PM, Jens Alfke  wrote:

> 
> On Jul 10, 2012, at 9:03 PM, Erik Stainsby  
> wrote:
> 
>> 2012-07-10 20:42:39.792 Trixie[41453:303] -[RSReactionRule loadFromPlugin:]: 
>> unrecognized selector sent to instance 0x1018961b0
> 
> What does the implementation of the -loadFromPlugin: method in that class (or 
> a superclass it inherits it from) look like? Not the body, just the outside 
> part.
> 
> —Jens


#import "RSTrixiePlugin.h"
@class RSReactionRule;

@interface RSReactionPlugin : RSTrixiePlugin

// various properties

- (void) loadFromRule: (RSReactionRule*) rule;

@end


#import "RSReactionPlugin.h"
#import "RSReactionRule.h"
@implementation RSReactionPlugin

- (void) loadFromRule: (RSReactionRule*) rule {
// setting various properties of the plugin 
}

@end
___

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

Please do not post 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: Instance not responding to selector

2012-07-10 Thread Erik Stainsby
Hi Fritz,

I should have stated that I am building against 10.8, and using ARC, and using 
Xcode 4.4DP6. I don't believe the issues I'm facing are all that esoteric so I 
don't think the version of XC is likely to effect this situation.


On 2012-07-10, at 10:02 PM, Fritz Anderson  wrote:

> On 10 Jul 2012, at 11:03 PM, Erik Stainsby wrote:
> 
>> Any advice on how I could narrow down what is causing this? I have tried 
>> using repondsToSelector: but this doesn't do anything but confirm what the 
>> error message states, that the selector is not recognized. 
> 
> More than that, it states that the selector is not recognized _by 
> RSReactionRule_. Are you sending that message to an RSReactionRule? If you 
> don't think you are, set a breakpoint (presumably somewhere in 
> -addRuleToStore:), and examine the recipient of that message; does the 
> debugger think it's an RSReactionRule?

The object which is failing to respond is of the correct class: RSReactionRule 
in this case, generally an RSTrixieRule subclass. The object is newly allocated 
and initialized. It has not been sent any other messages at the point of 
failure.

RSReactionRule *reactionRule= [[RSReactionRule alloc] init];
[reactionRule loadFromPlugin:(RSReactionPlugin*)self.reactionPlugin];


> There are two main reasons an object won't recognize a selector.
> 
> - You blundered and wrote code that sent the selector to the wrong object. 
> This is fairly obvious, and the compiler usually urges you not to do it 
> anyway.

I believe I have sent it to the correct object.

> - You sent the message via an object pointer that _used_ to point to a 
> legitimate receiver for the selector, but that object had been deallocated, 
> and the address recycled for another object (an RSReactionRule) that doesn't 
> implement it. In other words, the object got (over)released out from under 
> you. Audit your memory management (better, adopt ARC). The Allocations 
> instrument, set to record reference counts and enabling zombie detection, 
> should help you track this down.

I am using ARC and have no reason to believe that ARC has reclaimed my newly 
instantiated object. Calling on it for a description in NSLog statements 
results in a coherent description being logged. So something of the correct 
class is at the other end of the pointer being referenced.

> Or, maybe there's something esoteric going on with your plugin loading. But 
> I'd look at these two possibilities first.

The plugin loading seems straightforward.  I create a loader from the 
framework, iterate over the plugins found in my apps' Plugins folder, 
instantiate and store the plugins in an array. When they have been loaded, I 
set the loader nil.  Each plugin has a UI component which loads in its correct 
place and exhibits all the behaviour I expect it to.  It just doesn't;t seem to 
me that there is room for subtle errors here. I'd be happy to post loader code 
if that seems likely to anyone.

~ Erik


___

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

Please do not post 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: Instance not responding to selector

2012-07-11 Thread Erik Stainsby


On 2012-07-10, at 11:47 PM, Quincey Morris 
 wrote:

> On Jul 10, 2012, at 23:11 , Erik Stainsby wrote:
> 
>> @interface RSReactionPlugin : RSTrixiePlugin
>> 
>> // various properties
>> 
>> - (void) loadFromRule: (RSReactionRule*) rule;
>> 
>> @end
> 
> Are you sure that's what you mean? According to this you implemented 
> 'loadFromRule:' but according to your log you invoke 'loadFromPlugin:'.


My error, this is the other side of the symmetric relationship.


@interface RSReactionRule : RSTrixieRule

// various properties

-(void) loadFromPlugin: (RSReactionPlugin*) plugin;

@end



___

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

Please do not post 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: Instance not responding to selector

2012-07-11 Thread Erik Stainsby


On 2012-07-11, at 7:13 AM, Fritz Anderson  wrote:

> On 11 Jul 2012, at 1:33 AM, Erik Stainsby wrote:
> 
>> I should have stated that I am building against 10.8, and using ARC, and 
>> using Xcode 4.4DP6
> 
> Then I can't help. Aside from the fact that my problem-solving technique* 
> would require me to sit down for an hour or two and grope around your project 
> by hand, those products are still under nondisclosure.
> 
> * (Others, with direct experience and better imaginations, may be more 
> effective.)
> 
> I know it's hairsplitting, given that what's currently on the servers is 
> likely to be identical to what will be public in a week or two, but that's 
> where the line is drawn.
> 
>   — F

The build results behave exactly the same when I switch the target to 10.7


___

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

Please do not post 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: Load UIWebView with new content

2012-07-13 Thread Erik Stainsby
You need to use -loadHtmlString:


Time Dwarf,
Roaring Guy

On 2012-07-13, at 4:51 AM, Vavelin Kevin  wrote:

> Hi there,
> 
> I want to "refresh" my webView when I add something that i've write in 
> javascript with 
> stringByEvaluatingJavaScriptFromString: .
> 
> But when I call the method my html is still the same. I want to reload my 
> html page and just modify one thing with javascript. Do you have any idea of 
> how I can do it ?
> 
> Thanks in advance for your answers.
> 
> Vavelin Kévin
> Twitter | Blog | LinkedIn 
> Entrepreneur
> Developer OS X / iOS
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca

___

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

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

ABPerson does not have interface properties ?

2012-07-14 Thread Erik Stainsby
This one has to be pretty simple.  
There is a category of ABPerson which provides this interface. So what have I 
missed ?
OSX, 10.7


#import "RSAppDelegate.h"
#import 
#import 

@implementation RSAppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *) notification {

addressBook = [ABAddressBook addressBook];
// this line works and loads 81 records into the content array...
//  [peopleArrayController setContent:[addressBook people]];


for(ABPerson * person in [addressBook people]) {

NSArray * props = [person properties];  // No visible 
@interface for 'ABPerson' declares the selector 'properties' 

NSMutableDictionary * d = [[NSMutableDictionary alloc] init];
for( NSString * propName in props ) {
[d setObject:[person valueForProperty:propName] 
forKey:propName];
}
[peopleArrayController addObject:d];
}

NSLog(@"%s- [%04d] Number of people records loaded:  %lu", 
__PRETTY_FUNCTION__, __LINE__, [[peopleArrayController content] count]);
}

@end
___

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

Please do not post 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: ABPerson does not have interface properties ? SOLVED

2012-07-14 Thread Erik Stainsby
My mistake.  'properties' is a class method, returning the keys; not an 
instance method, as I was using it below.


On 2012-07-14, at 7:01 PM, Erik Stainsby  wrote:

> This one has to be pretty simple.  
> There is a category of ABPerson which provides this interface. So what have I 
> missed ?
> OSX, 10.7
> 
> 
> #import "RSAppDelegate.h"
> #import 
> #import 
> 
> @implementation RSAppDelegate
> 
> - (void)applicationDidFinishLaunching:(NSNotification *) notification {
> 
>   addressBook = [ABAddressBook addressBook];
>   // this line works and loads 81 records into the content array...
>   //  [peopleArrayController setContent:[addressBook people]];
>   
> 
>   for(ABPerson * person in [addressBook people]) {
>   
>   NSArray * props = [person properties];  // No visible 
> @interface for 'ABPerson' declares the selector 'properties' 
>   
>   NSMutableDictionary * d = [[NSMutableDictionary alloc] init];
>   for( NSString * propName in props ) {
>   [d setObject:[person valueForProperty:propName] 
> forKey:propName];
>   }
>   [peopleArrayController addObject:d];
>   }
>   
>   NSLog(@"%s- [%04d] Number of people records loaded:  %lu", 
> __PRETTY_FUNCTION__, __LINE__, [[peopleArrayController content] count]);
> }
> 
> @end


___

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

Please do not post 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 can I convince an NSBigMutableString to become a mere NSAttributedString ?

2012-07-17 Thread Erik Stainsby
I'm working with the text from a multiline NSTextField. When it arrives in the 
delegate it is represented in an NSBigMutableString. Casting this to a 
NSAttributedString seems to have no effect on the actual class being used by 
the NSString cluster. 

I can't seem to find any documentation on NSBigMutableString.  

Can someone with deep experience tell me if I can _safely_ assume that NSBMS 
will respect all of NSAttributedString's method calls ?

Also if I have a convenience function in a category, should I rewrite it as a 
category on NSString ? Or directly on the NSBMS, which seems to be a hidden 
class? Writing a category on a hidden class just doesn't feel right.

~ Erik
___

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

Please do not post 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: How can I convince an NSBigMutableString to become a mere NSAttributedString ?

2012-07-17 Thread Erik Stainsby
Sorry I should have said a little more about my context.  I'm looking at the 
object passed to the delegate method -control:isValidObject:
Documentation states: "In validating, the delegate should check the value in 
the object parameter…"  I am however unable to assess the value since it is 
being rep'd by an impenetrable class clustered object.

~ Erik


On 2012-07-17, at 5:11 PM, David Duncan  wrote:

> On Jul 17, 2012, at 4:58 PM, Erik Stainsby  
> wrote:
> 
>> I'm working with the text from a multiline NSTextField. When it arrives in 
>> the delegate it is represented in an NSBigMutableString. Casting this to a 
>> NSAttributedString seems to have no effect on the actual class being used by 
>> the NSString cluster. 
>> 
>> I can't seem to find any documentation on NSBigMutableString.  
>> 
>> Can someone with deep experience tell me if I can _safely_ assume that NSBMS 
>> will respect all of NSAttributedString's method calls ?
>> 
>> Also if I have a convenience function in a category, should I rewrite it as 
>> a category on NSString ? Or directly on the NSBMS, which seems to be a 
>> hidden class? Writing a category on a hidden class just doesn't feel right.
> 
> 
> Your assuming you should care that it is an NSBigMutableString in the first 
> place. From what I can see, the delegates all declare that you are receiving 
> an NSString, and as such you should be treating the value you get as an 
> NSString. 
> --
> David Duncan
> 


___

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

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

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

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

Re: How can I convince an NSBigMutableString to become a mere NSAttributedString ?

2012-07-17 Thread Erik Stainsby
Thanks for filling in my knowledge gap, Ken. 

I think between what you and Dave have said, I've realised that I am trying to 
do too much with the object passed in to -control:isValidObject:
I was on my way to line-parsing the attributed string to determine if the 
user-added content is validly formatted.  I think now that would be better 
done/ought to be done in the -control:textShouldEndEditing: which actually 
gives me the fieldEditor to work with.

Thanks for your time.


On 2012-07-17, at 5:20 PM, Ken Thomases  wrote:

> On Jul 17, 2012, at 6:58 PM, Erik Stainsby wrote:
> 
>> I'm working with the text from a multiline NSTextField. When it arrives in 
>> the delegate it is represented in an NSBigMutableString.
> 
> The fact that you felt compelled to investigate its actual dynamic class is a 
> sign that you're on the wrong track.  You should only rely on the documented 
> static type.
> 
>> Casting this to a NSAttributedString seems to have no effect on the actual 
>> class being used by the NSString cluster. 
> 
> Those are two completely different classes.  An NSAttributedString *is not* 
> an NSString or any variety thereof.  It's a different thing that has-a 
> NSString (not is-a NSString).
> 
>> I can't seem to find any documentation on NSBigMutableString.  
> 
> That means it's private.  You should not write any code which embodies any 
> knowledge of its existence.
> 
>> Can someone with deep experience tell me if I can _safely_ assume that NSBMS 
>> will respect all of NSAttributedString's method calls?
> 
> No, you can't.  As I said above, an NSAttributeString is not an NSString or 
> any variety of NSString.  They are not interchangeable.
> 
> You can construct an NSAttributedString from an NSString, but then it won't 
> be the same attributed string as the text field is using, so it's unlikely to 
> be helpful.  What are you actually trying to do?  What delegate method are 
> you implementing?
> 
>> Also if I have a convenience function in a category, should I rewrite it as 
>> a category on NSString ? Or directly on the NSBMS, which seems to be a 
>> hidden class? Writing a category on a hidden class just doesn't feel right.
> 
> You definitely shouldn't write a category on a private class.  I suspect 
> you're on the wrong path in writing a category on NSString for this 
> situation, too.
> 
> Regards,
> Ken
> 


___

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

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

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

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


Regex library recommendations ?

2012-07-18 Thread Erik Stainsby
My project is going to require several rounds of string parsing, and I'm an old 
perl hand, so I naturally want to add a regex wrapper to my workspace. Anyone 
got a favorite to recommend ?

Erik


___

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

Please do not post 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: Regex library recommendations ?

2012-07-18 Thread Erik Stainsby
End of thread. 
(Now looking for better indexed third party documentation…)


On 2012-07-18, at 8:04 PM, Conrad Shultz  wrote:

> NSRegularExpression?
> 
> (Sent from my iPhone.)
> 
> --
> Conrad Shultz
> 
> On Jul 18, 2012, at 19:59, Erik Stainsby  wrote:
> 
>> My project is going to require several rounds of string parsing, and I'm an 
>> old perl hand, so I naturally want to add a regex wrapper to my workspace. 
>> Anyone got a favorite to recommend ?
>> 
>> Erik
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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/conrad%40synthetiqsolutions.com
>> 
>> This email sent to con...@synthetiqsolutions.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: NSAutounbinder not releasing my object in a timely manner

2012-07-19 Thread Erik Stainsby
Jonathan, 
Could you not watch the serial queue you mentioned? When it is empty, release 
the progress window. 

- Erik

Sent from my iPad

On 2012-07-19, at 4:02 AM, Jonathan Taylor  wrote:

> this nasty NSAutounbinder thingy then jumps in and re-retains it in some 
> evil under-the-covers voodoo to do with avoiding retain cycles (as I 
> understand it). Unfortunately the balancing autorelease only occurs 16 
> seconds later when I move the mouse! While not catastrophic this is 
> pretty annoying and looks rather embarrassing.
>>> 
 It's not embarrassing unless your users are running your app in a 
 debugger.  
>>> 
>>> Sorry, you've lost me there. Are you saying this will not occur if I am 
>>> running standalone rather than under XCode? (Unfortunately I don't have the 
>>> code in front of me to try this out). If that is the case then that's good 
>>> - if frustrating - news. Is this a known issue then? I was working on the 
>>> assumption that I was doing something obscurely wrong, or at least 
>>> non-standard somewhere to trigger this from happening.
>>> 
>>> Or are you saying you only see the NSAutounbinder stuff in the debugger? If 
>>> so then - sure, but it's the fact that the progress bar is just sitting 
>>> there until I move the mouse that alarms me.
>> 
>> Are you saying you're relying on an object being deallocated to change your 
>> GUI?  You shouldn't be.  If you want to close or hide a window, send it a 
>> -close or -orderOut: message.  If you want to remove or hide a view, remove 
>> it from the view hierarchy or send it -setHidden:YES.  If its hidden binding 
>> is bound to a model or controller property, set that property (on the main 
>> thread).
> 
> Right, that makes a lot of sense. I can understand the principle of not 
> relying on the dealloc for that sort of thing and on first reading that made 
> complete sense. However, I have now tracked down/remembered the piece of code 
> that was my motivation for taking the approach I did. As always, it turns out 
> the real question is probably not quite the one I originally asked! Can I get 
> your opinion on this workflow? This is how I had previously done things:
> 
> - User requests batch processing of data within a folder tree, which will 
> result in between 0 and many separate movies being generated.
> - Application allocates a "progress" tracker, subclassed from 
> NSWindowController, in control of a window containing a progress indicator 
> and various other feedback elements. 
> - This is supplied to separate traversal/parsing code which identifies source 
> data from which movies should be generated.
> - For each movie to be generated, the progress indicator is retained in 
> association with a GCD block which will be executed to perform the actual 
> work, added to a serial queue
> - Following tree traversal, the application releases its reservation on the 
> progress tracker. If no movies are due to be generated, I had intended this 
> to cause it to be deallocated, at which point I had been closing the window.
> 
> If work was queued, this will in due course be executed. The current work 
> block will take control of updating the progress tracker. When it is finished 
> it will release its reservation of the progress tracker. Again, when all work 
> has been completed I intended the retain count to fall to zero at which point 
> it would be deallocated and closed.
> 
> My intention with all this was to avoid the need for any "information 
> sharing" between bits of code that I felt should be fairly independent. The 
> application-level code that originally allocates the progress tracker doesn't 
> need to care about what any more specific code wants to do with the progress 
> tracker, it just makes it available to anything that wants to retain it for 
> future use, and then relinquishes any further "personal" interest in that 
> object.
> 
> Now, your statement that "[you shouldn't be] relying on an object being 
> deallocated to change your GUI" seems fair, but how would you tackle my 
> scenario here? One possible solution would be to have an intermediary object 
> with no gui/binding/etc of its own, which allocates and owns the progress 
> window and is retained and released by my code as necessary, 
> closing/releasing the window when it is deallocated. In practice, I suspect 
> that would work because that intermediary object "shouldn't" get caught up in 
> any of the deferred autoreleasing that was associated with my original 
> problem. However I am genuinely not sure whether that is just a slightly more 
> indirect way of violating your advice, or whether it is acceptable. I guess I 
> am not sure whether your statement is a generic design principle or a 
> practical rule of thumb for avoiding the sort of issue I encountered.
> 
> In my mind retain/release is a way of tracking the interest that my different 
> work packages have on the progress window. If you say you don't like my 
> in

Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-07-31 Thread Erik Stainsby
The NSSortDescriptor documentation seems especially opaque to me tonight. 
Surely there is a useful short description somewhere … ?  *whimper*


___

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

Please do not post 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: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-07-31 Thread Erik Stainsby
This has me thinking that to get the alpha sorted list of keys from a 
dictionary I should be passing the keypath as the param for 
sortDescriptorWithKey: and not trying to externalize the keys into an array 
first … ?


On 2012-07-31, at 10:13 PM, Graham Cox  wrote:

> 
> On 01/08/2012, at 3:07 PM, Graham Cox wrote:
> 
>> NSSortDescriptor* desc = [NSSortDescriptor sortDescriptorWithKey:@"compare:" 
>> ascending:YES];
> 
> 
> Oops, this wasn't what I meant.
> 
> The "key" should be the property you're comparing to sort the objects. If 
> your array is a bunch of strings to be sorted, then what is the key? Well, 
> it's actually "self":
> 
> NSSortDescriptor* desc = [NSSortDescriptor sortDescriptorWithKey:@"self" 
> ascending:YES];
> 
> Because internally the descriptor is looping over the array and doing a 
> -valueForKey:@"self" on each object, and that returns the object itself. The 
> sort comparison itself is done by invoking -compare: on the objects.
> 
> 
> If it's another sort of object that has a string property, then you would 
> pass the name of that property, e.g. @"lastName".
> 
> --Graham
> 
> 


___

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

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

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

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

Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Erik Stainsby
Hi Mark,

So I have a dictionary like so:  

NSDictionary * countries = [NSDictionary dictionaryWithObjects:[NSArray 
arrayWithObjects:@"Australia",@"Canada",@"United Kingdom",@"United States",nil] 
forKeys:[NSArray arrayWithObjects:@"au",@"ca",@"uk",@"us",nil]];

I want to present them alphabetically as menuItems in an NSPopUpButton.  I grab 
the list of keys:

NSMutableArray * sortkeys  = [NSMutableArray arrayWithArray:[countries 
allKeys]];

What I have come up with is this:

[sortkeys sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
return [(NSString*)obj1 compare:(NSString*)obj2 ];
} ];

Is this a sane approach ? Seems a bit fussy to have to spec the cast like this. 
Or is this just the what-is of this kind of functionality?

~ Erik



On 2012-08-01, at 3:20 AM, Mark Woollard  wrote:

> Can you give a bit more info on what is stored in your NSArray? NSString? 
> NSManagedObject? NSDictionary? Something else?
> Regards
> Mark
> 
> On 1 Aug 2012, at 06:01, Erik Stainsby  wrote:
> 
>> The NSSortDescriptor documentation seems especially opaque to me tonight. 
>> Surely there is a useful short description somewhere … ?  *whimper*
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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/mark.woollard%40mac.com
>> 
>> This email sent to mark.wooll...@mac.com
> 


___

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

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

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

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

Re: reading preferences from com.apple.mail under 10.8

2012-08-02 Thread Erik Stainsby
Would it not be more in keeping with sandbox culture to ask the user for 
permission to read the Mail.app preferences at run time? Thereby obviating the 
need to maintain a supported under the hood path to the same info.  It could be 
a single request made once during first run.

~ Erik


Sent from my iPad

On 2012-08-02, at 12:17 PM, Jens Alfke  wrote:

> 
> On Aug 2, 2012, at 5:19 AM, Rob McBroom  wrote:
> 
>> And I question whether Scripting Bridge is “more supported” than 
>> `NSUserDefaults`. :-)
> 
> Those are both supported APIs, but that's irrelevant. The point is that an 
> application's scripting API (as declared in its dictionary) is supported, 
> whereas apps' user defaults keys are for internal use only.
> 
> (I do know of a couple of user-defaults domains that have well-known 
> supported keys in them — such as the ones that give the locations of the 
> iLife media index files — but those are separate domains containing only 
> those settings, not the internal domains of the iLife apps.)
> 
> —Jens
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca

___

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

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

Very basic table binding blind spot

2012-08-02 Thread Erik Stainsby


I do so wish there was a Complete Idiot's Guide to Cocoa Table Bindings … The 
very flexibility which I know must be their great virtue tends to obscure the 
clear path from my sight more often than not.  Forest, trees, trees, forest … 
Oh! Something shiny! 
---

So tonight I have an NSArrayController (RSTableArrayController) which I have 
populated with dictionary objects of the form:

[self.content addObject:[NSDictionary dictionaryWithObjects: [NSArray 
arrayWithObjects: key, [mvo valueForKey:key],nil] forKeys:[NSArray 
arrayWithObjects:@"label",@"value",nil]]];



For this simple two column data I have a two column table, using Table View 
Cells (I'm going to have visual objects in place of the 'label' later on).
I have set the identifier for the tableView columns very imaginatively to 
"label", and "value". 
The array controller is also < NSTableViewDataSource, NSTableViewDelegate >. I 
have implemented the following two delegate methods:

- (NSInteger)   numberOfRowsInTableView:(NSTableView *)aTableView {
return self.content.count;
}

- (id)  tableView:(NSTableView *)aTableView 
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex {
NSString * identifier = [tableColumn identifier];
NSDictionary * dict = [self.content objectAtIndex:rowIndex];
NSLog(@"%s- [%04d] %@: %@", __PRETTY_FUNCTION__, __LINE__, 
identifier,[dict valueForKey:identifier]);
return [dict valueForKey:identifier];
}

In the nib, I have an ArrayController object of the class described above 
RSTableArrayController. It is wired up as the delegate and dataSource for the 
tableView. 


And here is where I get lost time and again, tracing the appropriate path to 
the content and it's constituent data parts and binding them to the appropriate 
element in the tableView.

» Scroll View
» Table View
» Table Column
» Table Cell View
» Static Text
 Text Field Cell

Given that the delegate method is called  -[tableView: 
objectValueForTableColumn: row:]  I should expect to bind the arrayController's 
objectValue in the Bindings Inspector to the ?node?  in the object browser.  Do 
I need to do more than get that right?  

~ Erik, 
currently batting .034 in the bindings league ... 


___

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

Please do not post 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: Very basic table binding blind spot

2012-08-03 Thread Erik Stainsby
Thank you gentlemen, both, for taking the time to educate me. I have lots to 
rethink in my "design", such as it was.


On 2012-08-03, at 12:27 AM, Quincey Morris 
 wrote:

> On Aug 3, 2012, at 00:16 , Kyle Sluder  wrote:
> 
>> Hmm, now that Quincy's pointed it out, it looks like you are indeed using a 
>> view-based table view.
> 
> No bonus points to me though. Having cleverly focused on the forest instead 
> of the trees, I didn't register the fact that using the data source was 
> inconsistent with trying to bind what's supposed to be in the columns.
> 
> 


___

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

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


Master-detail views and managing next responder sequence

2012-08-05 Thread Erik Stainsby
My current project is built around a master-detail style interface: the primary 
record owns the window content, while subviews display related content from 
various sources. My problem is that the tableViews which display these 
subordinate lists seem to mess up the responder chain's sequence for advancing 
the focus when the user tries to tab through page.  What I would like to 
accomplish is to have the user be able to tab through top-to-bottom without 
noticing there are additional components in the page, as if it were one 
seamless document instead of (in this case) four.  Further complicating this a 
little (I suspect) is that the m-d form is not shown in the window when the 
application launches, but replaces a window subview when called for, 
necessitating that the responder chain sequence be established on-the-fly, at 
runtime.

My first higher-level question then is how I ought to be going about 
establishing the tab-key behaviour sequence I want to achieve?

My thought at the moment is to work out the list of controls I mean to have in 
order, then create outlets for them in the windowController, and as the 
master-detail view is added to the window, set the responder chain sequence in 
code. With the three subviews in this case, tabbing into and out of them in 
turn leaves me with six junction points with the main view. Tedious perhaps but 
manageable. 

Clearly this would not scale well as a solution, which makes me think there 
must be a better way to build a bridge than with matchsticks. 

Any guidance appreciated.

~ Erik
___

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

Please do not post 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: Master-detail views and managing next responder sequence

2012-08-05 Thread Erik Stainsby
Thanks Graham, that has 90% of my issue addressed.  The system seems to swallow 
a couple of keystrokes entering each table, but at least it does get there. I 
suspect a few judiciously placed refusesFirstRespnder's and I'm home free.

Cheers,
Erik


On 2012-08-05, at 6:47 PM, Graham Cox  wrote:

> 
> On 06/08/2012, at 11:38 AM, Erik Stainsby  wrote:
> 
>> My first higher-level question then is how I ought to be going about 
>> establishing the tab-key behaviour sequence I want to achieve?
> 
> 
> 
> Have you investigated whether -[NSWindow recalculateKeyViewLoop] would do the 
> job? I've used this after installing a view in a M-D interface and it works 
> as expected. The only difference in my implementation is that the detail 
> views are never tables, or ever include tables, but I don't see why that 
> would make much difference.
> 
> --Graham
> 
> 


___

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

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

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

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


Detecting focus on control

2012-08-10 Thread Erik Stainsby
Is it the case that setting up a trackingArea over a given control is the 
easiest way to detect the arrival of focus on a given control? 

I'm thinking in terms of tab-advancing keyboard activity here, where the user 
advances onto a modestly complex screen region (a postal address displayed in 
NSBox holding a multiLineLabel). Upon arrival of focus I want to swap in a 
fielded edit interface.

It seems like this sort of awareness ought to be trivial to glean, but I'm not 
seeing it in NSView nor NSControl where I would expect to find it documented.  
Advice on where I ought to look?

TIA
~ Erik
___

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

Please do not post 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: userSpaceScaleFactor in class NSWindow is deprecated - so what?

2012-08-11 Thread Erik Stainsby
>From the docs:

Returns the scale factor applied to the window. (Deprecated. Use 
convertRectToBacking: and backingScaleFactor instead.)


On 2012-08-11, at 5:55 AM, Gerriet M. Denkmann  wrote:

> userSpaceScaleFactor


___

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

Please do not post 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: Detecting focus on control

2012-08-11 Thread Erik Stainsby
On 2012-08-10, at 7:30 PM, Andy Lee  wrote:

> If there's one specific control class that you want to detect focus for, you 
> can subclass it and override becomeFirstResponder. If super returns true, do 
> your thing.
> 
> If you want to apply this to a bunch of varied controls, you might want to 
> use a subclass of NSWindow and override makeFirstResponder: (again, checking 
> what super returns).
> 
> --Andy
> 

So I do have a handful of cases which I will want to swap in editing views for 
the display views. So I have a subclass of NSWindow with the following method:

- (BOOL) makeFirstResponder:(NSResponder *)responder {
if([super makeFirstResponder:responder]) {
if([responder isEqualTo:[self.windowController displayField]]) {
NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, 
@"call activateEditorView");
[self.windowController activateEditorView:self];
}
return YES;
}
return NO;
}


The windowController has the following method:

- (IBAction) activateEditorView: (id)sender {

// self.displayField is the field which triggers this line of action 
if([self.displayField resignFirstResponder]) {
NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, 
@"replaceSubView:with:");

[[self.window contentView] replaceSubview:self.displayView 
with:self.editorView];
[editorView setNeedsDisplay:YES];   
}
}

Sadly, although the messages are logged the -replaceSubview:with: does not 
accomplish any change.  Have I done (or not done) something foolish in here? I 
have tried moving firstResponder out of the displayField prior to the 
replaceSubview: call but without apparent effect on the replaceSubview: outcome 
 (relocating the focus did happen).

~ Erik
___

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

Please do not post 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: 32-bit on 10.8

2012-08-11 Thread Erik Stainsby
An argument on the internet is like arguing with an idiot.. Even if you win you 
were arguing with an idiot.

~ Erik



___

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

Please do not post 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: Perplexity with X3D and XML

2012-08-15 Thread Erik Stainsby
XML attributes are properly formed when they are double-quoted, not single 
quoted. This is why the default for NSXML is double-quoted.  It is likely that 
what you need to do is encode the x3d MFString before using it as the attribute 
body, perhaps as simply as slash escaping the quotes:  attr="\'\"alpha\" 
\"bravo\"\' ".
You may have to use DTD entities to represent the internal quote and 
double-quote characters.

~ Erik

On 2012-08-15, at 7:47 PM, Christopher Henrich  wrote:

> I am working on an app which will, among other things, write out an X3D file, 
> in XML format. (Background: X3D is a language for describing 
> three-dimensional scenes*; one way to put an X3D scene in a file is to use 
> XML.) Some of the X3D "fields," which map to "attributes" of XML nodes, are 
> of the X3D type MFString. The idea is to wrap 0, 1, or more character strings 
> in a single package.
> 
> The specification of the XML form for X3D requires that an MFString be 
> enclosed in single quotes, and the enclosed strings must be enclosed in 
> double quotes. Example: ' "alpha" "bravo" '.
> 
> Now, if I construct an NSXML document in my program, and write it out using  
> XMLDataWithOptions, I do not have fine-grained control over whether strings 
> are enclosed in single or double quotes. I can apply the option 
> NSXMLNodeUseSingleQuotes, but I have to apply it to the entire document. This 
> is acceptable for the moment, but it seems clunky. What if I later have to 
> use X3D fields of type SFString, which X3D requires to be enclosed in double 
> quotes?
> 
> There are, as far as I can tell, no magic hooks into the mechanism of 
> XMLDataWithOptions to apply an option in certain cases but not others. I face 
> the prospect of having to re-implement XMLDataWithOptions, adding special 
> wrinkles to apply an option in certain cases. 
> 
> I am tempted to wonder about the rule that X3D wants to enforce upon its XML 
> representation of fields of type SFString or MFString. I do not see how it 
> can be expressed in an XML Data Type Definition. It doesn't seem to appear in 
> the dtd files published by the X3D committee. Is it for real? And, according 
> to the customer of the XML community, should it be for real?
> 
> Thanks in advance for any relevant insights.
> 
> *X3D is good for a lot of other stuff as well, but this is the aspect I am 
> trying to use. 
> 
> Christopher Henrich
> chenr...@monmouth.com
> mathinteract.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/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca


___

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

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


Calculating row heights for view-based table rows, on re-use throws error

2012-08-17 Thread Erik Stainsby
Hello all,

I have a view-based table in which there are four distinct row types, 
representing distinct object types which may appear. The tableRowViews are in 
the nib and represented in the code here as xxxCellView entities. 


- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row {

id obj = [_content objectAtIndex:row];

if([obj isKindOfClass:[RSPostalAddress class]]) {
return self.postalCellView.bounds.size.height;
}
else if([obj isKindOfClass: [RSEmailAddress class]]) {
return self.emailCellView.bounds.size.height;
}
else if([obj isKindOfClass: [RSPhoneNumber class]]) {
return self.phoneCellView.bounds.size.height;
}
else {  // note field
return self.notesCellView.bounds.size.height;
}
}


My problem is that on first pass, this code returns quite sane and reasonable 
results: the manually set sizes of the prototype tableRowViews.  However on 
second pass, it goes insane: 132.0 becomes 266.0, 28.0 becomes 118.0, 104.0 
becomes 210.0 ...  And the next thing the -tableView:heightOfRow: does is throw 
it's brain in the air and gives up …. :P


2012-08-17 18:51:52.766 RSSuperContactsX[24075:303] -[RSTableController 
tableView:heightOfRow:]- [0136] self.postalCellView.bounds.size.height: 
266.00
2012-08-17 18:51:52.766 RSSuperContactsX[24075:303] -[RSTableController 
tableView:heightOfRow:]- [0136] self.postalCellView.bounds.size.height: 
266.00
2012-08-17 18:51:52.766 RSSuperContactsX[24075:303] -[RSTableController 
tableView:heightOfRow:]- [0140] self.emailCellView.bounds.size.height: 
118.00
2012-08-17 18:51:52.766 RSSuperContactsX[24075:303] -[RSTableController 
tableView:heightOfRow:]- [0140] self.emailCellView.bounds.size.height: 
118.00
2012-08-17 18:51:52.767 RSSuperContactsX[24075:303] -[RSTableController 
tableView:heightOfRow:]- [0144] self.phoneCellView.bounds.size.height: 
118.00
2012-08-17 18:51:52.767 RSSuperContactsX[24075:303] -[RSTableController 
tableView:heightOfRow:]- [0148] self.notesCellView.bounds.size.height: 
210.00
2012-08-17 18:51:52.767 RSSuperContactsX[24075:303] *** -[__NSArrayM 
objectAtIndex:]: index 6 beyond bounds [0 .. 5]
2012-08-17 18:51:52.769 RSSuperContactsX[24075:303] (
0   CoreFoundation  0x7fff900a8716 
__exceptionPreprocess + 198
1   libobjc.A.dylib 0x7fff8ad98470 
objc_exception_throw + 43
2   CoreFoundation  0x7fff900455dc -[__NSArrayM 
objectAtIndex:] + 252
3   RSSuperContactsX0x000130f5 
-[RSTableController tableView:heightOfRow:] + 101
4   AppKit  0x7fff8a2e3322 
-[NSTableView _sendDelegateHeightOfRow:] + 130
5   AppKit  0x7fff8a2e30db 
-[NSTableView _uncachedRectHeightOfRow:] + 197
6   AppKit  0x7fff8a2e2f7a 
-[_NSTableRowHeightStorage _cacheRowHeights] + 241
7   AppKit  0x7fff8a29d6f5 
-[_NSTableRowHeightStorage _ensureRowHeights] + 80
8   AppKit  0x7fff8a2e3469 
-[_NSTableRowHeightStorage copyWithZone:] + 89
9   AppKit  0x7fff8a2e03eb 
-[NSTableRowData _saveCurrentRowHeightState] + 293
10  AppKit  0x7fff8a2e0282 
-[NSTableRowData beginUpdates] + 93
11  AppKit  0x7fff8a29be0b 
-[NSTableView _beginUpdate] + 63
12  AppKit  0x7fff8a2b473d 
-[NSTableView reloadData] + 33
13  RSSuperContactsX0x00013016 
-[RSTableController setPerson:] + 2982
14  RSSuperContactsX0x0001240b 
-[RSTableController setActivePerson:] + 779





My expectation is that I ought to be able to clear the table (iterating through 
the rows and applying -removeRowsAtIndexes:withAnimation:  to discard the 
present rowViews, and start clean with the next record to be displayed, 
generating new rowViews as needed (because the number of component elements 
(phone numbers/email addresses/etc) will vary from one record to the next). 

I have no iterator code running at the time this error occurs, so I suspect I 
have failed to correctly setup some aspect of the tableView/rowView mechanics.  
Does anything suggest itself to anyone ? 

Hopefully,
Erik




___

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

Please do not post 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: Calculating row heights for view-based table rows, on re-use throws error

2012-08-18 Thread Erik Stainsby
Thanks for the thought Fritz. Removing my ham-handed attempt to purge the 
tableView of its rows indeed resolved the out of range error.

On 2012-08-18, at 8:24 AM, Fritz Anderson  wrote:

>> My expectation is that I ought to be able to clear the table (iterating 
>> through the rows and applying -removeRowsAtIndexes:withAnimation:  to 
>> discard the present rowViews, and start clean with the next record to be 
>> displayed, generating new rowViews as needed (because the number of 
>> component elements (phone numbers/email addresses/etc) will vary from one 
>> record to the next). 
> 
> Not a good expectation, if you are altering a collection while you are 
> iterating it. (You imply that's what you're doing, but it's not clear.) Doing 
> so leaves the collection in an inconsistent condition, and anything that 
> depends on the collection will have invalid data. (But see next paragraph.) 
> The table view might, for instance, try to index to a row for which the 
> backing data no longer exists.

I am now left with the two simple problems of 
a) trying to remove populated but out dated tableRowViews from the tableView, 
and 
b) establishing the correct rowHeight for each subsequent reuse of the 
tableView.

Any advice on where to start reading appreciated.

~ Erik


___

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

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


Switching between window controllers in code ?

2012-08-20 Thread Erik Stainsby
This is either a stupid question or it is trivial. I just haven't run across 
the situation before. 

My app has two windows, ergo two windowControllers. I would like to toggle 
between them from a single menu item, ergo a single method handler. However 
that requires that the two window controllers have a common ancestor(?) in the 
responder chain. That let's appDelegate out, not a responder object. So, is 
there any way to have the same object in two nibs without getting caught in 
recursive looping, or retain cycles ?

10.8 (target 10.7), XC4.4 

(I suppose it could be both trivial and stupid.)

~ Erik
___

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

Please do not post 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: Switching between window controllers in code ?

2012-08-20 Thread Erik Stainsby


On 2012-08-20, at 9:15 PM, Jens Alfke  wrote:

> 
> On Aug 20, 2012, at 8:53 PM, Erik Stainsby  
> wrote:
> 
>> My app has two windows, ergo two windowControllers. I would like to toggle 
>> between them from a single menu item, ergo a single method handler. However 
>> that requires that the two window controllers have a common ancestor(?) in 
>> the responder chain. That let's appDelegate out, not a responder object.
> 
> Just wire the menu command directly to the app delegate object, instead of to 
> First Responder.
> 
> —Jens

Okay so that is working fine, but isn't that a venal sin in Cocoa programming?

~ Erik
___

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

Please do not post 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 feasible to nest NSTableViews inside a view-based NStableView ?

2012-08-24 Thread Erik Stainsby
I have a situation where my data contains arrays of values: a list of phone 
numbers belonging to a person object. I'd like to be able to display the 
numbers in a single cell contained in a nested table of editable fields. Am I 
insane? 

I've been circling trough the hierarchies trying to accomplish the connection 
of the person's array of phone numbers with a subclass of NSTableCellView 
acting as the subtable's delegate/datasource. I gotten tantalizingly close, but 
I just can't seem to bridge the gap. Corbin's TableViewPlayground doesn't quite 
get to this: all of the TableCellViews in his examples are first-generation 
children of the top-level table. 

Does anyone know if it is (im)possible to do this? Should I be looking at a 
different view strategy?  Does anyone know of a clean clear example of how to 
accomplish this that I could study?  

~ Erik

OSX 10.8,  XC4.4


___

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

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


Docs describing in-code loading of standard media icons?

2012-09-01 Thread Erik Stainsby
I am building out custom tableCellViews and have a case in which I would like 
to show the NSUser silhouette from the standard media library.

Is there a method for doing this in code? The Xcode docs organizer is not 
providing anything related.

TIA

Erik Stainsby
erik.stain...@roaringsky.ca



___

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

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


Seeking advice re: placement of UndoManager

2012-09-02 Thread Erik Stainsby
I am questioning where in the app I ought to locate my UndoManager code:

1) in the model classes?
2) in window controller class?
3) on its own as a controller-mediator class?

The model is kvo compliant and so will be notified by observing itself. It has 
to broker the changes into the persistent store. Seems like a good locale to 
capture undo requirements. However it also seems like this is more a controller 
logic piece of the puzzle and as such doesn't really belong in the model 
classes.

Advice from those who know would be much appreciated.


Erik Stainsby
erik.stain...@roaringsky.ca



___

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

Please do not post 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: Seeking advice re: placement of UndoManager

2012-09-02 Thread Erik Stainsby
Forgot to mention this is not a NSDocument based app, nor am I using CD.

OSX 10.8/deploying 10.7

Erik Stainsby
erik.stain...@roaringsky.ca


On 2012-09-02, at 3:10 PM, Erik Stainsby  wrote:

> I am questioning where in the app I ought to locate my UndoManager code:
> 
> 1) in the model classes?
> 2) in window controller class?
> 3) on its own as a controller-mediator class?
> 
> The model is kvo compliant and so will be notified by observing itself. It 
> has to broker the changes into the persistent store. Seems like a good locale 
> to capture undo requirements. However it also seems like this is more a 
> controller logic piece of the puzzle and as such doesn't really belong in the 
> model classes.
> 
> Advice from those who know would be much appreciated.
> 
> 
> Erik Stainsby
> erik.stain...@roaringsky.ca
> 
> 


___

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

Please do not post 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: autosavesInPlace and sandbox

2012-09-07 Thread Erik Stainsby
What autosave really needs is a reliable differential incremental save engine. 
This could cache diffs and perform a merge during "slow moments" of user 
inactivity.  I wonder if this is where Apple might be heading with this 
technology.

~ Erik

Sent from my iCapsule somewhere in orbit

On 2012-09-07, at 11:15 AM, Kyle Sluder  wrote:

> On Fri, Sep 7, 2012, at 11:05 AM, Charles Srstka wrote:
>> On Sep 7, 2012, at 12:54 PM, Kyle Sluder  wrote:
>> 
 - An app that opens a particularly large or complex document type such
 that the save operation would take a large amount of time won't work very
 well in the autosave paradigm.
>>> 
>>> This problem already exists with the old timer-based autosave paradigm.
>>> If saving is slow, you need to smarten your save algorithm.
>> 
>> What if the file you're saving is 4 GB in size and you're saving it to a
>> laptop hard drive? No amount of "smartening" is going to fix that.
> 
> I guess the question is, "why are you saving a 4GB file?" Media editors
> don't do that; they split the file into chunks and bundle them in a
> project folder. For other apps, we have document wrappers.
> 
> If you really need to edit a single monolithic multi-GB file, there are
> ways to do it other than holding the entire thing in memory and
> overwriting the file on disk. For example, you can stream the file to
> disk as it's created and maintain a dirty list, or mmap the file and
> just let the VM system take care of it.
> 
>> Also, some file types are just large and complex, and take a certain
>> amount of computing power to save no matter how "smart" you are. Have you
>> ever tried opening and editing a really high-resolution image file with
>> Pixelmator with autosave turned on? It gets almost unusable. With a video
>> editor, it would be even worse.
> 
> No I have not, but what I have done is used versions of OmniOutliner
> that use old-school autosave on gigantic documents customers have sent
> us (usually with huge collections of image attachments). Whenever the
> autosave timer expires, the app freezes for ten seconds at a time
> because it's doing a naive rewrite-the-world save. This isn't a product
> of Lion autosave.
> 
>> Sure there are, and I gave you four of them (which doesn't necessarily
>> rule out other cases that just aren't coming to mind at the moment).
> 
> The reason I replied to your message is that I don't believe you
> succeeded. You enumerated cases for which perhaps no good
> *implementation* of Lion Autosave currently exists. But that does not
> imply anything about the applicability of the *paradigm.*
> 
> --Kyle Sluder
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca

___

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

Please do not post 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: binding an array controller to columns in an NSTableView

2012-09-11 Thread Erik Stainsby
I keep wondering as I'm watching this thread if it might be easier and more 
closely match the extensibility of the "row of color views" Chuck is trying to 
create if he were to use an NSMatrix instead of the full blown NSTable ?  

Sent from my iCapsule somewhere in orbit

On 2012-09-11, at 11:23 AM, Quincey Morris 
 wrote:

> On Sep 11, 2012, at 10:13 , Chuck Soper  wrote:
> 
>> When adding additional colors, I understand that the following code can
>> create a color object, but I'm not sure where to put this code or if I can
>> use bindings instead.
>> NSManagedObject *color = [NSEntityDescription
>> insertNewObjectForEntityForName:@"Color"
>>   inManagedObjectContext:self.managedObjectContext];
>> [color setValue:@"Dark Blue" forKey:@"name"];
> 
> Where you put this code will depend on what triggers creation of the color 
> object. If, for example, there's a button that's clicked to create a color, 
> then you'd probably have an action method in a controller (e.g. window 
> controller, view controller or app delegate) that's responsible for creating 
> the new color object. This might contain the above code, or if it's a bit 
> more complicated it might call a data-model method that creates the color 
> object with all its properties set properly.
> 
>> Essentially, I want each "color" object to be a bindable custom view.
>> Ideally, this custom view would be a NSTableCellView subclass. My table
>> would always have a single row, so I misspoke when I described that as a
>> column. I'm not sure how I create and remove this view when creating and
>> removing color objects.
> 
> I'm not sure what you mean by "a single row" here. The table only ever has 
> one row? Or are you saying there should be multiple color subviews in each 
> row?
> 
> Perhaps it would be clearer if you asked the whole question again -- I'm a 
> little unsure what you're asking.
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca

___

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

Please do not post 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: Setting NSTableColumnIdentifier in Xcode 4.4.1?

2012-09-13 Thread Erik Stainsby
Same place as earlier. Second row input field in the properties inspector. Make 
sure the column is the active node. 

Erik
Roaring Sky

On 2012-08-24, at 2:31 PM, Gerd Knops  wrote:

> 
> On Aug 24, 2012, at 4:27 PM, Laurent Daudelin  
> wrote:
> 
>> Am I missing something? Where do you set the column identifier in Xcode 4.4?
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca

___

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

Please do not post 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: maintaining alpha value for intersecting lines?

2012-09-13 Thread Erik Stainsby
On 2012-09-13, at 9:02 AM, Koen van der Drift  wrote:

> On Sep 13, 2012, at 11:44, Ken Thomases  wrote:
> 
>> On Sep 13, 2012, at 7:40 AM, Koen van der Drift wrote:
>> 
>>> When I draw two lines using NSBezierPaths, both of which have an alpha
>>> value of let's say 0.5, the alpha value appears to be higher at the
>>> intersection (the color becomes more opaque). Is there a way to
>>> maintain the original alpha value for lines that intersect?
>> 
>> Does this still happen with a single NSBezierPath containing both lines?
> 
> Is that possible, since they all have different begin and end points?
> 
> - Koen.

Each stroke can have separate begin and end points from previous strokes. Look 
at -[NSBezierPath moveToPoint:]

Erik





> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca

___

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

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


kABHomeLabel … and companions

2012-09-13 Thread Erik Stainsby
Hello folks,

So the AddressBook framework's xxxLabel keys render out as strings encoded like 
so: _$!!$_, _$!!$_, _$!!$_   Is there framework method I am 
meant to use with the property keys kABHomeLabel, kABWorkLabel, etc, to render 
a legible text outcome ?  Or am I meant to create my own lookup reference and 
to translate them as I see fit ? 


Erik Stainsby
erik.stain...@roaringsky.ca


___

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

Please do not post 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: kABHomeLabel … and companions

2012-09-13 Thread Erik Stainsby
I understand that ABAddressBook methods are concerned with ABPerson and ABGroup 
entities, subclasses of ABRecord.
However, the ABMultiValue collections are less intuitive. Among these are 
stored the (potentially) multiple instances of addresses, phone numbers and 
email addresses.  For each instance of user supplied data, a multiValue object 
can store - in properties keyed with kABXxxx keys - arbitrary labels: home, 
work, iPhone, mobile, etc.   The documentation leaves much to be desired, but 
in particular, I cannot glean how to retrieve a user-supplied string from a 
given multiValue object.

Some code: 

Given some address, stored in an ABMultiValue object, such that:  

- (void) unwrapMV:(ABMultiValue*)mv atIndex:(int)index {

NSString *  _uuid   = [mv identifierAtIndex:index];
NSString *  _label  = [mv labelForIdentifier:[mv 
identifierAtIndex:index]];
NSDictionary *  _dict   = [mv valueAtIndex:index];
// am I the identified primary entry?
BOOL_primary= ([mv primaryIdentifier] == self.uuid)? 
YES: NO; 

NSLog( @"%@", _label) ;
}

produces  _$!!$_, 
or one of the other variants of the actual value of the key, not the value it 
refers to.

Clearly I am failing to understand where these strings are being stored.

Erik Stainsby
erik.stain...@roaringsky.ca


On 2012-09-13, at 9:04 PM, Jerry Krinock  wrote:

> 
> On 2012 Sep 13, at 19:45, Erik Stainsby  wrote:
> 
>> So the AddressBook framework's xxxLabel keys render out as strings encoded 
>> like so: _$!!$_, _$!!$_, _$!!$_   Is there framework 
>> method I am meant to use with the property keys kABHomeLabel, kABWorkLabel, 
>> etc, to render a legible text outcome 
> 
> Maybe you're looking for -[ABRecord valueForProperty:].  Note that 
> ABAddressBook methods typically return ABPerson objects, and ABPerson 
> inherits from ABRecord.
> 
> If that doesn't explain it, post some 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:
> https://lists.apple.com/mailman/options/cocoa-dev/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca

___

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

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


Position of my item in the statusBar

2012-09-17 Thread Erik Stainsby
HI,

I'm wondering if anyone can explain to me (or point me in the right direction) 
as to how I can determine the current position of my stats bar item at runtime. 
It seems that the status bar mechanisms are unpublished except for the very 
basic use of popping an item into the collection and hanging a menu from it.  
I'd like to know where on screen my item's image is so that I can place a panel 
window adjacent to it.  

Advice?
 
Erik Stainsby
erik.stain...@roaringsky.ca



___

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

Please do not post 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: Position of my item in the statusBar

2012-09-17 Thread Erik Stainsby
On 2012-09-17, at 2:17 PM, Kyle Sluder  wrote:

> On Mon, Sep 17, 2012, at 02:12 PM, Tim Schröder wrote:
>> Use something like this: 
>> 
>> NSRect frame = [[statusItem valueForKey:@"window"] frame];
> 
> Don't do this. -[NSStatusItem window] is private API and is not
> guaranteed to exist.
> 
> Create a view, assign it to your status item, and use that for your
> frame.
> 
> --Kyle Sluder


Is it any safer to assume a window will be returned from this code ? 

RSStatusItemViewController * _statusViewCtrl = [[RSStatusItemViewController 
alloc]init];
[self.statusItem setView:[_statusViewCtrl view]];
NSWindow * statusWindow = [[_statusViewCtrl view] window];

NSRect rect = [statusWindow frame];

I mean I assign the view through setView: - does that implicitly guarantee 
there will be a window context when I invoke  [myView window] later on?  I see 
nothing contractual.  It works, and I am glad, but I don't know if I can trust 
it.


Erik Stainsby
erik.stain...@roaringsky.ca

___

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

Please do not post 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: kABHomeLabel … and companions

2012-09-21 Thread Erik Stainsby
That is the one. Found it the other day. Tanks Vince.

Erik Stainsby
erik.stain...@roaringsky.ca


On 2012-09-21, at 1:33 PM, Vince DeMarco  wrote:

> 
> On Sep 13, 2012, at 7:45 PM, Erik Stainsby  
> wrote:
> 
>> Hello folks,
>> 
>> So the AddressBook framework's xxxLabel keys render out as strings encoded 
>> like so: _$!!$_, _$!!$_, _$!!$_   Is there framework 
>> method I am meant to use with the property keys kABHomeLabel, kABWorkLabel, 
>> etc, to render a legible text outcome ?  Or am I meant to create my own 
>> lookup reference and to translate them as I see fit ? 
>> 
>> 
> 
> Try this
> 
> // 
> //  Localization of property or label
> // 
> 
>// Returns the localized version of built in properties, labels or keys
>// Returns propertyOrLabel if not found (e.g. if not built in)
> NSString *ABLocalizedPropertyOrLabel(NSString *propertyOrLabel);
> 
> 
> 
> 
> 
> 
> 
> in ABGlobals.h
> 
>> Erik Stainsby
>> erik.stain...@roaringsky.ca
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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/demarco%40apple.com
>> 
>> This email sent to dema...@apple.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


NSSearchField(Cell) changes size with typing

2012-09-21 Thread Erik Stainsby
… and I can't stop it. Argh.

There is nothing expressed in my code which addresses the searchField's size 
methods:
– searchTextRectForBounds:
– searchButtonRectForBounds:
– cancelButtonRectForBounds:

This is totally whacky and I'm hoping someone on the list has an immediate "Oh 
yes, just do x" moment.

Erik Stainsby
erik.stain...@roaringsky.ca


___

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

Please do not post 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: NSSearchField(Cell) changes size with typing

2012-09-21 Thread Erik Stainsby
On 2012-09-21, at 4:06 PM, Erik Stainsby  wrote:

> … and I can't stop it. Argh.
> 
> There is nothing expressed in my code which addresses the searchField's size 
> methods:
> – searchTextRectForBounds:
> – searchButtonRectForBounds:
> – cancelButtonRectForBounds:
> 
> This is totally whacky and I'm hoping someone on the list has an immediate 
> "Oh yes, just do x" moment.
> 
> Erik Stainsby
> erik.stain...@roaringsky.ca

It is behaving as if sizeToFit: were being called on it with each key stroke.

OS X SDK 10.8.2 (deploy target 10.7)
Xcode 4.4.1

Erik

___

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

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

KVO change dict not reflecting edits in UI

2012-09-22 Thread Erik Stainsby
Hello again list,

I have a custom object class RSPerson with a handful of string properties. I 
have registered a singleton undoManager to observe changes, but the change dict 
is always coming up symmetrical. 

Edits made to the properties through UI do not appear in the change dict.
However setting the stringValue from the UI on the custom objects' properties 
does trigger the observer method (?!)

Some code. The observer is set on each person as the person is populated. 

RSPerson:

#import 
@interface RSPerson : NSObject

@property (strong) IBOutlet NSString * firstName;
@property (strong) IBOutlet NSString * lastName;
@property (strong) IBOutlet NSString * organization;

@property (strong) IBOutlet NSUndoManager * observer;

- (void) registerObserver:(id)observer;

@end

@implementation RSPerson

- (id) init {
self = [super init];
if(self) {

}
return self;
}

- (void) registerObserver:(id)observer {
self.observer = observer;
[self addObserver:observer forKeyPath:@"firstName"  
options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) 
context:NULL];
[self addObserver:observer forKeyPath:@"lastName"   
options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) 
context:NULL];
[self addObserver:observer forKeyPath:@"organization"   
options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) 
context:NULL];
}

- (void) dealloc {
[self removeObserver:self.observer forKeyPath:@"firstName"];
[self removeObserver:self.observer forKeyPath:@"lastName"];
[self removeObserver:self.observer forKeyPath:@"organization"];
self.observer = nil;
}

@end



RSUndoManager:

#import 
@interface RSUndoManager : NSUndoManager

+ (RSUndoManager *) sharedInstance;
+ (BOOL) sharedInstanceExists;

- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object 
change:(NSDictionary *)change context:(void *)context;

@end

@implementation RSUndoManager

static RSUndoManager * instance = nil;

+ (RSUndoManager *) sharedInstance {
if(!instance ) {
instance = [[[self class] alloc] init];
}
return instance;
}

+ (BOOL) sharedInstanceExists {
return (nil != instance);
}

- (id) init {
if(![[self class] sharedInstanceExists])
{
self = [super init];
if(self) {
}
return self;
}
return instance;
}

- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object 
change:(NSDictionary *)change context:(void *)context
{
NSLog(@" [%04d] %s %@: %@",__LINE__,__PRETTY_FUNCTION__, keyPath,[change 
description]);

if([keyPath isEqualToString:@"organization"])
{
NSString * newVal = [change valueForKey:NSKeyValueChangeNewKey];
NSString * oldVal = [change valueForKey:NSKeyValueChangeOldKey];
if(newVal != oldVal) {
NSLog(@" [%04d] %s %@: %@: %@",__LINE__,__PRETTY_FUNCTION__, @" not 
equal",oldVal,newVal);
}
else {
NSLog(@" [%04d] %s %@: %@: %@",__LINE__,__PRETTY_FUNCTION__, @" is 
equal",oldVal,newVal);
}
}
}

@end


The case illustrated here ought to be showing me distinct values when I enter a 
value into my UI in the organization field. No such luck. 

Any suggestions?



Erik Stainsby
erik.stain...@roaringsky.ca


___

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

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

2012-10-05 Thread Erik Stainsby
> @"SNPreferencesViewController.xib"

Don't included the xib file extension.


Erik Stainsby
erik.stain...@roaringsky.ca


On 2012-10-05, at 8:38 PM, koko  wrote:

> Ok, I have done this:
> 
>m_SNPreferencesViewController = 
> (SNPreferencesViewController*)[[NSViewController alloc] 
> initWithNibName:@"SNPreferencesViewController.xib" bundle:nil];
> 
> and this
>m_SNPreferencesViewController = 
> (SNPreferencesViewController*)[[NSViewController alloc] 
> initWithNibName:@"SNPreferencesViewController" bundle:nil];
> 
> and stepping over I get a value in m_SNPreferencesViewController but its 
> initWithNibName:bundle: is not called.
> 
> How can this be?
> 
> -koko
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca


___

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

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


NSTextFieldCell assertion failure messages?

2012-10-07 Thread Erik Stainsby
Can anyone tell me what I ought to be doing in response to the following 
message?

 *** Assertion failure in -[NSTextFieldCell 
_objectValue:forString:errorDescription:], 
/SourceCache/AppKit/AppKit-1187.34/AppKit.subproj/NSCell.m:1532


This is cropping up in a table delegate/datasource when I bind: the textField 
in an NSTableViewCell to my model object.
Each model object has three fields and any of them may be empty. So in my 
tableView:viewForColumn:row: method I set each of the textFields' stringValue: 
to @" " before binding it to it's object.


- (NSView*) tableView:(NSTableView *)tableView 
viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {

RSPerson * person = (RSPerson*)[self.personAC.content objectAtIndex:row];
NSTableCellView * cellView = [tableView makeViewWithIdentifier:[NSString 
stringWithFormat:@"%@Cell",[tableColumn identifier]] owner:self];
cellView.textField.stringValue = @" ";
[cellView.textField bind:@"stringValue" toObject:person 
withKeyPath:[tableColumn identifier] options:nil];
    return cellView;
}


Any advice appreciated.  


Erik Stainsby
erik.stain...@roaringsky.ca


___

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

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


Running a-foul of bindings with multiple-value subfields

2012-10-23 Thread Erik Stainsby
Hello all,

I am working my way through trying to understand  the correct use of bindings 
for a non-trivial model.  

The model I am working on is derived from the contacts database ABPerson. I am 
unclear how to bind to the elements of a multiple entry list. 

A person has a handful of direct properties: firstName, lastName, organization, 
image, etc.
There are also three arbitrary length lists of related data:  postal addresses, 
phone numbers, email addresses.

I have no trouble using  - bind: toObject: withKeyPath: options: for the direct 
properties.  However, try as I might I can't seem to bind to the elements of 
lists.  

My question is ought I to be using (or subclassing) an arrayController for each 
of these lists ? And then binding through the selectedIndex or some such ?

I hope this makes enough sense to someone so that they can point me down a 
lighted path.  My code at the moment is a total mess, hence no samples.

OSX 10.8
XC 4.5.1
This is a learning exercise so no legacy issues.


___

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

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


Determining which control has focus

2012-10-25 Thread Erik Stainsby
Hi list,

It seems to me this ought to be a trivial function of the OS, but I can't find 
anything that tells me how to go about this. 

I have a window which contains half a dozen text fields and three table views. 
I'd like to be able to use a single key-combo to trigger an insert into the 
current table. To make this work I need to be able to recognize each tableView 
distinctly, obviously. I also need to recognize if the current focus is not 
within one of the tables, which case I will handle differently.

I have thought of overriding - keyDown: but reading though the docs it looks 
like I would have to create a tag and reference a hand-built index associating 
the tags with the input controls, which seems insanely error prone and tedious. 
  

Is there something in the docs which I've missed? Any pointers please?

TIA,
Erik



___

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

Please do not post 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: App rejection due to app-sandboxing invalid entitlement

2012-11-01 Thread Erik Stainsby
Surely you could make the specific email client a Preference the user sets 
once, and then handle the act of sending with one menu item?  Not any help with 
the sandbox issue however...

Sent from my iCapsule somewhere in orbit

On 2012-11-01, at 7:43 AM, Martin Hewitson  wrote:

> 
> On Nov 1, 2012, at 3:37 PM, Sean McBride  wrote:
> 
>> On Thu, 1 Nov 2012 05:17:09 +0100, Martin Hewitson said:
>> 
>>> I did include a description on the resubmit. Seems it didn't help. I wrote:
>>> 
>>> "I'm using this entitlement to allow the app to send documents by mail
>>> from within the app. On 10.8 I can use the new
>>> com.apple.security.scripting-targets but this isn't available on 10.7,
>>> so there I need to use the temporary exception together with the entry
>>> com.apple.mail."
>>> 
>>> I'm really stuck on this now, so I'll probably fold and contact DTS. My
>>> guess is it will be something trivial, or a non-issue related to the way
>>> MAS does the review (automated). Clearly there can't be much wrong with
>>> the entitlements because they actually work. The app is sandboxed and
>>> can't send mails without the entitlements but can with them (tested on
>>> 10.7 and 10.8).
>> 
>> I'm curious... what about people that use non-Apple Mail.app email clients?  
>> Did you support that before? are you still able to with App Sandbox?  Maybe 
>> you can make use of NSSharingService, which does seem to support 3rd party 
>> email clients.
> 
> I supported only limited email clients before (ones with applescript 
> support), essentially by having an applescript for each, and a menu item for 
> each. Not so nice, but I could never find a simple way to just tell the 
> system to send an email using the user's default mail client. Does 
> NSSharingService do that?
> 
> Martin
> 
>> 
>> 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/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca

___

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

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

Searching array with block

2012-11-11 Thread Erik Stainsby
Following an example from Stephan Kochan's book I concocted the following 
method, which alas does not work:


- (IBAction) updateIncrementalSearch:(id)sender {

NSString * term = [sender stringValue];
if(term) {
NSMutableArray * matchResults = [NSMutableArray new];

NSUInteger index = [[self content] indexOfObjectPassingTest:^(RSPerson 
* rsp, NSUInteger idx, BOOL *stop) {
if([[rsp firstName] caseInsensitiveCompare:term] == NSOrderedSame) {
 //   *stop = YES;
[matchResults addObject:rsp];
return YES;
}
else {
return NO;
}
}];

#pragma unused(index)

if([matchResults count]){
self.matches = [NSArray arrayWithArray:matchResults];
// throw a notification
}
else {
NSLog(@" [%04d] %s %@",__LINE__,__PRETTY_FUNCTION__, @"no match 
found");
}

for(RSPerson * p in self.matches) {
NSLog(@" [%04d] %s %@",__LINE__,__PRETTY_FUNCTION__, p.firstName);
}
}
}


This consistently reports 
2012-11-11 14:20:14.050 SearchController[30109:303]  [0105] 
-[RSSearchController updateIncrementalSearch:] (null)

in spite of having 51 records which have firstName values…  And regardless of 
the number of matches which it ought to be generating it returns exactly one 
result each time. (And btw, is it legit to NSLog() from inside a block ?)

What have I missed ? Anyone ?

TIA,
Erik  
___

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

Please do not post 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: Searching array with block

2012-11-11 Thread Erik Stainsby
Quincey wrote: 

> Perhaps "matches" should really be an array-valued simple property as this 
> code suggests, but it's far more usual to have an indexed property backed by 
> an array variable. 

Are you saying hereby that I ought to be building an indexSet rather than 
duplicating the objects? and publishing the indexSet as perhaps - 
selectionIndexes  ?
That was my intention; the previous code was by way of testing that I had the 
searching and selections correct to my satisfaction.

Thanks,

- Erik
___

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

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


filterPredicate not effecting NSArrayController

2012-11-21 Thread Erik Stainsby
Hello list,

I have the following code as the action for an NSSearchField (lifted liberally 
from a CIMGF article)):


- (IBAction) updateFilter:(id)sender
{   
// clobber any previous value - from SO article - has no effect
[self.peopleArrayController setFilterPredicate: nil];

NSMutableString * searchText = [NSMutableString 
stringWithString:self.searchField.stringValue];

// Remove extraenous whitespace
while ([searchText rangeOfString:@"  "].location != NSNotFound) {
[searchText replaceOccurrencesOfString:@"  " withString:@" " options:0 
range:NSMakeRange(0, [searchText length])];
}
//Remove leading space
if ([searchText length] != 0) [searchText replaceOccurrencesOfString:@" " 
withString:@"" options:0 range:NSMakeRange(0,1)];

//Remove trailing space
if ([searchText length] != 0) [searchText replaceOccurrencesOfString:@" " 
withString:@"" options:0 range:NSMakeRange([searchText length]-1, 1)];

if ([searchText length] == 0) {
[self.peopleArrayController setFilterPredicate:nil];
return;
}

NSArray * searchTerms = [searchText componentsSeparatedByString:@" "];

if ([searchTerms count] == 1) {
NSPredicate * p = [NSPredicate predicateWithFormat:@"(firstName 
contains[cd] %@) 
OR (lastName contains[cd] %@) OR (organization 
contains[cd] %@)", searchText, searchText, searchText];

[self.peopleArrayController setFilterPredicate:p];
}
else
{
NSMutableArray * subPredicates = [[NSMutableArray alloc] init];
for (NSString * term in searchTerms) {
NSPredicate * p = [NSPredicate predicateWithFormat:@"(firstName 
contains[cd] %@) 
OR (lastName contains[cd] %@) OR (organization 
contains[cd] %@)", term, term, term];
[subPredicates addObject:p];
}
NSPredicate * cp = [NSCompoundPredicate 
andPredicateWithSubpredicates:subPredicates];

[self.peopleArrayController setFilterPredicate:cp];
}

[self.peopleArrayController rearrangeObjects];
[self.tableView reloadData];
}


The tableView is bound to an arrayController object in XIB, which is in turn a 
ref to this (weak) peopleArrayController in the windowController.

The predicates (whichever is triggered) print to log just as expected.  But the 
contents of the tableView are not reduced.
The table displays the entire contents of the 
peopleArrayController.arrangedObjects unfiltered.

Is there another step required? 
In the bindings inspector > Controller Content Parameters is a filterPredicate 
panel. Do I have to wire this up to a property which holds the current 
predicate to be applied ?

- Erik

OSX 10.8/XC 4.5.2
___

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

Please do not post 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: filterPredicate not effecting NSArrayController

2012-11-22 Thread Erik Stainsby
Thanks for leading this horse to water, Ken.
I removed the arrayController from the NIB and set the tableView's Content to 
File's Owner > peopleArrayController.arrangedObjects and VOILA.
*sigh* I seem to consistently try to put too much into the (nib/code) and get 
in the way of the services provided by the frameworks.
I'll learn… someday.




On 2012-11-22, at 3:47 PM, Ken Thomases  wrote:

> Could you be calling your -updateFilter: method prior to the NIB being loaded?
> 
> Also, did you say the peopleArrayController property is weak?  If so, then 
> that's why it's nil.  There's no strong reference to the array controller 
> you're allocating, so it gets deallocated, and weak references are nil'ed out.
> 
> Your original message said the array controller is instantiated in the NIB.  
> So why are you instantiating another one here?  peopleArrayController should 
> just point to the one from the NIB.
> 
> Regards,
> Ken
> 
> On Nov 22, 2012, at 9:38 AM, Erik Stainsby wrote:
> 
>> And then I stuck in 
>> 
>> NSAssert(self.peopleArrayController, nil);
>> 
>> which failed. Now I'm simply confused…
>> 
>> - Erik
>> 
>> On 2012-11-22, at 7:33 AM, Erik Stainsby  wrote:
>> 
>>> Sorry Ken, didn't articulate that well.  
>>> 
>>> The peopleArrayController is instantiated in the XIB, and then content is 
>>> populated using the outlet in code: 
>>> 
>>> - (void) awakeFromNib {
>>> 
>>>ABAddressBook * abk = [ABAddressBook addressBook];
>>> 
>>>NSMutableArray * temp = [NSMutableArray new];
>>>for(ABPerson * abp in [abk people]) {
>>>RSPerson * rsp = [[RSPerson alloc] initWithABPerson:abp];
>>>[temp addObject:rsp];
>>>}
>>> 
>>>NSSortDescriptor * lastNameSort = [[NSSortDescriptor alloc] 
>>> initWithKey:@"lastName" ascending:YES 
>>> selector:@selector(localizedStandardCompare:)];
>>>NSSortDescriptor * firstNameSort= [[NSSortDescriptor alloc] 
>>> initWithKey:@"firstName" ascending:YES 
>>> selector:@selector(localizedStandardCompare:)];
>>>//NSSortDescriptor * orgNameSort  = [[NSSortDescriptor alloc] 
>>> initWithKey:@"organization" ascending:YES 
>>> selector:@selector(localizedStandardCompare:)];
>>>NSArray * sortedArray   = [temp sortedArrayUsingDescriptors: 
>>> @[lastNameSort,firstNameSort]]; //,orgNameSort]];
>>> 
>>>self.people = [NSMutableArray arrayWithArray:sortedArray];
>>>self.peopleArrayController = [[NSArrayController alloc] 
>>> initWithContent:self.people];
>>> 
>>>[self.tableView reloadData];
>>> }
>>> 
>>> This works to populate the tableView using bindings in the XIB.  Therefore 
>>> I assume that the peopleArrayController is not nil.
>>> 
>>> ~ Erik
>>> 
>>> 
>>> 
>>> On 2012-11-22, at 3:31 AM, Ken Thomases  wrote:
>>> 
>>>> I don't understand.  That's a non sequitur.  I wasn't asking about the 
>>>> table view and what it displays.  I was asking whether an outlet was 
>>>> properly connected and whether the code in question was being run after 
>>>> the NIB had loaded and connected the outlet.
>>>> 
>>>> Regards,
>>>> Ken
>>>> 
>>>> On Nov 21, 2012, at 9:30 PM, Erik Stainsby wrote:
>>>> 
>>>>> Yes. The table view displays this same content. 
>>>>> 
>>>>> Erik
>>>>> 
>>>>> On 2012-11-21, at 6:42 PM, Ken Thomases  wrote:
>>>>> 
>>>>>> On Nov 21, 2012, at 6:27 PM, Erik Stainsby wrote:
>>>>>> 
>>>>>>> [self.peopleArrayController setFilterPredicate: nil];
>>>>>> 
>>>>>>>[self.peopleArrayController setFilterPredicate:p];
>>>>>> 
>>>>>>>[self.peopleArrayController setFilterPredicate:cp];
>>>>>> 
>>>>>>> [self.peopleArrayController rearrangeObjects];
>>>>>>> [self.tableView reloadData];
>>>>>> 
>>>>>>> The tableView is bound to an arrayController object in XIB, which is in 
>>>>>>> turn a ref to this (weak) peopleArrayController in the windowController.
>>>>>>> 
>>>>>>> The predicates (whichever is triggered) print to log just as expected.  
>>>>>>> But the contents of the tableView are not reduced.
>>>>>>> The table displays the entire contents of the 
>>>>>>> peopleArrayController.arrangedObjects unfiltered.
>>>>>>> 
>>>>>>> Is there another step required?
>>>>>> 
>>>>>> Have you verified that self.peopleArrayController is not nil?
>>>>>> 
>>>>>> Regards,
>>>>>> Ken
>>>>>> 
>>>> 
>>> 
>> 
> 


___

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

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

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

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

How to properly clear subordinate arrayControllers in master-detail hierarchy?

2012-11-23 Thread Erik Stainsby
I have a windowController which swaps two views, a list versus a single 
record's detail view.
The detail view contains a hierarchy of arrayControllers which each support 
table views.  
At the top level of the detail view is an arrayController which contains the 
current selection from the list view. 
Each subordinate arrayController is bound to this top 
singleItemArrayController.selection.aDetailList array.

NSWindow
ListView
arrayController
objects

DetailView
singleItemArrayController
selection
subordArrayController1
selection.subordArray1
subordArrayController2
selection.subordArray2

This works fine to a point, but fails to clear the subordinate array 
controllers when the singleItemArrayController has no selection, or even just 
when it changes.

How ought I go about flushing the current selection content from the 
subordinate array controllers? 

- Erik
___

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

Please do not post 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: Compiler can't find method declared in protocol

2012-12-18 Thread Erik Stainsby
May I ask where the actual implementation ? 

Sent from my iCapsule somewhere in orbit

On 2012-12-18, at 6:31 AM, Jerry Krinock  wrote:

> I am so stumped as to why llvm cannot see the declaration of a method in a 
> protocol that I have reproduced the issue in a small test project.  An error 
> or warning occurs in the last line of the following code, where I send the 
> message to a delegate which is declared to implement the protocol.
> 
> If ARC is on, I get this the error:
> No visible @interface for 'NSObject' declares the 
> selector 'tokenControl:renameToken:'
> 
> If ARC is off, it instead appears as a warning:
> Instance method '-tokenControl:renameToken:' not found (return type defaults 
> to 'id')
> 
> In my real project, which is non-ARC, if I ignore the warning, the code runs 
> OK.
> 
> Thank you for answering what must be a simple question.
> 
> Jerry Krinock
> D
> ***  JunkLib.h **
> 
> #import 
> 
> @protocol RPTokenControlDelegate ;
> 
> @interface RPTokenControl : NSObject {
>NSObject  * m_delegate ;
> }
> 
> @property (assign) NSObject  * delegate ;
> 
> @end
> 
> 
> ***  JunkLib.m **
> 
> #import "JunkLib.h"
> 
> @protocol RPTokenControlDelegate
> 
> - (void)tokenControl:(RPTokenControl*)
> renameToken:(NSString*)token ;
> 
> @end
> 
> @implementation RPTokenControl
> 
> - (IBAction)renameSelectedToken:(NSMenuItem*)sender {
>[[self delegate] tokenControl:self
>  renameToken:@"junk"] ;  // ERROR!!
> }
> 
> @end
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca

___

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

Please do not post 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: book for n00b

2013-01-16 Thread Erik Stainsby
I'd also recommend Scott Stevenson's "Cocoa and Objective-C: Up and Running"  
and follow that with Stephen G. Kochan's Programming in Objective-C"

$0.02


Sent from my iCapsule somewhere in orbit

On 2013-01-16, at 10:14 AM, Scott Ribe  wrote:

> I know someone who's developed an interest in developing for Mac. No 
> programming experience, some HTML, so classic newbie.
> 
> Would Hillegass' book still be the best intro?
> 
> -- 
> Scott Ribe
> scott_r...@elevated-dev.com
> http://www.elevated-dev.com/
> (303) 722-0567 voice
> 
> 
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/erik.stainsby%40roaringsky.ca
> 
> This email sent to erik.stain...@roaringsky.ca

___

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

Please do not post 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: file url to string path

2013-11-22 Thread Erik Stainsby

On Nov 22, 2013, at 10:15 AM, Jeremy Pereira  wrote:

> 
> On 21 Nov 2013, at 00:01, Kyle Sluder  wrote:
> 
>> On Wed, Nov 20, 2013, at 03:26 PM, koko wrote:
>>> How does one turn this:
>>> 
>>> file://localhost/Volumes/Macintosh%20HD/Included%20Free%20Designs/Aibnb18(colorized).pes
>> 
>> http://lmgtfy.com/?q=NSURL
> 
> Which leads you, via an enormous list to the -path method, which gives you 
> the path part of the URL after unescaping it.  
> 

… which is what I told you at the beginning when you asked this question … 
___

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

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