NSControllers, NSLocks, NSThread, Setters and Getters

2008-05-22 Thread Todd Heberlein
Hopefully this isn't already well discussed... Or if it is, someone  
can point me to the appropriate discussion or docs.



I want to have a controller observe an object's variables accessed  
through accessor methods, but I also want to set the value for those  
variables via a separate NSThread. Furthermore, I want to protect  
those variables via locks.


Can I use NSLocks inside the accessor methods that are being used by  
NSControllers, or will this just really screw things up (other than  
the many usual ways you can screw things up with multiple threads and  
locks)?



Thanks,

Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


Re: NSControllers, NSLocks, NSThread, Setters and Getters

2008-05-23 Thread Todd Heberlein


On May 22, 2008, at 9:21 PM, Ken Thomases wrote:

KVO change notifications are sent and received on the same thread  
where the change is made.


Thanks!  Yeah, that will definitely screw up my plans. Thanks for the  
heads up.


Ideally, a background thread should be given all of the data it  
needs to do its work at the beginning and it would work in isolation  
until its job is done and only then provide results in a lump to the  
main thread.


In my case, I am constantly looking for more data to be added to a  
file that is being written to by another process, then read the  
additional data, and potentially update some data structures. I wanted  
to put the code to check and process the file data in a separate  
thread, but I think I will just try an NSTimer for now.


Thanks again! I could have seen my efforts leading to a major headache  
as I tried to figure out why the Controller wasn't properly updating  
the GUI.


Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


Re: Cocoa Classes from C++?

2008-05-27 Thread Todd Heberlein
 
On Tuesday, May 27, 2008, at 04:32PM, "Jens Alfke" <[EMAIL PROTECTED]> wrote:

>We did that the PubSub framework and it works fine, actually. You just  
>have to check the "Call C++ Ctors/Dtors in Obj-C" build option in  
>Xcode.

Ooh, I can learn something every day in these mailing lists. :-)

Just to add my $0.02...

I write all my libraries in clean C++ for portability, because I am comfortable 
in C++ and I have a lot of legacy code in C++. Then I build Objective-C objects 
when I build a Cocoa-based app, and I embed the C++ objects as needed into the 
Objective-C objects. For the most part, everything is painless.

The gotchas that I often run into are: (1) Changing an Objective-C file to an 
Objective-C++ object (by renaming it to a .mm file) often causes me to rename a 
lot of files to .mm, because if the Objective-C class definition has a C++ 
object in it, every source code file that includes that Objective-C class 
definition needs to be renamed to a .mm file; (2) I always declare my C++ 
objects in Objective-C classes as pointers, and then in the init method I 
allocate the C++ object; (3) I often have two container classes for some 
content -- one in C++ used in my libraries and one in Objective-C so I can 
connect it to the GUI (e.g., via a controller), so I need to do a little work 
to keep them consistent.

Todd


___

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

Please do not post 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 [EMAIL PROTECTED]


NSNumber Formatter with percent?

2008-07-19 Thread Todd Heberlein

Hi all,

(Using Xcode 3.1)

I was working through Hillegass's latest book and chapter 8 has me  
applying an NSNumberFormatter to one of the columns of a table view.  
Unfortunately I get unexpected behavior when I modify one of the  
values in the column. For example, if I add several employees (which  
have a default value of 5%), then I modify one of the numbers (say to  
7%) then *all* the other number values get displayed as 500%.  
Furthermore, all new values are automatically displayed with a raise  
of 500% (as opposed to just 5%).


It is as if the Multiplied field of the NSNumberFormatter is changed  
from 1 (which I set) to 100 for all cells.


I don't seem to see this behavior when the NSNumberFormatter has a  
different style (say "Decimal").


Am I doing something wrong? If not, is this a known problem, or should  
I file a bug report?


Thanks,

Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


Re: NSNumber Formatter with percent?

2008-07-19 Thread Todd Heberlein



On Jul 19, 2008, at 5:25 PM, Aron Nopanen wrote:

This is a known bug which has been raised with Apple.


Thanks.



I think a workaround is to use the 10.0 compatibility mode, as  
illustrated in the book...


(Embarrassed) Thanks again. I had assumed the difference between the  
Xcode display I was using (10.4+) and the figure in the book was due  
to a change between the time the book was set and 3.1 was officially  
released. I didn't realize it was actually a workaround.


Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


linking NSArrayController and Undo manager

2008-07-21 Thread Todd Heberlein
Is there a way to link a controller (e.g., the NSArrayController) to  
my NSDocument's NSUndoManager without having to add a bunch of code to  
my NSDocument subclass?


For example, in Hillegass's book, the first example of RaiseMan (Chap  
8) has a nice clean design that lets the NSArrayController manage all  
interactions between the table view and the NSArray model.


But when adding the undo/redo capability (Chap 9) you have to add a  
lot of code to MyDocument to intercept and register with the  
NSUndoManager all insertion/deletion and edits to the model. This  
seems inelegant.


It would be nice to register MyDocument's NSUndoManager with the  
NSArrayController so that the NSArrayController can handle all the  
undo and redos.


Is it possible to do this?

Thanks,

Todd



___

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

Please do not post 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 [EMAIL PROTECTED]


Re: NSArrayController and bindings and RaiseMan

2008-07-23 Thread Todd Heberlein

Before I spend a lot of time on this, I'm just wondering if the undo
functionality described in Chapter 9 is even possible without bindings
and NSArrayController.


Well, NeXTSTEP, OpenStep, Cocoa applications have been doing undo/redo  
well before Apple relatively recently added Controllers, so I suspect  
it can be done.


In fact, IMHO, it seems adding the functionality of the Undo Manager  
already removes some of the freedom's introduced by the  
NSArrayController. Before, the controller handled everything without  
your MyDocument object needing to be notified about anything. By  
adding Undo Manager capability, MyDocument has to receive and carry  
out all the changes in the model (in order to notify the Undo Manager  
about each change).


Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


First Responder, NSUndoManager, and MyDocument

2008-07-23 Thread Todd Heberlein

Just a intellectual curiosity question here:

I have a question about First Responder and the Document-based  
architecture. Why does "undo" go to the NSUndoManager and not my  
NSDocument subclass?


I was playing around with Hillegass's RaiseMan with Undo capabilities  
(Chap 9), and from looking at the call stack it appears that while the  
"Undo" menu is configured to go to the First Responder which I thought  
would be the MyDocument object, it instead it goes to MyDocument's  
NSUndoManager. Other menu items that I set up to go to the First  
Responder *do* make it to MyDocument, and even if I add my own -undo:  
method to MyDocument, selecting Undo in the menu will not call it.


What gives? Why doesn't an undo: message get sent to my MyDocument  
object?


Thanks,

Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


Re: First Responder, NSUndoManager, and MyDocument

2008-07-23 Thread Todd Heberlein
Because it's handled by something earlier in the responder chain.  
Your document isn't going to be first responder.


Got it. Thanks!

I didn't realize my document was so *far* down the list, but it all  
makes sense now. I should have known better.


Thanks again,

Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


Re: Folder has limited permissions.

2008-07-24 Thread Todd Heberlein

http://developer.apple.com/samplecode/BetterAuthorizationSample/index.html


From the page: "This involves putting the privileged code into a  
small, privileged helper tool that is run by launchd."


Argh! Since MacOS 10.4 all processes that are spawned from launchd  
(and their children) are *not* audited by Mac's audit system (BSM). So  
it feels like Apple is saying, "Install privileged code in a way that  
cannot be monitored and pray that it does everything correctly."


Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


Re: Folder has limited permissions.

2008-07-24 Thread Todd Heberlein

Well it would certainly have been a feat for them to audit launchd
jobs in 10.3!  :D  Speaking of which, can you provide a reference?
This is more than mildly intriguing to me.


I filed a bug report for this about a year ago for 10.4, but I  
discovered it when someone complained that access to files were not  
being audited by BSM. My tests showed access via the local shell  
(i.e., from the Terminal app) generated audit records fine, but coming  
in remotely via ssh meant that all your activities were *not* audited.


After further investigations I tracked it down to any process being  
launched from launchd (e.g., remote ssh login or a timed process).  
When looking at the audit mask for these processes, it is set to all  
zeros (meaning no events will generate a record) regardless what the  
BSM configuration files said.


(Note: the BSM audit system for 10.5 is fundamentally broken, so  
pretty much nothing is audited.)


Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


Re: NSTimer and a problem with document-based apps

2008-07-26 Thread Todd Heberlein

- (id)init {
...
timer = [NSTimer scheduledTimerWithTimeInterval:10.0
...
}

...


That new instance of course calls init, and suddenly I have two  
NSTimers

running when I only wanted one timer for the whole app.


I think you want to make your timer a global variable and then  
initialize it within a call to a +load or +initialize method for one  
of your classes. See the following link:


http://developer.apple.com/documentation/DeveloperTools/gcc-3.3/gcc/Executing-code-before-main.html

Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


NSDocument and window ivar

2008-07-27 Thread Todd Heberlein
In the documentation for NSDocument there is a method called -  
(void)setWindow:(NSWindow*)aWindow, for which aWindow is described as  
"The window to which the receiver’s window outlet points."


Furthermore, if I ctrl-click on the File's Owner in MyDocument.xib (a  
document-based app), which is of class MyDocument (subclass of  
NSDocument), it *does* show the window outlet there and it *does* show  
it pointing to the window.


But I cannot pass messages to the window variable. For example, I  
cannot send it the "setTitle:" message.


Have I gone bonkers? Am I doing something wrong? For now I just added  
another IBOutlet for NSWindow in MyDocument class and have that  
connected up, but this seems like a kludge to have two outlets  
pointing to the same object.


Any words of wisdom?

Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


Re: NSDocument and window ivar

2008-07-27 Thread Todd Heberlein


On Jul 27, 2008, at 7:34 PM, Alex Heinz wrote:

Don't you want NSDocuments -(NSWindow*)windowForSheet: rather than - 
(void)setWindow:? I assume you're trying to retrieve the object  
rather than set it.


That may not be your problem, but it's the only thing I can think of


I was trying [window setTitle: @"blah"]; (or something like this), but  
the compiler wouldn't let me send the setTitle message to the "window"  
variable.


I guess I shouldn't be terribly surprised since the NSDocument can  
actually have multiple windows associated with it, but that "window"  
outlet (shown when ctrl-clicking the File's Owner) was just screaming  
to me "use me".


Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


Responder Chain & Multiple Windows

2008-11-10 Thread Todd Heberlein
I have a Documen-based application, and the besides the document's  
main window, the user can create additional windows to be opened to  
show aspects of the document/data from a different perspective; these  
windows are loaded by an instance of an NSWindowController subclass.


Unfortunately, when one of these secondary windows are key, Menu items  
connected to the First Responder are disabled even though the  
NSWindowController subclass implements the action method.


Am I missing something?

From the documentation it seems that the window's  
NSDocumentController, even though it isn't the document's main window,  
should still be in the responder chain.


Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


Re: Responder Chain & Multiple Windows

2008-11-10 Thread Todd Heberlein


On Nov 10, 2008, at 5:31 AM, Graham Cox wrote:



On 11 Nov 2008, at 12:11 am, Todd Heberlein wrote:

From the documentation it seems that the window's  
NSDocumentController, even though it isn't the document's main  
window, should still be in the responder chain.


I assume you actually mean the window's NSDocument (or subclass  
thereof) - there is only one shared NSDocumentController in an app.


How are you creating the secondary windows? If you instantiate the  
controllers yourself you need to add them as subcontrollers of the  
document using its -addWindowController: method.


Oops. Yes, MyDocument is a subclass of NSDocument and  
BrowserViewController is a subclass of NSWindowController



In MyDocument I have a method that has the following code:

  BrowserViewController* bvc;

  bvc = [[[BrowserViewController alloc] init] autorelease]; //  
init loads NIB

  [self addWindowController:bvc];
  [bvc showWindow:self];


Both MyDocument and BrowserViewController implement the method (which  
is the action for the menu item):


- (IBAction) extractAuditSession: (id) sender;

But the menu item is only available when the window associated with  
MyDocument is key. When the window associated with  
BrowserViewController is key, the menu item is dimmed out.


Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


Re: Responder Chain & Multiple Windows

2008-11-10 Thread Todd Heberlein

What if you make the window controller the delegate of the window?


Ka-ching!  Thanks. that did it.

Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


NSArrayController with a base class

2008-12-09 Thread Todd Heberlein

Hi all,

I'm looking for documentation/tutorial/pointers on how to handle the  
situation when an NSArrayController is managing an NSMutableArray  
which will contain multiple types of objects but all of which have the  
same base class. So the NSArrayController's "Object Controller" "Class  
Name" is actually a base class.


Then when a user selects an item in the list, depending on the  
subclass type a different view will be displayed, each with different  
fields that will be views for the data in the subclass instance.


Is this possible with controllers? Is it recommended/discouraged? Any  
pointers?


Thanks,

Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


Re: Authorization Question (Possibly a simple POSIX question?)

2009-08-21 Thread Todd Heberlein
I don't understand how the app allowed to use that file descriptor  
to read the file's contents.


Its a general UNIX thing. If you have a book on UNIX interprocess  
communications, you can probably find some details in it. And as  
others have pointed out, permissions are checked at the time of the  
initial open only.



but how can another process just start using that descriptor? Is it  
because it's the parent process?


I am pretty sure your helper tool's parent process is actually the  
launchd process which is owned by root.



The app only preauthorized some arbitrary right, it didn't actually  
get any privileges to open and read a protected file.


Authorization in MacOS X is a little difficult for me to get my head  
around, but here is what I think is happening. When you authorize or  
preauthorize, you can have those authorization rights credentials  
stick around for a specified period of time. This authorization  
credential cache is global, so other processes can look into it. Then  
later when another process (i.e., your HelperTool) needs authorization  
to do something, like opening the file, it first checks the cache to  
see if you already have the credential. If so, it doesn't bother to  
prompt you again to access your password.


One reason to preauthorize in your Cocoa app is simply to prevent your  
code from launching the helper tool if you aren't going to be able to  
provide the right information (i.e., password) in the first place.


Todd

___

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

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


virtual ivars

2009-08-29 Thread Todd Heberlein
I've been playing with KVC and KVO with my own setters and getters  
(along with Controllers) to create virtual ivars. That is, there never  
is any storage created for the variable and its value is calculated on  
the fly when the getter is called. This seems to have some cool  
potential, but it raises the following question:


Could this break with future Xcode or OS X upgrades?

In other words, is this approach an officially supported way to code  
by Apple, or do they have the freedom to break this in the future?



Thanks,

Todd


Simple example where the ivar "myInt" never really exists:

@interface MyObj : NSObject  {
NSWindow *window;
}
@property (assign) IBOutlet NSWindow *window;

-(int)myInt;
-(void)setMyInt:(int)newVal;

@end




-(int)myInt
{
return 43;
}

-(void)setMyInt:(int)newVal
{
// do nothing right now
}


___

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

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

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

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


Re: virtual ivars

2009-08-29 Thread Todd Heberlein

If you can't set a value, don't provide a setter.


I see from another post I was conflating "ivars" with "properties".  
With regards to the setters, I have some C++ libraries, and I was  
thinking about having "property" wrappers in an Objective C object  
doing setting and getting into values in the C++ object. I just didn't  
want to make the demo code very long. My bad for a poor example.


Todd

___

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

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

2009-08-29 Thread Todd Heberlein
I see from another post I was conflating "ivars" with "properties".  
With regards to the setters, I have some C++ libraries, and I was  
thinking about having "property" wrappers in an Objective C object  
doing setting and getting into values in the C++ object.


So here is a slightly more detailed scenario while still trying to  
keep it as simple as possible.


My "Model" is captured in C++ code (i.e., "CppObj" below). I want to  
use normal Cocoa "View" objects (e.g., an NSTextField) and  
"Controller" objects (e.g., NSObjectController). So I create an  
Objective C object ("MyWrapper ") to wrap the C++ object, and access  
to the C++ content is done through "properties". Both the setters and  
getters reach down into the C++ object to set or get its values.


Things seem to be working. I just wanted to make sure I wasn't doing  
something illegal or not supported. I guess I have always had  
properties associated with actual variables, so it never occurred to  
me before that they are really independent things.


Todd


//- C++ model 
class CppObj {
public:
int myInt;
};


//- Objective-C++ wrapper 
@interface MyWrapper : NSObject  {
CppObj* p_cppObj;
}
-(int)myInt;
-(void)setMyInt:(int)newVal;
@end



//- getter/setter wrappers of C++ model 
-(int)myInt
{
return p_cppObj->myInt;
}

- (void)setMyInt:(int)newVal
{
p_cppObj->myInt = newVal;
}


___

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

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


completion handlers?

2009-09-06 Thread Todd Heberlein
It seems that the way I previously used an NSSavePanel has been  
deprecated. :(


The new approach seems to use an approach (a function definition  
embedded in the message) that I am not familiar with (I hear ghosts of  
lambda notation whispering into my ear). I assume this is an Objective  
C 2.0 feature, but I am not even sure of the name for this approach.


I would like to look up information on this approach, but I don't even  
know a name for it in order to google it. Could someone give me a  
pointer for pages or keywords?


Thanks,

Todd


[savePanel beginSheetModalForWindow:window completionHandler:^ 
(NSInteger result) {

if (result) {
NSLog(@"Save as: %@", savePanel.URL);
}
}];
___

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

Please do not post 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: completion handlers?

2009-09-06 Thread Todd Heberlein

Thanks for the information.

OK, now a scoping rule question, in the sample code below, does "self"  
refer to my object (i.e., the "self" when the block is declared) or  
the NSSavePanel (i.e., the "self" when the code is executed)?


Todd

[savePanel beginSheetModalForWindow:window completionHandler:^ 
(NSInteger result) {

   if (result) {
   [self someMethod];   //   <-- what "self" should be used?
   }
   }];


___

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

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

2009-09-14 Thread Todd Heberlein


On Sep 14, 2009, at 12:57 PM, Mark Thomas wrote:

I was wondering if anybody could tell me if it's correct to use  
authorizationExecuteWithPrivileges and wait() calls together, so the  
parent process wait's until that new child process finishes.  
Googling seems to imply this from the examples I've seen.


This is an indirect answer since I don't know the real one :-/I  
use the BetterAuthorizationSample (BAS) library, and my Cocoa process  
is *not* the parent of the privileged process. I don't think this can  
happen since I think it would break the UNIX model -- a process  
escalating its privilege (other than executing a SUID, SGID file).  
Rather, a launchd process already running as root executes my program  
with the requested privileges and communication from my Cocoa program  
to the privileged process is over a socket.


Using the BAS library, the function call does block until the  
requested remote procedure call finishes (and you get the results from  
the call in the response dictionary). But the privileged process can  
actually live a while longer waiting for subsequent calls. If none  
come after a certain amount of time, then it dies.


Todd

___

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

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


NSNumber bound to NSTextField

2009-09-14 Thread Todd Heberlein
I am trying to understand the behavior of an NSNumber bound to an  
NSTextField. It seems that an NSNumber isn't always and NSNumber.


--
SET UP

I have a class with an NSNumber* bound to an NSTextField via an Object  
Controller

NSNumber*  <---> NSObjectController  <---> NSTextField

Accessors to the NSNumber* are created via
@property (nonatomic, retain) NSNumber* myNum;

The object is initialized as
myNum = [[NSNumber alloc] initWithInt: 5];

--
BEHAVIOR

Then I have an action method to query some aspects of myNum. Before  
changing the number in the NSTextField I get the following:


myNum is NOT a member if NSNumber
myNum IS a kind of NSNumber
myNum responds to intValue
myNum responds to unsignedLongValue


After changing the value in the NSTextField to say 3, I get the  
following results from querying myNum:


myNum is NOT a member if NSNumber
myNum is NOT a kind of NSNumber
myNum responds to intValue
myNum does NOT responds to unsignedLongValue


--
QUESTIONS:
	(1) Why does [myNum isMemberOfClass:[NSNumber class]] return NO when  
I explicitly did an [NSNumber alloc]?


	(2) [myNum isKindOfClass:[NSNumber class]] returns YES, so what type  
of subclasses are there to NSNumber?


	(3) After changing the value in the text field, myNum is neither an  
NSNumber of even a kind of NSNumber. What is it?


	(4) I guess the answer to 3 might explain this, but after the number  
is changed, why does myNum still respond to intValue but *not*  
unsignedLongValue?


--
NOTE:
	By applying an NSNumberFormatter to the NSTextField, the object  
always is "a kind of" NSNumber and always responds to both "intValue"  
and "unsignedLongValue". So I guess the lesson is: If you are going to  
have a GUI NSTextField represent an NSNumber, you should put an  
NSNumberFormatter on it.



Any insights would be appreciated,

Todd

___

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

Please do not post 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: Binding a model's ivar array to the contents of an NSArrayController

2009-09-16 Thread Todd Heberlein
So in short, my need is pretty simple: Bind an array to an  
NSArrayController.  That being said, it seems that no combination of  
exposeBindings:, bind:toObject:withKeypath:options:,  
observeValueForKey:ofObject:change:context:, etc. is working as I  
expect it to.  Admittedly, I have done most of my binding work via  
IB and I've never really done much with  
bind:toObject:withKeypath:options: before, so I wouldn't be  
surprised to find that that was where my problem lay.


Might be a stupid question on my part, but are you using the  
appropriate accessors for your array? For example, if you have


@interface MyDocument : NSDocument
{
NSMutableArray* myStuff;
}

You then need use accessors of the form:

-(NSUInteger)countOfMyStuff;
-(id)objectInMyStuffAtIndex:(NSUInteger)index;
-(void)insertObject:(id)newObj inMyStuffAtIndex:(NSUInteger)index;
-(void)removeObjectFromMyStuffAtIndex:(NSUInteger)index;

Todd

___

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

Please do not post 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: Creator Codes in Snow Leopard

2009-09-23 Thread Todd Heberlein
Some may find the following Apple Insider article on the the topic  
useful:


Inside Snow Leopard's UTI: Apple fixes the Creator Code
http://www.appleinsider.com/articles/09/09/22/inside_snow_leopards_uti_apple_fixes_the_creator_code.html

On Sep 23, 2009, at 9:11 AM, Jens Alfke wrote:


On Sep 23, 2009, at 9:06 AM, Gerriet M. Denkmann wrote:

So I looked at Launch Services Reference, but could not figure out,  
how to inform Lauch Services which app to use for some document.
But if Finder can tell Lauch Services, then my app should be also  
able to do this, shouldn't it?

Where should I look?


My guess is there's some new extended file attribute being used to  
store this. You could use command-line tools ('xattr', I think) to  
inspect the attributes of a file before and after changing its  
default app.




Todd

___

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

Please do not post 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: Creator Codes in Snow Leopard

2009-09-23 Thread Todd Heberlein
As a result, most of their conclusions are incorrect as well.  If  
you can't set the UTI differently on two files with the same type  
code and extension, it can't serve as a creator code.


I've been wondering about this. Daring Fireball carried some links  
with some strong criticisms on this, and I've been waiting for them to  
pick up on AI article, but so far they haven't. I'm just waiting for  
the dust to settle.


Todd

___

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

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


NSTableView Drag & Drop as a string

2009-09-24 Thread Todd Heberlein
I have an NSTableView and I have Drag & Drop working between table  
views for my application where I encode the object to an NSData and  
write it to the NSPasteboard. But now I want to create a string  
representation of the object, add it to the pasteboard as well, and  
then when the object is dragged to something like an email, the string  
representation of the object is written in. The content does seem to  
be written to the pasteboard, but the "drop" doesn't seem to happen in  
an appropriate target (email message, editor, etc.)


The same basic code works in -copy: but it doesn't seem to work in - 
tableView:writeRowsWithIndexes:toPasteboard:


The line of code is:

[pboard setString:str forType:NSStringPboardType];

Is there something different with the NSPasteboard passed into - 
tableView:writeRowsWithIndexes:toPasteboard: versus the pasteboard you  
get from [NSPasteboard generalPasteboard]? Any suggestions on what I  
am doing wrong?


Thanks,

Todd

___

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

Please do not post 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: NSTableView Drag & Drop as a string

2009-09-25 Thread Todd Heberlein

Solved it!

... But now I want to create a string representation of the object,  
add it to the pasteboard as well, and then when the object is  
dragged to something like an email, the string representation of the  
object is written in.


The problem was that I was trying to do a cross-application drag and  
drop. The solution was to add to my -awakeFromNib method the line:


[myTableView setDraggingSourceOperationMask:NSDragOperationEvery  
forLocal:NO];


This allows drag-and-drop across applications.

Todd

___

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

Please do not post 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: Efficient searching of an NSArray of NSDictionary

2009-09-29 Thread Todd Heberlein
 By the way, a quick google search of, "nspredicateeditor example"  
yields a very helpful first result ...


Don't forget, Google yields different results for different people  
based on a variety of factors.


Todd

___

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

Please do not post 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: [iPhone] Application running for the very first time...

2009-09-30 Thread Todd Heberlein
I am wondering if there is a simple way to find out when my  
application is running for the VERY FIRST TIME on an iPhone?

So that I can set an integer variable once only at this moment...

What's the best way to do this?


One approach is to test if a file exists on the file system, and if it  
doesn't:


(1) You know this is the first time the program is running
(2) Then create the file so that future checks will find it

Todd

___

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

Please do not post 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: [iPhone] Application running for the very first time...

2009-10-01 Thread Todd Heberlein
I am wondering if there is a simple way to find out when my  
application is running for the VERY FIRST TIME on an iPhone?

So that I can set an integer variable once only at this moment...

What's the best way to do this?


Also, NSUserDefaults supports this basic capability. I'm just  
wondering if all these defaults for your app are visible from the  
settings application on the iPhone (it is too late and my brain is  
fried); that would screw up this approach.


Todd

___

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

Please do not post 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: Auto Install Login Item

2009-10-03 Thread Todd Heberlein


On Oct 3, 2009, at 12:30 PM, David Blanton wrote:

Should my cocoa app write an entry to com.apple.loginitems.plist so  
it launches at login or is there a better way?


Look at the documentation for launchd.

___

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

Please do not post 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: Probs with "BetterAuthorizationSample"-code

2009-10-03 Thread Todd Heberlein
1.	How can I debug my HelperTool? Obviously any breakpoints set in  
XCode won't work because the HelperTool is launched outside by the  
launchd.
2.	My idea is to use asl to debug "barefoot". But for that I have to  
install aeach time when I have compiled a modified version of the  
HelperTool to the system. But how to do this? InstallerTool does not  
do this itself.


I have used asl_log() messages as a substitute for printf(). The  
messages goes to your Console (the one under /Applications/Utilities)  
and not to the "Console" in Xcode, so make sure you are looking in the  
right place for output.


I think printf() will just cause the HelperTool to exit with error.

Every time I modify any code used by my helper tool I run

$ ./SampleUninstall.sh

I just had to change all the references in the shell script to my  
application's Identifier. For example, my modified shell script has  
the lines:


sudo launchctl unload -w /Library/LaunchDaemons/ 
com.netsq.ACManager.plist

sudo rm /Library/LaunchDaemons/com.netsq.ACManager.plist
sudo rm /Library/PrivilegedHelperTools/com.netsq.ACManager
sudo rm /var/run/com.netsq.ACManager.socket

And the Cocoa app's "Identifier" in the target's property window is:

com.netsq.${PRODUCT_NAME:rfc1034identifier}

(the Project is called ACManager) so "com.netsq.ACManager" is inserted  
in all the appropriate places in the script.


If things are really screwed up, you can look in the directories  
identified in the shell script, remove the appropriate files by hand,  
and then logout and log back in (if that doesn't solve your launchctl  
errors you may need to reboot as a crude but effective step).


But once you have your SampleUninstall.sh script set up correctly,  
running it each time you make code modifications should work.


Todd

___

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

Please do not post 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: Bundle is not using icon or CFBundleIdentifier

2009-10-03 Thread Todd Heberlein

Anyone want to point out what I'm doing wrong?  Any help appreciated.


I think I had to do a Project->Add To Project... and then select the  
icon file in order to get the icon to be used. Dragging the icons into  
my project didn't do the trick.


Todd

___

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

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


Alert prompts for BetterAuthorizationService

2009-10-07 Thread Todd Heberlein
In Apple's BetterAuthorizationSample application pressing the  
"LowNumberedPorts" button brings up a window to authorize yourself. It  
includes the following text to explain why you are authorizing yourself:


"You must be authorized to open low-numbered TCP ports. Type your  
password to allow BetterAuthorizationSample SampleApp to make changes"


The problem is I cannot find where this prompt comes from.

There is the line in the file SampleAuthorizationPrompts.strings
"LowNumberedPortsPrompt" = "You must be authorized to open low- 
numbered TCP ports."


But before even the first build I completely changed the right side to
"LowNumberedPortsPrompt" = "The quick brown fox jumped over the  
lazy dog";


It has no effect on what is displayed in the authorization window.

After the change I have done a find for the phrase that is displayed,  
and it isn't in any of the code in the directory as far as I can tell.  
*Where* is the text being displayed coming from? Please, any help  
would be appreciated.


Todd

___

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

Please do not post 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: Alert prompts for BetterAuthorizationService

2009-10-07 Thread Todd Heberlein


On Oct 7, 2009, at 12:05 PM, Olivier Palliere wrote:

If you already installed your tool once and didn't change the kind  
of rights that it is using, then it is most likely in the /etc/ 
authorization file.


If you remove your rights from there, re-installing your helper will  
recreate the rights with the new value.


Ka-ching!  Thanks a million! I was at my wit's end.

I thought running "SampleUninstall.sh" would take care of things, but  
I was obviously wrong.


Todd

___

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

Please do not post 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: Alert prompts for BetterAuthorizationSample

2009-10-08 Thread Todd Heberlein
I've had trouble with this too, even though my /etc/authorization  
has *my* strings in it.  (I just checked again).   I gave up and  
moved it to my "fix someday" list.  Haven't checked in Snow Leopard  
yet.  Here's my story:


I found the following bug: In my Snow Leopard created project the  
prompt specified in /etc/authorization by BAS  
("BetterAuthorizationSample") is going under the key "English", but if  
I change it to "en" it works fine.


That is, the following, which is put into /etc/authorization by the  
BAS code, does *not* work (note, I've modified the spacing for  
readability):


com.netsq.ACManager.ReadAuditConfig

default-prompt


ReadAuditConfigPrompt
 English
		Reading the system's audit_config file requires an  
administrator password.


rule
default



Whereas the following, in which I just changed "English" to "en" by  
hand, *did* work:


com.netsq.ACManager.ReadAuditConfig

default-prompt


ReadAuditConfigPrompt
 en
		Reading the system's audit_config file requires an  
administrator password.


rule
default



Of course, I can't expect my users to go into /etc/authorization to  
change the entry themselves, and I'm not going to much around with it  
from my code, so I guess I'll wait for Apple to fix this. I'm not even  
sure which code is to blame (the BAS code or the Authorization code).


Todd

___

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

Please do not post 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: Alert prompts for BetterAuthorizationSample

2009-10-08 Thread Todd Heberlein


On Oct 8, 2009, at 4:01 PM, Todd Heberlein wrote:

Of course, I can't expect my users to go into /etc/authorization to  
change the entry themselves, and I'm not going to much around with  
it from my code, so I guess I'll wait for Apple to fix this. I'm not  
even sure which code is to blame (the BAS code or the Authorization  
code).


I found a simple work around.

When the authorization code fails to retrieve the text for the prompt  
in the password request panel that come up, it only displays the  
prompt key, so I simply made the prompt "key" the entire sentence I  
want to display.


For example, in my Common.c code I have

const BASCommandSpec kSampleCommandSet[] = {
{
kACManagerCopyToAuditControlCommand,// commandName
kACManagerCopyToAuditControlRightName,  // rightName
 "default",  // rightDefaultRule
		"To replace the system's audit_config file, you need to authenticae  
yourself.",

NULL// userData
},
...

The "rightDescriptionKey" is that full sentence "To replace ..."  And  
then in the "SampleAuthorizationPrompts.strings" file (no, I didn't  
change the names of the variable or file names from the example code)  
I have the key and the value the same (i.e., the full sentence):


"To replace the system's audit_config file, you need to authenticae  
yourself." = "To replace the system's audit_config file, you need to  
authenticae yourself.";



Now when Snow Leopard doesn't do the right thing and only displays the  
key (and not the value), it's OK because my key is also the value I  
want to display. Now, this wouldn't work if I wanted to do more than  
one language, but it will get me through the current day.


Todd

___

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

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


NSString of selected text in NSTextView

2009-11-07 Thread Todd Heberlein
This seems like a simple task, but it has become a series of steps. Am  
I missing a simple method that will do this?


I have a Text View and want to get the selected text in an NSString  
form. I can get an NSString for the entire NSTextView (-string), but  
to get the string for just the selected text seems to take multiple  
steps:


NSRange range = [theTextView selectedRange];
NSData* rtfData = [theTextView RTFFromRange: range];
	NSAttributedString* aStr = [[NSAttributedString alloc]  
initWithRTFData:rtfData documentAttributes: NULL];

NSString* str = [aStr string];

Is there a method that combines all these steps?

Thanks,

Todd

___

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

Please do not post 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: NSString of selected text in NSTextView

2009-11-08 Thread Todd Heberlein

[[myTextView string] substringWithRange:[myTextView selectedRange];

(Warning, composed in Mail.  Potential thorny issues with text
attachment characters, surrogate pairs, composed characters, marked
text… "the selected text" isn't as simple of a concept as it may
seem.)


Yeah, one of the concerns I had was whether the selected NSRange is  
preserved when -string is called. Thats why I was thinking it might be  
more robust to extract the RTF and then down convert that to a string  
(actually, I may convert it to an C-string) :(.


What I am trying to do is a context sensitive menu, so when a user  
right-clicks in the NSTextView and the selected content looks like an  
IP address, menu items for IP addresses can be presented, and if the  
selected item looks like a file path, menu items for file paths can be  
added. Then of course is the user selects one of those menu items, I'm  
going to need to go through the steps again to extract the content in  
the method.


I just feel this must be a common thing to do (like when menu items  
"Search in Google" and  "Look up in Dictionary" are added to the  
context menu), so I am hoping there is a method that already exists.


Todd

___

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

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

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

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


Re: Help needed in Writing network usage monitor application

2009-11-18 Thread Todd Heberlein
> What APIs/library/Technology we should use that notifies us about network
> usages and also provides us with the data being transmitted.
> 
> I have look in libpcap that pretty much gives the packets but i dont know
> how much it helps in notification kind of things.

I don't think there are any Cocoa-specific things that could help, so you may 
want to look at other mailing lists (the moderators try very hard to keep this 
mailing list just for Cocoa questions).

The libpcap library can capture traffic from all your network interfaces, but I 
think you will need to open up a separate tap for each interface. The data will 
be raw packets, pretty much the same thing a network monitor would see, so you 
will have to parse the data. Fortunately most protocols are well documented and 
there are lots of code examples out there, but you may need to handle a lot of 
different cases such as duplicate packets. This would not allow you to map the 
traffic to a specific process, however, and certainly not to a specific element 
thread or sub-object (e.g., the browser window or tab) associated with the 
traffic. This gets even more complicated if you are running virtual machines on 
your system.

If the traffic is encrypted (e.g., encrypted web, encrypted IMAP traffic, SSL 
tunnels, VPNs, etc.), then you are pretty much hosed as far as content analysis 
goes.

Todd

___

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

Please do not post 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: Newbie Question on "self"

2008-08-11 Thread Todd Heberlein

- (id)initWithString:(NSString *) string {
   self.myString = [[NSString alloc] initWithString:string];
}


Well, you don't need the "self" prefix, but you may want to look at  
using "setters" and "getters". It would look like this


@interface MyThingy : NSObject {
...
NSString*   myString;
...
};
...
@property (copy) NSString* myString;
...
@end



And then in the implementation file you would have something like this:

@implementation MyThingy
...
@synthesize myString;
...
@end


And then, when you set the value, you do it like this:

[self setMyString: anotherString];


The benefit of this approach is that Apple has a run-time system that  
monitors access to variables set via setters like this, and other  
objects can subscribe to receive notifications when the value has  
changed. In particular, you can use Apple's Controller objects to glue  
your model (i.e., MyThingy) to GUI elements (e.g., a label in a  
window). Then whenever you set myString with the setMyString method,  
then the GUI is automatically updated. Likewise, an update in a GUI  
element will automatically get pushed into your variable.


All very cool (although a bit confusing when you are first getting  
started).


Todd

___

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

Please do not post 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 [EMAIL PROTECTED]


Re: De-Mystifying NSCell

2009-03-23 Thread Todd Heberlein



I put together a short video to try to explain the rationale and
mechanisms of NSCell: http://www.cs.loyola.edu/~ksluder/NSCell.mov .
If you're confused about why NSCell exists and how it's used inside
NSTableView, I hope that my video is able to shine a bit of light.


That was fantastic!!  I really appreciated it.

Todd

___

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

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


BAS use of asl_log()

2009-04-16 Thread Todd Heberlein
I am looking the Apple's "Better Authorization Sample" code to figure  
out how to launch privileged helper tools from a Cocoa app. The BAS  
code includes use of asl_log(), but sometimes the  field is a  
string literal like:


err = asl_log(asl, aslMsg, ASL_LEVEL_ERR, "Request failed: %m");


and sometimes  is a variable like:

const char * errStr = NULL;
...
errStr = "Unexpected error while accepting a connection: %m";
...
err = asl_log(asl, aslMsg, ASL_LEVEL_ERR, errStr);


Is there a requirement that at compile time the  field be  
known (as in the first example), or can it also be generated at run  
time (as in the second condition)?


Thanks,

Todd

___

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

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


CF autorelease?

2009-04-23 Thread Todd Heberlein
Many of the Cocoa object allocation methods automatically do an  
autorelease before returning the pointer to the object, so I can call  
something like:


foo( [NSString stringWithCString: "bar" encoding:  
NSASCIIStringEncoding] );


and then not worry about memory leakage. Is the same true with Core  
Foundation calls? For example, will


foo2( CFSTR("bar") ); or
foo2 ( CFStringCreateWithCString(NULL, "bar", kCFStringEncodingASCII) );

leak memory?

I am wondering if I need to do stuff like:

CFStringRef tmp_str = CFSTR("bar");
foo2(tmp_str);
CFRelease(tmp_str);

Thanks,

Todd

___

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

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


NSFileHandleDataAvailableNotification problems

2009-05-11 Thread Todd Heberlein

Hi all,

I have a problem reading periodic data from a file descriptor, and I  
am wondering if I am using the methods wrong. The basic code is below,  
but essentially I


	(1) register my object to be called when an  
NSFileHandleDataAvailableNotification is sent to the notification  
center;


	(2) create an NSFileHandle for the file descriptor and send it the  
waitForDataInBackgroundAndNotify method;


	(3) in the callback method, I read the data and then call  
waitForDataInBackgroundAndNotify again so it can look for new data.


The callback method will be called sometimes just once but often  
several times until eventually I get a EXC_BAD_ACCESS signal.


Is there something glaringly wrong with my code? Should I not call  
waitForDataInBackgroundAndNotify in the callback function? Does  
reading from the file descriptor via read() instead of through the  
NSFileHandle cause problems?


Any suggestions would be appreciated,

Todd

// Register callback method when data is available
[nc addObserver:self
selector:@selector(dataAvailable:)
name:NSFileHandleDataAvailableNotification
object:nil];

// Use an NSFileHandle for the file descriptor
myFileHandle = [[NSFileHandle alloc] initWithFileDescriptor:fd];
[myFileHandle waitForDataInBackgroundAndNotify];


- (void) dataAvailable: (NSNotification*)notification
{
// read data directly from the fd
[myFileHandle waitForDataInBackgroundAndNotify];
}

___

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

Please do not post 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: Privilege elevation of a cocoa app

2009-05-21 Thread Todd Heberlein


Is there any way in which i can elevate the privilege of the  binary  
after

authentication.


Look at the BetterAuthorizationSample code and documentation at
http://developer.apple.com/referencelibrary/Security/idxAuthorization-date.html

Basically you put your privileged code in a non-GUI application (e.g.,  
a BSD shell application) called "HelperTool" in the  
BetterAuthorizationSample (BAS). One of the reasons for this is you  
don't want to incorporate a huge amount of GUI and other library code  
that might have bugs (my apologizes to Apple engineers) into a  
privileged process. Also, you usually have only a very small amount of  
code in the HelperTool that needs to run with privileges, so it is  
easier to check for your own bugs. The HelperTool is then started by  
launchd, which can launch it with an elevated privileges. The BAS  
library code provides some APIs to pass arguments to, and receive data  
back from the HelperTool.


For example, I use HelperTool to open a specific file that require  
root access, and then I pass the file descriptor back to my Cocoa  
application.


Still, it took me a little while to figure out how to integrate the  
BAS code into my own -- there are quite a few steps you need to follow.


Todd

___

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

Please do not post 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: What's the differnece between API and Framework?

2009-05-21 Thread Todd Heberlein

ok... so an API is like a lower level framework?  wikipedia states
that Carbon and Cocoa are APIs on Mac, but i always thought those were
frameworks.


The terms are thrown around loosely. Here is how I would define them:

The API is the design or *blueprint* that tell you how to interact  
with another body of code.


The framework is the actual code that *implements* the blueprint and  
that you link with.


For example, you write your code using the Cocoa APIs (e.g., the  
function calls to the code), but when you link your program, you link  
it against *some* library/framework that implements those calls. It  
could be Apple's implementation, but in theory, you could link it  
against someone else's implementation. There was a brief period in  
time when NeXT was promoting OpenStep -- an open standard for what has  
now become Cocoa, and at least one group was writing a library to  
implement it for X windows I believe. Sun was supposed to adopt  
OpenStep as their API, but they got all wrapped up with Java and  
abandoned OpenStep... now look where they are. :)


A better example is the UNIX APIs, which allows you to write your code  
using a standard set of library/system calls, and then you can build  
your program on multiple systems using multiple implementations of the  
API.


Todd

___

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

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

2009-05-30 Thread Todd Heberlein
Sorry about the confusion, yes I meant it will run normally but  
unattended.
I need to make sure it recovers from any errors. in the worst case  
if it
crashes, I need it to launch again automatically, even if there's 1  
minute

or whatever delay, it's absolutely fine.


So it is a GUI app that will run unattended, but someone will be  
logged in at the console?


One approach is to have a very simple, bullet-proof UNIX program that  
launches the GUI app (via fork()/exec()) and then calls wait() or wait4 
(), which should block until the GUI application dies or quits. Then,  
when wait() returns indicating the GUI program has exited you could  
check to see if you want to relaunch it again or not.


You could also write a small daemon to be started by launchd at  
regular intervals (say once a minute, or whatever your threshold is)  
to look to see if the other program is running, and if it isn't, start  
it again.


Todd


___

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

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

2009-05-31 Thread Todd Heberlein
You can use launchd to keep your app alive.  That way you, don't  
have to worry about adding code to your application to do it, you  
just have to ensure the launchd property list is in the right place.


So if in your launchd module you have the key-value pair:

KeepAlive


will launchd automatically restart the program when it exists no  
matter what the exit status is? I wasn't a 100% sure.


Todd

___

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

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

2009-06-01 Thread Todd Heberlein

why should your app stops responding?

Do you want to detect time-outs (network-times, IO-timeouts, ...) or  
will your app be crap and full with bugs?


I wish my code never had infinite loops (Apple's address:) or  
multithreaded deadlocks or other types of bugs... but sometimes sh*t  
happens. I'm not sure how launchd would reliably detect all the  
potential variations however. I liked someone else's suggested  
solution -- periodically send your application something it should  
respond to, or maybe have it generate some type of heartbeat (e.g.,  
send a message to another application, append data to a file, or  
update the timestamp on a file).


Todd

___

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

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

2009-06-01 Thread Todd Heberlein
FYI: I was looking through some Darwin mailing lists archives, and I  
ran across this posting about launchd at WWDC that may be of interest  
to this thread:



Hello all,

If you're attending WWDC and are interested in the BSD-level  
technologies in Mac OS X, I'm giving a talk on launchd this year. It's  
session 500, "Managing Processes with launchd", and several of us from  
the BSD team will be available for Q&A afterward. We'll all be happy  
to answer your questions.


Hope to see you there!
--
Damien Sorresso
BSD Engineering
Apple Inc.

___

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

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

2009-06-01 Thread Todd Heberlein


Great, so I understand from what you're saying that I can launch a  
GUI app

using launchd?


Out of curiosity, I just tried this. I created a basic Cocoa app (I  
made no changes to it, I just built the default skeleton application  
that Xcode creates for you). The project is in the directory:

/Users/heberlei/Development/Tests/BasicApp/
and the full path to the program is
	/Users/heberlei/Development/Tests/BasicApp/build/Debug/Basic.app/ 
Contents/MacOS/BasicApp


I then created a launchd XML file called app_shouldnt_die.plist and  
put it in the directory


/Library/LaunchAgents

(I also set it to be owned by root:wheel, don't know if that matters).

Now when I log in, that BasicApp starts up. If I quit the app, it  
starts again (usually within ~5 seconds). If I do the "kill "  
command from the command line, the application starts again.


Also, when I login as a completely different user, the application  
still starts up automatically. So no matter who logs in, they have to  
live with this darn app alway on.  Pretty cool (or maybe just  
irritating :).


The content of app_shouldnt_die.plist that directs launchd to always  
keep the program running is:



http://www.apple.com/DTDs/PropertyList-1.0.dtd 
">



Label
com.netsq.app_shouldnt_die
Program
	/Users/heberlei/Development/Tests/BasicApp/build/Debug/ 
BasicApp.app/Contents/MacOS/BasicApp

KeepAlive





Todd


___

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

Please do not post 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: launchd detecting when an application is running

2009-06-04 Thread Todd Heberlein
I have written an application that I would like to launch whenever a  
certain app is launched.  I have used LaunchAgents in the past to  
detect events such as USB insertion and volume mounting to perform  
certain actions.  I was wondering if there was a launchd.plist key  
that allowed for launchd to detect an application startup.


One approach is to have an agent monitor the audit trail to look for  
the application starting. The agent can then do something that can  
cause your app to launch, but now you are introducing a third program  
into the mix.


Todd

___

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

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


State of the Union videos?

2009-06-12 Thread Todd Heberlein
Does anyone know if/when Apple will post the "State of the Union"  
presentations from WWDC 09?


Todd

___

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

Please do not post 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: Discussion to splinter off cocoa-dev list

2009-06-12 Thread Todd Heberlein
so grueling and satisfying at the same time, we may never know. With  
all the new functionality (APIs) to be provided in 10.6 and for the  
iPhone 3.0, I wonder if it would be worth having some frank  
discussion on if now is a good time to split off from this list some  
more focused discussion lists.


Well, I don't think the 10.6 stuff can be talked about in a public  
forum until after it ships in September. There is a forum site at developers.apple.com 
 on which NDA-related stuff can be discussed.


I was part of many discussions that revolved not around demanding  
new features per-se', but more of hashing things out among  
developers and engineers in order to get something coherent to  
submit as a Radar or Enhancement/Bug report.


I find writing a good bug report very time consuming. I have to  
isolate the problem, develop the simplest example possible to allow  
the engineers to reproduce the problem, then write up instructions on  
reproducing it, what should be seen, what is actually seen, etc. In  
short, it is sort of like writing a mini-academic paper. But I have  
been very pleased with the responses I've gotten from Apple for my  
efforts, so I usuallly feel it is worth it.


One trouble we already have is cross-posting or posting to the wrong  
list. Using launchd to launch a Cocoa app for example should probably  
be taken to the Darwin mailing list, but if someone is already a  
subscriber to Cocoa, they probably don't know about the Darwin list or  
don't want to subscribe just to post a single question. So it gets  
posted to this mailing list. With more focused mailing lists I fear  
there will just be more emails sent to the wrong mailing lists.


Maintaining "mailing list purity" is always a challenge. At which  
point, a moderator should probably come along and respond to this  
email as "off topic" for this mailing list.  ;^)


Todd

___

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

Please do not post 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: Securely limit the running an application by serial number

2009-07-03 Thread Todd Heberlein

This is for limited use, and isn't a product for the masses.


There has already been some pretty good stuff posted, but just keep in  
mind that once you've released your code, if someone is really  
interested in modifying your code, they probably will. I doubt there  
will ever be a 100% guaranteed solution.


The military has been investigating elements of this for a few years  
with respect to unmanned combat vehicles (they know they are going to  
be captured by their enemy, so for a variety of reasons they want to  
protect the code), so you may want to look around at DARPA and DARPA  
contractors to see what unclassified papers have been published.


Todd

___

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

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


Using private APIs

2009-07-09 Thread Todd Heberlein
From time to time someone posts a question about using non-public  
Apple APIs -- you know, the ones that let you do something really cool  
or fast but causes your app to break on a future OS release. :)   
Anyways, I saw this purported private API for OS X, and I thought I'd  
share it. Pretty funny. :)


From:
http://ericasadun.com/iPhoneDocs300/_u_i_view_controller-_u_i_view_controller_class_dump_warning_8h-source.html

@interface UIViewController (UIViewControllerClassDumpWarning)

- (void)attentionClassDumpUser:(id)fp8
yesItsUsAgain:(id)fp12
althoughSwizzlingAndOverridingPrivateMethodsIsFun:(id)fp16
itWasntMuchFunWhenYourAppStoppedWorking:(id)fp20
pleaseRefrainFromDoingSoInTheFutureOkayThanksBye:(i))fp24;

@end


Todd

___

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

Please do not post 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: testing your app on a virtual machine?

2009-07-15 Thread Todd Heberlein
Is there anyway one can install an OSX system on a virtual machine  
for testing purposes?


Check the EULA for Mac OS X Server. I think you can run that under a  
VM, and I think VMWare has support for it in either the current or  
future version.


Todd

___

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

Please do not post 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: Finding an available port for chat

2009-07-17 Thread Todd Heberlein
but there will be persons like myself with draconian isp who block  
gobs of ports and make it hard to for chat apps to work.


There are a lot of very good reasons for a Draconian policy like  
that. :)



how can I, in a reasonably economic way, find an open port to talk on?


Are you trying to specify a specific port on your machine you know  
will get past the ISP's filtering? Or are you just trying to find a  
random high-numbered port that the ISP will unlikely have blocked? Or  
are you trying to get around the blocking in general.


If you drop down to Berkeley sockets layer, you can specify a port for  
your server, or you can pass 0 as the port and the server will  
(somewhat) randomly choose a high numbered port for you. If you think  
lots of potential users are going to suffer port filtering, you could  
set up a server somewhere else on the Internet and have both users  
connect to that. For example, user's A and B connect to each other by  
connecting to a third machine C. That way neither user A or B need to  
have their machine open up a server on their machine.


Todd

___

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

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


Avoiding KVO in dealloc?

2009-08-03 Thread Todd Heberlein
While working through "Beginning iPhone 3 Development" I've seen the  
following a lot, and it seems like a general Cocoa issue.


In -viewDidUnload methods the code has the form:
self.foo = nil;

Whereas in -dealloc methods the code has the form:
[foo release];

Both methods seem to me to do the same thing (releasing foo), but I  
presume the first one would trigger any KVO observers where as the  
second wouldn't. Is that why the simple "release" is used instead of a  
setter in the dealloc methods, to avoid KVO? Is this a general Cocoa  
pattern?


Thanks,

Todd

___

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

Please do not post 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: Notification for launch of root daemon process?

2009-08-17 Thread Todd Heberlein
Is there some notification that's posted by the OS when a root  
daemon process is launched?  Here's what I've tried:


Off the Cocoa topic, but I track processes using the BSM audit trail.

Todd

___

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

Please do not post 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: devil of a time with an NSImageView

2009-08-19 Thread Todd Heberlein
 The standard practice is to start any nib-dependent startup stuff  
on -awakeFromNib ... forcing it to load seems dirty. :-)


or
-viewDidLoad

on the iPhone (?).

Todd

___

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

Please do not post 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: Finding process path from Cocoa?

2009-12-09 Thread Todd Heberlein

On Dec 9, 2009, at 4:23 AM, Alastair Houghton wrote:

> Specifically, a potential attacker will deliberately not follow this 
> convention.  The Security Server used to get the information for the program 
> name in this manner, which created quite an interesting vulnerability since 
> you could get it to display an authorisation dialog with *any* name you 
> wanted in it.  I blogged about that particular security hole some time ago:

Drifting far afield from Cocoa... but it seems that there isn't a good Cocoa 
solution for this. Snow Leopard has a very good audit trail system with a live 
audit stream /dev/auditpipe. With a little work, this could potentially be used 
to map process IDs to the disk image they are running.

Todd

___

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

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


Menu items unexpectedly disabled

2009-12-18 Thread Todd Heberlein
I have a document-based app. For each document there can be a couple of 
satellite windows brought up for specific views of some of the data. Each of 
these satellite windows is controlled by an NSWindowController subclass loaded 
by MyDocument and added via addWindowController:.  A menu item's target is the 
First Responder, and the method to implement the action is in MyDocument. 
Everything works as expected when the primary window is key.

The problem is that when one of the satellite windows is key, menu items 
implemented by MyDocument are disabled. I thought the responder chain went 
through the NSWindowController and then through to its NSDocument? Or is this 
only the case when for the document's primary window (and NSWindowController)?

Note: The work around is trivial. I just implemented the method name in the 
satellite window's NSWindowController subclass and forwarded the call to the 
document:

-(IBAction) doMenuThing: (id)sender
{
[[self document] doMenuThing: sender];
}

but I feel this isn't the "Cocoa Way" of doing it. Am I missing a configuration 
step?

Todd

___

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

Please do not post 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: Menu items unexpectedly disabled

2009-12-18 Thread Todd Heberlein
> That's correct, and that's how it should work. It works here in a test app. 
> Are you doing anything "unusual" in your NSWindowController? What methods are 
> you overriding?

My bad. After getting your email I kept dug around a bit more, and I discovered 
I had not connected the NSWindowController subclasses' "window" outlets to the 
NIB's windows. Once I did that, everything started working.

Thanks,

Todd

___

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

Please do not post 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: Encrypting Binary Strings

2009-12-30 Thread Todd Heberlein

On Dec 30, 2009, at 9:17 AM, Mr. Gecko wrote:

> Is it possible for me to encrypt the strings in my binary so hackers can't 
> easily figure out what my application has in it? Reason I'm asking is I have 
> some private keys that encodes data that I/parents don't want kids or 
> teenagers to find.

Have you tried the OpenSSL crypto library? Maybe you could could encrypt your 
data, and then use an algorithm to put together the key at runtime. It isn't 
super secure, but he will prevent the data from sitting there on the disk in 
plaintext.

Another thing to look at is DRM techniques. They need to solve a similar 
problem.

Todd

___

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

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

2010-01-02 Thread Todd Heberlein
> I'm fairly new to programming for the iPhone (still getting up to speed!),
...
> but I can't figure out from the docs, nor from online code examples, how to 
> do this. 

I liked the book "Beginning iPhone 3 Development: Exploring the iPhone SDK". It 
is a good way to get up to speed on iPhone development. I think it would have 
answered your question too.

Todd

___

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

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


Resolution Independence

2010-01-05 Thread Todd Heberlein
A friend of mine loves her new 27" iMac but has complained at how small 
everything is. Searching around on the net I found that it has about a 109 dpi 
pixel density. I also saw today that the new Nexus phone has a pixel size of 
800x480 (as opposed to my iPhone's 480x320 pixel size), and the two together 
got me thinking more seriously about resolution independence again. Other than 
making big icons for my apps, I had pretty much ignored the resolution 
independence issue.

Today I fired up Quartz Debug to set the UI Resolution to a bigger scale, and I 
am happy that my applications did OK.


But how accurate of a test is this compared to real-world resolution 
independence?

Or in other words, is there real resolution independence built into Snow 
Leopard for apps? Can I (or my friend with her 27" iMac) set a scale factor on 
an application without using Quartz Debug?

Is there something similar for iPhone development?

Or is the Xcode mailing list a better place for this question?

Thanks,

Todd

___

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

Please do not post 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: Allow only root/admin users to execute the cocoa app

2010-01-24 Thread Todd Heberlein
> I want to allow my cocoa app to be only launched by root/admin users.
> How can i achieve this?

As I think has already been mentioned, the UNIX approach is to set the 
application's owner as root and then make it only executable by the owner. 
However, Apple largely discourages programmers from developing Cocoa apps that 
will be run with root privileges.

A better approach, if possible, is to factor out the section of code that needs 
to be run with root privilege (e.g., to read a protected file or open a network 
tap) and place that in a command line helper tool. The Cocoa app then runs with 
normal privileges. When the program needs to perform the privileged operation 
it calls that helper app (think of it as a kind of remote procedure call).

Look up Apple's BetterAuthorizationSample code for how to do this.

Todd

___

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

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

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

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


Re: How to resume an XCode Download

2010-02-10 Thread Todd Heberlein
My problem is that my ISPs use long-haul WiFi links that seem to go down fairly 
regularly (which is why I keep redundant ISPs). This make multi-hour downloads 
occasionally frustrating.

Todd

On Feb 10, 2010, at 9:00 AM, Philip Ershler wrote:

> 
> On Feb 10, 2010, at 9:45 AM, Richard Somers wrote:
> 
>> On Feb 10, 2010, at 2:28 AM, Tharindu Madushanka wrote:
>> 
>>> Is there any way I could resume a broken XCode download due to session 
>>> expire..
>> 
>> I also have a slow connection. I have never been able to resume a broken 
>> XCode download. The only solution I have found is making sure your computer 
>> stays awake during the entire download.
>> 
>> --Richard
>> 
> 
> I don't know why this is such a mystery. Just go to the Energy Save panel in 
> System Preferences and set the computer  to never sleep. You can set the 
> screen to sleep if you wish.

___

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

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