Getting Computer Name

2010-06-20 Thread Steve Steinitz

Hello,

I've found several examples of getting the computer Name but 
some give warnings about making a pointer from an integer and 
they all fail with signal EXC_BAD_ACCESS here


objc_msgSend_vtable5
_NSDescriptionWithLocaleFunc
_CFStringAppendFormatAndArgumentsAux
_CFStringCreateWithFormatAndArgumentsAux
_CFLogvEx
NSLogv
NSLog

Here are three examples I've tried:

1.  CFStringRef temp = SCDynamicStoreCopyComputerName (NULL, NULL);
NSString * name = [NSString stringWithString: temp];
return name;

2.  CFStringEncoding encoding = kCFStringEncodingUTF8;
CFStringRef name = SCDynamicStoreCopyComputerName (NULL, &encoding);
return name;

3.  #import 

SCDynamicStoreContext context = {0, NULL, NULL, NULL};
SCDynamicStoreRef store = SCDynamicStoreCreate (kCFAllocatorDefault,
CFSTR("testStrings"),
NULL,
&context);
NSLog(@"SCDynamicStoreCopyLocalHostName() = %@",
SCDynamicStoreCopyLocalHostName(store));

According to the docs CFStringRef is toll-free-bridged with 
NSString and so interchangeable.  The authors of the examples 
cite no issues.  Could I have done something to my project to 
break toll-free bridging?  I confess, I haven't thought about 
toll-free bridging since the WebObjects days.


Thanks for any ideas,

Steve

___

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

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

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

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


Re: Getting Computer Name

2010-06-20 Thread Paul Sanders
I use #1 and it works fine for me.  Note that SCDynamicStoreCopyComputerName 
might return NULL, and don't forget to CFRelease temp.

In the case of #1, what is the NSLog statement that is failing?  And I take it 
that name hasn't been autoreleased before you log it - it will only survive 
until the current autorelease pool 'pops'.  You can look at name (and probably 
temp, but I'm not sure) in the debugger, of course.

Regards,

Paul Sanders.

- Original Message - 
From: Steve Steinitz 
To: cocoa-dev@lists.apple.com 
Sent: Sunday, June 20, 2010 11:10 AM
Subject: Getting Computer Name


Hello,

I've found several examples of getting the computer Name but 
some give warnings about making a pointer from an integer and 
they all fail with signal EXC_BAD_ACCESS here

 objc_msgSend_vtable5
 _NSDescriptionWithLocaleFunc
 _CFStringAppendFormatAndArgumentsAux
 _CFStringCreateWithFormatAndArgumentsAux
 _CFLogvEx
 NSLogv
 NSLog

Here are three examples I've tried:

1.  CFStringRef temp = SCDynamicStoreCopyComputerName (NULL, NULL);
 NSString * name = [NSString stringWithString: temp];
 return name;

2.  CFStringEncoding encoding = kCFStringEncodingUTF8;
 CFStringRef name = SCDynamicStoreCopyComputerName (NULL, &encoding);
 return name;

3.  #import 

 SCDynamicStoreContext context = {0, NULL, NULL, NULL};
 SCDynamicStoreRef store = SCDynamicStoreCreate (kCFAllocatorDefault,
 CFSTR("testStrings"),
 NULL,
 &context);
 NSLog(@"SCDynamicStoreCopyLocalHostName() = %@",
 SCDynamicStoreCopyLocalHostName(store));

According to the docs CFStringRef is toll-free-bridged with 
NSString and so interchangeable.  The authors of the examples 
cite no issues.  Could I have done something to my project to 
break toll-free bridging?  I confess, I haven't thought about 
toll-free bridging since the WebObjects days.

Thanks for any ideas,

Steve
___

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

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

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

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


Re: Getting Computer Name

2010-06-20 Thread jonat...@mugginsoft.com

On 20 Jun 2010, at 11:10, Steve Steinitz wrote:
> 
> 
> According to the docs CFStringRef is toll-free-bridged with NSString and so 
> interchangeable.  The authors of the examples cite no issues.  Could I have 
> done something to my project to break toll-free bridging?  I confess, I 
> haven't thought about toll-free bridging since the WebObjects days.
> 
You can't break toll free bridging.
The NSObject and CF type collaborate to route objects and function calls 
appropriately. 

The following works for me:

NSString *name = NSMakeCollectable(SCDynamicStoreCopyLocalHostName(NULL));

You may have retain issues with your logging call.

Jonathan Mitchell___

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

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

2010-06-20 Thread Steve Steinitz

Hi Paul,

Thanks for your reply.

On 20/6/10, Paul Sanders wrote:


I use #1 and it works fine for me.  Note that
SCDynamicStoreCopyComputerName might return NULL, and don't forget to
CFRelease temp.


OK, thanks.


In the case of #1, what is the NSLog statement that is failing?  And I
take it that name hasn't been autoreleased before you log it - it will
only survive until the current autorelease pool 'pops'.


Good points and questions.  Here is my method:

+ (NSString *)
computerName
{
CFStringRef   temp = SCDynamicStoreCopyComputerName (NULL, NULL);
NSString* name = [NSString stringWithString: temp];
NSLog (@"computer name = %@", name);
CFRelease (temp);
return name;
}

The line creating temp warns: initialization makes pointer from integer.

The line creating name warns: passing argument 1 of 
StringwithString from incompatible pointer type

and fails with signal EXC_BAD_ACCESS

Thanks again,

Steve

___

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

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

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

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


Re: Getting Computer Name

2010-06-20 Thread Paul Sanders
It looks like SCDynamicStoreCopyComputerName is not prototyped correctly so the 
compiler assumes it returns an int.  In what I assume is a 64-bit build this 
will lose the top 32 bits of the CFStringRef.

Are you #including ?  Other than that I am 
compiling 32 bit so I don't know what else might be wrong with the setup of 
your project but at least now you have an idea of what to look for.

Regards,

--
Paul Sanders
AlpineSoft
http://www.alpinesoft.co.uk

- Original Message - 
From: Steve Steinitz 
To: Paul Sanders ; cocoa-dev@lists.apple.com 
Sent: Sunday, June 20, 2010 11:52 AM
Subject: Re: Getting Computer Name


Here is my method:

+ (NSString *)
computerName
{
 CFStringRef   temp = SCDynamicStoreCopyComputerName (NULL, NULL);
 NSString* name = [NSString stringWithString: temp];
 NSLog (@"computer name = %@", name);
 CFRelease (temp);
 return name;
}

The line creating temp warns: initialization makes pointer from integer.

The line creating name warns: passing argument 1 of 
StringwithString from incompatible pointer type
and fails with signal EXC_BAD_ACCESS

Thanks again,

Steve
___

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

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

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

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


Re: Getting Computer Name

2010-06-20 Thread Steve Steinitz

Hi Paul,

On 20/6/10, Paul Sanders wrote:


It looks like SCDynamicStoreCopyComputerName is not prototyped
correctly so the compiler assumes it returns an int.  In what I assume
is a 64-bit build this will lose the top 32 bits of the CFStringRef.


Yes, your diagnosis holds water.  I'm building and running in 
64-bit mode.  I'm wondering how to keep those top 32 bits.



Are you #including ?


I wasn't.  I added it.  Were you wondering if it would make a difference?

Other than that I am compiling 32 bit so I don't know what else 
might be wrong with the setup of your project but at least now 
you have an idea of what to look for.


Yes, thanks a lot for your ideas.  I think you're on the right track.

Best regards,

Steve

___

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

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

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

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


Re: Getting Computer Name

2010-06-20 Thread Paul Sanders
>> Are you #including ?

> I wasn't.  I added it.  Were you wondering if it would make a difference?

Well, yes.  Default return type is int.  In fact I'm suprised you didn't get a 
warning about the function being undefined.  My Mac is powered off or I would 
check.  Does adding the #include sort things out?

Regards,

Paul Sanders.
___

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

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


RADPlugin framework

2010-06-20 Thread Angelo Chen
Hi,I have seen some Apple's applications having this RADPlugin, iMovie, 
FinalCut pro:
/Applications/Final Cut Pro.app/Contents/PlugIns/AVCHD.RADPlug
and sometimes, those files can be interchanged between iMovie and FinalCut Pro, 
is there documentation on this?  Thanks,
Angelo



___

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

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

2010-06-20 Thread Steve Steinitz

Hi Paul,

On 20/6/10, Paul Sanders wrote:


Are you #including ?



I wasn't.  I added it.  Were you wondering if it would make a difference?


Well, yes.  Default return type is int.  In fact I'm suprised you
didn't get a warning about the function being undefined.  My Mac is
powered off or I would check.  Does adding the #include sort things
out?


No, it doesn't seem to make a difference.  I might raise a bug 
report.  in the meantime I'm using:


[[NShost currentHost] name];

which apparently can block for a while and doesn't guarantee 
which host name it will return from among the array of host 
names.  Surprisingly, my development machine has four, including 
one that Adobe slipped in there.


Thanks again for your help Paul.

Signing off for the night,

Steve

___

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

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

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

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


Re: Getting Computer Name

2010-06-20 Thread Steve Steinitz
Hi Jonathan,

Thanks for replying.

On 20/6/10, Jonathan Mitchell wrote:

>> Could I have done something to my project to break toll-free bridging?

> You can't break toll free bridging.

> The NSObject and CF type collaborate to route objects and function calls 
> appropriately. 

Thanks for that clarification.

> The following works for me:
> 
> NSString *name = NSMakeCollectable(SCDynamicStoreCopyLocalHostName(NULL));

Thanks.  NSMakeCollectable looks useful.  I tried:

NSLog (@"machine %@", NSMakeCollectable (SCDynamicStoreCopyLocalHostName 
(NULL)));

But it gets a warning and signal EXC_BAD_ACCESS.  I'm still thinking 64-bit 
issue.

Thanks again,

Steve

___

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

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

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

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


Re: Getting Computer Name

2010-06-20 Thread jonat...@mugginsoft.com

On 20 Jun 2010, at 14:46, Steve Steinitz wrote:

> Hi Paul,
> 
> On 20/6/10, Paul Sanders wrote:
> 
 Are you #including ?
>> 
>>> I wasn't.  I added it.  Were you wondering if it would make a difference?

The correct import is #import 
.
Omitting it causes the compiler to assume integer return type.

I do get the expected warnings: 
warning: implicit declaration of function 'SCDynamicStoreCopyComputerName'
warning: initialization makes pointer from integer without a cast

I wouldn't fancy living without these.

>> 
>> Well, yes.  Default return type is int.  In fact I'm suprised you
>> didn't get a warning about the function being undefined.  My Mac is
>> powered off or I would check.  Does adding the #include sort things
>> out?
> 
> No, it doesn't seem to make a difference.  I might raise a bug report.  in 
> the meantime I'm using:
> 
>[[NShost currentHost] name];
This can really block. Sometimes unexpectedly, depending on your machine 
configuration.
I wouldn't touch it for all the beer on Bondi.

Jonathan


___

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

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

2010-06-20 Thread Paul Sanders
> The correct import is #import 
> .

So it is, sorry.  It was half-way down my source file.

Regards,

Paul Sanders.
___

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

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

2010-06-20 Thread Kyle Sluder
On Jun 20, 2010, at 6:28 AM, Angelo Chen  wrote:

> Hi,I have seen some Apple's applications having this RADPlugin, iMovie, 
> FinalCut pro:
> /Applications/Final Cut Pro.app/Contents/PlugIns/AVCHD.RADPlug
> and sometimes, those files can be interchanged between iMovie and FinalCut 
> Pro, is there documentation on this?  Thanks,
> Angelo

No, that's a private plugin, hence why it lives in those apps' wrappers.

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


NSWindow and IBPlugins

2010-06-20 Thread Martin Pilkington
Hey All,

I'm creating an IBPlugin for my framework and one of the last classes I'm 
wanting to add is an NSWindow subclass. I've added a library item to my library 
nib, I've set up the image view in it, I've added an NSWindow to my nib and 
changed the class and I've hooked up the library item's representedObject 
outlet to the NSWindow. So everything is set up just like every other object in 
my plugin.

The issue is, when I then try to drag the window out of the library, IB throws 
an exception because (supposedly) NSWindow doesn't support archiving. Even if I 
make it try to add a plain NSWindow it does the same. I'm not quite sure what 
is happening as the docs for NSWindow says it does implement NSCoding via 
NSResponder. Here is the full log if I try to drag my window out of the library 
and click continue on the error that pops up:

2010-06-20 17:16:53.616 Interface Builder[40543:a0f] Assertion Failure: NO
2010-06-20 17:16:53.616 Interface Builder[40543:a0f] File: 
/SourceCache/InterfaceBuilder/InterfaceBuilder-762/Application/IBApplication.m
2010-06-20 17:16:53.617 Interface Builder[40543:a0f] Line: 695
2010-06-20 17:16:53.775 Interface Builder[40543:a0f] Backtrace:
0   AppKit   0x7fff857b39d3 -[NSApplication run] + 
651
1   AppKit   0x7fff857ac5f8 NSApplicationMain + 364
2   Interface Builder0x00011305
3   Interface Builder0x00011294
4   ???

2010-06-20 17:16:53.776 Interface Builder[40543:a0f] Message: An uncaught 
exception was raised.

Exception Name: NSInvalidArgumentException
Reason:  does not support archiving
User Info: (null)
2010-06-20 17:17:08.854 Interface Builder[40543:a0f] *** -[NSKeyedArchiver 
dealloc]: warning: NSKeyedArchiver deallocated without having had 
-finishEncoding called on it.

I've not got a clue what is causing it so if anyone has had any experience of 
this before I'd appreciate it.

Thanks

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: NSWindow and IBPlugins

2010-06-20 Thread Kyle Sluder
On Sun, Jun 20, 2010 at 9:25 AM, Martin Pilkington  wrote:
> The issue is, when I then try to drag the window out of the library, IB 
> throws an exception because (supposedly) NSWindow doesn't support archiving. 
> Even if I make it try to add a plain NSWindow it does the same. I'm not quite 
> sure what is happening as the docs for NSWindow says it does implement 
> NSCoding via NSResponder. Here is the full log if I try to drag my window out 
> of the library and click continue on the error that pops up:

NSWindow only implements NSCoding for legacy reasons, as per the
really big note at the top of the NSWindow documentation. IB doesn't
archive NSWindows in nibs; it archives instances of the private class
NSWindowTemplate.

I'm afraid you won't be able to do what you want to do. File an
enhancement request! In the meantime, you'll have to use standard
NSWindows and change their class on the Identity inspector.

--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: Getting Computer Name

2010-06-20 Thread John Joyce

On Jun 20, 2010, at 8:46 AM, Steve Steinitz wrote:

> Hi Paul,
> 
> On 20/6/10, Paul Sanders wrote:
> 
 Are you #including ?
>> 
>>> I wasn't.  I added it.  Were you wondering if it would make a difference?
>> 
>> Well, yes.  Default return type is int.  In fact I'm suprised you
>> didn't get a warning about the function being undefined.  My Mac is
>> powered off or I would check.  Does adding the #include sort things
>> out?
> 
> No, it doesn't seem to make a difference.  I might raise a bug report.  in 
> the meantime I'm using:
> 
>[[NShost currentHost] name];
> 
> which apparently can block for a while and doesn't guarantee which host name 
> it will return from among the array of host names.  Surprisingly, my 
> development machine has four, including one that Adobe slipped in there.
> 
> Thanks again for your help Paul.
> 
> Signing off for the night,
> 
> Steve
Which name are you trying to acquire ?
The host name is not guaranteed to be the same as the name set in System 
Preference > Sharing

The "Computer Name" there is where most users will set it, and is the one 
commonly seen in Finder windows. It can be localized.
This is different from a localhost name. The host name can be very different.

If you want the Computer Name of the computer as set by an admin user in System 
Preferences, use CSCopyMachineName()

As an example, try this in your app delegate:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application 
NSLog(@"Computer Name: %@",CSCopyMachineName());
}

Please keep in mind, that this may not be in English.

I myself found this to be difficult to locate with simple searches both in the 
developer docs and on the web, though less than 5 minutes of googling did turn 
it up.


Hope that helps,
John Joyce___

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

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

2010-06-20 Thread Jens Alfke

On Jun 20, 2010, at 11:01 AM, John Joyce wrote:

> This is different from a localhost name. The host name can be very different.

And each active network interface will have a different hostname, just as it 
has a different IP address. So I might simultaneously be “jens.foocorp.com” on 
Ethernet where I have a static address, and “guest-e3f6.wifi.foocorp.com” on 
the public WiFi network.

Getting a hostname for the computer you’re on is not usually very useful.

—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


NewStyle Preferences

2010-06-20 Thread Jeremy Matthews
In my project I have some preferences in a tabview style, but I'd like to move 
towards a more mac-like interface for this (Safari, Mail)...probably using 
NSToolbar.

I've seen examples (usually pretty dated) that reference a few different styles:

1) Tabless NSTabView using a Toolbar with actions (selectTabViewItem:Blah)
2) Some third-party frameworks and code (BWToolkit - buggy, SS_PrefsController, 
DBPrefsWindowController, etc)
3) Private APIs from Apple (NSPrefernces)
4) Toolbar-only approach

I'd read through the archives...but see mostly older posts, so I'd like to see 
what people are doing these days...

I was wondering about the experiences out there...and any best practices 
recommendations. I see a lot of projects using the last method, and using code 
more than IB to put it together - love to know what people are using out there!

Thanks,
jeremy
___

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

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

2010-06-20 Thread jonat...@mugginsoft.com
On 20 Jun 2010, at 22:53, Jeremy Matthews wrote:

> 
> 1) Tabless NSTabView using a Toolbar with actions (selectTabViewItem:Blah)
> 2) Some third-party frameworks and code (BWToolkit - buggy, 
> SS_PrefsController, DBPrefsWindowController, etc)
> 3) Private APIs from Apple (NSPrefernces)
> 4) Toolbar-only approach
> 
> I'd read through the archives...but see mostly older posts, so I'd like to 
> see what people are doing these days...
> 
DBPrefsWindowController

I haven't tried any of the other approaches but DBPrefsWindowController seems 
to handle the matter effectively.

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.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: [Cocoa-students] NewStyle Preferences

2010-06-20 Thread Marc Respass
Jeremy,

I would go with a toolbar that swaps views.

I think tab views are a fine control but before NSViewController, they were 
used in a tab-less style in order to make it easy to swap views. I think that 
approach is outdated. I would use a simple toolbar which you can setup in IB 
and swap your various views. Use NSViewControllers to manage the views and 
resize the window accordingly. I haven't looked at preferences controllers out 
there but it's such a simple thing to load a view. You hook everything up to 
shared defaults and for all preferences, read the value from defaults. You only 
have to deal with things if a default change needs to take place immediately. 
Once you have a window that loads views and sizes itself, you just make views 
and add buttons.

Hope this helps
Marc

El Jun 20, 2010, a las 5:53 PM, Jeremy Matthews escribió:

> In my project I have some preferences in a tabview style, but I'd like to 
> move towards a more mac-like interface for this (Safari, Mail)...probably 
> using NSToolbar.
> 
> I've seen examples (usually pretty dated) that reference a few different 
> styles:
> 
> 1) Tabless NSTabView using a Toolbar with actions (selectTabViewItem:Blah)
> 2) Some third-party frameworks and code (BWToolkit - buggy, 
> SS_PrefsController, DBPrefsWindowController, etc)
> 3) Private APIs from Apple (NSPrefernces)
> 4) Toolbar-only approach
> 
> I'd read through the archives...but see mostly older posts, so I'd like to 
> see what people are doing these days...
> 
> I was wondering about the experiences out there...and any best practices 
> recommendations. I see a lot of projects using the last method, and using 
> code more than IB to put it together - love to know what people are using out 
> there!
> 
> Thanks,
> jeremy
> 
> ___
> Cocoa-students mailing list
> cocoa-stude...@mylist.net
> http://mylist.net/listinfo/cocoa-students

___

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

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

2010-06-20 Thread Steve Steinitz

Thanks Jonathan Mitchell, John Joyce, Paul Sanders and Jens Alfke.


John:

Bingo! CSCopyMachineName() works perfectly.

To answer your question, I want a human-readable machine 
identifier, but one that's not tied to the hardware, the way, 
say, serial number is.


Our Core Data point-of-sale system has 8 machines making sales 
and I'm thinking of tagging each sale, for several reasons.  
Some examples:


1. to temporarily hide sales that are in progress on other machines.
   I currently do that but in a more awkward way,

2. to know where sales are actually occurring, to get a 
sense of

   wear and tear on printers and other disposable hardware, etc.

3. Maybe to compare the performance of the different shop 
floors in

   an employee-independant way.  The director suspects that employees
   who go downstairs become "slackers" :)


Jonathan:

I confirm that

#import 

allows

NSLog (@"machine %@", NSMakeCollectable 
(SCDynamicStoreCopyLocalHostName (NULL)));


and, I assume, similar forms, to work.  Who'd a thunk it?

Thanks again to all of you.

Cheers,

Steve

___

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

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

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

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


Re: Getting Computer Name

2010-06-20 Thread Kyle Sluder
On Sun, Jun 20, 2010 at 4:26 PM, Steve Steinitz
 wrote:
>    1. to temporarily hide sales that are in progress on other machines.
>       I currently do that but in a more awkward way,

Might you instead want to make a sale an atomic thing? Perform the
sale on a scratch MOC, and then when the sale is complete (or voided),
merge the scratch MOC into the main MOC.

Also, this seems to imply that you're sharing the same persistent
store amongst all your clients. This way lies madness.

--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: Getting Computer Name

2010-06-20 Thread Steve Steinitz

Hi Kyle,

On 20/6/10, Kyle Sluder wrote:


to temporarily hide sales that are in progress on other machines.
I currently do that but in a more awkward way,


Might you instead want to make a sale an atomic thing? Perform the
sale on a scratch MOC, and then when the sale is complete (or voided),
merge the scratch MOC into the main MOC.


That's a good idea. I do that to a small degree when the sale is 
first created, so I can "micro-save" it.  After that there are 
so many relationships from the other MOC: products, bikes, 
customer, employee... that I had felt it might be troublesome.  
I'm rethinking that.


But that aside, I do actually save in-progress sales during idle 
time to update the inventory levels so, for example, a bike 
doesn't get sold twice.  Once saved, I need to 'hide' the Sale 
from other machines.



Also, this seems to imply that you're sharing the same persistent
store amongst all your clients. This way lies madness.


The madness had its four-year anniversary this very day :)

Each machine runs idle-time code which ensures it has recent 
data from the shared store.  It was hard to get right but after 
a year of tweaking, it works well.  SQLite has just enough 
locking capability to make it work.


The shared store is on a Synology NAS that claims to be able to 
saturate gigabit ethernet.  Its really fast.  It has a 128-meg 
cache and our database is only 30 meg.  Flies.  Does complex 
queries and returns the results often in under 5 msec.  I've 
seen 1 msec.


Others have described theoretical alternatives but they don't 
sound inviting at all and I haven't seen any sample code.  A 
friend gave me a book with a complex alternative which looks 
complete, at least.  Some day, maybe,


I have an irrational hope that Apple will, one day, add another 
back-end option to Core Data.


All that said, I'm all ears to simple, practical, proven, 
scalable alternatives with sample code.


Cheers,

Steve


___

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

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

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

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


Re: Getting Computer Name

2010-06-20 Thread John Joyce

On Jun 20, 2010, at 6:26 PM, Steve Steinitz wrote:

> Thanks Jonathan Mitchell, John Joyce, Paul Sanders and Jens Alfke.
> 
> 
> John:
> 
> Bingo! CSCopyMachineName() works perfectly.
> 
> To answer your question, I want a human-readable machine identifier, but one 
> that's not tied to the hardware, the way, say, serial number is.
> 
> Our Core Data point-of-sale system has 8 machines making sales and I'm 
> thinking of tagging each sale, for several reasons.  Some examples:
> 
>1. to temporarily hide sales that are in progress on other machines.
>   I currently do that but in a more awkward way,
> 
>2. to know where sales are actually occurring, to get a sense of
>   wear and tear on printers and other disposable hardware, etc.
> 
>3. Maybe to compare the performance of the different shop floors in
>   an employee-independant way.  The director suspects that employees
>   who go downstairs become "slackers" :)
> 
> 
> Jonathan:
> 
> I confirm that
> 
>#import 
> 
> allows
> 
>NSLog (@"machine %@", NSMakeCollectable (SCDynamicStoreCopyLocalHostName 
> (NULL)));
> 
> and, I assume, similar forms, to work.  Who'd a thunk it?
> 
> Thanks again to all of you.
> 
> Cheers,
> 
> Steve
> 
Hi Steve,

Glad to hear it.
Glad it's also in the archives for others to search and find now.
One thing, not to question your own algorithms, but you may also want to 
consider checking the MAC address (ethernet) or the a host of combinations of 
identifiers in addition to the computer name.
It's really just a sanity check. 
Admin users can change their computer name at anytime, and more than one 
machine can have the same computer name. 
Hence, the hostname and the way Bonjour manages that scenario.

Also, simply taking a user ID system to identify a user and hiding the sale in 
progress from others is more reliable like with any web commerce site.

It's a good idea to use a multitude of criteria to identify a system.

I don't know if you need the data in real time, but you can also generate logs 
and parse local logs for particular activities as well.

It's still admirable and user-friendly to attempt to refer to the computer name 
properly for the end user. Love it when people keep it about the users.

Regards,
John Joyce___

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

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


AppleScript in a Cocoa app

2010-06-20 Thread Angelo Chen
Hi,
I need to create an AppleScript and run it inside the app to activate another 
program, the applescript should call 'add' function the the other program with 
different file names, any idea how to achieve this? Thanks,
Angelo



___

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

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

2010-06-20 Thread Kyle Sluder
On Jun 20, 2010, at 10:53 PM, Angelo Chen  wrote:

> Hi,
> I need to create an AppleScript and run it inside the app to activate another 
> program, the applescript should call 'add' function the the other program 
> with different file names, any idea how to achieve this? Thanks,
> Angelo

Of course we know how to achieve this. We learned it by reading the 
documentation.

--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: AppleScript in a Cocoa app

2010-06-20 Thread John Joyce

On Jun 21, 2010, at 12:53 AM, Angelo Chen wrote:

> Hi,
> I need to create an AppleScript and run it inside the app to activate another 
> program, the applescript should call 'add' function the the other program 
> with different file names, any idea how to achieve this? Thanks,
> Angelo

One approach:
http://developer.apple.com/mac/library/technotes/tn2006/tn2084.html___

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

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

2010-06-20 Thread Kyle Sluder
On Sun, Jun 20, 2010 at 6:25 PM, Steve Steinitz
 wrote:
> Each machine runs idle-time code which ensures it has recent data from the
> shared store.  It was hard to get right but after a year of tweaking, it
> works well.  SQLite has just enough locking capability to make it work.

Be aware that as of 10.6, this is an officially unsupported
configuration, prone to breaking in point releases as happened in
10.6.2. See Ben Trumbull's post here for the nitty-gritty:
http://lists.apple.com/archives/cocoa-dev/2010/Mar/msg01026.html

> I have an irrational hope that Apple will, one day, add another back-end
> option to Core Data.

That won't happen without us filing lots of bugs. Believe me, I'd love
to have an officially supported multi-user Core Data solution.

> All that said, I'm all ears to simple, practical, proven, scalable
> alternatives with sample code.

Core Data stickies shows the basics of synchronizing multiple data stores.

As far as your application (point of sale) is concerned, history has
shown that keeping all terminals live and in sync is the wrong
approach. The correct way to do it is to periodically reconcile all
transactions, performing reconciliation as infrequently as possible
and with as little data as possible.

To solve your problem, I would go with a standard client-server
approach, using a custom protocol for communication between your POSes
and a central server. The server would be responsible for all business
logic, while the POS would only have responsibility for the till and
the sales themselves. Your current solution, trying to get everyone to
agree on the state of the world at all times, is not generally
considered good practice.

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