A handy console output category .

2011-11-15 Thread John C. Randolph

Hi All,

Recently, I was writing a command-line tool and I didn't feel like dropping 
down to printf() for console output,  so I wrote this category.

Drop this in your project…

 @interface NSString (console)
 
 - (void) writeToFileHandle:(NSFileHandle *) handle;
 - (void) writeToStdOut;
 - (void) writeToStdErr;
 
 @end
 
 @implementation NSString (console)
 
 - (void) writeToFileHandle:(NSFileHandle *) handle { [handle writeData:[self 
 dataUsingEncoding:NSUTF8StringEncoding]]; }
 - (void) writeToStdOut { [self writeToFileHandle:[NSFileHandle 
 fileHandleWithStandardOutput]]; }
 - (void) writeToStdErr { [self writeToFileHandle:[NSFileHandle 
 fileHandleWithStandardError]]; }
 
 @end

…and you'll be able to tell strings to output themselves like so:

[@Hello, World!\n writeToStdOut];

[@Oh, no!  Something broke!\n writeToStdErr];

[[self description] writeToStdOut];

-jcr___

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

Please do not post admin requests or moderator comments to the list.
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: Sample code using the new document model?

2011-09-15 Thread John C. Randolph

On Aug 26, 2011, at 7:55 PM, Jerry Krinock wrote:

 I'm just surprised that, of 733 Sample Code projects available in the Mac Dev 
 Center, none of them use either of these much-touted but quite complicated 
 new features.

Sample code projects get updated in DTS engineers' spare time, for the most 
part.  Since Lion shipped so recently, I wouldn't expect them to have any spare 
time for at least another six months.  

I would take a look at TextEdit, I think that's using al the new iCloud 
document features.

-jcr
___

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

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

2011-05-04 Thread John C. Randolph
Several years ago, I wrote this sample code project:

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

It demonstrates the use of NSAffineTransform to rotate, scale, and shear images.

-jcr


On Apr 29, 2011, at 7:48 AM, Amy Heavey wrote:

 Hi,
 
 I'm trying to generate a new image that is made up of a combination of other 
 images.
 
 As I iterate over the array holding the images I want to do is...
 - place the componant image in the new canvas at a certain point (150,187)
 - rotate the componant image by a certain value (calculated previously)
 
 I don't mind how the image fits in the new canvas, it doesn't have to be 
 completely within it.
 
 I think I need to use NSAffineTransform?
 
 I was using drawinrect previously for non-rotated movement.
 
 Do I need to draw the componant image to the canvas first then rotate it?
 
 The code I have at the moment is
 
 [code]
 //calc rotation
   double rotation = 360 / ki;
   double rotateby = rotation;
   
   //set coordinates to x,y - 150,187 to start
   float x = 150;
   float y = 187;
   
   //for each image
   NSEnumerator *imageLoop = [kitImages objectEnumerator];
   NSString *imgPath;
   
   while ((imgPath = [imageLoop nextObject])) {
   NSImage *img = [[NSImage 
 alloc]initWithContentsOfFile:imgPath];
 
   //rotate image
   
   
   //apply image to view
   [targetImage lockFocus];
   
   
   //[img drawInRect:NSMakeRect(x,y,xb,yb) 
 fromRect:NSMakeRect(150,150,0,0) operation:NSCompositeCopy fraction:1];
   
   //set new rotation
   rotation = rotation+rotateby;
 [/code]
 
 I've tried looking at some of the samples, but they seem to be cover rotating 
 in place and resizing which is more complicated than I'm looking for. I'm 
 expecting to effectively have the componant images fan out on the canvas.
 
 If anyone could help me with the process I'd be grateful, do I have to create 
 a intermediary image to make the rotated image square?
 
 Thanks,
 
 Amy
 
 
 
 Many Thanks
 
 Amy Heavey
 Willow Tree Crafts
 www.willowtreecrafts.co.uk
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/jcr%40mac.com
 
 This email sent to j...@mac.com

___

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

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

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

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


Re: NSWorkspaceWillPowerOffNotification not working with Qt Cocoa Mac Application

2011-04-08 Thread John C. Randolph


On Apr 7, 2011, at 11:34 PM, manoj wrote:


I am working on Mac application using Qt Cocoa.
Please help me to figure out what is the difference between two.


You'll have to ask Nokia.

-jcr
___

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

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

2010-12-24 Thread John C. Randolph
NSMenuItem's -setView: method should do what you need.

-jcr


On Dec 24, 2010, at 11:49 AM, Joshua Garnham wrote:

 How can I display an editable NSTextField inside an NSMenuItem? I'm looking 
 to 
 do something similar to Spotlight.
 Would it work by simply usingsetView: on the menu item?
 
 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/jcr%40mac.com
 
 This email sent to j...@mac.com

___

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

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

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

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


Re: NSTask with unzip

2010-12-12 Thread John C. Randolph
You don't need to launch a separate task for this.  Just use Pierre- 
Olivier LaTour's NSData category:


http://code.google.com/p/polkit/

  • NSData+GZip adds gzip compression / decompression methods to NSData

-jcr

___

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

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

2010-12-12 Thread John C. Randolph


On Dec 12, 2010, at 7:34 AM, Matt Neuburg wrote:

I feel like I'm missing something. I can't seem to typecast as  
CFRange to an NSRange. I know I can pull a CFRange apart and  
reassemble it as an NSRange, but shouldn't there be a simpler way? m.


CFRange is defined as a pair of unsigned longs, and NSRange is defined  
as either unsigned ints or unsigned longs depending on whether you're  
compiling 32- or 64-bit.


-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: Garbage collection 32 64-bit

2010-09-25 Thread John C. Randolph


On Sep 14, 2010, at 7:34 AM, Jonathan Guy wrote:


Hi all
Having an issue with GC. I compile an app 32  64-bit intel only  
with GC supported (not required). The app has a webview which loads  
a flash animation (hence requiring the flash plugin).


Does it have to be a flash animation?  Could it be done with HTML 5 or  
Quartz Composer instead?


-jcr
___

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

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

2010-09-15 Thread John C. Randolph

On Sep 14, 2010, at 7:36 PM, k...@highrolls.net wrote:

 what do i need to implement so I can drag item within an NSOutline View?

http://developer.apple.com/library/mac/#samplecode/DragNDropOutlineView/Introduction/Intro.html

-jcr

___

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

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

2010-09-15 Thread John C. Randolph

On Sep 14, 2010, at 7:36 PM, k...@highrolls.net wrote:

 what do i need to implement so I can drag item within an NSOutline View?

http://developer.apple.com/library/mac/#samplecode/DragNDropOutlineView/Introduction/Intro.html

-jcr

___

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

Please do not post admin requests or moderator comments to the list.
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: isTemporaryID unrecognized selector - how do I debug this?

2010-09-09 Thread John C. Randolph
This was covered in a couple of WWDC talks.  Look for the sessions on debugging.

-jcr

On Sep 9, 2010, at 12:23 PM, Sean McBride wrote:

 On Fri, 3 Sep 2010 19:52:54 -0700, Jerry Krinock said:
 
 http://developer.apple.com/mac/library/technotes/tn2004/tn2124.html 
 Architecture Considerations
 
 Sadly this awesome technote has not been updated in 3 years.  We should
 all file bugs. :)
 
 But there's a problem.  I see you've got a 64-bit machine.  The first
 article says that 64-bit Intel restores sanity to the equation by
 passing arguments in registers, but he doesn't say which registers, and
 neither does the Apple Technical Note.
 
 I'm going to have to get a 64-bit Mac one of these days.  Does anyone
 know the register mapping for Intel 64?
 
 Forgot where I got this (ie credit not mine), but:
 
 given:
 -(id)method:(id)arg2 bar:(id)arg3 baz:(id)arg4
 
ppc/ppc64:  x86_64: i386:
 arg0 (self) $r3 $rdi*(id*)($ebp + 8)
 arg1 (_cmd) $r4 $rsi*(SEL*)($ebp + 12)
 arg2$r5 $rdx*(id*)($ebp + 16)
 arg3$r6 $rcx*(id*)($ebp + 20)
 arg4$r7 $r8 ?
 arg5$r8 $r9 ?
 
 --
 
 Sean McBride, B. Eng s...@rogue-research.com
 Rogue Researchwww.rogue-research.com
 Mac Software Developer  Montréal, Québec, Canada
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/jcr%40mac.com
 
 This email sent to j...@mac.com

___

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

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

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

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


Re: recalling the original view height

2010-09-07 Thread John C. Randolph
Views have no storage for previous frame or bounds rectangles.  If you want to 
remember them, you'll need to save them yourself.

-jcr


___

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

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

2010-09-02 Thread John C. Randolph

On Sep 2, 2010, at 3:17 PM, David Duncan wrote:

 On Sep 2, 2010, at 11:29 AM, vincent habchi wrote:
 
 You mean I shall use your dispatch_async invocation instead of calling 
 [layer setNeedsDisplay]?
 
 Calling -setNeedsDisplay arranges for -display to later be called on the 
 current runloop. As such using -setNeedsDisplay is reliant on a runloop 
 running (and running regularly) neither of which you have on a GCD queue.
 
 I was thinking of calling dispatch_async () inside -drawInContext, but, if I 
 understand your example correctly, this is wrong.
 
 Doing so would cause you all manners of pain and suffering, the most common 
 of which is things mostly working but occasionally your drawing going into 
 the wrong view. Basically *never* use the context given to you in 
 -drawInContext: outside of that invocation.

More generally,  -draw…: methods should never have side effects, whether we're 
talking about a layer, a view, or what have you.

-jcr

___

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

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

2010-09-01 Thread John C. Randolph

On Sep 1, 2010, at 8:15 PM, Eric E. Dolecki wrote:

 Top left, the traffic lights have been turned to the vertical. Is this
 something new or was this easy to do before? Is it just a custom
 implementation, or?

If you miniaturized the iTunes 9 window, the window controls are vertical.  Not 
sure if this has always been the case or not.  It's pretty easy to implement 
that kind of thing.  NSWindow has a -standardWindowButton: method that will 
give you a close button, zoom button, etc.

-jcr

___

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

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

2010-08-25 Thread John C. Randolph

On Aug 25, 2010, at 12:30 PM, Richard Somers wrote:

 On Aug 25, 2010, at 1:30 AM, Quincey Morris wrote:
 
 @implementation MyCustomDocumentView
 
 - (void)windowDidBecomeKeyNotification:(NSNotification *)notification
 {
  if ([notification object] == [self window]) {
  NSPoint point = [[self window] mouseLocationOutsideOfEventStream];
  NSRect frame = [self convertRectToBase:[self frame]];
  BOOL condition = NSMouseInRect(point, frame, NO);
  if (condition) {
  [[NSCursor crosshairCursor] set]; // Called but does not work!
  }
  }
 }
 
 @end
 
 The implication of this is likely that the cursor is being set again after 
 you do it. Have you tried setting a breakpoint on [NSCursor set]? It's 
 tricky to debug, because you don't want application switching to mess up the 
 testing conditions, so you probably need to enable the breakpoint from the 
 floating debugger window, and/or use carefully constructed debugger 
 conditions.
 
 I checked this with a breakpoint. When a window become key the cursor is set. 
 So setting a custom cursor using this approach will never work. This also 
 explains why setting the cursor in initWithFrame: or awakeFromNib of a NSView 
 object also will not work.

Sounds like a job for delayed messaging.

Change the code above to:

- (void)windowDidBecomeKeyNotification:(NSNotification *)notification
{
 if ([notification object] == [self window]) {
 NSPoint point = [[self window] mouseLocationOutsideOfEventStream];
 NSRect frame = [self convertRectToBase:[self frame]];
 BOOL condition = NSMouseInRect(point, frame, NO);
 if (condition) {
 [[NSCursor crosshairCursor] performSelector:@selector(set) 
withObject:nil afterDelay:0];
 }
 }
}

That will send a -set message the next time through the event loop.

-jcr

___

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

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

2010-08-24 Thread John C. Randolph

On Aug 23, 2010, at 9:41 PM, Richard Somers wrote:

 If a new document is opened and the cursor happens to already be over the 
 view, the cursor is not updated until it is moved out of the view and then 
 back in. How can I fix this? None of the NSTrackingArea options address this 
 issue.

You can just check where the cursor is when you open your document and send 
[[NSCursor IBeamCursor] push] yourself if it's inside your view.

-jcr
___

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

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

2010-08-18 Thread John C. Randolph
-stringByReplacingCharactersInString: creates and returns a new string, which 
is autoreleased.  You're getting the bus errors when something tries to access 
that string after it's been released.

-jcr


On Aug 17, 2010, at 2:03 PM, James Miller wrote:

 Hello.
 
 I'm a little new to Objective-C / Cocoa so please don't shoot me, but I've 
 been looking around for a few hours and can't seem to figure out what I'm 
 doing wrong on my own and could use a second/third/fourth set of eyes.
 
 I have NSTimer that runs several times a second against an NSString called 
 level,  which is 190 characters long and previously initialized from:
 
 // NSString *level = [[NSString alloc]
 // initWithContentsOfFile:path
 // encoding:NSUTF8StringEncoding
 // error:error];
 
 
 During the timer call, the level NSString is modified by the following line 
 of code:
 
 level=[level stringByReplacingCharactersInRange:NSMakeRange(5,1) 
 withString:@ ];
 
 This operation appears to succeed as I print it via NSLog and it looks fine 
 and the length checks out, but the next time through the NSTimer I get a bus 
 error and the application dies.
 
 If I comment out the line above, the code continues to run fine. Am I doing 
 something wrong in terms of how I am using this method or assigning it back 
 to the NSString?
 
 
 I appreciate the help!
 
 --Jim___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/jcr%40mac.com
 
 This email sent to j...@mac.com

___

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

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

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

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


Re: Erratic Cocoa Behavior

2010-08-16 Thread John C. Randolph
That looks like what happens when you turn on show tracking rectangles in 
Quartz Debug.  It could also be the effect of turning on NSShowAllDrawing in 
your app's defaults.

-jcr

On Aug 16, 2010, at 2:07 PM, k...@highrolls.net wrote:

 Hello fritz -
 
 I will reply to the list.  I did paste the URL and do not know why it did not 
 appear .  Trying again.
 The problem is hard to describe and I thought a picture with description 
 would be best.
 
 Bottom line, highlight artifacts are left in an NSOutlineView upon drag exit 
 and cause bad redraw when the view is scrolled.
 
 -koko
 
 http://highrolls.net/high_light_issue/page.html
 
 
 
 
 On Aug 16, 2010, at 3:03 PM, Fritz Anderson wrote:
 
 On 16 Aug 2010, at 3:57 PM, k...@highrolls.net wrote:
 
 Pictures and description of problem.
 
 Please review the above link for my problem and be so kind as to tell me 
 what I am doing wrong.
 
 Speaking of erratic...
 
 Could you paste in the URLs for what you mean to show us?
 
 Also, you should try to engage the people you want to make an effort for 
 you, by telling them what your problem is. Help me is not an engaging 
 reason to help you.
 
 Remember to reply on-list.
 
  — F
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/jcr%40mac.com
 
 This email sent to j...@mac.com

___

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

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

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

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


Re: iPhone Camera

2010-08-11 Thread John C. Randolph

On Aug 11, 2010, at 6:24 PM, k...@highrolls.net wrote:

 Can an iPhone app get input from the camera?

Yes.

-jcr

___

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

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


Allowing incoming connections.

2010-03-24 Thread John C. Randolph
So, I've got this app that connects to RTSP streams, and I'd rather  
not nag the user every time it's launched with that Do you wan the  
application to accept incoming network connections? dialog box.   
Anyway to have  the user authorize it once and have that authorization  
stick, or is this a matter of security policy?


Thanks,

-jcr
___

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

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


Accessing the contextual menu of a QTMovieView?

2010-03-10 Thread John C. Randolph
I'd like to add an item to the menu that comes up when you right-click  
on a QTMovieView. I want to copy the URL of the movie it's showing  
into the pasteboard.  I'm not finding any obvious API to get hold of  
that menu.  Any suggestions?


Thanks,

-jcr

___

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

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

2010-01-02 Thread John C. Randolph


On Jan 2, 2010, at 10:44 AM, PCWiz wrote:

 The only reason I dont want to completely draw the whole window is  
that resizing is not easily implemented with a custom window.


Sure it is.  This is how I did it in the Core Data Stickies example:

#import StickyResizeCornerView.h

@implementation StickyResizeCornerView

- (void)drawRect:(NSRect)rect
{
NSRect bounds = [self bounds];
[[NSColor brownColor] set];
	[NSBezierPath strokeLineFromPoint:NSZeroPoint  
toPoint:NSMakePoint(NSMaxX(bounds), NSMaxY(bounds))];

}

- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
{
return YES;
}

- (void)mouseDragged:(NSEvent *)theEvent
{
NSWindow *window = [self window];
NSRect frame = [window frame];
float newHeight = frame.size.height + [theEvent deltaY];
float newWidth  = frame.size.width  + [theEvent deltaX];
NSSize minSize = [window minSize];
if (newHeight = minSize.height) {
frame.size.height = newHeight;
frame.origin.y -= [theEvent deltaY];
}
if (newWidth = minSize.width)
frame.size.width = newWidth;
[window setFrame:frame display:YES];
}


-jcr
___

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

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

2009-12-19 Thread John C. Randolph
There's a far easier way to do it than that, which is to use  
compositing instead of clipping.


On Dec 17, 2009, at 9:49 PM, Gordon Apple wrote:

If you capture the entire laid-out text string as a single Bezier  
path,
then you can fill it with whatever you want -- gradient, image,  
burning fire
QTMovie, more text, etc.  I've done it and it works.  Of course, all  
of that
takes a significant amount of effort.  In my case, I already had all  
the

fill mechanisms, so all I had to do was get the Bezier Path.

The SpeedyCatagories file in the SpeedometerView example has most of  
what

you need to get the Bezier.  You have to modify it somewhat to get
everything you need.

On 12/17/09 8:29 PM, cocoa-dev-requ...@lists.apple.com
cocoa-dev-requ...@lists.apple.com wrote:


On 18/12/2009, at 4:31 AM, Chris Purcell wrote:

I've tried setting the gradient as NSForegroundColorAttributeName  
in the
attributes dictionary when creating the string but as I expected  
that didn't

work. How would I go about filling the string with a gradient?


Why would you even expect that to work? NSGradient is not a colour.  
At present

there is no supported attribute for gradients.

You could create this effect by converting the string to its glyphs  
as a path
and fill the path. Alternatively you can create a subclass of  
NSLayoutManager

and override the method:

- (void)showPackedGlyphs:(char *)glyphs
length:(NSUInteger)glyphLenglyphRange:(NSRange)glyphRange
atPoint:(NSPoint)point font:(NSFont *)font color:(NSColor*)color
printingAdjustment:(NSSize)printingAdjustment

and render the glyphs using a gradient. Doing that implies you'll  
need to set
up a text system programatically, which is a fairly advanced topic  
- see:


http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/TextArch
itecture/TextArchitecture.pdf

--Graham





___

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

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

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

This email sent to j...@mac.com


___

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

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

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

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


[JOB] iPhone development gig in Tampa, FL.

2009-09-23 Thread John C. Randolph

Ladies and Gentlemen,

Looks like I'm about to go to Florida for a month, and the client  
wants me to help them find someone to join them on a permanent basis.   
The work is an in-house app for managing their service vendors and  
streamlining their billing processes.


If you've got a solid Objective-C Cocoa or Cocoa Touch background and  
you're interested, drop me a note at jcr at mac.com.  I have advised  
the client of what the market rates are, so they won't be asking you  
to take java-monkey rates for iPhone work.  Contract or permanent is  
negotiable.


-jcr

___

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

Please do not post admin requests or moderator comments to the list.
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: [JOB] iPhone development gig in Tampa, FL.

2009-09-23 Thread John C. Randolph


On Sep 23, 2009, at 7:54 PM, Scott Anguish wrote:

And a reminder, all job offers to be posted must be sent to the  
admin address for approval first.



Sorry about that, Scott.  I didn't require pre-approval for job  
postings back when I moderated cocoa-dev, and I didn't realize that  
you do.  I'll check with you first before I post any other gigs.


-jcr

This is not a book to be tossed aside lightly. Rather, it should be  
hurled with great force. -Dorothy Parker


___

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

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

2009-09-19 Thread John C. Randolph


Looks like NSFontColorAttribute is deprecated after 10.4.   Try  
NSForegroundColorAttributeName instead.


-jcr



___

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

Please do not post admin requests or moderator comments to the list.
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: Developing a Stand-Alone Service in Snow Leopard

2009-09-14 Thread John C. Randolph


On Sep 13, 2009, at 10:55 PM, Steve Cronin wrote:

I have convinced myself that the only way to get Snow Leopard to  
recognize the newer version of the service is to log out and back in.

This is tedious.  Is there something I'm missing?


As I recall, each app builds its services menu when it launches.  Any  
app launched after you run pbs should show a correctly updated  
services menu.


-jcr

___

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

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

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

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


Re: What about revamping OpenUp.app for Snow Leopard?

2009-09-03 Thread John C. Randolph
I'd completely forgotten about that presentation.  Thanks for the link  
to the slides.  I'll have to dig up my 2003 WWDC disks and watch it.


-jcr


“The two most important tools an architect has are the eraser in the  
drawing room and the sledge hammer on the construction site. ”

-Frank Lloyd Wright

___

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

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

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

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


Re: [iphone] split an image

2009-08-08 Thread John C. Randolph


On Aug 4, 2009, at 12:45 PM, Dragos Ionel wrote:


Hi,

Is there a simple way to split an image? For example, divide it in  
to 2x2 =

4 pieces.

Is UIImage the way to go?


If you want to slice and dice an image like that, you probably want to  
use CGImage instead.  See CGImageCreateWithImageInRect()


-jcr

___

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

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

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

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


Re: [iPhone] networking-is it crippled on the simulator?

2009-08-04 Thread John C. Randolph


On Aug 4, 2009, at 5:43 AM, James Lin wrote:


Hi all,

Does anyone know the limitation of the iPhone simulator when it  
comes to networking?

Is it crippled on the simulator?

I've tried two seperate ways of opening up a server socket.
1. is by opening up a CFSocket
2. is by a socket wrapper class called LXSocket class obtained from  
google codes.


but i've so far failed to obtain the ip address of the server  
socket.


the CFSocket method returned the ip address as 0.0.0.0
the LXSocket class returned the ip address as a Null object.

I am wondering, if there is a limitation of some kind that's  
limiting the networking functionality on the simulator.


Does anyone know?


Safari works for me on the simulator, so it's got to have  
communications.  Does the same code work if you load it on your phone?


-jcr
___

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

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

2009-07-31 Thread John C. Randolph


I wrote a sample project to find the difference image between to given  
images several years ago.  You can find that code here:


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

These days, I'd do this kind thing in a Quartz Composer view.

-jcr
___

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

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

2009-07-23 Thread John C. Randolph


On Jul 22, 2009, at 10:05 PM, Randall Meadows wrote:


 newBounds.origin.x -= delta/2.0;
  newBounds.size.width += delta;
  newBounds.origin.y -= delta/2.0;
  newBounds.size.height += delta;


BTW, you might want to look up the NSInsetRect() function.

-jcr
___

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

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

2009-07-22 Thread John C. Randolph


On Jul 22, 2009, at 2:19 AM, Mahaboob wrote:


Is it possible to develop an application for recording phone calls?


Possible?  Maybe.  Supported?  No.

-jcr

___

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

Please do not post admin requests or moderator comments to the list.
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: Responding to mouseDown in an NSImageView

2009-07-21 Thread John C. Randolph


On Jul 21, 2009, at 11:35 AM, Lynn Barton wrote:

My window has an NSImageView object within an NSScrollView. After  
setting the image and the image frame, I want to detect and respond  
to mouseDown on the image. The image appears in the view, but I  
found nothing responding to the mouseDown.


I tried subclassing NSImageView and putting a -(void)mouseDown: 
(NSEvent *)theEvent method in the subclass. That allowed me to get  
and process the event, but the image did not appear in the view. Can  
anyone help?


Not with the minimal information you've given.  Show us the code.

-jcr

___

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

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

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

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


Re: Cocoa Graphics Parsing

2009-07-20 Thread John C. Randolph


On Jul 20, 2009, at 7:25 PM, Courtney Arnold wrote:


I want to be able to manually parse an image of a UPC barcode.



That's not parsing, that's image recognition.  There's a rather  
extensive academic literature on the subject.


-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: Mouse move messages sent to both superview and a subview

2009-07-20 Thread John C. Randolph


On Jul 19, 2009, at 12:39 AM, Oleg Krupnov wrote:


I want to display one view on top on the other view, so according to
the documentation, I nest the topmost view inside the background view.

It works just fine except that the mouse move messages are sent to
both the subview and the superview, whereas I'd like them to be
directed only to the subview when it's visible. Why is this happening?
I used to think that normally the same mouse messages cannot be
delivered to more than one view. What is my mistake? Thanks!


I believe that any number of views can get mouseMoved events if they  
get a -setAcceptsMouseMoved:YES message.  They're not like mouseDown  
and mouseUp.


-jcr

___

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

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

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

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


Re: iPhone runtime browser.

2009-07-19 Thread John C. Randolph


On Jul 19, 2009, at 5:33 AM, Nicolas Seriot wrote:


There is also another iPhone runtime browser: 
http://code.google.com/p/runtimebrowser/

Here is what it dumps on iPhone OS 3.0: 
http://seriot.ch/resources/dynamic_iPhone_headers/3_0/


Looks like they got rather more elaborate about it than I did.

I just added a bit to mine, it lists ivars and methods now, too.   
Anyone who wants the later version, ping me at j...@mac.com


-jcr

___

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

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


iPhone runtime browser.

2009-07-18 Thread John C. Randolph
For anyone who hasn't done it themselves already, I just wrote up a  
little Cocoa touch app that shows you all the classes in the objective- 
C runtime.  No point in submitting it to the app store, but if anyone  
would like a copy, drop me a note and I'll mail it to you.  It's a  
36KB .zip file.  Offered as-is, no help, no support, no guarantees, etc.


-jcr

This is not a book to be tossed aside lightly. Rather, it should be  
hurled with great force. -Dorothy Parker


___

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

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

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

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


Re: iPhone runtime browser.

2009-07-18 Thread John C. Randolph

Oop, forgot to add:  send requests to me, not the list.

-jcr


“The two most important tools an architect has are the eraser in the  
drawing room and the sledge hammer on the construction site. ”

-Frank Lloyd Wright

___

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

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

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

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


Re: iPhone runtime browser.

2009-07-18 Thread John C. Randolph
Couple of notes:  I built it for the 3.1 SDK, and I didn't try it on  
anything earlier.  One friend of mine told me that to make it work on  
the 3.0 SDK, he had to change line 31 of ClassesViewController.m from:


[self.tableView reloadData];

to

[super.tableView reloadData];


-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: Why do I receive KVO notification when new value IS the old value?

2009-07-08 Thread John C. Randolph


On Jul 8, 2009, at 3:05 PM, Jerry Krinock wrote:

Why do I receive KVO notifications when a key is set to the same  
value that it already is?


Because the notification mechanism doesn't know or care if you're  
setting the same value that's already there.


-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: looks like my syntax is wrong. Does not compile

2009-07-04 Thread John C. Randolph


On Jul 3, 2009, at 9:29 PM, Agha Khan wrote:


NSNumber* aNumber = [Aobject _Edge] numberWithInt:j;
   // looks like my syntax is wrong. Does not compile


Objective-C isn't smalltalk.  All message expressions have to be  
enclosed in square brackets:


NSNumber* aNumber = [[Aobject _Edge] numberWithInt:j];

-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: User interface validation doesn't work, right?

2009-07-03 Thread John C. Randolph


On Jul 2, 2009, at 10:52 AM, Bill Cheeseman wrote:

Apple will probably say I should move on to Cocoa Bindings and get  
over it.



I certainly would.

-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: Dynamically loading a part of a Window in Cocoa

2009-07-01 Thread John C. Randolph


On Jul 1, 2009, at 12:21 AM, Debajit Adhikary wrote:

I have an area of a Window (in my MainMenu.xib) which I'd like to  
populate
dynamically with unrelated views such as an NSTable,  
IKImageBrowserView
etc. at different points of time depending on some user-selected  
criteria.


  - How do I define this area of the window such that it can be  
replaced

  with different views?
  - How do I attach a table or some other view to this area of the  
window?


(Is it enough to place a generic NSView there and add a subview each  
time?

I'm fairly new to Cocoa, so any pointers are welcome)


The typical way to do this is with an NSTabView.  YOu can show the  
tabs or not.


-jcr
___

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

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

2009-06-30 Thread John C. Randolph


On Jun 30, 2009, at 7:03 AM, Mr. Gecko wrote:


Is there anyway to get raw Infrared data from the Apple IR Controller?



AFAIK, there's no published API for that, but could take a look  
through the classes in the Kernel Framework documentation and see if  
I'm mistaken.  If not, you should contact Apple developer relations,  
tell them what you want to do, and see if they're willing to help you  
out.


-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: Any Cocoa Developers on this list in Tallinn, Estonia?

2009-06-23 Thread John C. Randolph


On Jun 21, 2009, at 5:17 PM, Kok-Yong Tan wrote:

There's a potential client there I'd like to refer to you.  Please  
reply to me off-list.


Don't know about Estonia, but the guys at Software MacKiev would  
probably know.


-jcr

___

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

Please do not post admin requests or moderator comments to the list.
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: -viewDidMoveToWindow without subclassing? NSViewController?

2009-04-17 Thread John C. Randolph
On a general note, if you want something to happen later than - 
awakeFromNib, you can always send - 
performSelector:withObject:afterDelay:cancelPrevious:.  If you pass a  
delay of zero, it will happen the next time through the event loop.   
I've used this many times to deal with situations similar to what  
Jerry described.


-jcr


This is not a book to be tossed aside lightly. Rather, it should be  
hurled with great force. -Dorothy Parker


___

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

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

2009-04-15 Thread John C. Randolph


Jason,

I just tried dropping your code into a new Foundation Tool project,  
and it looks like your problem happens when your subclass of  
NSOutputStream sends [super initToFileAtPath:append:].


Check the subclassing notes on NSOutputStream.  It looks like it's a  
class cluster, and NSOutputStream itself doesn't implement - 
initToFileAtPath:append:. That would be left up to concrete subclasses  
to implement.


-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: persisting user credentials -- how?

2009-03-09 Thread John C. Randolph


On Mar 9, 2009, at 2:32 PM, Stefan Wolfrum wrote:


Hi,

I have a little app that needs a username  password to log into  
some web service.
These user credentials should be stored permanently so that the user  
doesn't have to enter them after each start of the application again.


What's the most common way to do this? In a .plist file? But how  
does one encrypt the password? What does Apple suggest?


I googled and searched developer docs -- to no avail.

A pointer to a webpage, tutorial, document, code snippet would be  
cool!


Look for Keychain in the Apple developer docs.

-jcr

___

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

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

2009-03-05 Thread John C. Randolph


On Mar 5, 2009, at 1:43 PM, Norio wrote:


Hi,

Would you give me any suggestions to get the mouseUp event for  
NSSlider?


I've tried to make subclass of NSSlider and override mouseUp: and  
then put a breakpoint,

but the debugger didn't stop at the breakpoint.


What's tripping you up there is a legacy of how some of the older  
controls are implemented.  NSSliderCell has a bad habit, which is  
capturing the event stream.  Once you send it a -mouseDown: message,  
it will consume all mouse events until -mouseUp:.  If you subclass  
NSSliderCell to work around this, don't send [super mouseDown:].


-jcr

___

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

Please do not post admin requests or moderator comments to the list.
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: [Q] NSObject's poseAsClass - Replacement?

2009-03-05 Thread John C. Randolph


On Mar 5, 2009, at 12:00 PM, Eric Gorr wrote:



On Mar 5, 2009, at 2:47 PM, Benjamin Stiglitz wrote:

I have a need to use poseAsClass, but I see that it has been  
deprecated

in 10.5 and won't be available for 64-bit applications.

So, is there a replacement?


WAYTTD: What are you trying to do? Maybe you don’t need to pose.


Well, sadly, I am pretty sure I do...at least for now.

Although, this bug is not quite confirmed yet, but I suspect I know  
what the problem is.


I am working on a Carbon - Cocoa conversion. In the carbon part,  
the cursor is being set to a 64x64 cursor constantly - via NSCursor  
set. The problem comes when I move the cursor over a cocoa view  
which I believe, by default, changing the cursor to what it wants -  
which I believe is a 32x32 cursor.


So, in the constantly fighting over what the cursor should be, there  
is some weird cursor behavior...it flickers - moves quickly to a  
nearby location and then back again.


I figure I could write my own NSCursor subclass, pose it as the  
normal NSCursor class and make sure that it is always trying to set  
cursor in the same way in every situation.


Yes, I know, this isn't a good situation any way you slice it...but  
I need a quick fix and poseAsClass: seems to be the best option -  
assuming the bug is what I think it is.


That's a band-aid, not a solution.  Figure out why the carbon code is  
constantly trying to change the cursor, and fix it.


-jcr

___

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

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

2009-03-05 Thread John C. Randolph


On Mar 5, 2009, at 5:55 AM, Erik Buck wrote:

As an author, I humbly recommend http://my.safaribooksonline.com/9780321591210 
.  Check out the table of contents.


I'll second Eric's recommendation.  Also, there's a pretty good  
conceptual intro to MVC in the Cocoa docs.  See


file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/chapter_5_section_4.html

on any machine with Xcode installed.

-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: NSView bottom part is cut off

2009-03-05 Thread John C. Randolph


On Mar 5, 2009, at 9:29 PM, Adam Gerson wrote:


I have a view that looks just fine in interface builder. When I
display it in a window in my app it cuts off the bottom part of the
content. Visual:

http://screencast.com/t/YEXgqlAcP

What could cause this?


Looks to me like you've probably got the wrong resizing attributes on  
either the scrollview or its superview.


-jcr

___

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

Please do not post admin requests or moderator comments to the list.
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: NSScrollView's content view doesn't un-hide

2009-02-25 Thread John C. Randolph


On Feb 25, 2009, at 4:28 PM, Scott Hamilton wrote:


Am I missing something?


From your description, you're sending -setNeedsDispay to the the  
clipview, not to the subviews within the clipview.


-jcr

___

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

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

2009-02-25 Thread John C. Randolph


On Feb 24, 2009, at 8:04 PM, Ken Case wrote:

You'll find it at http://www.omnigroup.com/developer/ 
omniobjectmeter/.


Thanks, Ken!

 We also recently posted updated versions of our open source Omni  
frameworks to github, including OmniDataObjects (our CoreData-like  
implementation which works on both Mac and iPhone).  For more  
information, see http://www.omnigroup.com/developer/.



Note to the list:  Reading the code in Omni's frameworks is highly  
recommended.   Omni's been writing Objective-C code for a long time.


-jcr

___

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

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

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

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


Re: What is a CALayer?

2009-02-17 Thread John C. Randolph


On Feb 17, 2009, at 10:40 AM, Gordon Apple wrote:


   OK, I've said it.  WHAT is a CALayer?  I'm using a lot of them and
appreciate what they can do, but still don't understand them.


It's an object that manages an OpenGL surface, its location in 3D  
space and its place in a hierarchy of layers.


Does that help?

-jcr

___

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

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

2009-02-12 Thread John C. Randolph


On Feb 12, 2009, at 9:42 AM, Anthony Smith wrote:

What is the best way to set the max zoom size for NSWindow? I was  
able to implement a solution by overriding zoom but that feels  
rather invasive so I'm assuming there's probably a better way.


Check the docs for -windowWillResize:toSize:.

-jcr


___

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

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

2009-02-12 Thread John C. Randolph


On Feb 10, 2009, at 11:32 PM, Valentin Dan wrote:


Hi,



What tools are there to analyze memory leaks in programs ? Is there
something that would tell the exact location of the leak (the object
that's not being released) ?


Try /Developer/Applications/Instruments.  It has a template  
specifically for finding leaks.


-jcr

The problem with trying to child-proof the world, is that it makes  
people neglect the far more important task of world-proofing the  
child. -- Hugh Daniel


___

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

Please do not post admin requests or moderator comments to the list.
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: Matching String With ObjectForKey?

2009-02-12 Thread John C. Randolph


On Feb 12, 2009, at 10:45 PM, Chunk 1978 wrote:


if ([defaults objectForKey:@OriginalBackground] == pathy)

..


but they are the same!  aren't they?!


Nope.  You're comparing two addresses, not the contents of the objects  
at those addresses.


Try:

if ([[defaults objectForKey:@OriginalBackground] isEqualToString:  
pathy])


-jcr
___

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

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

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

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


Re: Getting pixel color from NSView

2009-01-25 Thread John C. Randolph


On Jan 25, 2009, at 11:06 AM, Ashley Perrien wrote:

Is there a way to get the color of a pixel or area of an NSView  
during the drawRect method?


Sure.  Have a look at this:

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

NSReadPixel() will tell you the color of the pixel nearest to the  
given location, in the current drawing context.


-jcr


This is not a book to be tossed aside lightly. Rather, it should be  
hurled with great force. -Dorothy Parker


___

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

Please do not post admin requests or moderator comments to the list.
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: Where is the Computer Image ?

2008-12-15 Thread John C. Randolph


On Dec 14, 2008, at 8:53 PM, Gerriet M. Denkmann wrote:


Finder.app can show in its Sidebar an image of a computer.
I want to create a button with this same (or similar) image.

I can use [ sharedWorkspace iconForFile: fullPath ] to get an image  
of a home folder, or of a disk partition.


But I cannot find a computer image. Also looked at Icon Services  
and Utilities Reference but did not find anything there.


When I need to do this kind of thing, I use  spotlight to show me all  
the images in /System/Library/ in icon view.


-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: design pattern for data acquisition in background thread?

2008-09-28 Thread John C. Randolph


On Sep 27, 2008, at 8:10 PM, Joe Keenan wrote:



On Sep 27, 2008, at 4:25 PM, Chris Hanson wrote:


On Sep 26, 2008, at 3:37 PM, Joe Keenan wrote:

Right now, the  app controller object sends a message to the  
device controller, requesting the value of a specified variable.   
The device controller does the telnet command to get it, returns  
it to the app controller, and the app controller sends it to the  
text field.  Repeat 25 times for a full update.  Slow, and there's  
no return to the run loop in there to allow for keyboard or UI  
events.


I'm looking for suggestions on how to deconstruct this to get the  
object talking to the device into another thread so the main  
window can take UI events.  I'm thinking I can package up the  
variable requests into a dictionary so that the device controller  
can do a bunch at once.  Then the main thread can do all the  
updates from the dictionary, which should be quick.


It doesn't even need to be that complicated.

You can follow a delegate model in your device controller's design  
to make it asynchronous, rather than have it provide a synchronous  
API.


Thanks for that pseudo-code.  I think you're right about doing it  
that way.  I was also thinking I could add a request queue and a  
response queue so that there can always be a request in the works,  
instead of waiting to start the next one after the UI is updated.


The problem with any async method is that I haven't figured an  
elegant way to know which update code to use for each return value.   
They're not all the same.  Different data elements need different  
processing to update the UI.  When I get a response back  
asynchronously, I have the variable name and the value, and I have  
to figure out which UI element it belongs to.  The brute force  
method is a long if/else chain that tests the name of the variable  
to do it, like:


if ([key isEqualToString: @lnbcolor])
{
			[lnbLight   setTextColor:[NSColor colorFromHexidecimalValue:  
keyValue]];

}
else if ([key isEqualToString: @lancolor])
{
			[lanLight   setTextColor:[NSColor colorFromHexidecimalValue:  
keyValue]];

}

With lots (25 or so) more possible key values, and a half-dozen or  
more different ways to update the UI element.


This sounds like you're reinventing bindings and key-value observing.

Bind the controls in question to the relevant keys, and whenever you  
get a callback that changes one of the values, send out a - 
willChangeValueForKey: and a -didChangeValueForKey: message.


-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: Need to override +(Class) class?

2008-09-28 Thread John C. Randolph


On Sep 27, 2008, at 7:38 PM, Dave DeLong wrote:

My question is, do I need to override the +(Class) class method for  
each InputElement subclass, and if so how do I make a Class object?


The only situations I can think of where you might want to do that is  
if you're writing some kind of a proxy class, if you were implementing  
a distributed objects or a high-order messaging facility.


-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: fullscreen quicktime across multiple monitors

2008-09-18 Thread John C. Randolph


On Sep 17, 2008, at 12:03 PM, Memo Akten wrote:

Hi All, I'd like to create a little app the runs a quicktime movie  
(prores) fullscreen across multiple monitors. I think I can figure  
out the QTKit stuff, but couldn't find upto date documentation on  
going fullscreen. I've found some code snippets to do it, but they  
are all pre-leopard and I have a feeling that its a bit more  
straightforward on leopard (i'm hoping). Can anyone point me in the  
right direction? (or has this already been done?) Its for personal  
use and not distribution so min specs 10.5.5 etc. is fine.


Leopard introduced a new API for this.  See NSView's  
enterFullScreenMode:withOptions: method.


-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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 read pixel values of monochrome images

2008-08-23 Thread John C. Randolph


On Aug 23, 2008, at 2:51 PM, Shawn Erickson wrote:


On Fri, Aug 22, 2008 at 2:54 AM, Eduardo Areitio [EMAIL PROTECTED] wrote:
I'm trying to read individual pixel values in a monochrome image  
using

NSReadPixel, but I haven't  been able to.

I would much appreciate anyone's help


It is usually best to post some code or better explain what you tried
and what is going wrong otherwise we have to guess at the difficulty
you are having.

Anyway...

http://developer.apple.com/samplecode/Color_Sampler/listing5.html


You'll notice from the comments in that sample, that NSReadPixel()  
gets a value from the graphics context that has the current drawing  
focus.  If you're trying to read a value from an image, you've got to  
have somewhere to draw it first.


-jcr

___

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

Please do not post admin requests or moderator comments to the list.
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: ObjC 2.0, properties, KVC, special _ hacks etc.

2008-08-23 Thread John C. Randolph


On Aug 21, 2008, at 7:59 PM, Thomas Engelmeier wrote:



Am 22.08.2008 um 00:59 schrieb Dave MacLachlan:

Also, are the _ in front of member variables for Apple only (so we  
don't stomp on each other with member var names) or are they using  
them for the readability reason mentioned above? There is  
documentation where they have claimed _ at the beginning of method  
names as being Apple only, but nothing about method vars, and the  
KVC compliance docs seem to imply that it is fine to do.


Officially it is Apple only, but everybody and his dog uses it - in  
consistency to quite some Apple-provided samples.


Please file bugs when you see a sample that does so.  A single leading  
underscore is an Apple internal coding convention, which should not be  
used for code samples.  I  did what I could to get those kinds of  
things fixed when I was there, but someone's got to file a bug for it  
to get noticed.


-jcr


___

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

Please do not post admin requests or moderator comments to the list.
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: !foo vs foo == nil

2008-08-20 Thread John C. Randolph


On Aug 20, 2008, at 4:15 PM, Torsten Curdt wrote:


There was a common perception that NULL is not really the same as  
nil. But seems like in the end it really is (void*)0.



They differ in type, not in value.

NULL is (void *) 0.
nil is (id) 0.
Nil is (Class) 0.

Personally, I prefer if (!foo) over if (foo == nil), because the  
latter has the hazard of a typo that compiles.  You can lose a fair  
bit of time staring at if (foo = nil) before you spot the mistake.


-jcr

___

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

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

2008-08-20 Thread John C. Randolph


On Aug 20, 2008, at 8:09 AM, Gordon Apple wrote:

   I just had a revelation I though I would share -- thanks to some  
sample

code David Duncan sent me.  When IB makes a connection, it calls the
outlet's accessor, if one is available.  That fact can be used to  
initialize
related items in your code.  Ok, maybe everybody but me already knew  
that,

but maybe a few don't know or just hadn't thought about it.


That's a legacy behavior that goes back to the days when NeXT was a  
bit more strict about encapsulation and data hiding.  It used to be  
that nib instantiation could only set values if accessors were  
available.


-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: !foo vs foo == nil

2008-08-20 Thread John C. Randolph


On Aug 20, 2008, at 5:04 PM, j o a r wrote:



On Aug 20, 2008, at 4:56 PM, John C. Randolph wrote:

Personally, I prefer if (!foo) over if (foo == nil), because  
the latter has the hazard of a typo that compiles.  You can lose a  
fair bit of time staring at if (foo = nil) before you spot the  
mistake.



There is a GCC warning to help you with that, but in addition, you  
can learn to type:


if (nil == foo)

Problem solved!   :-)


...at the cost of five additional keystrokes, not to mention the  
aesthetics.


-jcr

___

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

Please do not post admin requests or moderator comments to the list.
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: tracking area problems on 10.4.11

2008-07-04 Thread John C. Randolph


On Jul 2, 2008, at 11:21 AM, Wesley Smith wrote:


I did that.  my window and content view both have those methods
defined.  I've tried setting both of them to owner to no avail :(



From QA #1355:

Technical QA QA1355
Why aren't my tracking rects working?
Q: I'm trying to implement tracking rectangles so that I can recieve - 
mouseEntered: and -mouseExited: messages and provide visual feedback  
to the user. I've sent my view an - 
addTrackingRect:owner:userData:assumeInside:message, but it seems to  
have no effect.
A: This symptom usually results from trying to set tracking rectangles  
before your view has been added to a window.


Although NSView implements the - 
addTrackingRect:owner:userData:assumeInside: method, the list of  
tracking rectangles is kept by the window, not the view. When your - 
initWithFrame: method is executed, your view is not yet associated  
with any window, so the view can't actually set any tracking rects.


A better place to send your -addTrackingRect:.. messages is in a - 
viewDidMoveToWindow: or -awakefromNib method.

___

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

Please do not post admin requests or moderator comments to the list.
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 do I draw text on a custom button?

2008-06-21 Thread John C. Randolph

Michael,

By implementing -drawRect: in your view class, you become responsible  
for all drawing in that view.  The code below doesn't attempt to draw  
the text, it only sets a value.


To draw text in the current drawing context, see the - 
drawAtPoint:withAttributes: method of NSString for one way to to do so.


I won't go into the intricacies of NSControl and NSCell just yet.

-jcr


On Jun 21, 2008, at 12:44 AM, Michael A. Crawford wrote:

I'm using a CustomView that inherits from NSButton.  I have no  
problem drawing the graphical representation of the button in the  
view but it is not immediately obvious to me how to draw text.   
setTitle does not work with my custom button.  Can you point me to  
some examples?  Here is the code:


#import Cocoa/Cocoa.h

@interface TwoStateButton : NSButton
{}

@end

- (void)drawRect:(NSRect)rect
{
// draw initial black button
NSRect bounds = [self bounds];
[[NSColor blackColor] set];
[NSBezierPath fillRect:bounds];

// draw green LED inset in button (grey if not on)
bounds.origin.x += (bounds.size.width * 0.25) / 2;
bounds.origin.y += bounds.size.height * 0.25;
bounds.size.width *= 0.75;
bounds.size.height *=  0.25;

if ( NSOnState == [self state] )
{
[[NSColor greenColor] set];
}
else
{
[[NSColor lightGrayColor] set];
}

[NSBezierPath fillRect:bounds];
[self setTitle:@NDB];
}

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jcr%40mac.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: Race in Apple's NSTreeContoller/NSOutlineView

2008-06-21 Thread John C. Randolph


On Jun 21, 2008, at 12:44 AM, Godfrey van der Linden wrote:

Ok I gave up.  No response was expected and I received what I  
expected.



Godfrey,

Being a former Apple engineer, you should know as well as any of us  
that nobody is assigned to glean bug reports from the mailing lists.   
Until and unless you file this in Radar, it's not a bug, it's just a  
gripe.


-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: CoreData local and on server sync

2008-06-21 Thread John C. Randolph


On Jun 21, 2008, at 3:33 AM, René v Amerongen wrote:


Dear All,

Does someone has any experience about having a local data store  
which is syncing wit the server store using Coredata?


Rene,

This is not what CoreData is intended to do.  CoreData is for local  
storage of object maps, and really doesn't deal with the issues of  
database synchronization across multiple users on multiple hosts.


I would recommend looking into OpenBase and FrontBase, which are both  
SQL database products that offer an Objective-C API.


-jcr

___

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

Please do not post admin requests or moderator comments to the list.
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: Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread John C. Randolph
I didn't say not to use Ruby if you want.  What I took exception to is  
your statement that you don't have to fully learn Objective-C's  
syntax at the same time as Cocoa.   Use whatever language you like,  
but if you're going to use Cocoa, you'd *better* learn Objective-C.


-jcr

___

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

Please do not post admin requests or moderator comments to the list.
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: Learning Cocoa with RubyCocoa (was Regular Expressions)

2008-06-07 Thread John C. Randolph


On Jun 7, 2008, at 7:38 AM, Jose Raul Capablanca wrote:

I never understood why Apple stopped supporting the Java bridge to  
Cocoa.



Two reasons:  First, not enough people were using it to make it cost- 
effective to maintain, and second, it was sucking up a lot of  
development time when new classes were added to the frameworks.   
Java's fundamental deficiencies make it far more difficult to bridge  
than Ruby and Python.


The Java bridge came into existence for political reasons, and those  
political reasons have become moot.


-jcr


___

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

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

2008-06-06 Thread John C. Randolph


On Jun 6, 2008, at 2:10 AM, Allison Newman wrote:

 you don't have to fully learn Objective C's syntax at the same time  
as Cocoa.


Ok, all kinds of alarm bells just went off.   Obj-C is a very small  
delta from C, and if you avoid learning it, you will regret it.


-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: Cover Flow in Cocoa?

2008-05-29 Thread John C. Randolph


On May 28, 2008, at 2:19 PM, Scott Anguish wrote:


I really can't stress how bad an idea using private API is.


Speaking as a former DTS engineer, I will second Scott's statement  
above.


-jcr
___

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

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

2008-05-15 Thread John C. Randolph
I got caught procrastinating, too.  Anyone who can't make it to the  
show and wants to sell their ticket, I'm interested.


-jcr


John C. Randolph,
VP, Engineering
Stealth Imaging, Inc. [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: Event loop in a secondary thread? Nibless Cocoa?

2008-05-03 Thread John C. Randolph


On May 3, 2008, at 4:35 PM, Bruce Sherwood wrote:

 We very much want a native-mode version of Visual.


If you want a native app, then don't fight the framework.  Rolling  
your own event system, and doing away with nib files is not a project  
for someone new to the platform, and once you have experience with  
Cocoa, you'll know better than to reinvent the wheel.


-jcr
___

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

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

2008-04-26 Thread John C. Randolph


On Apr 25, 2008, at 10:18 PM, Aaron Wallis wrote:

I've been having a fair few issues with NSBezier boxes lately (a.k.a  
boxes with rounded corners)


I've created a NSView subclass that contains the following code,  
then threw a few on a window with some controls over the top:

- ( void ) drawRect: ( NSRect ) rect
{
NSBezierPath* thePath = [NSBezierPath bezierPath];
  	[thePath appendBezierPathWithRoundedRect:rect xRadius:10.0  
yRadius:10.0];


Change the line above to:

	[thePath appendBezierPathWithRoundedRect:[self bounds] xRadius:10.0  
yRadius:10.0];


and you should get what you want, although it would still be less than  
ideal code.



Any ideas?


Several things.  First, the rectangle you get as a parameter to - 
drawRect: is often smaller than the view recieving the message.  The  
rect is given so that you don't have to draw the entire view every  
time.  (See also -needsToDrawRect:, if you want to optimize this.)   
Second, figure out your drawing geometry in -setFrame:, not in - 
drawRect:.   -drawRect: itself should be as little code as possible,  
because it can be invoked at any time.


-jcr


___

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

Please do not post admin requests or moderator comments to the list.
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 import drawing paths into a Cocoa application?

2008-04-26 Thread John C. Randolph


On Apr 21, 2008, at 5:35 PM, Graham Cox wrote:


- (NSPoint) pointOnPathAtLength:(float) length slope:(float*) slope;


I notice that your lengthOfBezier() function does an approximation  
similar to what we'd get in postscript by executing flattenpath and  
then adding up the lengths of the resulting line segments.


I've asked several math majors over the years if they could give me an  
exact function for the length of a bezier curve.  They've generally  
told me it was possible, but none of them actually produced it.


If there are any mathematicians on this list who can solve for the  
length of a bezier cubic spline, please enlighten me!


-jcr

___

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

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

2008-04-03 Thread John C. Randolph


On Apr 3, 2008, at 11:19 AM, Kristan Kennedy wrote:


I desperately need to hire two Mid-Level Mac/Cocoa Developers.


Cocoa-dev is a technical discussion list. If you have a job opening,  
then post a description of the position, and include [JOB] in the  
title.  If anyone's interested, they'll contact you.


-jcr
___

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

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

2008-03-25 Thread John C. Randolph


On Mar 24, 2008, at 10:30 PM, Alex ROUGE wrote:

Hi everybody.
I guess it's not the best place to put my request but perhaps you  
can help with a CoreAudio / AudioUnit question.


Try here:

http://lists.apple.com/mailman/listinfo/coreaudio-api

Cocoa-dev is a pretty high-volume list, and you're far more likely to  
get a timely reply from one of Apple's CoreAudio guys on their more  
specific mailing list.


-jcr



This is not a book to be tossed aside lightly. Rather, it should be  
hurled with great force. -Dorothy Parker


___

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

Please do not post admin requests or moderator comments to the list.
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 do I disable this warning: local declaration of 'varname' hides instance variable

2008-03-24 Thread John C. Randolph


On Mar 23, 2008, at 10:31 PM, Dave Hersey wrote:

If it's really important to you, send an incident to DTS and pay  
them $195 for the answer. I suspect they'll tell you what we've told  
you.


Speaking as a former Apple DTS engineer, I would ask you not to advise  
Charlie to waste their time in this manner.


-jcr

___

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

Please do not post admin requests or moderator comments to the list.
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 do I disable this warning: local declaration of 'varname' hides instance variable

2008-03-24 Thread John C. Randolph


On Mar 23, 2008, at 10:04 PM, charlie wrote:


I could care less what anyone else thinks about this decision.


The phrase you're trying to use is couldn't care less.  Think about  
it for a second, try to parse it.


In any case, if you're going to be surly when people who know more  
than you do give you advice, then you should probably just unsubscribe  
from cocoa-dev.


-jcr 
___


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

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

2008-03-24 Thread John C. Randolph


On Mar 24, 2008, at 4:19 AM, Eddy Hatcher wrote:

Hi,

I am detaching a selector A on a separate thread in another class.  
In this selector I am calling another selector B  in the same  
class using [self performSelector:@selector(B)];


Which thread will this selector B be run on? The main, or the one  
i created for A.


Any messages you send will be performed on the same thread unless you  
explicitly dispatch them to another thread.


-jcr
___

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

Please do not post admin requests or moderator comments to the list.
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: mysterious crash in [NSCell menu]

2008-03-05 Thread John C. Randolph


On Mar 5, 2008, at 5:45 AM, Hendrik Schreiber wrote:

a customer of mine experiences a crash that I cannot reproduce and  
that I have no idea where its coming from.
He is trying to export some photos from iPhoto using our export  
plugin (iP2F) and at some point always gets a Bus Error. I pasted a  
partial crash log below.
This person apparently has a few InputManager based plugins and all  
kinds of other stuff installed.


My bet is that the crashes are due to the haxies he's installed.  Ask  
him to check whether the  problem persists when he removes them.


-jcr
___

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

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

2008-02-25 Thread John C. Randolph

Check out the lasso style crop maker here:

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

-jcr

___

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

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