Re: Possible causes of "attempted layout while textStorage is editing"?

2011-08-31 Thread Gideon King
Here is the complete stack trace

2011-08-31 15:25:11 -0400[5]: ERROR - 14764064ms (NMApplication.m:81) 
-[NMApplication handleRunException:] - NSException Exception encountered: 
-[AAMainEditingLayoutManager 
_fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:] *** attempted 
layout while textStorage is editing. It is not valid to cause the layoutManager 
to do layout while the textStorage is editing (ie the textStorage has been sent 
a beginEditing message without a matching endEditing.)

2011-08-31 15:25:11 -0400[5]: 0 CoreFoundation 0x7fff8b3e0986 
__exceptionPreprocess + 198
2011-08-31 15:25:11 -0400[5]: 1 libobjc.A.dylib 0x7fff8bb11d5e 
objc_exception_throw + 43
2011-08-31 15:25:11 -0400[5]: 2 CoreFoundation 0x7fff8b3e07ba +[NSException 
raise:format:arguments:] + 106
2011-08-31 15:25:11 -0400[5]: 3 CoreFoundation 0x7fff8b3e0744 +[NSException 
raise:format:] + 116
2011-08-31 15:25:11 -0400[5]: 4 AppKit 0x7fff89f1d0bc 
-[NSLayoutManager(NSPrivate) 
_fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:] + 432
2011-08-31 15:25:11 -0400[5]: 5 AppKit 0x7fff89f1ccce 
-[NSLayoutManager(NSPrivate) _fillLayoutHoleAtIndex:desiredNumberOfLines:] + 203
2011-08-31 15:25:11 -0400[5]: 6 AppKit 0x7fff89f1af46 
_NSFastFillAllLayoutHolesUpToEndOfContainerForGlyphIndex + 500
2011-08-31 15:25:11 -0400[5]: 7 AppKit 0x7fff89f1ac5e -[NSLayoutManager 
textContainerForGlyphAtIndex:effectiveRange:] + 223
2011-08-31 15:25:11 -0400[5]: 8 AppKit 0x7fff89f1aa42 -[NSLayoutManager 
glyphRangeForTextContainer:] + 304
2011-08-31 15:25:11 -0400[5]: 9 NovaMind5 0x00010014453c -[AARichTextModel 
recalculateSize] + 1640
2011-08-31 15:25:11 -0400[5]: 10 NMFoundation 0x000100476f2f 
-[MAKVObservation observeValueForKeyPath:ofObject:change:context:] + 122
2011-08-31 15:25:11 -0400[5]: 11 Foundation 0x7fff8b83118a 
NSKeyValueNotifyObserver + 387
2011-08-31 15:25:11 -0400[5]: 12 Foundation 0x7fff8b852387 
NSKeyValueDidChange + 486
2011-08-31 15:25:11 -0400[5]: 13 Foundation 0x7fff8b7fea2f 
-[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 130
2011-08-31 15:25:11 -0400[5]: 14 CoreData 0x7fff8f7e7007 
_PF_ManagedObject_DidChangeValueForKeyIndex + 103
2011-08-31 15:25:11 -0400[5]: 15 CoreData 0x7fff8f7e6558 
_sharedIMPL_setvfk_core + 264
2011-08-31 15:25:11 -0400[5]: 16 NovaMind5 0x00010016118e 
-[AATopicShapeModelBase setNewWidthForMainRect:fromOldWidth:] + 2657
2011-08-31 15:25:11 -0400[5]: 17 NovaMind5 0x0001001606b4 
-[AATopicShapeModelBase setNewSizeForMainRect:fromOldSize:] + 130
2011-08-31 15:25:11 -0400[5]: 18 NovaMind5 0x0001001882e2 
-[AAMapView(mouse) resizeTopicNodeVisual:usingHandle:withEvent:] + 2287
2011-08-31 15:25:11 -0400[5]: 19 NovaMind5 0x000100187721 
-[AAMapView(mouse) mouseDown:] + 5283
2011-08-31 15:25:11 -0400[5]: 20 AppKit 0x7fff89f4066e -[NSWindow 
sendEvent:] + 6280
2011-08-31 15:25:11 -0400[5]: 21 AppKit 0x7fff89ed8f19 -[NSApplication 
sendEvent:] + 5665
2011-08-31 15:25:11 -0400[5]: 22 OmniAppKit 0x000100574900 -[OAApplication 
sendEvent:] + 144
2011-08-31 15:25:11 -0400[5]: 23 AppKit 0x7fff89e6f42b -[NSApplication run] 
+ 548
2011-08-31 15:25:11 -0400[5]: 24 OmniAppKit 0x000100571774 -[OAApplication 
run] + 132
2011-08-31 15:25:11 -0400[5]: 25 AppKit 0x7fff8a0ed52a NSApplicationMain + 
867
2011-08-31 15:25:11 -0400[5]: 26 NovaMind5 0x00011688 start + 52
2011-08-31 15:25:11 -0400[5]: 27 ??? 0x0002 0x0 + 2


There are no other console log messages before this.

Regards

Gideon








On 01/09/2011, at 8:02 AM, Martin Wierschin wrote:

>> _fillLayoutHoleForChar acterRange:desiredNumberOfLines:isSoft: *** attempted 
>> layout while textStorage is editing. It is not valid to cause the 
>> layoutManager to do layout while the textStorage is editing (ie the 
>> textStorage has been sent a beginEditing message without a matching 
>> endEditing.)
> 
> ...
>> I have not called begin editing or end editing at all, and there are no 
>> unmatched begin and end editing calls in my code, and there are no other 
>> threads editing the text storage. Nothing that I can see that would trigger 
>> this.
> 
> That might be, but perhaps the begin/end editing calls are made for you 
> automatically as part of some bigger operation your code (or the user) 
> requested. For example, it might be that Apple's implementation of 
> -[NSTextView changeFont:] wraps its changes in begin/end editing.
> 
>> The offending line of code is:
>> 
>> [layoutManager glyphRangeForTextContainer:[[layoutManager textContainers] 
>> firstObject]];
> 
> 
> When are you requesting this layout exactly? Can you post the full backtrace 
> for the exception?
> 
> I'd ask the user to submit a recent console log to see if there have been any 
> other errors. It could be that an earlier exception is unwinding the stack 
> during text storage editing, leaving the storage in its invalid state. You 
> might also m

Re: setTitleWithMnemonic

2011-08-31 Thread KappA
I never said I was using the "mnemonic" feature... just using it for setting
plain text. Is that what you are curious to see?

Kappa

On Thu, Sep 1, 2011 at 12:07 AM, Jerry Krinock  wrote:

>
> On 2011 Aug 31, at 16:42, Fritz Anderson wrote:
>
> > I don't think it's because there's a strong '90s-revival faction in the
> AppKit team
>
> Oh?  How about the '90s-revival faction who recently decided it was cool to
> be able to resize a window by dragging any edge? :))
>
> On 2011 Aug 31, at 18:51, KappA wrote:
>
> > I actually use that API to set the text successfully in my applications,
> so far without any problems.
>
> KappA, I'd like to see one of your applications, or a screenshot with those
> mnemonics.  Probably other readers would, too.  Please post a link.
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/rejekted%40gmail.com
>
> This email sent to rejek...@gmail.com
>
___

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

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

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

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


Re: Linking an NSWindow in IB

2011-08-31 Thread Guy Halford-Thompson
Thanks for all the responses.

I have managed to get it working using Jens response... it seems I got
a bit confused about how the linking via IB goes.

@Ron, thanks for the recommendation, I am finding it very difficult to
find good resources for Cocoa programming, and the apple developer
docs are not exactly easy to follow.

Many thanks

Guy

On 31 August 2011 20:06, Ron Fleckner  wrote:
> Hello Guy,
>
> It's good that you posted some more code.  Your 'MyWindow' object is a 
> subclass of NSObject.  Even if it was a subclass of NSWindow, which I think 
> is what you want (a window, right?), you still set up a separate window in 
> code with alloc-init, which in any case is not a window but an NSObject.  
> Really, at this point, you can't keep asking questions without first doing 
> some basic homework yourself. I doubt that people here will bother answering 
> your questions until you've done that.
>
> I recommend Aaron Hillegas's excellent 'Cocoa Programming For Mac OS X'
>
>
> On 01/09/2011, at 12:54 PM, Guy Halford-Thompson wrote:
>
>> Hi,
>>
>> Thanks for the help, I really appreciate it.
>>
>> I still appear to be having some trouble tho.
>>
>> Here is my code:
>>
>> MyWindow.h
>> 
>> #import 
>>
>> @interface MyWindow : NSObject  {
>>
>>   IBOutlet NSWindow *window;
>> }
>>
>> -(void)showWindow:(id)sender;
>>
>> @property (assign) IBOutlet NSWindow *window;
>>
>> @end
>>
>> MyWindow.m
>> ---
>>
>> #import "MyWindow.h"
>>
>> @implementation MyWindow
>>
>> @synthesize window;
>>
>> -(void)showWindow:(id)sender {
>>   NSLog(@"**Window %@",window);
>>   [window makeKeyAndOrderFront:nil];
>> }
>>
>> @end
>>
>>
>> Then... in my main app delegate
>>
>> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
>>
>> if {...condition is met} {
>>        MyWindow *uni = [[MyWindow alloc] init];
>>        [uni showWindow:nil];
>>  }
>> }
>>
>> But its still not working...
>>
>> Sorry if this is pretty basic, but getting my head round objective C
>> is proving to be difficult.
>>
>> Thanks
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/ronfleckner%40ozemail.com.au
>>
>> This email sent to ronfleck...@ozemail.com.au
>
>



-- 
Guy Halford-Thompson
Blog                  - http://www.cach.me/blog
Twitter               - https://twitter.com/mrwooster
Google Plus       - http://gplus.name/guy
___

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

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

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

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


Re: setTitleWithMnemonic

2011-08-31 Thread Jerry Krinock

On 2011 Aug 31, at 16:42, Fritz Anderson wrote:

> I don't think it's because there's a strong '90s-revival faction in the 
> AppKit team

Oh?  How about the '90s-revival faction who recently decided it was cool to be 
able to resize a window by dragging any edge? :))

On 2011 Aug 31, at 18:51, KappA wrote:

> I actually use that API to set the text successfully in my applications, so 
> far without any problems.

KappA, I'd like to see one of your applications, or a screenshot with those 
mnemonics.  Probably other readers would, too.  Please post a link.

___

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

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

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

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


Re: Linking an NSWindow in IB

2011-08-31 Thread Conrad Shultz
Sorry I'm on my phone so I can't write a detailed response, but you're just 
structuring your app kind of backwards. 

In IB you would want to have a connection between your custom window and an 
outlet in your app delegate in this case. You would then send the window an 
"order front" message from the app delegate. 

Putting an outlet to your window _inside the window_ is counterproductive. (I 
assume also that you meant for MyWindow to be a subclass of NSWindow, not 
NSObject.)

(Sent from my iPhone.)

--
Conrad Shultz

On Aug 31, 2011, at 19:54, Guy Halford-Thompson  wrote:

> Hi,
> 
> Thanks for the help, I really appreciate it.
> 
> I still appear to be having some trouble tho.
> 
> Here is my code:
> 
> MyWindow.h
> 
> #import 
> 
> @interface MyWindow : NSObject  {
> 
>   IBOutlet NSWindow *window;
> }
> 
> -(void)showWindow:(id)sender;
> 
> @property (assign) IBOutlet NSWindow *window;
> 
> @end
> 
> MyWindow.m
> ---
> 
> #import "MyWindow.h"
> 
> @implementation MyWindow
> 
> @synthesize window;
> 
> -(void)showWindow:(id)sender {
>   NSLog(@"**Window %@",window);
>   [window makeKeyAndOrderFront:nil];
> }
> 
> @end
> 
> 
> Then... in my main app delegate
> 
> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
> 
> if {...condition is met} {
>MyWindow *uni = [[MyWindow alloc] init];
>[uni showWindow:nil];
>  }
> }
> 
> But its still not working...
> 
> Sorry if this is pretty basic, but getting my head round objective C
> is proving to be difficult.
> 
> Thanks
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Linking an NSWindow in IB

2011-08-31 Thread Jens Alfke
MYWindow isn’t a window, it’s an NSObject that can act as a window delegate. So 
creating one isn’t going to create a window. You don’t have any code that 
creates a window; there’s a window property but nothing that sets it. Also, 
you’re calling a -showWindow: method on your MyWindow class, but you never 
defined or implemented such a method.

What you want to do is

- Add a window to your main nib/xib file.
- Add a MyWindow object too (drag in a generic object and set its class to 
MyWindow)
- Wire the window up to the MyWindow (control-drag from MyWindow to the 
NSWindow and select the “window” outlet)
- Create another IBOutlet variable in your app delegate’s class, of type 
MyWindow* … let’s say it’s named myWindow.
- Wire that up to the MyWindow object in the nib.
- Now to display the window your app delegate calls [[myWindow window] 
makeKeyAndOrderFront: self]

I haven’t looked at the tutorials and intro docs in a while, but there must be 
some that cover this stuff.

—Jens___

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

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

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

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


Re: Linking an NSWindow in IB

2011-08-31 Thread Guy Halford-Thompson
Hi,

Thanks for the help, I really appreciate it.

I still appear to be having some trouble tho.

Here is my code:

MyWindow.h

#import 

@interface MyWindow : NSObject  {

   IBOutlet NSWindow *window;
}

-(void)showWindow:(id)sender;

@property (assign) IBOutlet NSWindow *window;

@end

MyWindow.m
---

#import "MyWindow.h"

@implementation MyWindow

@synthesize window;

-(void)showWindow:(id)sender {
   NSLog(@"**Window %@",window);
   [window makeKeyAndOrderFront:nil];
}

@end


Then... in my main app delegate

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

 if {...condition is met} {
MyWindow *uni = [[MyWindow alloc] init];
[uni showWindow:nil];
  }
}

But its still not working...

Sorry if this is pretty basic, but getting my head round objective C
is proving to be difficult.

Thanks
___

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

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

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

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


Re: Problems with firstResponder

2011-08-31 Thread Ron Fleckner
Hello Geert,

I'm certainly no expert.  However, I've noticed that people learning Cocoa 
(and/or OOP) often directly set things that in fact don't need setting at all.  
A lot of the basic functionality of Cocoa based apps comes for free.  Things 
like the responder chain usually do the right thing with very little input from 
the programmer.  This is no answer to your question, of course, but I suspect 
there may be something you've done that breaks the desired behaviour.  I've 
just spent literally about 30 seconds creating a test app with one window and 
six text fields.  Build and run and the first text field has firstResponder 
status -- that is, the text cursor is live and blinking inside it.  Pressing 
Tab moves firstResponder status to each other text field in turn and eventually 
comes back to the first.  Not a line of my own code.

So I guess the best thing for you to do is read the documentation and take some 
time to learn the system before beginning to modify it.  Or perhaps someone 
else with more intimate knowledge will help you.

Ron

PS NSApp is a global for your app, so [NSApp delegate] will get you a reference 
to your FakturaAppDelegate  instance.

On 01/09/2011, at 7:51 AM, Geert-Jan Korsbø Nilsen wrote:

> Thanks, Ron, I did put in the following code instead of becomeFirstResponder:
> 
> FakturaAppDelegate *appDelegate = (FakturaAppDelegate *)[[NSApplication 
> sharedApplication] delegate]; 
> [appDelegate.window makeFirstResponder:self.invoiceCredit];
> 
> Now nothing works...
> 
> 
> On Aug 31, 2011, at 11:22 PM, Ron Fleckner wrote:
> 
>> 
>> On 01/09/2011, at 7:05 AM, Geert-Jan Korsbø Nilsen wrote:
>> 
>>> Im working on a tiny app just to learn cocoa, and Im having a hard time 
>>> with setting FirstResponder to some NSTextFields.
>>> 
>>> When the view opens, I want the first NSTextField, clientNumber, to be 
>>> selected, so I trigger [clientNumber becomeFirstResponder] at the end of my 
>>> loadView method, but it does not select the text field.
>>> But when I click the button that fires the (IBAction)addToArray method, it 
>>> selects the right text field. Further do I have another text field, it 
>>> should contain integers only, so I have a crude verification for it. When 
>>> the content is not a int, I get a beep, just like it should, but it does 
>>> not select the text field.
>> 
>> Geert,
>> 
>> here's an excerpt from the documentation.  Note the last sentence.
>> 
>> 
>> 
>> - (BOOL)becomeFirstResponder
>> Return Value
>> Returns YES.
>> 
>> Discussion
>> If the previous first responder was not an NSTextView on the same 
>> NSLayoutManager as the receivingNSTextView, this method draws the selection 
>> and updates the insertion point if necessary.
>> 
>> Use the NSWindow method makeFirstResponder:, not this method, to make a text 
>> view the first responder. Never invoke this method directly.
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/ronfleckner%40ozemail.com.au
> 
> This email sent to ronfleck...@ozemail.com.au

___

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

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

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

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


Re: setTitleWithMnemonic

2011-08-31 Thread KappA
Interesting.

I actually use that API to set the text successfully in my applications, so
far without any problems.

Thanks,
Kappa

On Wed, Aug 31, 2011 at 7:42 PM, Fritz Anderson wrote:

> On 31 Aug 2011, at 2:00 PM, Rajendran P wrote:
>
> > is it advisable to use the API setTitleWithMnemonic ? the document
> discussion
> > says
> >
> > "Discussion
> > Mnemonics are not supported in Mac OS X. "
> >
> > strangely , the API is not deprecated
>
> Given that the method has never had any effect in the ten years Mac OS X
> has existed, I'm not sure why you wonder if it is advisable to use it
> anyway? Mnemonics are not displayed, and there is no way to trigger them.
>
> The API probably carried over from NeXTStep or possibly the Yellow Box (the
> long-abandoned Cocoa for Windows). It is deprecated for NSMenuItem. You'd
> have to ask Apple why it hasn't been dropped. I don't think it's because
> there's a strong '90s-revival faction in the AppKit team, so I'm guessing
> it's just inertia.
>
>— F
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/rejekted%40gmail.com
>
> This email sent to rejek...@gmail.com
>
___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread Martin Wierschin
>>>  NSFileHandle   *hndl = [NSFileHandle fileHandleForReadingAtPath:path];
>>>  long long lngth = [hndl seekToEndOfFile];
>>> 
>>> This gets you the length in bytes.
>> 

>> And loads the entire file into memory!!

> 
> Does it? I didn't think seek loaded anything, and it was just for random 
> access.

Either way, I think avoiding NSFileHandle is the right thing to do. 
NSFileHandle implies a desire to read/write data. Who knows what the reading 
initializer does. Maybe it assigns a file descriptor (limited resource) right 
away, or does something silly like prefetch data into a buffer.

~Martin

___

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

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

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

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


Re: Won't Applescript command use defined ivars?

2011-08-31 Thread Martin Wierschin
> But I am going to need the application to use the instance of the class from 
> when it's started, not make a new instance every time the script command is 
> given.

As Scott mentioned, that's not how the Cocoa framework works with regard to 
AppleScript. It's going to create a new instance of your command subclass every 
time; don't try and fight that. 

It's a structural problem, but one that's easily overcome by splitting apart 
your AppleScript and database logic, which you should probably be doing 
anyways. Similarly, your application delegate should not be your 
NSScriptCommand subclass.

> -(void)applicationDidFinishLaunching:(NSNotification *)aNotification
> {
> userName = NSUserName(); //I also may have tried to retain it but no 
> difference in outcome when Applescript calls the method
> theConnection = [[ODBCConnection alloc] init];

Retaining the ivar might not make a difference now, but you really need to 
understand and implement the Cocoa memory management guidelines. Carelessly 
ignoring the rules because they don't make a difference during testing is 
dangerous and will cause you heartache and lost time later. Also, because your 
subclass doesn't implement a dealloc method, you're leaking that connection 
object. 

I can't stress enough that it's imperative you understand the memory management 
rules.

~Martin

___

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

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

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

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


Re: setTitleWithMnemonic

2011-08-31 Thread Fritz Anderson
On 31 Aug 2011, at 2:00 PM, Rajendran P wrote:

> is it advisable to use the API setTitleWithMnemonic ? the document discussion 
> says
> 
> "Discussion
> Mnemonics are not supported in Mac OS X. "
> 
> strangely , the API is not deprecated 

Given that the method has never had any effect in the ten years Mac OS X has 
existed, I'm not sure why you wonder if it is advisable to use it anyway? 
Mnemonics are not displayed, and there is no way to trigger them. 

The API probably carried over from NeXTStep or possibly the Yellow Box (the 
long-abandoned Cocoa for Windows). It is deprecated for NSMenuItem. You'd have 
to ask Apple why it hasn't been dropped. I don't think it's because there's a 
strong '90s-revival faction in the AppKit team, so I'm guessing it's just 
inertia.

— F

___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread Andy Lee
I hate when that happens.

--Andy

On Aug 31, 2011, at 7:33 PM, Kyle Sluder wrote:

> On Wed, Aug 31, 2011 at 4:32 PM, Andy Lee  wrote:
>> Does it? I didn't think seek loaded anything, and it was just for random 
>> access.
> 
> Yeah, my brain substituted -readDataToEndOfFile.
> 
> --Kyle Sluder

___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread Kyle Sluder
On Wed, Aug 31, 2011 at 4:32 PM, Andy Lee  wrote:
> Does it? I didn't think seek loaded anything, and it was just for random 
> access.

Yeah, my brain substituted -readDataToEndOfFile.

--Kyle Sluder
___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread Andy Lee
On Aug 31, 2011, at 7:27 PM, Kyle Sluder wrote:
> On Wed, Aug 31, 2011 at 4:21 PM, dct  wrote:
>> Jon
>> 
>> Or, knowing the path,  you might try using NSFileHandle :
>> 
>>  NSFileHandle   *hndl = [NSFileHandle fileHandleForReadingAtPath:path];
>>  long long lngth = [hndl seekToEndOfFile];
>> 
>> This gets you the length in bytes.
> 
> And loads the entire file into memory!!

Does it? I didn't think seek loaded anything, and it was just for random access.

--Andy

___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread Kyle Sluder
On Wed, Aug 31, 2011 at 4:21 PM, dct  wrote:
> Jon
>
> Or, knowing the path,  you might try using NSFileHandle :
>
>  NSFileHandle   *hndl = [NSFileHandle fileHandleForReadingAtPath:path];
>  long long             lngth = [hndl seekToEndOfFile];
>
> This gets you the length in bytes.

And loads the entire file into memory!!

There are so many better approaches that have already been mentioned
in this thread.

--Kyle Sluder
___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread dct
Jon

Or, knowing the path,  you might try using NSFileHandle :

  NSFileHandle   *hndl = [NSFileHandle fileHandleForReadingAtPath:path];
  long long lngth = [hndl seekToEndOfFile];

This gets you the length in bytes.

Don
___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread Charles Srstka
I think the NSURL methods are actually the “preferred” way to do it these days 
on the Mac, since the NSFileManager method takes paths, and URLs are clearly 
the direction that Apple is moving.

In addition to NSURLFileSizeKey and NSURLFileAllocatedSizeKey, which will give 
you the logical and physical sizes of the data fork, NSURL also provides 
NSURLTotalFileSizeKey and NSURLTotalFileAllocatedSizeKey, which will include 
the size of the resource fork and any other extended attributes the file may 
have.

Charles

On Aug 31, 2011, at 3:21 PM, Kyle Sluder wrote:

> On Wed, Aug 31, 2011 at 12:51 PM, Jon Sigman  wrote:
>> How does one determine the size of a file on disk using Cocoa?
>> I've looked at NSFileManager but it doesn't seem to offer any
>> methods for finding file attributes.
> 
> You mean other than -attributesOfItemAtPath:error:?
> 
> http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html
> 
> Or -[NSURL resourceValuesForKeys:error:], which is newer, unsupported
> on iOS, and the existence of which I find mysterious:
> http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html
> 
> --Kyle Sluder
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40charlessoft.com
> 
> This email sent to cocoa...@charlessoft.com

___

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

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

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

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


setTitleWithMnemonic

2011-08-31 Thread Rajendran P
hi All,
   
Question 1 : 
 is it advisable to use the API setTitleWithMnemonic ? the document discussion 
says

"Discussion
Mnemonics are not supported in Mac OS X. "

strangely , the API is not deprecated 

Question 2 : 
if the answer is yes for the  Question 1 , how do i do a binding with Mnuemonic 
 
? i hate to get the IBoutlet connected and all ui elements referenced in my 
code 
.


 

 
  P.Rajendran or Raju   

(for further details contact 
me ) 

___

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

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

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

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


Re: Possible causes of "attempted layout while textStorage is editing"?

2011-08-31 Thread Martin Wierschin
> _fillLayoutHoleForChar acterRange:desiredNumberOfLines:isSoft: *** attempted 
> layout while textStorage is editing. It is not valid to cause the 
> layoutManager to do layout while the textStorage is editing (ie the 
> textStorage has been sent a beginEditing message without a matching 
> endEditing.)

...
> I have not called begin editing or end editing at all, and there are no 
> unmatched begin and end editing calls in my code, and there are no other 
> threads editing the text storage. Nothing that I can see that would trigger 
> this.

That might be, but perhaps the begin/end editing calls are made for you 
automatically as part of some bigger operation your code (or the user) 
requested. For example, it might be that Apple's implementation of -[NSTextView 
changeFont:] wraps its changes in begin/end editing.

> The offending line of code is:
> 
> [layoutManager glyphRangeForTextContainer:[[layoutManager textContainers] 
> firstObject]];


When are you requesting this layout exactly? Can you post the full backtrace 
for the exception?

I'd ask the user to submit a recent console log to see if there have been any 
other errors. It could be that an earlier exception is unwinding the stack 
during text storage editing, leaving the storage in its invalid state. You 
might also make sure the user isn't running any text system haxies.

~Martin

___

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

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

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

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


Re: Problems with firstResponder

2011-08-31 Thread Geert-Jan Korsbø Nilsen
Thanks, Ron, I did put in the following code instead of becomeFirstResponder:

FakturaAppDelegate *appDelegate = (FakturaAppDelegate *)[[NSApplication 
sharedApplication] delegate]; 
[appDelegate.window makeFirstResponder:self.invoiceCredit];

Now nothing works...


On Aug 31, 2011, at 11:22 PM, Ron Fleckner wrote:

> 
> On 01/09/2011, at 7:05 AM, Geert-Jan Korsbø Nilsen wrote:
> 
>> Im working on a tiny app just to learn cocoa, and Im having a hard time with 
>> setting FirstResponder to some NSTextFields.
>> 
>> When the view opens, I want the first NSTextField, clientNumber, to be 
>> selected, so I trigger [clientNumber becomeFirstResponder] at the end of my 
>> loadView method, but it does not select the text field.
>> But when I click the button that fires the (IBAction)addToArray method, it 
>> selects the right text field. Further do I have another text field, it 
>> should contain integers only, so I have a crude verification for it. When 
>> the content is not a int, I get a beep, just like it should, but it does not 
>> select the text field.
> 
> Geert,
> 
> here's an excerpt from the documentation.  Note the last sentence.
> 
> 
> 
> - (BOOL)becomeFirstResponder
> Return Value
> Returns YES.
> 
> Discussion
> If the previous first responder was not an NSTextView on the same 
> NSLayoutManager as the receivingNSTextView, this method draws the selection 
> and updates the insertion point if necessary.
> 
> Use the NSWindow method makeFirstResponder:, not this method, to make a text 
> view the first responder. Never invoke this method directly.

___

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

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

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

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


Re: Problems with firstResponder

2011-08-31 Thread Ron Fleckner

On 01/09/2011, at 7:05 AM, Geert-Jan Korsbø Nilsen wrote:

> Im working on a tiny app just to learn cocoa, and Im having a hard time with 
> setting FirstResponder to some NSTextFields.
> 
> When the view opens, I want the first NSTextField, clientNumber, to be 
> selected, so I trigger [clientNumber becomeFirstResponder] at the end of my 
> loadView method, but it does not select the text field.
> But when I click the button that fires the (IBAction)addToArray method, it 
> selects the right text field. Further do I have another text field, it should 
> contain integers only, so I have a crude verification for it. When the 
> content is not a int, I get a beep, just like it should, but it does not 
> select the text field.

Geert,

here's an excerpt from the documentation.  Note the last sentence.



- (BOOL)becomeFirstResponder
Return Value
Returns YES.

Discussion
If the previous first responder was not an NSTextView on the same 
NSLayoutManager as the receivingNSTextView, this method draws the selection and 
updates the insertion point if necessary.

Use the NSWindow method makeFirstResponder:, not this method, to make a text 
view the first responder. Never invoke this method 
directly.___

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

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

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

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


Re: ARC + CF types

2011-08-31 Thread Thomas Davie

On 31 Aug 2011, at 21:55, Clark Cox wrote:

> On Mon, Aug 29, 2011 at 7:20 AM, Thomas Davie  wrote:
>> I'm not really very clear on how ARC and CF types are meant to interact yet, 
>> because of that I've managed to create some buggy code, could someone have a 
>> quick stare at this and tell me what I've misunderstood that's causing a 
>> segfault when adding to the mutable set:
>> 
>> https://gist.github.com/1178475
> 
> Does the implementation of those objects' -hash method agree with your
> definition of equality? (i.e. it is almost always wrong to change the
> concept of equality without also changing the hash implementation).

The only change in the equality concept is that isEqualToAPIObject: assumes 
that it's been given an APIObject and doesn't check that the other object is 
the right class.  Otherwise the equality semantics are identical.
if (*ra4 != 0xffc78948) { return false; }

___

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

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


Problems with firstResponder

2011-08-31 Thread Geert-Jan Korsbø Nilsen
Im working on a tiny app just to learn cocoa, and Im having a hard time with 
setting FirstResponder to some NSTextFields.

When the view opens, I want the first NSTextField, clientNumber, to be 
selected, so I trigger [clientNumber becomeFirstResponder] at the end of my 
loadView method, but it does not select the text field.
But when I click the button that fires the (IBAction)addToArray method, it 
selects the right text field. Further do I have another text field, it should 
contain integers only, so I have a crude verification for it. When the content 
is not a int, I get a beep, just like it should, but it does not select the 
text field.

Here is my code:


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
  NSLog(@"initWithNibName");
}
return self;
}

- (void)viewWillLoad {
NSLog(@"viewWillLoad");
}

- (void)viewDidLoad {
NSLog(@"viewDidLoad");
[self initNewInvoice];
}

- (void)loadView {
NSLog(@"loadView");
[self viewWillLoad];
[super loadView];
[self viewDidLoad];
[clientNumber becomeFirstResponder]; 
}

- (void)awakeFromNib
{
NSLog(@"awakeFromNib");
}

- (IBAction)saveInvoice:(id)sender
{
[invoiceCredit becomeFirstResponder];
}

- (IBAction)addToArray:(id)sender
{
[clientNumber setStringValue: @"Toodeloo"];
[clientNumber becomeFirstResponder];   
}

- (IBAction)updateCreditDays:(id)sender
{
if(invoiceCredit.intValue){
[self updateCredit];
}else{
NSBeep();
[invoiceCredit becomeFirstResponder];
}
}


I really hope someone can help me out here.

Regards,


GJ Nilsen

___

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

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

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

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


Re: ARC + CF types

2011-08-31 Thread Clark Cox
On Mon, Aug 29, 2011 at 7:20 AM, Thomas Davie  wrote:
> I'm not really very clear on how ARC and CF types are meant to interact yet, 
> because of that I've managed to create some buggy code, could someone have a 
> quick stare at this and tell me what I've misunderstood that's causing a 
> segfault when adding to the mutable set:
>
> https://gist.github.com/1178475

Does the implementation of those objects' -hash method agree with your
definition of equality? (i.e. it is almost always wrong to change the
concept of equality without also changing the hash implementation).

-- 
Clark S. Cox III
clarkc...@gmail.com
___

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

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

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

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


Re: LLVM 2.1 Error

2011-08-31 Thread Bruce Cresanta
No, there is no such file at that path.




On Aug 31, 2011, at 12:08 AM, Jens Alfke wrote:

> 
> On Aug 29, 2011, at 11:04 PM, Bruce Cresanta wrote:
> 
>> clang: error: no such file or directory: 
>> '/Volumes/Volume/proSEOLion/proSEO/proSEO/proSEO-Prefix.pch'
>> clang: error: no input files
>> Command /Developer/usr/bin/clang failed with exit code 1
> 
> Is there such a file at that path? If not, what is the actual path to your 
> .pch file?
> 
>> I've checked the PCH settings in the Linker Section of the Target.   Nothing 
>> is out of the ordinary.   Can you suggest why this is happening?
> 
> Um, the PCH settings are in the compiler section, not linker. And since 
> clearly something _is_ out of the ordinary, it would help if you told us what 
> they are set to :)
> 
> I’m guessing that the relative path to your .pch file is specified 
> incorrectly in the target settings; there’s probably one too many “proSEO/“ 
> in it.
> 
> —Jens

___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread Martin Hewitson
Hi Jon,

You can do something like:

NSFileManager *fm = [NSFileManager defaultManager];
NSDictionary *fattrs = [fm attributesOfItemAtPath:fullpath error:NULL];
sizeOnDisk = [fattrs objectForKey:NSFileSize];

Martin

On Aug 31, 2011, at 09:51 PM, Jon Sigman wrote:

> How does one determine the size of a file on disk using Cocoa? 
> I've looked at NSFileManager but it doesn't seem to offer any 
> methods for finding file attributes. 
> OSX 10.6.8
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/martin.hewitson%40aei.mpg.de
> 
> This email sent to martin.hewit...@aei.mpg.de


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread Nick Zitzmann

On Aug 31, 2011, at 1:51 PM, Jon Sigman wrote:

> How does one determine the size of a file on disk using Cocoa? 
> I've looked at NSFileManager but it doesn't seem to offer any 
> methods for finding file attributes. 

If you don't care about the size of the resource fork if present: 


Nick Zitzmann


___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread Jon Sigman
Many thanks to all who responded. 
Somehow I didn't notice the attributes methods of NSFileManager. 
I've got it working!
-Jon

___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread Andy Lee
On Aug 31, 2011, at 3:51 PM, Jon Sigman wrote:
> How does one determine the size of a file on disk using Cocoa? 
> I've looked at NSFileManager but it doesn't seem to offer any 
> methods for finding file attributes. 
> OSX 10.6.8

NSFileManager has attributesOfItemAtPath:error:.

Not to be confused with attributesOfFileSystemForPath:error:.

--Andy


___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread Hank Heijink (Mailinglists)
See the documentation for - (NSDictionary *)attributesOfItemAtPath:(NSString 
*)path error:(NSError **)error in NSFileManager.

The returned dictionary has a convenience method -fileSize.

Best,
Hank

On Aug 31, 2011, at 3:51 PM, Jon Sigman wrote:

> How does one determine the size of a file on disk using Cocoa? 
> I've looked at NSFileManager but it doesn't seem to offer any 
> methods for finding file attributes. 
> OSX 10.6.8
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/hank.list%40runbox.com
> 
> This email sent to hank.l...@runbox.com
> 

___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread Gary L. Wade
If all you care about is the logical size of the datafork of a file,
NSFileManager's method attributesOfItemAtPath:error: will give you a
dictionary, but if you want to factor in the physical size, resource fork,
or extended attributes, you'll need to use a lower-level API, such as
FSGetCatalogInfo.  Note that physical size is not always returned as
expected, so search for solutions on how to handle those cases.

On 08/31/2011 12:51 PM, "Jon Sigman"  wrote:

>How does one determine the size of a file on disk using Cocoa?
>I've looked at NSFileManager but it doesn't seem to offer any
>methods for finding file attributes.
>OSX 10.6.8


___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread Jens Alfke

On Aug 31, 2011, at 12:51 PM, Jon Sigman wrote:

> How does one determine the size of a file on disk using Cocoa? 
> I've looked at NSFileManager but it doesn't seem to offer any 
> methods for finding file attributes. 

You mean like -attributesOfItemAtPath:error: ? :) It returns a dictionary of 
file attributes. It also offers some category methods on NSDictionary to make 
it easy to get their values, so you can just use [attrDict fileSize]. (They’re 
listed at the very end of NSFileManager.h.)

—Jens___

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

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

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

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


Re: Size of a file on disk

2011-08-31 Thread Conrad Shultz
NSFileManager's attributesOfItemAtPath:error:

(Sent from my iPhone.)

--
Conrad Shultz
www.synthetiqsolutions.com

On Aug 31, 2011, at 12:51, Jon Sigman  wrote:

> How does one determine the size of a file on disk using Cocoa? 
> I've looked at NSFileManager but it doesn't seem to offer any 
> methods for finding file attributes. 
> OSX 10.6.8
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Size of a file on disk

2011-08-31 Thread Kyle Sluder
On Wed, Aug 31, 2011 at 12:51 PM, Jon Sigman  wrote:
> How does one determine the size of a file on disk using Cocoa?
> I've looked at NSFileManager but it doesn't seem to offer any
> methods for finding file attributes.

You mean other than -attributesOfItemAtPath:error:?

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html

Or -[NSURL resourceValuesForKeys:error:], which is newer, unsupported
on iOS, and the existence of which I find mysterious:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html

--Kyle Sluder
___

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

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

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

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


Size of a file on disk

2011-08-31 Thread Jon Sigman
How does one determine the size of a file on disk using Cocoa? 
I've looked at NSFileManager but it doesn't seem to offer any 
methods for finding file attributes. 
OSX 10.6.8
___

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

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

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

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


Re: LLVM 2.1 Error

2011-08-31 Thread Bruce Cresanta
Jens,

The compiler crashes when compiling the pch file.   There is not an 
extra proSEO in the path.


GCC_CHAR_IS_UNSIGNED_CHAR = NO
GCC_ENABLE_ASM_KEYWORD = YES
GCC_C_LANGUAGE_STANDARD = gnu99
GCC_INPUT_FILETYPE = automatic
GCC_ENABLE_CPP_EXCEPTIONS = YES
GCC_ENABLE_CPP_RTTI = YES
GCC_LINK_WITH_DYNAMIC_LIBRARIES = YES
GCC_ENABLE_OBJC_EXCEPTIONS = YES
GCC_ENABLE_TRIGRAPHS = NO
GCC_ENABLE_FLOATING_POINT_LIBRARY_CALLS = NO
GCC_USE_INDIRECT_FUNCTION_CALLS = NO
GCC_USE_REGISTER_FUNCTION_CALLS = NO
GCC_INCREASE_PRECOMPILED_HEADER_SHARING = NO
GCC_CW_ASM_SYNTAX = YES
OTHER_CPLUSPLUSFLAGS = $(OTHER_CFLAGS)
GCC_PRECOMPILE_PREFIX_HEADER = YES
GCC_PREFIX_HEADER = proSEO/proSEO-Prefix.pch
GCC_ENABLE_BUILTIN_FUNCTIONS = YES
GCC_ENABLE_PASCAL_STRINGS = YES
GCC_FORCE_CPU_SUBTYPE_ALL = NO
GCC_SHORT_ENUMS = NO
GCC_USE_STANDARD_INCLUDE_SEARCHING = YES

Thank you,

Bruce


On Aug 31, 2011, at 12:08 AM, Jens Alfke wrote:

> 
> On Aug 29, 2011, at 11:04 PM, Bruce Cresanta wrote:
> 
>> clang: error: no such file or directory: 
>> '/Volumes/Volume/proSEOLion/proSEO/proSEO/proSEO-Prefix.pch'
>> clang: error: no input files
>> Command /Developer/usr/bin/clang failed with exit code 1
> 
> Is there such a file at that path? If not, what is the actual path to your 
> .pch file?
> 
>> I've checked the PCH settings in the Linker Section of the Target.   Nothing 
>> is out of the ordinary.   Can you suggest why this is happening?
> 
> Um, the PCH settings are in the compiler section, not linker. And since 
> clearly something _is_ out of the ordinary, it would help if you told us what 
> they are set to :)
> 
> I’m guessing that the relative path to your .pch file is specified 
> incorrectly in the target settings; there’s probably one too many “proSEO/“ 
> in it.
> 
> —Jens

___

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

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

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

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


Re: LLVM 2.1 Error

2011-08-31 Thread Jens Alfke

On Aug 31, 2011, at 11:05 AM, Bruce Cresanta wrote:

> GCC_PREFIX_HEADER = proSEO/proSEO-Prefix.pch

What’s the path of the project file itself?

—Jens___

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

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

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

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


Re: LLVM 2.1 Error

2011-08-31 Thread Bruce Cresanta
/Volumes/Volume/proSEOLion/proSEO

inside of that directory there is anotherproSEO.

Bruce




On Aug 31, 2011, at 11:16 AM, Jens Alfke wrote:

> 
> On Aug 31, 2011, at 11:05 AM, Bruce Cresanta wrote:
> 
>> GCC_PREFIX_HEADER = proSEO/proSEO-Prefix.pch
> 
> What’s the path of the project file itself?
> 
> —Jens

___

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

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

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

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


Re: Long delay of NSPopUpButton first click

2011-08-31 Thread Kyle Sluder
On Wed, Aug 31, 2011 at 10:05 AM, Jens Alfke  wrote:
>
> On Aug 31, 2011, at 2:19 AM, Rimas M. wrote:
>
>> Not really. Unless I am missing something. Menu-item's background is 
>> changing when item is selected (blue one, by default).
>
> C’mon, be creative. Cache two copies of the image, one with the plain 
> background and one with the highlighted.

FWIW, iWork 09 does not do sub-pixel AA in its font popup. Which means
they only have to cache one bitmap and composite it against the
system-provided menu item.

This is useful because the selected menu item color is actually a
gradient, not a solid color. The downside is that the menu items draw
black-on-blue, instead of white-on-blue like elsewhere in the OS.
Since they're not using sub-pixel AA, I wonder if a simple color
inversion would work when drawing the selected menu item.

--Kyle Sluder
___

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

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

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

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


Re: Long delay of NSPopUpButton first click

2011-08-31 Thread Jens Alfke

On Aug 31, 2011, at 2:19 AM, Rimas M. wrote:

> Not really. Unless I am missing something. Menu-item's background is changing 
> when item is selected (blue one, by default).

C’mon, be creative. Cache two copies of the image, one with the plain 
background and one with the highlighted.

—Jens___

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

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

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

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


Re: Won't Applescript command use defined ivars?

2011-08-31 Thread Scott Ribe
On Aug 31, 2011, at 8:58 AM, Chris Paveglio wrote:

> But I am going to need the application to use the instance of the class from 
> when it's started, not make a new instance every time the script command is 
> given.

Well, that's not likely to happen, because that's not the way the framework 
works.

> I have to connect to a database, and for performance, would rather not have 
> to create/open/use/close/destroy that connection every time it's called 
> (could be called a lot). I would rather have the connection created and ready 
> to use, and then just pass in my calls as needed, until the app quits (it's 
> going to run in the background). 

Fine, create it at startup, or on first need, and keep it around. Use a static 
variable, or some ivars & methods in your app controller class, or create a 
singleton class (although I don't recommend all the hoohah of enforcing 
singleton-ness, just create one at startup and keep it in a global variable). 
You don't have to, and probably shouldn't, stuff all your database connection 
management into a subclass of an AppleScript command anyway--probably better to 
abstract that into a class that deals with the database.

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

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


Re: Long delay of NSPopUpButton first click

2011-08-31 Thread Glenn L. Austin

On Aug 31, 2011, at 2:19 AM, Rimas M. wrote:

> On Mon, Aug 29, 2011 at 7:13 PM, Jens Alfke  wrote:
> 
> On Aug 28, 2011, at 11:25 PM, Rimas M. wrote:
> 
>> Well.. that worked. Generally. But those images must have transparent
>> background. And as I have discovered, when dealing with text drawing, that
>> causes loose of sub-pixels antialiasing. This is unacceptable. Will need to
>> use NSAttributedString+attributedTitle way... Any hints on speeding up menu
>> showing time on the first click?
> 
> Personally, I would find it worse for an app load and render every installed 
> font (I have something like 1,000), than for it to draw that menu quickly but 
> slightly less smoothly.
> 
> Can’t you render the text onto a solid background that’s been filled in with 
> the menu-item background color?
> 
> —Jens
> 
> Not really. Unless I am missing something. Menu-item's background is changing 
> when item is selected (blue one, by default).
> 
> I am wondering how iWork apps was able to solve this. Their menu has full 
> antialiasing and responds to keyboard for selecting items by first letter of 
> title. This suggests AttrbutedString way. But it loads fast... Strange.

Having worked on that code at one time, they are doing *exactly* what I 
outlined -- they are pre-creating item images (image with mask) and putting 
plain text titles in the menu item and drawing the images with the proper menu 
background for the menu item content.

They are NOT using AttributedString.

-- 
Glenn L. Austin, Computer Wizard and Race Car Driver <><




___

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

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

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

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


Re: Won't Applescript command use defined ivars?

2011-08-31 Thread Chris Paveglio
Ah OK that sheds some light on things. Thanks Martin.
Yes I have subclassed NSScriptCommand, as it seemed to be the only way I could 
get any Applescript command to work by using "performDefaultImplementation". 
But I am going to need the application to use the instance of the class from 
when it's started, not make a new instance every time the script command is 
given. I have to connect to a database, and for performance, would rather not 
have to create/open/use/close/destroy that connection every time it's called 
(could be called a lot). I would rather have the connection created and ready 
to use, and then just pass in my calls as needed, until the app quits (it's 
going to run in the background). 
(Sorry for my poor use of terminology, I come from an Applescript background 
and still cross pollinate my terms sometimes.)
I was looking at the Apple sample code "simple scripting verbs" and "simple 
scripting". I could not get a verb command to work unless I did it this way, 
but there must be a way where I don't have to use 
"performDefaultImplementation" and can specify what method to run in the SDEF.


#import 
#import "ODBCKit/ODBCKit.h"
@interface Clipper_Tracking_DaemonAppDelegate : NSScriptCommand
{
    NSWindow*window;
NSString*userName;
ODBCConnection*theConnection;

}

-(id)performDefaultImplementation;
-(void)logEventDoc:(NSString *)docPath operType:(NSString *)opType 
withTC:(long)tcNumber;

@property(assign) IBOutletNSWindow *window;
@end

--

@implementation Clipper_Tracking_DaemonAppDelegate
@synthesizewindow;

-(id)performDefaultImplementation
{
//self directParameter is the first data in the script command

NSDictionary * theArguments = [self evaluatedArguments];
NSString *filePath = [self directParameter];
//argument are what you put in the  in the SDEF
//and pull out with the objectForKey (string)
//it is not the actual argument in the method name
NSNumber *tcNumber = [theArguments objectForKey:@"tcNumber"];
NSString *operationType = [theArguments objectForKey:@"operationType"];
[self logEventDoc:filePath operType:operationType withTC:[tcNumber longValue]];
returnnil;
}

-(void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
userName = NSUserName(); //I also may have tried to retain it but no difference 
in outcome when Applescript calls the method
theConnection = [[ODBCConnection alloc] init];
[theConnection setDsn:@"DatabaseName"];
[theConnection setUserName:@"theserverlogin"];
[theConnection setPassword:@"theserverpassw"];
}

-(void)logEventDoc:(NSString *)docPath operType:(NSString *)opType 
withTC:(long)tcNumber
{
//post data to SQL
NSString *theCommand = [NSString stringWithFormat:@"SpLogEventEtc %@ %D %@ %@", 
docPath, tcNumber, opType, userName];
//[theConnection execCommand:theCommand]; //this is the ODBCKit command to talk 
to the sql server
//for testing, let's just do our favorite NSLog
NSLog(@"%@", theCommand);
//[theConnection close]; //needed?
}
@end

---
Here's the SDEF in case that helps:




http://www.w3.org/2003/XInclude";>
























- Original Message -
From: Martin Wierschin 
To: Chris Paveglio 
Cc: Cocoa Dev List 
Sent: Tuesday, August 30, 2011 5:25 PM
Subject: Re: Won't Applescript command use defined ivars?

> If I have an ivar that is global in scope,

As Scott mentioned, your ivar isn't global. Each instance of your class has its 
own ivar. Also as he mentioned, you seem to be ignoring the memory management 
guidelines. That's not the immediate cause of your troubles, but is important 
for you to understand and fix.

What exactly is your class? Your post omits important parts:

> @interface...
> {
> NSString *userName;
> }

Are you subclassing NSScriptCommand? If so, then I'm guessing that the 
AppleScript machinery is creating a new instance of your class every time you 
run your AppleScript. Which means that your instance is not in existence when 
the -applicationDidFinishLaunching method might be called, and hence why your 
ivar is nil.

~Martin
___

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

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

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

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


Re: Linking an NSWindow in IB

2011-08-31 Thread Ron Fleckner

On 31/08/2011, at 3:30 PM, Guy Halford-Thompson wrote:

> This is somewhat of a basic question, but I am having a lot of trouble
> getting it to work.
> 
> When my app loads, I check for certain parameters, and then display an 
> NSWindow.
> 
> I have created the window in IB and also created a custom class
> (MyWindow).  in IB I have given the window class MyWindow.
> 
> I have added a couple of extra functions to MyWindow and now I wish to
> trigger the window to be displayed given certain conditions.
> 
> How can I display the window?
> 
> I have tried
> 
> MyWindow *win = [[MyWindow alloc] init];
> [win makeKeyAndOrderFront:nil];
> 
> but it just displays a blank window...
> 
> I am pretty sure that I have not linked the window from IB properly
> but I am really confused about how to do it and the apple
> documentation / google don't seem to be able to help.
> 
> Thanks for any help
> 

Guy, the instance of MyWindow in the nib file is the one you want to show.  So, 
you don't want to make another window in code as you have above.  The 
[[Classname alloc] init...] construct is one way to create instances of a class 
in code.  But you already have an instance in the nib file.  All you need to do 
is make a connection to your instance of MyWindow in IB.  First declare an 
IBOutlet in your nib's File's Owner class, then in IB, control-drag from the 
instance to File's Owner.  This gives you a reference to that instance in your 
code.

HTH,

Ron

PS You can also, in IB, simply check the box in the MyWindow instance's 
inspector panel to make it visible at launch.

___

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

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

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

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


Re: Long delay of NSPopUpButton first click

2011-08-31 Thread Rimas M.
On Mon, Aug 29, 2011 at 7:13 PM, Jens Alfke  wrote:

>
> On Aug 28, 2011, at 11:25 PM, Rimas M. wrote:
>
> Well.. that worked. Generally. But those images must have transparent
> background. And as I have discovered, when dealing with text drawing, that
> causes loose of sub-pixels antialiasing. This is unacceptable. Will need to
> use NSAttributedString+attributedTitle way... Any hints on speeding up menu
> showing time on the first click?
>
>
> Personally, I would find it worse for an app load and render every
> installed font (I have something like 1,000), than for it to draw that menu
> quickly but slightly less smoothly.
>
> Can’t you render the text onto a solid background that’s been filled in
> with the menu-item background color?
>
> —Jens
>

Not really. Unless I am missing something. Menu-item's background is
changing when item is selected (blue one, by default).

I am wondering how iWork apps was able to solve this. Their menu has full
antialiasing and responds to keyboard for selecting items by first letter of
title. This suggests AttrbutedString way. But it loads fast... Strange.

Regards,

Rimas M.
___

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

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

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

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


Re: LLVM 2.1 Error

2011-08-31 Thread Jens Alfke

On Aug 29, 2011, at 11:04 PM, Bruce Cresanta wrote:

> clang: error: no such file or directory: 
> '/Volumes/Volume/proSEOLion/proSEO/proSEO/proSEO-Prefix.pch'
> clang: error: no input files
> Command /Developer/usr/bin/clang failed with exit code 1

Is there such a file at that path? If not, what is the actual path to your .pch 
file?

> I've checked the PCH settings in the Linker Section of the Target.   Nothing 
> is out of the ordinary.   Can you suggest why this is happening?

Um, the PCH settings are in the compiler section, not linker. And since clearly 
something _is_ out of the ordinary, it would help if you told us what they are 
set to :)

I’m guessing that the relative path to your .pch file is specified incorrectly 
in the target settings; there’s probably one too many “proSEO/“ in it.

—Jens___

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

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

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

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


Re: Linking an NSWindow in IB

2011-08-31 Thread Jens Alfke

On Aug 30, 2011, at 10:30 PM, Guy Halford-Thompson wrote:

> I have created the window in IB and also created a custom class
> (MyWindow).  in IB I have given the window class MyWindow.
> 
> I have added a couple of extra functions to MyWindow and now I wish to
> trigger the window to be displayed given certain conditions.
> 
> How can I display the window?

You need to know which object is being called when the condition is met, and 
that object has to have a pointer to your window so it can call it. Generally 
you’d wire a connection in Interface Builder from that object to your window, 
so the object will have an instance variable pointing to the window.

In a simple app the object that’s doing stuff is most likely the application 
delegate object, so you’d add an instance variable of type MYWindow*, put the 
IBOutlet keyword on it so IB knows it can be wired to, and then control-drag a 
connection from the window to the app delegate. Now when a method of the app 
delegate is called (like some menu-triggered action) it can use that instance 
variable to call the window.

—Jens___

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

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

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

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


Re: Large over 100K pixel high ruler scroll view

2011-08-31 Thread Jens Alfke

On Aug 30, 2011, at 9:49 PM, Julie Porter wrote:

> What I do not get, is why an accessor such as an abstract getObject can not 
> get the Object from the open and instantiated MyDocument class. 

I think maybe you’re not thinking the right way about “instantiated” (and 
“open” really doesn’t mean anything here.) “Instantiating” means “creating an 
instance”, i.e. creating an object that belongs to that class. It’s comparable 
to malloc. Saying “MyDocument is instantiated” just means that, somewhere in 
memory, there is an object whose class is MyDocument. It does not imply that 
there is any way to find that object given only knowledge of the class. There 
could be millions of MyDocument objects at any moment

The getObject accessor is a method of MyDocument, but methods have to be called 
on objects. Otherwise it’s like calling Carbon’s GetWindowTitle without giving 
it a WindowPtr. The state that you want to access belongs to an individual 
MyDocument object, so there is no way to get it without having a reference to 
that object.

> What does IB have to do with my database and communication between functions? 
>  I thought this was for things like buttons and cells so that when one 
> presses a button the value in a cell is passed to the function.

Wiring in IB defines connections between arbitrary objects. It just happens 
that most of the objects you wire up are views. When you define a connection in 
a nib, then when the objects are loaded into memory they will be set up to 
point to each other.

> I think cocoa is the other way around,  Where the document which has the 
> array of dictionaries I want is not visible to the View because the view is 
> not open to the document.

Honestly, the metaphor doesn’t apply at all. There is no such thing as “open” 
or “visible”. There is no state involved. Trying to make analogies to 
PostScript is just going to confuse you even more. The document and view are 
fancy structs in memory, and for one to be able to access the contents of 
another, it has to have a pointer to it as one of its members. Does that make 
more sense?

—Jens___

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

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

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

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