Float constants

2010-03-17 Thread Michael Vannorsdel
I've been working on some 64bit code cleaning but need some advice on float 
constants.  Currently on 32bit builds I use -fsingle-precision-constant since 
most of my code uses CGFloats and I'd like the constants to be the correct 
precision.  But in some places I do work with doubles and would like the 
constants involved to be double on 32bit and not float getting promoted.  I 
tried the L suffix on them but they still compile as floats.  So is there a way 
to force a constant to be a double when using 
-fsingle-precision-constant?___

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

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

2010-03-17 Thread Michael Vannorsdel
This is exactly why I do it for the 32bit builds.  What I'm trying to avoid in 
the sections that use doubles is having the constant generate a float load, 
double store, double load for each constant.  I'm still poking through the 
assembly to see if gcc is indeed doing this but I'm also checking if someone 
has experience with this and how to avoid causing unnecessary load/store/loads 
to promote the constants to doubles.  For instance if putting an explicit cast 
like (double)1.2345 will tell gcc to treat it as a double despite the single 
precision flag.


On Mar 17, 2010, at 4:52 PM, Nick Zitzmann wrote:

> For me, anyway, setting that compiler flag is SOP when building for 32-bit 
> code. A lot of older 32-bit Cocoa code was written under the assumption that 
> it's okay to use double constants in places that expect floats, because under 
> Xcode's default warning set, nothing happens when the code does that. 
> Changing them to float constants is tedious and causes a little 
> (insignificant) precision loss when building for 64-bit, so I just keep them 
> as double constants and use that flag to make them into float constants on 
> 32-bit builds.
> 
> Of course, I don't think there is any one true way of tackling this problem...

___

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

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

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

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


CALayer mask issue

2010-03-30 Thread Michael Vannorsdel
I have a CALayer that is larger than the window and I move that layer around to 
view various sections of it.  The layer is also masked by another CALayer.  The 
problem I have is if I move half of the layer out of view the mask stops 
working right.  As if the mask is transparent so none of the view layer 
contents is shown.  I've verified the contents of both layer and mask layer are 
valid and correct, but the masking just stops working.  After that point even 
applying a new mask for the layer still won't mask it.

Is there some gotchyas I should know about with masking 
layers?___

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

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

2010-06-11 Thread Michael Vannorsdel
I had this happen a couple times when dealing with threading accidents.  If the 
tracking rects are added from a secondary thread or the window is ordered front 
by a secondary thread, then the tracking areas will be stuck in a pending 
state.  There's probably more reasons for this but these are the two I'm 
personally familiar with.


On Jun 11, 2010, at 1:42 PM, Rainer Standke wrote:

> Hello all,
> 
> I have a subclassed NSImageView that is a drag source and a drag destination. 
> I am trying to have an NSTrackingArea so that when the drag out of the image 
> view leaves they window I can update the cursor to indicate deletion of the 
> item - I am thinking of the cursor that looks like an explosion cloud.
> 
> When I log my tracking area it tells me it's "pending install", and I never 
> get any of the expected mouse-move messages.
> 
> This snippet is in mouseDown on the image view:
> 
> NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited | 
> NSTrackingEnabledDuringMouseDrag | NSTrackingActiveAlways;
>   
> NSTrackingArea *trkArea = [[NSTrackingArea alloc] initWithRect:[[self window] 
> frame] options:options owner:self userInfo:nil];
> 
> [self addTrackingArea:trkArea];
> [self updateTrackingAreas];
>   
> NSLog(@"trkArea: %@", trkArea);
> 
> 
> I am running out of ideas what to try - any help would be appreciated.

___

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

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


Entitlements and specific files/dirs

2011-08-17 Thread Michael Vannorsdel
Apologies if this has been covered in the past but my searches did not turn up 
anything as specific as I'm looking for.

Is there a way to refine sandbox entitlements to allow read/write access to 
specific files and directories instead of just all or none?  For instance, only 
allowing RW to Caches and Preferences but nowhere else.

And on a side question, does outgoing network entitlement mean the binding of a 
port for services or does it mean any outbound data such as an http 
request?___

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

Please do not post admin requests or moderator comments to the list.
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: Entitlements and specific files/dirs

2011-08-18 Thread Michael Vannorsdel
After lots of playing and reading of obscure documentation, it looks like Lion 
creates a duplicate library in the Containers folder so even a sandboxed app 
with no read or write file access still has access to its own Application 
Support, Caches, and Preferences folders, among others.  The file access 
setting refers to files opened through standard appkit api panels; accessing 
arbitrary files without user interaction is still blocked (only files users 
open with these apis even appear in your sandboxed world while everything else 
appears to not exist).

I also found that Allow Incoming Connections is the one that blocks port 
binding and general server type behavior.  The outgoing covers general client 
behavior like requesting and receiving data responses.

Hopefully this will help someone else as I can't point to any easy docs to 
refer to as this info was gather piecemeal from official and unofficial docs 
and through trial and error.


On Aug 18, 2011, at 10:08 AM, Sean McBride wrote:

> On Wed, 17 Aug 2011 03:17:30 -0600, Michael Vannorsdel said:
> 
>> Apologies if this has been covered in the past but my searches did not
>> turn up anything as specific as I'm looking for.
> 
> Are you talking about on Lion?  If so, there hasn't been much discussion of 
> this new feature here yet.
> 
>> Is there a way to refine sandbox entitlements to allow read/write access
>> to specific files and directories instead of just all or none?  For
>> instance, only allowing RW to Caches and Preferences but nowhere else.
> 
> com.apple.security.temporary-exception.files.absolute-path.read-write
> 
> But "temporary-exception" suggests you should file bugs for better solutions.
> 
>> And on a side question, does outgoing network entitlement mean the
>> binding of a port for services or does it mean any outbound data such as
>> an http request?
> 
> I believe it allows any connections.  I haven't seen a way to permit access 
> to only some hosts or only some ports.

___

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

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


RegisterEventHotKey and keylogging

2010-02-02 Thread Michael Vannorsdel
Can RegisterEventHotKey be used to log an admin password or other  
passwords?  I accidentally hotkey'd some regular characters and had  
them trigger when typing in my admin pass on 10.5.8.

___

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

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

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

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


Re: RegisterEventHotKey and keylogging

2010-02-02 Thread Michael Vannorsdel
Ya makes sense and pretty much what I saw; input was getting absorbed  
by the hotkey app.  I'm just thinking if a userland processed hotkeyed  
all keys when the pass window popped.  I'm guilty of quickly typing my  
pass so I could get 3-4 characters into it before I'd notice input  
isn't working, and other users might type the whole thing a few times  
tying to get it to work.  I'm just wondering if there's built-in  
protection against this scenario or just something users have to know  
about and watch for.



On Feb 2, 2010, at 3:15 AM, Symadept wrote:


Hi Michael,

Basically RegisterEventHotKey registers given combination of hotkey  
identified with the keycode. If it happens to be your pressing key  
is registered as hotkey then you wont be able to see that. Lets say  
you have registered A as hotkey in some application then either in  
your password or username field you can never be able to print A and  
inturn fires hotkey which may be the response of that particular app.


Hope it is clear to you.=

___

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

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

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

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


Re: RegisterEventHotKey and keylogging

2010-02-06 Thread Michael Vannorsdel
I found that I can hotkey any keys and then use CGEventPost to post  
the key to the front application.  This effectively lets me track all  
the keys the user presses from a non-privileged application while  
still sending input to the key window/process.  I was also able to see  
my admin pass as it was typed in to an authentication window without  
any side-effects.


Am I missing something or is this a security flaw?


On Feb 2, 2010, at 3:15 AM, Symadept wrote:


Hi Michael,

Basically RegisterEventHotKey registers given combination of hotkey  
identified with the keycode. If it happens to be your pressing key  
is registered as hotkey then you wont be able to see that. Lets say  
you have registered A as hotkey in some application then either in  
your password or username field you can never be able to print A and  
inturn fires hotkey which may be the response of that particular app.


Hope it is clear to you.

___

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

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

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

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


Re: setAction:@selector is not working ?

2010-02-19 Thread Michael Vannorsdel

I would try and reset the target just after setting the action:

[myMenuItem setAction:@selector(myFunction:)];
[myMenuItem setTarget:self];

I remember a long time ago I had a problem where if I reset the item's  
action, it would set the target to nil for some reason.  So in  
practice I usually reset the target even if it's the same.


Not sure if this is your issue though.


On Feb 19, 2010, at 12:43 PM, David M. Cotter wrote:

just before the line of code that pops up the menu, i iterate over  
all the items

so yes, i am absolutely sure it is getting called
and i am absolutely sure that myMenuItem is non null

i'm just wondering if there is something which pre-empts my code,  
telling the menu item to NOT call the action selector.  what could  
*possibly* intervene here?


___

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

Please do not post admin requests or moderator comments to the list.
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: Determine if only single instance is running.

2010-02-22 Thread Michael Vannorsdel
When I have a process that I really don't want running more than once  
(some people will run copies or use LaunchServices to launch  
multiples) I register a named mach port with NSConnection.  When when  
an instance launches it checks for that connection and if it exists  
the new instance exits out after displaying an error.


Just one method to use, but beware that the bootstrap server limits  
what sessions can see registered ports.  But it will work to keep the  
same user from opening multiple instances.


Other methods are creating a device to check for, a shared memory  
page, ect.



On 22 Feb 2010, at 05:59, Poonam Virupaxi Shigihalli wrote:



Hi list,

Is there a way to check an application instance is running. I tried  
enabling application prohibits multiple instance in info.plist.

Still i am able to launch multiple instance of the same application.

___

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

Please do not post admin requests or moderator comments to the list.
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 draw background image in my app window

2009-05-30 Thread Michael Vannorsdel
You're creating an NSImage and pretending it's an NSImageView which  
it's not.  You'll need to create a new NSImageView and then the  
NSImage and set the image as the imageview's image.



On May 30, 2009, at 8:27 AM, cocoa learner wrote:

Thanx Nick for your reply.But in my window I am not getting the  
image I want

to display. Here is my code -

- (id) init

{

[super init];

NSLog(@"AppController::init : Setting the windows content");

NSBundle *myBundle = [NSBundle mainBundle];

if (myBundle == NULL)

{

NSLog(@"AppController::init : myBundle is NULL");

}

else

{

NSLog(@"AppController::init : myBundle is not NULL");

}

NSString *path = [myBundle pathForResource:@"winImg" ofType:@"png"];

NSLog(@"AppController::init : Image file path : %@", path);

NSImageView *winContent = [[NSImage alloc]  
initWithContentsOfFile:path];


[ appWindow setContentView: winContent];

NSLog(@"AppController::init : The windows content has been set");

return self;

}

I can see all the logs. But not the image in back ground of my app  
window.

Am I doing any thing wrong in this code?

Regards
Cocoa.learner.


On Tue, May 26, 2009 at 11:12 PM, Nick Zitzmann  
 wrote:




On May 26, 2009, at 11:04 AM, cocoa learner wrote:

How to draw background image in my app window?




You could change the window's content view using -setContentView:  
to a view
that will draw a background image, such as NSImageView... Of  
course, if you
have any other controls in the content view that is being replaced,  
then

they'll be lost.

Nick Zitzmann








___

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

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

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

This email sent to mikev...@gmail.com


___

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

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

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

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


Re: How to draw background image in my app window

2009-05-30 Thread Michael Vannorsdel
You'd really be better off making an NSView subclass and having it  
draw the image you want in drawRect:.


- (void)awakeFromNib
{
myImage = [[NSImage alloc] init

[self setNeedsDisplay:YES];
}

- (void)drawRect:(NSRect)rect
{
NSSize isize = [myImage size];
	[myImage drawInRect:[self bounds] fromRect:NSMakeRect(0.0, 0.0,  
isize.width, isize.height) operation: NSCompositeCopy fraction:1.0];

}

*this was written in mail, may gave errors.

On May 30, 2009, at 11:45 AM, cocoa learner wrote:

Yah Andy and Michael you all were right. But still I have some  
problem.

1>. While resizing the window Image is not getting resized.
2>. My controls (NSButton and NSTextField) are not visible after the  
awakeFromNib call.


___

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

Please do not post admin requests or moderator comments to the list.
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: Setting wantsLayer = YES; crashes on view load.

2009-06-01 Thread Michael Vannorsdel
Are you registering for any notifications?  It looks like it's  
crashing while trying to notify an object.



On Jun 1, 2009, at 12:31 AM, Kevin Ross wrote:

Hi everyone, I have a Core Data document based app that I've been  
working on for a while and I now want to change some of the view  
drawing to use CALayers.  The trouble I'm having is that when I set  
a view's wantsLayer = YES, I end up getting EXC_BAD_ACCESS.This  
happens when I try to set it on any arbitrary view in any of the  
nibs in my project, when setting it from code, or from clicking the  
checkbox in IB.  I've tried new CALayer projects from scratch and  
they work fine, is there something I could have done to my project  
that would prevent me from setting a view's wantsLayer property to  
YES?


Thank you for taking time to read this.


___

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

Please do not post admin requests or moderator comments to the list.
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: Setting wantsLayer = YES; crashes on view load.

2009-06-02 Thread Michael Vannorsdel

Great glad you found it.  Those are pretty hard to track down sometimes.


On Jun 2, 2009, at 2:36 AM, Kevin Ross wrote:

Turns out I did have an spurious NSNotificationCenter registration  
in a loaded view that was causing the crash.  Thank you for your  
help Michael!


___

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

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

2009-06-03 Thread Michael Vannorsdel
Could be one of many network programs like LittleSnitch or  
NetBarrier.  Could also be he's using a proxy.



On Jun 2, 2009, at 9:37 PM, Mr. Gecko wrote:

Hello. For some reason, one of my customers is having a problem  
which I determined to be NSDictionary dictionaryWithContentsOfURL  
can't connect to my server for some odd reason. I can't determine  
what reason because it works for all my other customers and so it's  
just this one guy. He can go to my website in Safari which makes it  
even more weird.


Any Ideas? I'll try and screen share with him tomorrow to run tests  
and see what it out puts in terminal.


___

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

Please do not post admin requests or moderator comments to the list.
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: Drop dowm status menubar item while hovering cursor over it

2009-06-11 Thread Michael Vannorsdel
What Mr. Farmer was saying is this problem is a known bug with no  
workaround or quick fix.  You will have to wait for Apple to fix this  
in a future system update.  There is nothing you can do to your  
application to make this work properly.


If you make a separate status item plugin, that will work properly  
because it is loaded and handled by the same process as all the system  
status items.  But a status item from an application won't work the  
same.



On Jun 11, 2009, at 1:51 AM, Gami Ravi wrote:

Oh, what he's asking is why you can't single-click to drop down  
one  menu, then switch over to a statusbar item's menu without  
clicking  again.


This behavior is common to all status bar items, and is arguably a   
bug. You can try reporting it to Apple, but it's unlikely to be  
fixed  for a while yet.


If this is the case, then it should also work with statusbar item  
that i created. i.e. If click on time machine icon then status menu  
will be displayed. now i move mouse over my application statusbar  
item then it should display status menu. Am i right?


because this was not the case with my application statusbar  
item.Status menu is not display when i move from other items to my  
statusbar item.

___

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

Please do not post admin requests or moderator comments to the list.
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: Get|SetControlProperty() equivalent

2009-06-11 Thread Michael Vannorsdel
Generally you subclass the control and implement whatever data  
association you want.



On Jun 11, 2009, at 4:41 AM, Jo Meder wrote:

I'm pretty sure I know the answer to this question, but I'll ask it  
anyway :-)...


Is there a Cocoa equivalent to Carbon's Get|SetControlProperty()  
family of functions? For those not familiar these functions let you  
associate user data with controls. I've never really used this for  
much, but it is very useful for storing a pointer to a C++ object  
representing the control in a UI framework, for example.


It would be great to be able to do this for NSViews but I haven't  
been able to find any equivalent. Are there any ingenious ways that  
you might be aware of so I could bolt this on to NSView?


I'm trying to avoid setting up a map from NSViews to UI framework  
objects, but I suspect it will be inevitable. Not really a big deal,  
but less hassle to be able to associate the data directly so that  
would be a preferable solution.


___

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

Please do not post admin requests or moderator comments to the list.
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: Get|SetControlProperty() equivalent

2009-06-11 Thread Michael Vannorsdel
Subclass NSView and use poseAsClass to replace the default  
implementation.  You'll need to do the posing before running  
NSApplicationMain.  You'll have to use a different approach if you're  
building for 64-bit.



On Jun 11, 2009, at 7:25 AM, Jo Meder wrote:


Hi Graham,

On 11/06/2009, at 11:50 PM, Graham Cox wrote:

The carbon mechanism exists because in classical procedural code,  
you can't subclass an "object" because there is no formal "object"  
to subclass. Therefore storage mechanisms have to be provided to  
hang extra stuff on.


It's still just a convenience rather than a necessity, there are  
other ways of doing it. It's a useful convenience though, in this  
case at least.


In Cocoa, we have proper objects, so you can simply (ingeniously!)  
subclass the NSControl or NSView as you wish and add any extra data  
members you want for any purpose you wish. For example you could  
subclass NSView and add a reference to your C++ object directly as  
a data member along with suitable accessors for it. If the view  
needs to be aware of the C++ code itself you can compile it as  
Objective-C++ using a .mm extension on the source file.


It's not really so simple, because I'd have to subclass all the  
views/controls I use, which is many of the UI elements available,  
and that means I have many disparate classes implementing the same  
functionality. Of course I then need to repeat that for any new  
controls I support. Less work and maintenance to maintain a map from  
NSViews to my C++ framework objects. I should have mentioned I had  
considered and rejected subclassing I guess.


As an aside, I'm using Objective-C++ extensively in my framework.  
It's quite the godsend really and has made things a lot quicker and  
easier.


Thanks anyway. I was a long time MacZoop user BTW. Well, some of  
MacZoop, I used all my own control classes. I use a messaging and  
commander system inspired by my experience with MacZoop in my own  
framework.


Regards,

Jo Meder

___

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

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

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

This email sent to mikev...@gmail.com


___

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

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

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

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


Re: Coming up with ideas

2009-06-12 Thread Michael Vannorsdel
Mostly listening to people going, hey I wish this was easier or if  
this program I always use had xyz and did abc better. Also ideas from  
yourself when you find something you need to make your life easier.   
I'm sure many developers have made their own various mini-tools to do  
random things for them and some don't realize other people might find  
them useful too.  Several of my public projects started as stuff I  
made for myself and later realized with some polish could be something  
good for the public.



On Jun 12, 2009, at 8:30 PM, Development wrote:

Hey, how do you guys come up with ideas for new programs? I'm going  
nuts trying to figure out what type of application I should make.


___

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

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

2009-06-13 Thread Michael Vannorsdel
To reiterate, this is probably the best solution if you want to blur  
all images that will be set on this image view.  From IB you just  
activate the Core Animation layer for the image view and attach the  
gaussian blur filter to it.  Then every image it displays will be  
blurred automatically.



On Jun 13, 2009, at 9:37 PM, Kyle Sluder wrote:


Look into Core Image filters.  You can apply them to any layer-backed
view.  You can even do it from within Interface Bulder, on the View
Effects tab of the inspector.


___

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

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

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

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


Quick DO endian question

2009-06-24 Thread Michael Vannorsdel
Do messages to remote proxies (a vended DO object) need to have their  
arguments adjusted for endianness or does DO handle that on its own?


ie:

[rootProxy myNumberIs:someInt32];

would I need to standardize alignment in the above or leave it alone.
___

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

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

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

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


Re: Quick DO endian question

2009-06-25 Thread Michael Vannorsdel
Thanks for the confirmation.  I did some testing using Rosetta and  
didn't see endian problems but I wanted to make sure this was intended  
and reliable on actual PPC and not just an anomaly leading me to  
believe the byte swapping was automatic for explicit types.



On Jun 24, 2009, at 10:54 PM, Michael Ash wrote:


This is the sort of thing that would be trivial to test if you have an
Intel machine on hand

In any case, the answer is no, you do not need to worry about
endianness in any data whose types that DO can see. DO gets full type
information about arguments and return values from the ObjC runtime,
and uses this to do any necessary conversions. Not just endianness,
but also size conversion (and potentially format conversion for
floating-point values, although everything Mac OS X runs on or
conceivably will run on uses IEEE754 format floats) will be done for
you.

Note the qualifier "whose types that DO can see". If you're shipping
around, say, raw data inside an NSData object, then DO can't know what
kind of stuff is in there and it will not do the conversion for you.
This is a pretty rare occurrence, of course, so normally you won't
have to worry about it.

___

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

Please do not post admin requests or moderator comments to the list.
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: NSProgressIndicator not animating when part of NSAnimation

2009-08-16 Thread Michael Vannorsdel
I had this problem once when I had accidentally called  
makeKeyAndOrderFront: on the window from a secondary thread.  Animated  
system controls and tracking rects would work.



On Aug 15, 2009, at 7:45 PM, Thomas Bauer wrote:


Thanks for your response.
I am not quite sure if I understand you correctly but here is what I  
tried:


- Calling the whole code (starting the NSAnimation and the  
ProgressIndicator animation) using a performSelectorOnMainThread  
does not fix it.
- Calling the whole code using performSelector delayed does not fix  
it.
- Calling the NSProgressIndicator startanimation alone on the main  
thread does not fix it either.


However your response triggered an idea and this works:

[myViewNSAnimation startAnimation];
[myindicator performSelector:@selector(startAnimation:)  
withObject:nil afterDelay:1.1];


Does the trick, but only if the delay is greater than the duration  
of the NSAnimation.
In short, if I call the selector (even on the main thread) during  
the NSAnimation is running, it does not work.
That would make some sense - but why the same thing works without  
those tricks in awakefromnib does not make sense to me...
Because I would think that running it in awakefromnib and running it  
using performSelectorOnMainThread should be somewhat identical?


While it is great that I have a workaround ... I would appreciate  
any explaination on why it behaves that way.

Technically this does not make sense to me.


___

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

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

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

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


Re: Autosave in place - common use case that makes me hate it

2012-09-21 Thread Michael Vannorsdel
I think if you have really good undo support people find autosave less of an 
annoyance.  Most people took advantage of the save-before-experimenting method 
because several apps had bad or nonexistent undo support so saving was the only 
way to reliably go back.


On Sep 21, 2012, at 10:05 AM, Uli Kusterer wrote:

> I run into it as well. But less and less. It's the same as the reversal of 
> the scroll wheel direction: It's hard to undo more than a decade of rote 
> memorization. But it's possible It's an aspect of having to manually save 
> that we power users have taken advantage of as a feature.
> 
> The real world doesn't work like that. New users don't expect it to work like 
> that. For everyone but us "damaged souls", this is actually an improvement. 
> If you wanted to scribble additional annotations into a drawing, you'd make a 
> photocopy of it. On the computer, you just have to train yourself to 
> duplicate the file before you do these changes.


___

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

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

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

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


Re: any help with [NSThread initWithTarget:selector:object]???

2008-05-15 Thread Michael Vannorsdel
You might try using pthreads, they're easy to use but not NSThread  
easy.  They have several more options and make the base NSThread is  
built upon.  There's a join option with pthreads where one can wait  
for another to finish which might be what you're looking for.  Look at  
pthread_join.



On May 15, 2008, at 12:02 AM, Alex Esplin wrote:


Doh.  I knew I had to be missing something trivial.  When you start a
thread with [threadname start] how do you wait for it?  I can't seem
to find anything on that...


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: glass effect - CG call to do this?

2008-05-15 Thread Michael Vannorsdel
You're probably thinking CoreImage.  Checkout the CIFilter docs,  
there's a few builtin glass filters available.



On May 15, 2008, at 3:01 AM, John Clayton wrote:

A few months ago, while browsing code headers at random (lets just  
call this a little passtime of mine), I noticed a method call that  
took an image and then added a glass effect to it.


I believe this was in the Core Graphics headers somewhere, but for  
the life of me can't find it now.


Does anyone know if this exists and where it might be? (don't tell  
me I was just dreaming).


___

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

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

2008-05-15 Thread Michael Vannorsdel
This has to do with non-printable characters in pathnames.  Each  
application can different how they visually represent these  
characters.  The terminal just replaces them with '?', the Finder  
might use a space.


When you have a path from NSFileManager, leave it as is in the  
NSString if you're going to pass it to other Foundation file manager  
APIs.  If you need a C string of the path for C APIs, you can use  
NSFileManager's fileSystemRepresentationWithPath: to get a properly  
encoded C string.  Also displayNameAtPath: can give you the proper  
representation for displaying the path to the user but may not work  
when passed to file system APIs.



On May 15, 2008, at 4:17 AM, JanakiRam wrote:

I'm facing an issue with NSFileManger directoryContentsAtPath API.  
This
seems to be an wried issue. But its very important for me to fix.  
Please

help me.

My application is trying to enumerate  the folders in inside a Mac
using NSFileManager  API. But for some files its failing.

It looks like the file name ( inside bundle ) is interpreted by  
Finder and
Terminal in a different ways. Can any one please suggest me a way to  
resolve

this issue.

Thanks in Advance

*Cocoa Code for your reference.*

NSFileManager *defaultManager = [NSFileManager defaultManager];
NSArray *filePath = [defaultManager directoryContentsAtPath:
@"/Users/janakiram/Downloads/Folder.tiff"];
int i , count = [filePath count];

for ( i = 0 ; i < count ; i++ ) {
NSLog(@" filepath  is (%@)",[filePath objectAtIndex:i]);

}

*Output:*

[Session started at 2008-05-15 15:34:38 +0530.]
2008-05-15 15:34:38.951 FileEnumerator[4094:10b]  filepath  is (Icon
)

FileEnumerator has exited with status 0.

*Terminal View of Folder :*

Janakirams-iMac-G5:~ janakiram$ cd /Users/janakiram/Downloads/ 
Folder.tiff


Janakirams-iMac-G5:Folder.tiff janakiram$ ls -la
total 112
drwxr-xr-x@  3 janakiram  staff   102 May 15 15:36 .
drwx--+ 92 janakiram  staff  3128 May 15 15:17 ..
-rwxr-xr-x@  1 janakiram  staff 0 Aug  8  2006 Icon?

Janakirams-iMac-G5:Folder.tiff janakiram$ cp -R Icon^M


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Dynamic message typing problem

2008-05-15 Thread Michael Vannorsdel
This block is probably causing some corruption.  You're assigning 123  
to a uchar pointer and not the uchar, then passing the address of a  
pointer to a method that tries to printout the pointer as an int  
rather than the intended uchar value.



On May 14, 2008, at 7:19 PM, Julius Guzy wrote:


- (void) callPrintConstUnsignedCharRef:(id)pId;
{
unsigned char * tvarUnsignedChar= 123;
[pId printUnsignedCharRef:&tvarUnsignedChar];
}


___

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

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

2008-05-15 Thread Michael Vannorsdel
Currently NDA software from Apple is intended for you to quietly play  
with.  No public or private forum exists for discussion on this SDK.



On May 15, 2008, at 5:39 AM, Rich Curtis wrote:

Been lurking on the list for a couple of days. Is there another list  
for iPhone SDK programmers?


Doesn't seem to be much of that in this list. Am I in the wrong  
place for that sort of stuff?


___

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

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

2008-05-15 Thread Michael Vannorsdel
Look at the Security framework and functions like  
AuthorizationExecuteWithPrivileges.



On May 14, 2008, at 6:12 PM, Ron Aldrich wrote:


Hello Folks,

I'm trying to figure out where the API for the system's password  
entry dialog is defined.


In particular, I'm interested in using the dialog which is used by  
Disk Utility (i.e. diskimages-helper) to enter passwords.


Is there a public API for password entry dialogs? Or should I just  
roll my own?

___

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

Please do not post admin requests or moderator comments to the list.
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: Guidance for Cocoa's steep learning curve

2008-05-16 Thread Michael Vannorsdel
Tutorial examples don't really belong in API docs.  Their ultimate  
goal is to state the purpose and usage as directly as possible so the  
developer can get what they need and move on.  Continuously sifting  
through tutorial information and examples would be quite tedious and  
redundant for the majority who already understand the general concepts  
and conventions.


Apple does provide many introductory and advanced "booklets" that help  
to grasp the concepts and conventions.  Once you learn these and put  
everything together a lot of the APIs make sense, mostly because of  
Apple's adherence to these concepts and conventions (especially with  
Cocoa).


Some of the booklets take a little extra looking to find and may  
contain redundant or seemingly irrelevant information to what you're  
looking for.  But I've found that continuing to read on would produce  
little gems, or pieces of the puzzle if you will, that spark  
connections for you that you previously didn't make before.


Apple's tutorials are meant to be used as samples of applying the  
concepts you've read in the booklets.  You know the lingo and basic  
idea, now you get to see how it's applied in real examples.  If you  
haven't yet learned the idea concepts, the code tutorials won't do  
much for you.  You'll see what code is needed to carry out a certain  
task, but you won't know why the code was done as it is and won't  
recognize the application of the concepts and conventions.  The  
tutorial would be mostly fruitless.


Several books have been written that take different approaches to  
teaching the concepts and showing their applications.  Not everyone  
will learn from the exact same approach, and I don't believe it's  
possible to make a single approach that works for everyone.  Apple  
presents one approach and it won't work for everyone, and when it  
doesn't work for you, you search for different approaches.


Back in the college days I had taken two different courses on object  
oriented programming at two different universities.  Both books were  
400 pages+.  And sadly I still didn't quite understand the  
relationship of objects and classes and why anyone would need many  
copies (objects) of something made up of one group of code (a class).   
I had come from a procedural background and had a procedural mindset.


Then one day I got desperate and bought an online course presented in  
Shockwave.  It took me 3 days to complete the course.  Not because it  
was short, but so much was making sense and I was making so many  
connections that I couldn't stop and would work at it for 12-15 hours  
each day.  Afterwards OO programing made complete sense and I  
understood its purpose and possibilities.  For some reason that  
particular approach was just what I needed.


I don't blame the college courses nor do I think they were bad or  
worthless; They just weren't for me.  Apple's approach is not for  
everyone either but that doesn't invalidate its value.  I personally  
found it extremely helpful.



On May 16, 2008, at 8:27 AM, I. Savant wrote:


 I don't think it's possible to continue a rational debate when you
keep going down this type of path. Nobody here even remotely suggested
that documentation should be hard to read. Conversely, nobody can
reasonably argue that it is possible for documentation (on such a
highly complex technical subject) to be made "easy".


___

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

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

2008-05-16 Thread Michael Vannorsdel
I've tried the code here and it works as expected.  Could you give  
more detail on your build setup?  Like what arch you're building for,  
how you're executing the program, if you're executing code other than  
this, if this is actually running as a plugin or loaded bundle.



On May 16, 2008, at 9:21 AM, Julius Guzy wrote:


Yes thanks.
That was careless of me.
And I had made the problem statement far too long for the actual  
problem to stand out.


It was that this:

- (void) callPrintConstFloat:(id)pId {
	[pId printFloat:98.76];	// pId is object of  
class AnonTargetClass

}

causes this method in object of class AnonTargetClass

- (void) printFloat:(float)pF {
NSLog(@" %6.3f",pF);
}

to print
-151996493463552.000

even though
AnonTargetClass *atcObj = [[AnonTargetClass alloc] init];
[atcObj printFloat:98.76];

prints
98.760

Here's the full mainline and results

#import 
#import "AnonTargetClass.h"
#import "CallingClass.h"

int main(int argc, char *argv[])
{
AnonTargetClass * atcObj = [[AnonTargetClass alloc]init];
CallingClass* callingObj   = [[CallingClass alloc]init];

[callingObj callPrintConstFloat:atcObj];
[atcObj printFloat:98.76];

}


2008-05-16 16:07:41.058 testDynamicBinding[856:10b]  
-151996493463552.000

2008-05-16 16:07:41.059 testDynamicBinding[856:10b]  98.760


___

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

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

2008-05-16 Thread Michael Vannorsdel

How are you invoking rsync?  With NSTask or system()?


On May 16, 2008, at 8:28 AM, JanakiRam wrote:

When i give this filename as part of rsync source file ( using -- 
files-from
) , rsync is treating this filename as 2 different file names ,  
because

rsync expects each filen name separated by \r.
Hence my rsync command is failing


___

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

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

2008-05-16 Thread Michael Vannorsdel
Just to add, it's generally important to include compiler warnings  
with your problem description as they provide valuable clues.  The  
compiler issues warnings when something doesn't look right, make  
sense, or lacking information.  Usually the compiler will make guesses  
and assumptions as to what you want the code to do, which is not  
always correct.  The binary will build but may not function as intended.



On May 16, 2008, at 3:34 PM, Bill Bumgarner wrote:


Thanks Scott.

Yes, the file did not include declaration of AnonTargetClass.
I did see compiler warnings but I've always seen these on the G4  
and the system worked perfectly well.


An almost universal rule of Mac OS X programming: If you see a  
compiler warning, you are doing something wrong.


Fix the compiler warnings first (and correctly -- i.e. casting willy- 
nilly is not a fix) and then address the real problems within your  
code that remain.


In this case, that the code worked on any platform is merely a  
coincidence brought about by the architecture of said platform and  
the compiler.



Any idea where I should look to find ways of correcting this code?
Does one need to store the SEL or something like that?


You need to declare -printFloat: someplace that the compilation of  
the above will see the declaration and will interpret the arguments  
correctly.


This may be as simple as #import'ing an appropriate header file.   A  
more precise fix would be to not use (id) as the parameter type, but  
to declare the type explicitly.  This would have the side effect of  
requiring that you #import the class definition (or use @class,  
which won't solve the problem).


Also do you have any idea of where I could look for a description,  
(possibly with an example ?) of the standard approach to dynamic  
typing when it is not possible to include the header of the called  
object, for instance when having to avoid circularity in header  
file definition or the object is being defined on the fly?


Circularity of includes is easily addressed by using @class in the  
header portion to forward declare classes such that the circularity  
is avoided.


As per the implementation, circularity of includes should not be any  
more of an issue than in headers.   It is simply a matter of  
including the files in the right order.


Which, of course, is a pain in the butt and for which Xcode projects  
offer project headers and precompiled headers such that you can have  
one master (or set of masters) header(s) that are included in your  
implementation files instead of mentioning individual header files.



Even so I'm puzzled.
I thought cocoa was designed to allow dynamic typing i.e. where the  
class of the called object is not declared in the calling file and  
that the run time resolution process involves searching a method  
table for a match of the method call and by this means, if the  
method name is unique, the types of the parameters are determined.  
Indeed is this not just the standard messaging mechanism? Or is  
this why I sometimes have the impression that cocoa encourages us  
to pass Objects as parameters to everything?  The Kochan   
"Programming in  Objective-C" does note the possibility of conflict  
when method names are not unique but here the method is unique. and  
exactly, even if we are passing object ids these will eventually  
need to be resolved so that brings us back to square one..


The runtime resolution process is very good about figuring out what  
method to call dynamically at runtime, but Objective-C is still a C  
derived language.  Thus, it benefits from all of the efficiencies  
and suffers from all of the idiosyncrasies of C.


In this case, you haven't given the compiler enough information  
about the size and encoding of the parameters.   By the time the  
runtime sees the method call, the compiler has already had its way  
with the arguments -- potentially promoting the float to an int or  
otherwise losing information.


You need to make the method declaration visible to the compiler to  
make this work.



P.S.
Does this problem of mine qualify as an example of the difficulties  
in learning cocoa recently discussed on this list?


Not really.   Ignoring compiler warnings is a common mistake that  
many many folk make when first learning C, Objective-C or C++,  
regardless of targeted programming environment.


The tools are trying to help you by pointing out where you have done  
something that is incompletely specified.   Fix the warning, most of  
your problems are likely to go away.


___

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

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

2008-05-17 Thread Michael Vannorsdel
The difficulty is methods in ObjC are dispatched messages rather than  
hardcoded functions so going from call to method execution has some  
hidden intermediate steps.  And there can be more than one method with  
the same name from different classes/protocols.  This is one of the  
pillars to ObjC's runtime flexibility as it allows methods to be added  
and checked during runtime.  Further complicating the matter is the  
differences in how PPC and 32 bit Intel pass arguments (why your  
previous code may have worked on PPC and not Intel; PPC passes args  
via registers, Intel 32 via the stack).  Not to mention any future  
differences of new archs.


Lets say for instance you had the method:

- (NSString*)doSomethingWith:(int)val;

and you used it like:

[obj doSomethingWith:(float)val];

The compiler knows the argument is supposed to be an int so it will  
cast val to a float and then to an int before passing it on to the  
method.  Casting the arg doesn't change the method's accepted arg  
type.  When the types are unknown the compiler has to assume the types  
(like id for return values) and will cast args to those assumed types,  
which may not be compatible for the actual type.  For instance, if the  
compiler assumed int for the arg type, stores val as an int on the  
stack (Intel 32), and the actual method expects a float, it will load  
the stack value believing it's a float type and end up with a weird  
value.  Int 5 and float 5.0 are totally different at the binary  
level.  On PPC the method would probably use the wrong register.


The method declaration is how the compiler knows what form to write  
the var to the stack as or which register to put it in.



On May 17, 2008, at 5:55 AM, Julius Guzy wrote:

The id type is completely nonrestrictive. By itself, it yields no  
information about an object, except that it is an object.


Since the id type designator can’t supply [the object's methods,  
variables] to the compiler, each object has to be able to supply it  
at runtime.


every object carries with it an isa instance variable that  
identifies the object’s class—what kind of object it is.


Objects are thus dynamically typed at runtime. Whenever it needs to,  
the runtime system can find the exact class that an object belongs  
to, just by asking the object. Dynamic typing in Objective-C serves  
as the foundation for dynamic binding, discussed later.



Assume a file which contains a call of the form
int tempVar = [idValue methodIdentifier:param];

Assume there is no header file to give information about  
methodIdentifier and its parameters.


The problem for the compiler is to determine the return type and the  
type of the parameter "param".


We have already established that (one way) this problem can be  
resolved is if the calling file includes the header of a dummy class  
which includes a method called "methodIdentifier:" of type say float  
and that returns an integer say.


Could not the compiler have been given the exact same information  
through coercion viz:

int tempVar = (int)[idValue methodIdentifier:(float)param];

This does not work but what is wrong with this line of reasoning and/ 
or why could the system not make use of coercion as part of a  
dynamic typing mechanism?


___

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

Please do not post admin requests or moderator comments to the list.
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: PlotIconRefInContext doesn't work

2008-05-17 Thread Michael Vannorsdel
I'm thinking the window might be redrawing itself right after your own  
drawing and erasing it.  You could try disabling the window's auto  
displaying and flush the window buffer after your draw to determine if  
this is the case.


I don't know where you're doing the drawing to know if it's safe from  
being erased or not.



On May 17, 2008, at 12:37 AM, Mike wrote:

It's a local NSRect which I assume is interchangeable with CGRect as  
they are the same.


I fill in the rect at the top of the method with the Rect of the  
item in the window from IB and then I hide the item before drawing  
to prevent my stuff from being drawn over.


CGContextFillRect doesn't do anything either. Just a blank space as  
with PlotIconRefInContext.


___

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

Please do not post admin requests or moderator comments to the list.
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: [SOLVED] PlotIconRefInContext doesn't work

2008-05-17 Thread Michael Vannorsdel
Well you didn't present the secret handshake that would open immediate  
access to such information.


Actually, it was probably not brought up earlier as it's kind of an  
unsaid list etiquette rule exercised by some not to critique someone's  
choice of APIs unless specifically asked for.  Most will try to  
directly address your questions or problems no matter what APIs you  
chose.  It can be somewhat rude to flat out say your choice of APIs is  
folly, and sometimes presumptuous that the specific APIs were not  
chosen for reasons undisclosed in the original problem.  If you're  
open for API alternatives you can state so with something like "...is  
there an easier or more reliable way to do this?".  Otherwise some  
will assume you have your reasons and will do their best to help make  
the chosen APIs work for you.


NSWorkspace is an oft-overlooked class that contains many useful  
external utilities.  The class name doesn't exactly scream URL  
launching or icon fetching, ect.  Though I'm not sure what name would  
completely describe NSWorkspace's broad ranged functionality.



On May 17, 2008, at 3:37 PM, Mike wrote:


Adam R. Maxwell wrote:

On May 17, 2008, at 2:15 PM, Mike wrote:

I solved the problem using the IconFamily library:

http://iconfamily.sourceforge.net/

IMO, that's killing a mosquito with a shotgun :).

It just astounds me there is no support for icons in Cocoa.
You can use -[NSImage initWithIconRef:] if you only support 10.5  
and later.  On 10.4 and earlier you can use -[NSWorkspace  
iconForFileType:NSFileTypeForHFSTypeCode(kSomeIconCode)] if you  
only need a 32x32 icon, but it's only a few lines of code to draw  
an IconRef to an NSImage of the appropriate size.


Oh NOW you tell me! :-)


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSLevelIndicator

2008-05-17 Thread Michael Vannorsdel
Set its cell as not editable in IB or programatically with [[indicator  
cell] setEditable:NO].



On May 17, 2008, at 4:41 PM, Philip Bridson wrote:

I have an NSLevelIndicator in a utility window that does the  
standard stuff, but I have just noticed that if I click on the  
indicator I can manually select the level. I have read the chapter  
about indicators but cannot find info about how to disable this  
functionality. Can any one point me in the right direction or tell  
me where to look in the docs as I have done a search but can't find  
anything.


___

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

Please do not post admin requests or moderator comments to the list.
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 et al as HCI usability problem

2008-05-18 Thread Michael Vannorsdel
Well what can you do.  Not sure why but lately many newcomers have  
been showing up and complaining about Cocoa's difficulty.  I'm not  
sure if they've done GUI work before, but I remember my days with  
PowerPlant and spending a massive amount of time just creating the GUI  
and the code to back it.  Perhaps this is what gave me the sense of  
how much time Cocoa saves.  It's easy to take things like webviews for  
granted.  I can guess the amount of code Apple wrote to back those to  
work out of the box is pretty massive and complicated.


If programming was just drag and drop and clicking some option boxes  
users could just write their own programs.  But the fact is  
programming is far more complicated than that (and probably will be  
for a long time) and making such a framework would take a decade or  
more, by which time it would be obsolete and outdated.


For professionals the GUI is a smaller part of development thanks to  
time saved by Cocoa.  If I have to write my own controls from scratch,  
I will as it's what programmers do, write code.  But I'm thankful 99%  
of the time I can use something from Cocoa that comes with much of the  
code already done for me.


I guess some people are upset Cocoa doesn't do enough, or all, of the  
work for them.  I'm more of the people happy Cocoa does any work for  
me at all.  If it saves me time, it's a good thing.



On May 18, 2008, at 10:41 AM, Jens Alfke wrote:

"Hobbyists"? I think "professionals" is more accurate — especially  
since in the early days of the Mac you had to spend hundreds of  
dollars to become a developer and get access to tools and  
documentation.


I can see your point about obsessive hackers having the stamina to  
overcome complicated APIs, but any platform vendor's main objective  
in developer tools is to target professional developers who will  
create the products that make the platform attractive to customers.  
"Professional" doesn't necessarily imply a big company; I refer  
equally to startups and indie outfits, anyone seriously devoted to  
creating a product.


In Apple's defense, the task of implementing a sophisticated GUI on  
such limited computers was extremely difficult. The top goals were  
usability, decent performance, and affordable price. That left no  
leeway for making the APIs themselves easy to use — the niceties we  
take for granted like object-oriented programming would have used up  
way too much of that 128k of RAM and 64k of ROM.


(Yes, some of the first GUIs were written in the first OOP language,  
Smalltalk. But the Xerox computers that ran Smalltalk-80 cost  
$10,000 or more; the ones that ran it with any kind of decent  
performance (the "Dorado") cost $50,000 and were basically  
supercomputers. They all had ten times as much RAM as the first Mac,  
and had custom CPUs with programmable microcode optimized for  
Smalltalk. Even so, performance was much worse than the original  
Mac, and the GUI was much cruder and harder to use. I'd already been  
using Smalltalk-80 when the first Mac came out, and the Mac's speed  
and aesthetics were just jaw-dropping.)


Anyway.

I have to say I find this whole discussion frustrating. The attitude  
of some people seems to be that writing computer programs, of  
arbitrary complexity, should be as easy as using a word processor.  
That's a Utopian goal at best, and more generally just naïve. Of  
course we should be trying to make the APIs and tools and  
documentation more useable; that's a constant task, and a very  
difficult one, and one Apple's doing a good job at. (The complexity  
under the hood is terrifying, and it's already been covered up  
enough that in an hour an experienced developer can throw together  
an app that fifteen years ago would have sold for $100.)


Face it, any sort of serious creative endeavor is hard! There's no  
way around it. And the hardest part is learning the techniques and  
tools. If you wanted to build a robot, play Vivaldi on the violin,  
design a house, paint landscapes, or cure Ebola, you'd have to  
accept that it would take months or years of serious study, that the  
tools and documentation would sometimes be hard to use, and you'd  
have to put up with frustration before you mastered the skills.


Why on earth is writing the best GUI applications in the world  
supposed to be trivial by comparison? Maybe I'm taking this too  
personally, but I sense a subtext that some people think the task of  
software design itself is somewhat trivial, more like programming a  
VCR than like architecture or painting or chemistry.


___

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

Please do not post admin requests or moderator comments to the list.
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 et al as HCI usability problem

2008-05-18 Thread Michael Vannorsdel
I'm also wondering if many of the people finding Cocoa difficult are  
also lacking OO programming experience.  The docs teach Cocoa really  
well but if you're unfamiliar with OO design and concepts the Cocoa  
docs are going to be very daunting.



On May 18, 2008, at 3:28 PM, Jason Stephenson wrote:


Have you read the Cocoa Fundamentals Guide?

http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/Introduction/chapter_1_section_1.html

Much of what you seek is explained therein. If the Guide makes no  
sense to you, I'd suggest picking up some basic books on OO  
programming and design patterns. Read them, then come back to the  
Cocoa Fundamentals Guide.


___

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

Please do not post admin requests or moderator comments to the list.
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 et al as HCI usability problem

2008-05-18 Thread Michael Vannorsdel

On May 18, 2008, at 7:39 PM, Julius Guzy wrote:

So I wouldn't have much to say about it except that it does have a  
tendency to make things seem more exciting than they actually are.  
For instance I can refer here to the idea of dynamic typing which  
still requires us to have the header files present in the calling  
file which isn't exactly in the enthusiastic spirit of how it's  
talked about.
Indeed many of my problems with dynamic typing came about because I  
took the enthusism at face value.



The header issue was just the compiler getting confused.  It would  
happen with most frameworks and C based languages.  ObjC objects can  
do all kinds of magical things like class posing, dynamic methods,  
ect.  But the compiler needs basic information so it knows how to pass  
args and whatnot.  Cocoa or ObjC can't fix this.  You can message an  
object without having any info about the method, but you have to be  
sure the compiler will put the args where the method will expect  
them.  And to do that it needs to know the arg types.




Well I do do a lot of jumping right in. Always done it.
Normally I find it the quickest way of becoming familiar with the  
language of the particular tribe i getting to know.
After that of course I set myself a small problem, e.g. open a  
window, write hello world, open another window, draw something etc.  
That for me is a natural way of proceeding. The real difficulties  
have come about because of the need for precise answers to  
relatively simple questions. What was one of these that took up a  
fair bit of my time once



Ask away here, that's what the list is for.  I don't think anyone here  
can claim they've never asked a stupid programming question before.   
Everyone at one time or another has a bad day when they forget how to  
do something simple and can't remember where they saw the docs  
covering it.  Hopefully you won't get rude people responding with RTFM  
and such.



Well this is exactly how things seem to pan out. Those who have been  
doing this for some time like the documentation they have. No doubt  
once I become a bit more adept I will too. But right now..



My best advice is to keep working at it, trying out classes just to  
learn how to make them work (and how to make them not work).  Browse  
the class listing and the methods in each class, often times you'll  
find a method you never knew about and could really use.  Soon things  
will click and you'll wonder why it was so hard just a week before.   
Kind of like those posters with all the weird patterns on them that  
you stare at for hours until finally the 3D shapes pop out and you see  
them.  After that you can see them every time and wonder why it was so  
hard the first time.


Keep making prototype programs like the dynamic typing one and try out  
new things, and feel free to ask "simple" questions here.  I often  
times will make prototype programs and keep them.  When I forget how I  
got something to work I just look through my prototypes to remind me  
and to grab code from.

___

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

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

2008-05-18 Thread Michael Vannorsdel
Checkout NSXML* and friends (NSXMLNode, NSXMLElement).  Also there's  
"Introduction to Tree-Based XML Programming Guide for Cocoa" and  
"Introduction to Event-Driven XML Programming Guide for Cocoa" guides  
in the docs.



On May 18, 2008, at 8:07 PM, David wrote:

Is there a Cocoa package that supports XML schema for either event  
driven

(SAX like) or tree based (DOM like) XML parsing?
I haven't seen any reference to XML schema for either Cocoa packages  
other

than a statement saying you can do your own validation.

___

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

Please do not post admin requests or moderator comments to the list.
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 et al as HCI usability problem

2008-05-18 Thread Michael Vannorsdel
Nothing wrong with saying "you should read such and such".  But RTFM  
is the condescending way of saying it (just look what it stands for).   
Would be like asking someone where the restroom is and getting "look  
at the building directory, you blind clueless moron".  My point was  
about posts that are belittling and snipe because the question was  
simple.



On May 18, 2008, at 8:42 PM, Andreas Mayer wrote:

Actually, I don't understand why an RTFM kind of answer is perceived  
as rude. I'm really happy when I get an RTFM *with a link* to the  
appropriate document.


Also, I often just don't answer at all, since an RTFM may not be  
well received and I don't have the time to write a more elaborate  
answer. Oh well.


___

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

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

2008-05-19 Thread Michael Vannorsdel
Delegates act like observers.  They register with another object  
saying "hey, if you do something important I want to know about it and  
have a chance to act on it too".  Each class that allows delegates  
have a list of delegate methods.  These are the methods the class is  
willing to notify the delegate with when some even happens.  For  
instance NSApplication has a delegate method  
applicationShouldTerminate:.  If an object registers as a delegate to  
NSApp and NSApp wants to terminate, it will ask its delegate if it's  
ok to do so by calling applicationShouldTerminate: on the delegate.   
The delegate can reply with "not yet, I have stuff I need to finish  
first" and NSApp will cancel the quit.  Or it can respond with "that's  
fine with me, please continue".  A delegate can be any object of any  
class and can be the delegate for any number of other important  
objects.  It can also choose to only implement the delegate methods it  
cares about.  If in the example the delegate for NSApp doesn't  
implement applicationShouldTerminate:, NSApp won't bother asking as  
it's clear the delegate doesn't care about termination.


Delegate methods are mostly like notifications, except there can be a  
chance for the notified object to intervene and partake in the event.   
NSNotifications are sent as-is; it's already happening so deal with it.



On May 19, 2008, at 10:22 AM, john darnell wrote:


 I've been trying to get my head wrapped around the concept of
"delegates" and I thought I would run it by the list to see if I am
approaching the correct idea behind a delegate.

  As far as I can tell, it is kind of like a virtual function (virtual
because I, the programmer, am expected to flesh it out) that resembles
an event attached to a given class.  It has specific times when it is
called and at that time it may perform just about any duty that the
programmer can dream of, or she can stick to something that relates to
the object calling it. In almost every description of a delegate  
that I
perused, I found the words "when" or "before," which is why I  
related a

delegate to an event.

  Am I getting close?


___

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

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

2008-05-19 Thread Michael Vannorsdel
Indeed.  I was just trying to keep it in simple terms as not to  
overwhelm the OP with heavy details.  I just wanted the concept to  
make some sense in better known terms at the risk of oversimplifying.



On May 19, 2008, at 11:01 AM, I. Savant wrote:


Well, no, not really. This is significantly different in that you
can set an object as another object's delegate, but if it (your custom
object acting as a delegate) doesn't respond to a particular delegate
method, the delegating object will not call the method. In this way,
you can set objA as objB's delegate and implement none of objB's
delegate methods in objA ... so none will be called.


___

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

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

2008-05-19 Thread Michael Vannorsdel
Even delegation is not a commonly known term in my experience (it's  
used for several differing ideas in the US).  I try my best to give  
terms and examples with the best chance of grasping, especially with  
beginner concepts.  Even the truest term of delegate doesn't perfectly  
fit Cocoa delegates, but it's really close.  I just hope to trigger  
the start of grasping the concept by giving little simplified  
(sometimes overly) ideas and hope it's enough for someone to run with  
who will eventually see the bigger, more complex, picture.  It's  
difficult to describe a complex idea without complex terms and still  
remain completely accurate.



On May 19, 2008, at 11:41 AM, I. Savant wrote:


Still ... my point is the same. I think this is a semantics argument
waiting to happen ( :-) ) but there is no 'observing' going on, per
se. It's quite literally delegation in its purest sense, which is
distinctly different.


___

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

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

2008-05-19 Thread Michael Vannorsdel
There's nothing that guarantees a Cocoa delegate will act for another  
object and that the represented object won't act how it wants as  
well.  Sometimes a delegate method is just a notification something  
happened/happening without the delegate having any say on the matter  
or affect on the represented object's course of action on that  
matter.  I'm just saying Cocoa delegates don't always act in  
dictionary form.


I know this discussion can go round and round, but I still think  
reading the english dictionary for delegates won't tell you the whole  
story on Cocoa delegates.



On May 19, 2008, at 12:25 PM, I. Savant wrote:


 To 'delegate' is to "entrust (a task or responsibility) to another
person, typically one who is less senior than oneself".


___

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

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

2008-05-19 Thread Michael Vannorsdel
Ditto, I'll surrender the last word to you.  Though I'm interested to  
know if the OP is having any success or not.  This thread got a little  
sidetracked.



On May 19, 2008, at 2:23 PM, I. Savant wrote:


I think that's the last I'll comment on the dictionary definition
matter; it's a silly argument. Suffice to say I was more concerned
with precision and it's vitally important to realize that delegation
has more dissimilarities than similarities with notifications.


___

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

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

2008-05-19 Thread Michael Vannorsdel

How are you creating the stream?


On May 19, 2008, at 7:07 PM, John MacMullin wrote:

Continuing on my efforts re: my modified Echo Server, the following  
code is crashing.


- (void)startStreamWrite:(NSOutputStream *)ostream
{
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
while ([ostream hasSpaceAvailable]) {
if (remainingToWrite > 0) {
actuallyWritten = 0;
actuallyWritten = [ostream write:marker maxLength:1];
if ((actuallyWritten == -1) || (actuallyWritten == -1)) 
{
NSLog(@"[ostream streamError]:[EMAIL 
PROTECTED]", [ostream streamError]);
NSLog(@"remainingToWrite:\n%u\n", 
remainingToWrite);
NSLog(@"ostream:[EMAIL PROTECTED]", ostream);
} else {
remainingToWrite -= actuallyWritten;
marker += actuallyWritten;
NSLog(@"remainingToWrite:\n%u\n", 
remainingToWrite);  
}
}
}
   [pool release];
}

The error returned is: [ostream streamError]:
NSError "POSIX error: Broken pipe" Domain=NSPOSIXErrorDomain Code=32

I have looked at the stream error docs in NSStream and this error is  
not even reference.


Any ideas on what this means and how I fix it would be greatly  
appreciated.


___

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

Please do not post admin requests or moderator comments to the list.
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: NSApp with wrong _running count

2008-05-20 Thread Michael Vannorsdel
When you mention running count, are you keeping an int or something to  
keep track of thread progress?  If so remember to use atomic  
operations to update the count from multiple threads to prevent data  
corruption.  As for NSAlert, a general rule is not to interact with  
the UI from any threads other than the main.  Use  
performSelectorOnMainThread: to forward messages to the main thread.



On May 20, 2008, at 5:07 AM, Micha Fuhrmann wrote:


Hi everyone,

some users are reporting a crash at start. From the logs it seems  
that the sys is recognizing multiple running of the app, but from  
there I have no clue as to how to remedy.


Any help greatly appreciated.


___

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

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

2008-05-21 Thread Michael Vannorsdel
You troubles are all in this method and how you handle cityArray.   
First you don't need to alloc and init a new array for cityArray as  
[NSArray arrayWithObjects: c0, ...c9, nil] gives you a new one already  
with the objects you specified.


Another thing you should watch for is there's an autorelease pool you  
can't see that's removing objects every time your code returns to the  
run loop (knowing when this happens takes experience and some doc  
reading).  But a beginner rule of thumb is once your code leaves your  
controller's control (returns to a caller you didn't make), you have  
to protect autoreleased objects by sending them a retain, stating that  
you want to keep that object around.


As a general convention Cocoa, methods with "alloc", "new", "copy",  
"create" in them return objects you are responsible for releasing.   
Objects returned by everything else is considered autoreleased unless  
otherwise noted in the API.  See Create Rule and Get Rule in the docs  
for more on this.


arrayWithObjects: is returning you a new array, but the name of the  
method does not have the magic words listed above, so the array that  
is returned is autoreleased, meaning it will be automatically  
discarded in the near future.


So here's a revised version of your init:

- (id) init
{
  NSString *c0 = @"New York";  //Ten NSString objects created here
  ...
  NSString *c9 = @"Virginia Beach";
  cityArray = [[NSArray arrayWithObjects: c0, ...c9, nil] retain];  // 
we want to save this array from being discarded

  return self;
}

And when you don't need cityArray anymore or are going to replace it  
with a new array with new objects, you want to send the old one a  
release to signal you don't need it around anymore.


On May 21, 2008, at 10:05 AM, john darnell wrote:


- (id) init
{
  cityArray = [[NSArray alloc] init];
  NSString *c0 = @"New York";  //Ten NSString objects created here
  ...
  NSString *c9 = @"Virginia Beach";
  cityArray = [NSArray arrayWithObjects: c0, ...c9, nil];
  return self;
}


___

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

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

2008-05-21 Thread Michael Vannorsdel
Would be like a cookbook including instructions on how to operate an  
oven and use a knife to cut vegetables in every single recipe.  I  
think most would find that pretty redundant and diluting, especially  
when the preface covers these topics in detail.



On May 21, 2008, at 8:37 PM, Jens Alfke wrote:


On 21 May '08, at 11:35 AM, Johnny Lundy wrote:

See? Not a word about autoreleasing anything, or having to retain  
the returned array. Nada.


It also didn't spell out that:
the return value is a pointer,
pointers are 4 or 8 bytes large,
the pointer value zero is special and is named "nil",
messaging nil is a no-op,
you can assign a pointer variable to another variable of the same  
type,

the type "id" is a generic object pointer type,
the character "*" is suffixed to a type to denote a pointer to that  
type,

...

Those are all generic behaviors, and they are well documented in the  
core reference and tutorial materials. Complaining because you  
turned to a random method in the reference and all of those generic  
behaviors were not described *right there in that one place where  
your eyes happened to fall*, of all the thousands of methods in the  
API that they apply to, is kind of, well, 'egotistical' is the  
kindest word I can think of.


I see you repeating the above argument over and over. You might want  
to try a different argument that actually makes sense, because this  
one isn't winning you any fans.


___

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

Please do not post admin requests or moderator comments to the list.
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: How to capture data from NSImageView and display in NSView

2008-05-23 Thread Michael Vannorsdel

On May 23, 2008, at 3:32 PM, Stephen Herron wrote:


The goal:
A window with two views. The view on the left, NSImageView, displays  
the NSImage from - (void)openPanelDidEnd:. The right view, NSView,  
displays the result of a CIFilter using the pixel data displayed in  
the right-hand view.


The problem:
I cannot convert the NSImage used in the NSImageView to a CIImage  
because:

1. I do not know how to access the NSImage pixel data



You can make an NSBitmapImageRep and draw the NSImage into that.


2. I do not know how to convert NSImage data to CIImage data. (The  
developer site has code samples for CGImage to CIImage but nothing  
for NSImage to CIImage?)



There's a handful of ways and depends what works best for you.  One is  
to get an NSData with TIFFRepresentation and use that data to  
initWithData: a CIImage.  Or make it with the bitmap created from the  
above.


There's also ways to do these using CoreGraphics if you need those  
types as well.  If so I can give examples using those.

___

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

Please do not post admin requests or moderator comments to the list.
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: How to Delay, Wait, Pause...

2008-05-25 Thread Michael Vannorsdel
There's usleep, but sleeping a thread just for a very small amount of  
time in a loop is gonna force a context switch every iteration and  
really hurt performance.  It might be better to poll or spin.



On May 25, 2008, at 12:45 AM, Steve Steinitz wrote:


This is hard to google for because they are such common words:

how do I delay, wait, pause for a tenth of a second?

I don't want to use NSTimer because I just want to resume where I  
left off.  I don't want to be in a tight loop because I need the  
system to finish something.  I just want to pause execution for a  
short time.  I think there was a wait() in OS9.  I found a wait() in  
wait.h but it wants an int * and made me nervous.


Specifically, when I send a fetch message to an NSArrayController,  
it sometimes takes a fraction of a second for its selection to  
become valid.  Currently I fire an NSTimer to call a 'part 2' method  
to finish what I am doing (scrolling the selection into view), but  
it lacks niceness.


___

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

Please do not post admin requests or moderator comments to the list.
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: How to Delay, Wait, Pause...

2008-05-25 Thread Michael Vannorsdel
This is an important consideration.  If you're relying on a specific  
event to finish within a finite amount of time, you're going to have a  
race condition where the event could finish later than expected and  
you may end up in an invalid state.


Perhaps if you told us what it is you're specifically doing we could  
offer better, more reliable solutions.



On May 25, 2008, at 3:40 AM, Thomas Davie wrote:

I hate to say this, but any form of delay here is the *wrong* way to  
do this.  You already know you have a race condition, all you're  
doing is making it so the race condition will work out in your favor  
99.99% of the time.  There are still exceptional cases where the OS  
will be busy doing something and your 0.1 second sleep will not be  
enough to sort it out.  Instead of doing this, do your threading  
properly, and get your locking right.


___

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

Please do not post admin requests or moderator comments to the list.
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: NSImage display quality and zooming

2008-05-27 Thread Michael Vannorsdel
I think this is right as well.  The image can be cached in a form best  
suited for the first draw of it.  Any further draws will very likely  
use the cached version and the original resolution is gone.  If you  
set it not to cache, the image will be drawn from the original data  
each time.  You will lose performance when drawing the same resolution  
over and over but at least you can scale it from the original higher  
detail for sharper results.



On May 27, 2008, at 6:58 PM, Graham Cox wrote:

I'm not 100% on this, but I think you need to set the cache mode on  
the NSImage to disable caching, i.e:


[image setCacheMode: NSImageCacheNever];


___

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

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

2008-05-27 Thread Michael Vannorsdel
Generally you'd use the mouseDown to get when and where the drag  
started (may have).  Then use the mouseDragged to track where the  
mouse is dragging to.  Then on mouseUp you know it's done.  Tracking  
area is only valid if a tracking rect you installed generated the event.



On May 27, 2008, at 9:38 PM, Graham Reitz wrote:

What is the typical information that people get from a mouse dragged  
event?


I have the following:

- (void) mouseDragged:(NSEvent*)event
{
NSPoint eventLocation = [event locationInWindow];
NSPoint center = [self convertPoint:eventLocation fromView:nil];
m_controller->left_mouse_dragged(center.x, center.y);
}

I tried getting the tracking area but ended up with an assertion  
error during runtime.


Do folks somehow get the direction of the drag, size of the  
rectangle, starting x,y, and etc.?


___

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

Please do not post admin requests or moderator comments to the list.
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: NSImage display quality and zooming

2008-05-28 Thread Michael Vannorsdel
Could you give more detail on what you're ultimately trying to and  
more on the problems you're seeing in the results?



On May 27, 2008, at 8:13 PM, also wrote:


I had noticed this flag, but it did not solve the problem.  I think
this must only effect scaling when the receiving view is resized such
as resizing a window.  The docs are a bit vague.


___

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

Please do not post admin requests or moderator comments to the list.
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: odd problem with NSMutableDictionary and initWithContentsOfFile

2008-05-29 Thread Michael Vannorsdel
You can't init an object more than once (well not an intended use).   
You do:


SimParamnames = [NSMutableDictionary dictionary];

and later:

[SimParamnames initWithContentsOfFile: aFile];

which are both initializing the object.  The second init is either  
being ignored or perhaps corrupting the object.  If you want a mutable  
dictionary of a file's contents you'll have to make a new one with  
[NSMutableDictionary dictionaryWithContentsOfFile:filePath].



[SimParamnames removeAllObjects] ;
[SimParamnames initWithContentsOfFile: aFile];

might work better as:

[SimParamnames release];//throw away the old dictionary
SimParamnames = [[NSMutableDictionary alloc]  
initWithContentsOfFile:aFile];	//make a new one from aFile


On May 28, 2008, at 1:58 AM, Leslie Smith wrote:


in a later method
NSArray *filesToOpen = [oPanel filenames];
  int i, count1 = [filesToOpen count];
  for (i=0; i

___

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

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

2008-05-29 Thread Michael Vannorsdel
What I'd suggest is to assign each selection with a tag number in IB  
(or programatically if need be).  Then in your code you can get the tag:


int colorID = [[colorButton selectedItem] tag];

Assign each its corresponding ID as the tag like 4 for black, 1 for  
red, ect.



On May 29, 2008, at 10:22 PM, Paul Archibald wrote:


Hi, its me again.

My interface consists (mostly) of a bunch of popup buttons with  
various values in them. Out user will set up all these popups and  
click "go", and the app will emit a string which can be used to run  
a command line program. So, for example we have a couple of popups  
like:


Color
-black
-red
-green
-blue

Size
-small
-medium
-large

So, lets say that the command line wants something like:
"runfoo -color 2 -size 1"

and that the "runfoo" help file says
-color : red = 1, blue = 2, green = 3, black = 4, default = 4
-size : small = 1, medium = 2, large = 3, default = 3

So, here is my question. What is the best way to translate between  
the popup item and the value? I was thinking of building an  
NSDictionary with item_string_key/command_line_argument_value pairs,  
but I realized that I have a bunch of different "default" values  
(color default = 4, size default = 3).


I guess I could have a dictionary for each popup, but that seems  
clunky. I see there is something called "Bindings" for menu/popup  
items, is that a way to go? (I am trying not to put the info in the  
NIB, I would prefer code, where I can see it.)


___

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

Please do not post admin requests or moderator comments to the list.
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: CGContextSetRGBFillColor() off by one?

2008-05-30 Thread Michael Vannorsdel

This is from the CGColorSpaceCreateDeviceRGB docs:

In Mac OS X v10.4 and later, this color space is no longer device- 
dependent and is replaced by the generic counterpart— 
kCGColorSpaceGenericRGB—described in “Color Space Names”. If you use  
this function in Mac OS X v10.4 and later, colors are mapped to the  
generic color spaces. If you want to bypass color matching, use the  
color space of the destination context.


So since 10.4 the device colorspaces are now just generic ones.


On May 30, 2008, at 1:38 PM, Ken Ferry wrote:

Well... I'm not sure that's true any more is it?  I mean, don't all  
the
DeviceXXX colour spaces get mapped to the new "Generic" ones as of  
10.4?


I don't believe so, and that isn't what I see in testing.

I filed a bug for this yesterday.  My understanding, which may be
flawed, is that using a 'device' colorspace is a pledge that you know
that your color components are already with respect to the colorspace
of the destination, so require no further color correction.


___

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

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

2008-05-31 Thread Michael Vannorsdel

If you method is something like:

- (void)func1

then you should use @selector(func1) without the colon.


On May 31, 2008, at 2:06 AM, Markus Spoettl wrote:


 NSInvocationOperation *theOp = [[NSInvocationOperation alloc]
  initWithTarget:self
selector:@selector(func1:)
  object:nil];


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: runloops and NSURLConnection

2008-05-31 Thread Michael Vannorsdel
I think you want to schedule the connection for the  
NSModalPanelRunLoopMode runloop mode.  This is the mode that is used  
for modal windows.



On May 31, 2008, at 7:28 AM, Torsten Curdt wrote:


A bit puzzled ...seems like I need some advise here.

From a NSWindowController I create a modal dialog

 [NSApp runModalForWindow:[self window]];

On a button click I am trying to use NSURLConnection to do retrieve  
information in a asynchronous fashion


 connection = [[NSURLConnection alloc] initWithRequest:request  
delegate:self];


Unfortunately this only works when I afterwards enter this runloop

   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
   while(!terminated) {
   if (![[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode  
beforeDate:[NSDate dateWithTimeIntervalSinceNow:10]]) {

   break;
   }
   [pool release];
   pool = [[NSAutoreleasePool alloc] init];
   }
   [pool release];

(the connectionDidFinishLoading:/connection:didFailWithError:  
terminates the above loop)


Now I am a bit surprised. Shouldn't runModalForWindow: do pretty  
much the same thing? The documentation states


"By default, for the connection to work correctly the calling  
thread’s run loop must be operating in the default run loop mode.  
See scheduleInRunLoop:forMode: to change the runloop and mode."


But I am a bit lost what to do with that information. I would assume  
that


scheduleInRunLoop:[NSRunLoop currentRunLoop]  
forMode:NSDefaultRunLoopMode


is the default anyway. Nevertheless I am targeting 10.4 and this is  
only available since 10.5.


I found this response from Fraser

http://lists.apple.com/archives/aperture-dev/2008/Feb/msg00036.html

...but I would like to understand the "why". Do I really have to  
spawn another thread for this? Or is it OK to process the run loop  
like shown above? I have the feeling I am somehow fighting the  
framework again here.


Comments?

cheers
--
Torsten___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

2008-05-31 Thread Michael Vannorsdel
I saw you using that in your included code so I thought you were ok  
with it.  For Tiger I can only suggest using secondary thread  
processing as the cleanest approach.  Or you can reconsider using a  
modal window.



On May 31, 2008, at 9:07 AM, Torsten Curdt wrote:

You mean with scheduleInRunLoop:forMode: ? ...but that's only  
available since 10.5


___

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

Please do not post admin requests or moderator comments to the list.
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: Converting string to double: NSString or NSScanner

2008-05-31 Thread Michael Vannorsdel
Basically NSString's floatValue and doubleValue methods only work when  
the numbers use the US style dot separator (as opposed to other locale  
separators such as a comma).  If your NSString might contain non-US  
separators (or other formatting differences) you'll have to use  
NSScanner to do a localized scan of the NSString to extract the  
correct number.  If you tried to use NSString's doubleValue on  
something like "12,34" you would get 12.000.



On May 31, 2008, at 10:22 PM, Markus Spoettl wrote:


Hello List,

 I'm having troubles deciphering the documentation. I have doubles  
stored in a text file which always use the dot "." as decimal  
separator. When converting the strings to doubles the conversion to  
be locale independent. The NSString:doubleValue documentation says:


> This method uses formatting information stored in the non- 
localized value;
> use an NSScanner object for localized scanning of numeric values  
from a string.


"Formatting information stored in the non-localized value" is really  
a little cryptic - what formatting information and where is the non- 
localized value stored. The part about NSScanner indicates that  
NSString:doubleValue is what I want, is it?


___

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

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

2008-06-02 Thread Michael Vannorsdel
This will happen if the window is deallocated.  It's probably getting  
cleaned up by garbage collection.



On Jun 2, 2008, at 2:36 AM, Francis Perea wrote:


i Wayne, first of all thanks for your quick reply.

Sorry to say that the Console says nothing :-(

--
[Session started at 2008-06-02 10:33:15 +0200.]

The Debugger has exited with status 0.

-

This is the log I get when I run the App, the Main window flashes  
and disappears. The app keeps running and when I close it, the log  
says that Debugger exited with 0 (Successful) status.


Any other clue?

Thanks again.


___

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

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

2008-06-02 Thread Michael Vannorsdel
Retain and release have no effect on ObjC types when using garbage  
collection.  If your code is written relying on retain counting then  
you should turn off garbage collection since you're trying to manage  
the memory yourself (and probably designed the code as such).  Garbage  
collection has specific requirements on how you treat objects to help  
the collector know what to deallocate and what to keep around.


If you really want to stick with GC, read the docs on it to understand  
how it works and how it determines what and when to deallocate.



On Jun 2, 2008, at 3:05 AM, Francis Perea wrote:


Hi Michael.

I've also supposed it was happening that, and I've tried to correct  
it by using retain in each one of init methods of both classes, but  
no results.


What I mean is, in every init method, when I call the [super init]  
I've tried [[super init] retain]. But no way.


Any other suggestion?

Thanks for your reply.


___

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

Please do not post admin requests or moderator comments to the list.
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: many-to-many relationships and retain cycles

2008-06-02 Thread Michael Vannorsdel
I've never tried it personally, but you might make a CFMutableArray  
with NULL callbacks and then cast it to an NSMutableArray since  
they're bridged types.



On Jun 2, 2008, at 10:36 AM, Todd Ransom wrote:

Unfortunately I need to target Tiger also. Thanks for the info,  
though, this will be useful to know in a year or so. ;)


Todd Ransom
Return Self Software
http://returnself.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 [EMAIL PROTECTED]


Re: Main window disappears. Sometimes.

2008-06-02 Thread Michael Vannorsdel
The retained option for windows in IB applies to the window's back  
buffer settings.  Retained means it only buffers sections offscreen  
and onscreen drawing is done directly instead of to a back buffer  
first.  Not related to the window's retain count.



On Jun 2, 2008, at 5:24 AM, Francis Perea wrote:


Hi Graham, thanks for your reply.

I didn't know I could set any memory setting trough Interface Builder!

After your question I looked into and I've seen that it states as  
Beffered.


I've tried to use the Retained option, thinking that this way I  
shouldn't use the retain message, but with Retained the windows  
appears but doesn't accept any interaction.


I'd take a deep look into de Memory Management doc you suggest.


___

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

Please do not post admin requests or moderator comments to the list.
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: how to run my app in privileged mode

2008-06-03 Thread Michael Vannorsdel
You can't really upgrade an already running process's privilege  
level.  What I'd suggest is make a small launcher program that the  
user opens.  This would ask for the admin password and then launch  
your main application using AuthorizationExecuteWithPrivileges and  
friends.



On Jun 3, 2008, at 7:07 AM, Nick Rogers wrote:


Hi,
I wish to access disk sectors using open() and pread(). but it fails  
for the system disk.
So how can I get the user to type in admin passwd and then run my  
app in privileged mode.

Please point me to any sample code etc.
I tried ""BetterAuthorizationSample" code from apple, but using it  
to access disk sectors is 10 times slower then open() and pread(),  
cause it installs a helper tool in the system and to get sectors  
from it is slow.


___

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

Please do not post admin requests or moderator comments to the list.
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: Newbie Question on a method signature

2008-06-04 Thread Michael Vannorsdel
You have to make sure your header has - (UIColor *)  
returnUIColorForFont:(NSString *) theString in it so when you use the  
method in other source files the compiler will know what the arguments  
and return types to returnUIColorForFont: are.  Without this the  
compiler has to make assumptions and is warning you that it is doing so.


Also, to compare if strings are equal you can just do:

if([theString isEqualToString:@"1"])
//do stuff

Just another shorter method eventhough the way you're doing it is  
perfectly fine.



On Jun 4, 2008, at 2:14 PM, James Cicenia wrote:


I have the following:

	((ProjectListCell *)cell).budgetHealth.textColor = [self  
returnUIColorForFont:s];


And here is my method:


- (UIColor *) returnUIColorForFont:(NSString *) theString{
if([theString compare:@"1"] == NSOrderedSame){
return [UIColor greenColor];
}else if([theString compare:@"0"] == NSOrderedSame){
return [UIColor yellowColor];
}else if([theString compare:@"-1"] == NSOrderedSame){
return [UIColor redColor];
}else{
return [UIColor grayColor];
}
}


why does it tell me:

warning: (Messages without a matching method signature will be  
assumed to return 'id' and accept...


___

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

Please do not post admin requests or moderator comments to the list.
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: Newbie Question on a method signature

2008-06-04 Thread Michael Vannorsdel
If the method is defined above the place you use it, you can avoid  
compiler warnings.  But the most common and more correct thing to do  
is declare the method in the header with the rest of your class so  
anyone that imports that header will know the specifics of that method  
(and the compiler won't have to make assumptions).



On Jun 4, 2008, at 2:26 PM, James Cicenia wrote:


Wow..

I didn't know the order of methods was important.


___

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

Please do not post admin requests or moderator comments to the list.
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: NSBundle getting location of file in bundle

2008-06-05 Thread Michael Vannorsdel
Try using NSURL's fileURLWithPath:, you won't need to preappend  
"file://".



On Jun 5, 2008, at 8:37 PM, Mark Bateman wrote:

I'm currently hardcoding the file location just for debugging my  
app.  It works great.


I'm now trying to use NSBundle to insert the resource location  
string for a webview. I'm using locally stored content inside the  
app bundle.  I tried using:


NSMutableString *url;   
url = [NSBundle pathForResource: @"AirportInfoPDA"];

I can't tell if this returns the full path including the filename &  
extension as the program now crashes.


the full path i've been using on the simulator is

file:Users/mark/Documents/Projects/FltPlan/PDA/AirportInfoPDA.htm

works well with:

[myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL  
URLWithString: url]]];


How do I form the correct path from the bundle location and use the  
AppendString to add the file:// on the front as I can't get it to  
work even when hard coding the strings using append.


___

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

Please do not post admin requests or moderator comments to the list.
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: App hangs when displaying any sheet in 10.5 [SOLVED]

2008-06-06 Thread Michael Vannorsdel
I suspect since the method had no prototype the compiler just assumed  
the default id return type, but due to a bug didn't generate a  
warning.  The problem is most likely the calling method was expecting  
the return value to be an integer (id; pointer) but instead is a  
float.  Even with a cast being assumed the calling method is still  
having a floating point register trashed by believing it was safe.



On Jun 5, 2008, at 11:37 PM, Hamish Allan wrote:


I'd have thought that in the case:

// id anonymous
float f = [anonymous position];

the compiler ought to assume that the method being used is the one
returning a float, or if not at least warn about an implicit cast from
CGPoint to float. Perhaps if it were -(int)position rather than
-(CGPoint)position, you might not expect a warning, but in that case
you would expect a cast, so it shouldn't break.

However, that does appear to be what is happening. In the absence of
any other explanation, I'd call it a compiler bug.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa n00b frustrations

2008-06-07 Thread Michael Vannorsdel
textShouldBeginEditing: and textDidBeginEditing: are generally methods  
you'd override in a subclass.  By default they call the  
control:textShouldBeginEditing: and controlTextDidBeginEditing: of the  
delegate (if there is one).  The latter are the methods your delegate  
needs to implement.



On Jun 7, 2008, at 9:44 PM, Charles Jenkins wrote:

Save everything, build and run. The window will show up with the  
text fields in place and with their text already set by  
awakeFromNib. However, you can edit them all you like and see in the  
log that textShouldBeginEditing and textDidBeginEditing are never  
called.


I copied those method signatures directly from the NSTextField  
reference in the documentation, to eliminate any possibility that a  
malformed method signature could prevent delegation from working as  
expected.


I am sure the reason why these methods never get called is painfully  
obvious to one of you more experienced Cocoa programmers, but there  
is some piece of information that I don't have which is preventing  
me from writing or hooking up these methods properly. Can you tell  
me what it is?


Also, there is a reason I am using this WhatKb app to ask my  
delegation question. When we get the delegation to work and the  
methods are called, I believe we will find that  
TISCopyCurrentKeyboardInputSource() can frequently return the wrong  
information, and so I will have followup questions! :-)


___

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

Please do not post admin requests or moderator comments to the list.
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: App hangs when displaying any sheet in 10.5 [SOLVED]

2008-06-10 Thread Michael Vannorsdel
Ah ok.  I was bit by something similar a few years ago.  I had  
forgotten to put the prototype in my class interface and believed the  
compiler was using a prototype from an unrelated class which had  
different arg and return types.  But the twist was the missing  
prototype caused the default id return and '...' arg types to be used  
(determined through asm studying).  The presence of the other class's  
prototype was just suppressing the usual 'may not respond to selector'  
warning.


As far as trashing memory it was very likely trashing a floating point  
register your calling code was using and eventually using the trashed  
value for calculations and/or storing it to memory.  For instance on  
i386 it might have had a float the calling code was using in fp0 and  
expecting the return value of your called method to come back on EAX,  
therefore believing fp0 would stay unchanged.  But the called method  
was writing its return in fp0 (destroying the original value) and the  
calling code was casting whatever junk was in EAX to your float.   
Actual register names might differ but the effect is the same.



On Jun 8, 2008, at 6:29 AM, Graham Cox wrote:

No, this is not it. The method definitely did have a prototype - in  
fact it had *two*, differing only in return type. Judging by the  
assembler code, it used the one returning an int (actually an enum)  
not a float. It's still unclear why this generated code that trashed  
memory, but it did. It also did silently cast the result as well,  
which is perhaps why no warning was issued, because in some cases  
that's the desired behaviour.


___

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

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

2008-06-10 Thread Michael Vannorsdel

Something like:

messageString = [[NSString alloc] initWithData:(NSData*)data  
encoding:NSASCIIStringEncoding];


the encoding type will depend on what encoding you expect the data to  
be in.



On Jun 10, 2008, at 4:08 AM, Angelo Chen wrote:

What is the correct way to cast from CFDataRef to NSString, I have  
this code:


CFDataRef data;
NSString *messageString = [NSString  
stringWithCString:CFDataGetBytePtr(data)];


it always return this warning, any idea?

warning:pointer targets in passing argument 1 of  
'stringWithCString:' differ in signedness


Thanks


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: launching standard apps with NSTask

2008-06-10 Thread Michael Vannorsdel

[[NSWorkspace sharedWorkspace] launchApplication:@"Safari"];


On Jun 10, 2008, at 4:55 PM, Memo Akten wrote:

Hi all, i'm writing an app that launches some default apps like  
safari, itunes, iphoto etc using NSTask. I was wondering if there is  
a way of writing the launch url  not fully hardcoded but using some  
system variables / methods etc.?


Memo (Mehmet S. Akten)


___

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

Please do not post admin requests or moderator comments to the list.
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: looking for a crc code

2008-06-14 Thread Michael Vannorsdel

I thought I saw a CRC32 implementation in zlib at one time.


On Jun 14, 2008, at 9:25 AM, Jens Alfke wrote:


On 14 Jun '08, at 4:59 AM, Ilan Volow wrote:

No mention at all I can find (in the 20 seconds I scanned the first  
two result pages) of any cocoa CRC implementations. If a newbie  
were to do a search like this and turned up such a fruitless list  
of leads, I wouldn't be surprised in the least  that they came to  
the list and asking for a personal recommendation of some hard-to- 
find Cocoa framework from experienced Cocoa programmers.


Yes, but what does CRC have to do with Cocoa? It's just a function  
that takes a pointer and a length and returns an int. It'd be  
trivial to use any C implementation in a Cocoa app, so there's no  
reason to restrict the search by adding "cocoa" as a keyword.


___

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

Please do not post admin requests or moderator comments to the list.
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: NSTextField "setStringValue" method - deallocates?

2008-06-14 Thread Michael Vannorsdel
In short yes.  The long answer is the textfield will release the  
string when it's done with it and if no one else retained the string  
it will be deallocated.



On Jun 14, 2008, at 9:35 PM, Christopher J Kemsley wrote:

I'm new to Obj-C, and I'm trying to make sure I start off writing  
good code so I don't have to come back and learn how to avoid dirty  
code and/or memory leaks.


That being said, if I do the following:


NSString *someString = [ NSString stringWithString:@"Hello World!" ] ;
[ someNSTextField setStringValue:someString ] ;


Does the NSTextField take care of de-allocating the memory from the  
old value by itself?


___

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

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

2008-06-14 Thread Michael Vannorsdel
NSFileHandle itself.  Use seekToFileOffset: and readDataOfLength: to  
get the bytes you want.  Or you can drop down to the BSD layer and use  
open/close, lseek, and read.



On Jun 14, 2008, at 8:05 PM, Angelo Chen wrote:


Hi,

NSFileManager's contentsAtPath can read the entire file, is there a  
way to read only a specific bytes? something similar to  
NSFileHandle's readDataOfLength? thanks,


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Convert CGImageRef from BGR to RGB

2008-06-16 Thread Michael Vannorsdel
If you get your image data into a bitmap form you can use vImage's  
(Accelerate Framework) permute functions to quickly rearrange the  
channel ordering.  There might be another way using color spaces, but  
none that I know off hand.



On Jun 16, 2008, at 5:09 PM, Rodrigo Gutierrez wrote:

I'm pulling data off a streaming web camera, and it appears that the  
camera sends jpeg data using the BGR color space. Right now I am  
creating a CGImageRef by doing the following:


	CGDataProviderRef provider = CGDataProviderCreateWithData(NULL,  
jpegData, jpegDataLength, NULL); 	
	CGImageRef imageRef = CGImageCreateWithJPEGDataProvider(provider,  
NULL, true, kCGRenderingIntentDefault);


Where jpegData is the payload of several packets concatenated, and  
jpegDataLength is the length of the jpegData buffer... basic stuff.  
This approach gets me an image but my reds and blues are flipped. I  
checked out the documentation and google and I couldn't find a clear  
way to swap the red and blue using Cocoa. Can someone steer me in  
the right direction?


I appreciate any help.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Where can I get some examples of if() conditionals being used with string variables in Objective-C

2008-06-25 Thread Michael Vannorsdel

You can do:

if([theName isEqualToString:@"John Lenon"])
//do stuff

NSString has some comparison methods in the class listing.  The above  
example will ask two different NSString objects if they have the same  
string values.



On Jun 25, 2008, at 8:24 AM, Papa-Raboon wrote:


Hi All,

Anybody know where can I get some examples of if() conditionals  
being used

with string variables in Objective-C?

To be specific, I am trying to use an if conditional to check the  
value of a
string being a certain value and then replacing it with a different  
value if

the condition returns TRUE.
Currently I have:

NSString *theName = [NSString stringWithFormat:@"%@ %@", [firstName
stringValue], [lastName stringValue]];

I thought that this would work but it doesn't:

if ([NSString theName] == @"John Lenon") {

// then something here using setStringValue but haven't got a clue  
how to do

this.

}

I want to check if "theName is currently "John Lenon" and change it  
to be

"Ringo Starr".

Any help would be greatly appreciated thanks as I am a complete  
newbie and

need to get my head around many things in Objective-C.

___

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

Please do not post admin requests or moderator comments to the list.
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: Trigonometric Problem, Particularly tan() Function

2008-07-13 Thread Michael Vannorsdel
I don't think it's the cause but you should probably use tanf to avoid  
value casting to and from a double.



On Jul 13, 2008, at 7:30 AM, Patrick Walker wrote:

I can't post the whole thing because it's sort of large and  
"integrated" but here is what I have originally done.


   float radians;

   radians = ([entryField floatValue] * M_PI / 180);
   [outField setFloatValue:tan(radians)];

A simple solution could involve using another trigonometgric  
implementation available to Xcode.  The question is are there any  
other than the numerical method "math.h" versions?   That's not so  
bad because I can simply trap +- 90 and +-270 angles but I am trying  
to get as much speed.


My other problems seems to be -2877334 itself.  To me, that appears  
to be a rather strange value for a floating point number, esp. when  
cos(pi/2) is returning near-zero (an "e-08") number as well.


Thanks for the replies.


___

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

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

2008-07-18 Thread Michael Vannorsdel
In my office we usually call objects returned directly without an  
autorelease as "short returned" and an retain-autoreleased object as  
"pooled".  Though these sound more slang than something that could be  
official.



On Jul 18, 2008, at 3:10 PM, Andy Lee wrote:

Unfortunately, there's no such thing as an unretained object.  When  
an object stops being retained, it gets dealloced.


I thought of "pre-retained" and not "not pre-retained," but those  
are ugly and probably flawed in some way too.  Anyway, I'm done  
making suggestions for now.  There will be plenty of opportunities  
the inevitable next time this topic heats up. :)


___

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

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

2008-08-25 Thread Michael Vannorsdel
Just start at inputTime 1.0 and increment down to 0.0.  This will  
rotate opposite from 0.0 to 1.0.



On Aug 25, 2008, at 11:42 PM, Seth Willits wrote:

CIRotatingCubeTransition is semi-public which confuses me. IB3  
exposes it, but it otherwise seems to be private. I'd like to change  
the direction of the rotation, but I don't see any way to do it.  
(Public or private.) The only input keys are inputImage,  
inputTargetImage, inputExtent, and inputTime. I also used class-dump  
to check for any private methods, but there aren't any. Has anybody  
had any experience with this?


___

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

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

2008-08-26 Thread Michael Vannorsdel
Ah I see what you're doing.  Off the top of my head you might be able  
to do this by rotating the two images 90 degrees and adding an affine  
transform filter to rotate back 90 (so images are upright again).  In  
essence rotating the animation 90 degrees so it rotates on the  
horizontal axis.  I've never actually tried this but seems feasible.



On Aug 26, 2008, at 2:47 AM, Seth Willits wrote:


That doesn't help with rotating up or down.


___

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

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


Feedback-Directed Optimization problem

2008-04-04 Thread Michael Vannorsdel
I'm trying to generate a profile using the Feedback-Directed  
Optimization (-fprofile-generate) but when it gets to the linking  
stage it aborts with missing symbols _close$UNIX2003, _open$UNIX2003,  
_fcntl$UNIX2003.  Any ideas what's causing this?  I've used this  
option in the past many times and never had this come up.

___

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

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

2008-04-04 Thread Michael Vannorsdel
The error 2 means tar is not happy with one of both provided paths.   
Try printing out both paths and make sure they're proper.  Paths  
passed to NSTask should not have escapes such as "/Some\ Folder/ 
file.tar", it should be "/Some Folder/files.tar".



On Apr 4, 2008, at 3:00 PM, Randall Meadows wrote:


On 04/04/2008, Randall Meadows <[EMAIL PROTECTED]> wrote:

NSArray *args = [NSArray arrayWithObjects:
 @"-cf",
 [NSString stringWithFormat:@"\"[EMAIL PROTECTED]"", tarFilePath],
 [NSString stringWithFormat:@"\"[EMAIL PROTECTED]"", plistPath],
 nil];
tarTask = [NSTask launchedTaskWithLaunchPath:@"/usr/bin/tar"
arguments:args];
[tarTask waitUntilExit];
int status = [tarTask terminationStatus];


I do something very similar.  The only difference is I'm not
constructing a path via stringWithFormat.  I'm using either  
NSString's

"fileSystemRepresentation" or NSURL's "path" method to get a well
formed path to pass in as a parameter...

So I wonder what your stringWithFormat results actually look like.


___

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

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

2008-04-07 Thread Michael Vannorsdel

Change the function declarations/definitions to

- (NSString*)ChooseString:(int) IntVal (the * goes inside the  
parenthesis)



On Apr 7, 2008, at 10:45 AM, john darnell wrote:


Hello all:

For those of you who do not like answering elementary questions, you
might want to give this message a pass.

I am making my first foray into writing Cocoa applications, and I have
created a very simple class.  The header file looks like this:

  /* Chooser */

  #import 

  @interface Chooser : NSObject
  {
  }

  - (NSString) *ChooseString:(int) IntVal;  //  If I comment out this
line, the error and first warning goes away
  @end


And the implementation file looks like this:


  @implementation Chooser
  /*  Commented out for debugging purposes
  - (NSString) *ChooseString:(int) IntVal;
  {
  }
  */
  - (id) init
  {
 self = [super init];
 if (self != nil)
 {
NSString * ListOfStrings = @"A stitch in time saves nine/No  
use
crying over spilt milk/A bird in the hand is worth two in the bush/ 
Never

put of to tomorrow what can be done today/Do not judge a man until you
have walked a mile in his shoes";
NSArray *StringList = [ListOfStrings
componentsSeparatedByString:@"/"];

 }
 return self;
  }

  @end

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSString format parameter order

2008-04-08 Thread Michael Vannorsdel
There's quite a few printf arguments the Mac OS doesn't support right  
now.  An alternative is to shuffle pointers around:


NSString * string1 = @"you", * string2 = @"hello";

...

if([language isEqualToString:@"Backwards Latin"])
{
NSString * temp = string1;

string1 = string2;
string2 = temp;
}

NSString * str = [NSString stringWithFormat:@"%@ %@", string1, string2];


On Apr 8, 2008, at 3:33 AM, Jere Gmail wrote:


I'm looking for a way to switch parameters order in order to use the
same parameters for different languages.
something like

NSString string1=@"you"
NSString string1=@"hello"
NSString str=[NSString stringWithFormat:@"%2 %1", string1,string2];

will make str value "hello you".
I have been working with CString over in windows and it is possible
but i don't find any alternatives


___

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

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

2008-04-08 Thread Michael Vannorsdel
You could load the strings into an NSArray and then use the proper  
indexes to print out the string you want.



On Apr 8, 2008, at 3:48 AM, Jere Gmail wrote:

Well, it's not a language thing at this moment but it started this  
way.

Right now I have a txt file with one string with the places where the
fields should be. I use it as a template to generate an HTML from some
fields obtained from and XML.
This way I can change the page displayed without having to recompile
the application.


___

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

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

2008-04-08 Thread Michael Vannorsdel
Mac OS X has layered bootstrap nameservers.  The bottom layer is the  
root layer and all others like the console user's layer go on top.   
For security, layers can see connections at their level or below, but  
not above.  This in short means the root layer cannot see any other  
connections not in its own layer.  But all other layers can see down  
into the root layer since they're all above it.


So basically it's not working because the root daemon can't see the  
user level's registered connections.  You'll have to make one from the  
root daemon for the user program to lookup or use a different IPC  
flavor.



On Apr 7, 2008, at 4:32 PM, SD wrote:

I have a deamon application that starts up and registers itself  
using a pre-defined name. (NSConnection registerName: name]



I have another application that is started and it looks for the  
connection with [NSConnection  
rootProxyForConnectionWithRegisteredName: name host:nil].


This all works correctly if the processes are all launched with  
Xcode or the command line.


If I launch the deamon via command line using my regular user and  
then I launch the application using the Security.framework  
authentication, the application does not find the connection and  
starts a second deamon.


Does anyone know what is going on here and how to fix it so that the  
connection is registered for the whole system (not per user as it  
appears).

___

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

Please do not post admin requests or moderator comments to the list.
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: Saving NSFonts and changedFont: trouble

2008-04-08 Thread Michael Vannorsdel
Are you sending convertFont: to the sender of changedFont:?  I think  
this is required or controls start to get confused. May or may not  
solve your problem though.



On Apr 8, 2008, at 8:41 AM, Thomas Backman wrote:

Hey everybody. I'm working on a small app - to make the post  
shorter, lets just say that it displays (plain) text, but I want the  
user to be able to pick the font used (the same font should be used  
for all the text).
Right now, I have a changedFont: method in my controller class, that  
changes the font successfully, and saves the font+size as a string  
and float. First off, is there a better way to save things? There  
has to be. Anyway, that wasn't my main question. More importantly,  
this does work, until you click in the textview... When that  
happens, changedFont: is no longer called, and the font stays the  
same.

Why? (It works again after an app restart.)
I've tried setting the textview delegate, and a sharedFontManager  
delegate, to my controller. (Not sure about what I'm doing here, as  
you might have noticed)


I realize I'm short on info, but I'm not exactly sure what info to  
provide, so please ask if you need more.


___

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

Please do not post admin requests or moderator comments to the list.
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: Reformatting percent string to two decimal places

2008-04-08 Thread Michael Vannorsdel
For string formats there's "%.2f" which means show 2 places after the  
decimal, it's rounded as well.  Also, you can use "%%" to print a  
literal % symbol.



On Apr 8, 2008, at 9:07 AM, Lorenzo Thurman wrote:


I have the string representation of a percentage value, that goes to 6
places beyond the decimal point. Something like this:
64.123456%. I want to round that to 2 places and keep the percent  
sign at
the end e.g. 64.12% and return it as an NSString. I was playing  
around with
NSNumberFormatter (in code not IB) and was not able to either, keep  
the
percent sign or round properly, depending on the value passed to  
setStyle of
my NSNumberFormatter object. What I initially did was convert the  
string I
was passed into an NSNumber using NSString floatValue. This would  
loose the

percent sign at the end, but I could restore it by passing
setStyle:NSFormatterPercentStyle to the formatter. But when I did  
this, the

decimal was lost, so the number would end up like this:
64,1234%. I played around with my formatter using  
NSFormatterDecimalStyle or
NSFormatterPercentStyle, but never get what I wanted. Can these be  
used
together in the same formatter? or'd maybe? The docs don't say, it  
doesn't

work in any case, so I assume no. What I ended up doing was this:

// Takes a string containing a decimal percent
// rounds it off toNumPlaces and returns the
// resulting string
-(NSString*) roundValue:(NSString*)valueToRound toNumPlaces:(unsigned
int)places{

   NSLocale* locale = [NSLocale currentLocale];
   NSDecimalNumberHandler* roundingBehavior = 
[NSDecimalNumberHandler

decimalNumberHandlerWithRoundingMode:NSRoundPlain scale:places
raiseOnExactness:NO

raiseOnOverflow:NO raiseOnUnderflow:NO
raiseOnDivideByZero:NO];
   NSDecimalNumber* fv = [[NSDecimalNumber
decimalNumberWithString:valueToRound ]
decimalNumberByRoundingAccordingToBehavior:roundingBehavior];

   NSNumberFormatter* formatter = [[NSNumberFormatter alloc] init];
   [formatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
   [formatter setNumberStyle:NSNumberFormatterDecimalStyle];
   [formatter setLocale:locale];

   NSString* newValue = [formatter stringFromNumber:fv ];
   [formatter release];

   return [NSString stringWithFormat:@"[EMAIL PROTECTED]@", newValue, @"%"];
}

Is this the best way to do this? It works just fine, but I was  
wondering if

there was a better way.
Thanks
--
"My break-dancing days are over, but there's always the funky chicken"
--The Full Monty
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

Please do not post admin requests or moderator comments to the list.
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: Saving NSFonts and changedFont: trouble

2008-04-08 Thread Michael Vannorsdel
The font panel sends it's messages to the shared font manager.  You  
can make your own font panel subclass and tell the font manager to use  
it with setFontPanelFactory:.  It's possible the textView is absorbing  
the changedFont: message, you might need to implement  
textView:shouldChangeTextInRanges:replacementStrings: for the textView  
or a different delegate handler.



On Apr 8, 2008, at 9:34 AM, Thomas Backman wrote:


ep, I am, unfortunately.
The whole method, bar 3 lines for saving to user defaults, is
- (void)changeFont:(id)sender {
   NSFont *oldFont = [textView font];
   NSFont *newFont = [sender convertFont:oldFont];
   [textView setFont:newFont];
}

Worth mentioning is that before clicking in the textview, the font  
panel is pretty "blank". No font or size selected. In this state,  
everything works. Then, when I click in the view, the correct family  
and size is selected, and it's no longer possible to change  
anything; it simply ignores it. I'm guessing the message is being  
sent to the wrong object... How do I tell the panel where to send  
all messages for the entire program? TBH I'm not sure why it *does*  
work at all. ;)


___

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

Please do not post admin requests or moderator comments to the list.
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: missing (some) window names in Window menu

2008-04-08 Thread Michael Vannorsdel
You can use NSApplication's addWindowsItem:title:filename: to manually  
add windows to the list.  Also make sure your windows don't have  
isExcludedFromWindowsMenu set to YES.



On Apr 8, 2008, at 3:21 PM, Hal Mueller wrote:

My NSPersistentDocument app has two kinds of windows that can be  
shown for a given document.


A few revisions back (I just noticed it last night, though), Type2  
windows stopped showing up in the Window menu.  I can create them,  
and they respond to the "Bring All To Front" menu item.  Type1  
windows still appear.  Type1 and Type2 window controllers are  
distinct classes with their own nibs.  This was working fine once;  
I'm looking for ideas on what sorts of errors might be causing this  
change in behavior.


Any suggestions on what I should be looking for?  How does the  
Window menu get populated?

___

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

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

2008-04-08 Thread Michael Vannorsdel

Try casting them to ints before formatting:

returnString = [NSString stringWithFormat:@"%c-%i-%i-%f", asciiString,  
(int)firstDouble, (int)secondDouble, thirdDouble];



On Apr 8, 2008, at 1:33 PM, Stuart Green wrote:


Hi,

I have a string declaration of:

	returnString = [NSString stringWithFormat:@"%c-%i-%i-%f",  
asciiString, firstDouble, secondDouble, thirdDouble];


Which is producing a weird output when used outside of an NSLog.

Examining each parameter in the debugger shows exactly what I want,  
i.e. an ASCII string, a floored double (no decimals), another  
floored double (no decimals) and a double with a decimal.


What do I need to do in order to display them correctly in the  
returnString?

___

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

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

2008-04-08 Thread Michael Vannorsdel
That's pretty much it.  Since 64bit on mac are LP64, int is always  
32bits.  Using NSUInteger gives you an integer that behaves like  
ILP64, 32bit on 32bit arch, 64bit on 64bit arch, if you're looking for  
that behavior.



On Apr 8, 2008, at 6:30 PM, Timothy Reaves wrote:

What advantage does NSUinteger have over uint32?   I realize that on  
a 64 bit machine, it would be a uint64.


___

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

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


  1   2   3   >