Re: NSDocument autosave doesn't show as edited

2012-05-24 Thread Martin Hewitson
Kevin, thanks for that. This was exactly the problem. My text view subclass asks its delegate for an undo manager, and I forgot to implement the delegate method in this particular document subclass. Many thanks! Martin On May 23, 2012, at 07:00 PM, Kevin Perry wrote: > > On May 23, 2012, at

Transforming UIImage (rotate, translate, scale) and then crop to constant size

2012-05-24 Thread Gustavo Adolfo Pizano
Hello all. I have an app which the user can transform an image (rotate, translate, scale), On top of this image is an image has, so mostly the user fits in the mask the portion of the image that he wants. Then I need to compose an image based on what is inside the mask. Problem is that the compos

Re: NSMutableData capacity

2012-05-24 Thread Andreas Grosam
Thank you for your replies. I appreciate your comments. Maybe you are interested in the background, and way I'm asking this. In fact, as some of you suspected, the reason for asking has to do with performance. The NSMutable data shall serve as an internal buffer of some "Streambuffer" class wh

stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Jason Teagle
I have need of rendering text manually to a UIView, along with graphics. I realise that I could probably use a UITextView as a subview and position it, but for now I'd like to learn the right way to render it manually. My aim is to render a particular string in a particular colour, in a parti

Arc and autorelease

2012-05-24 Thread Gerriet M. Denkmann
Without Arc, this: NSString *s = [ [ NSString alloc ] initWithFormat: ...]; [ someCollection addObject: s ]; [ s release ]; is clearly more efficient (because not using autoreleasepools) than: NSString *s = [ NSString stringWithFormat: ...]; [ someCollection addObject: s ]; But what about Arc?

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Mikkel Islay
Jason, Have a look at this doc-page: https://developer.apple.com/library/mac/ipad/#documentation/graphicsimaging/conceptual/drawingwithquartz2d/dq_text/dq_text.html It discusses your options when drawing text with Quartz2D, and also mentions other techniques. One option of note is the NSString ad

Multiple Inheritance

2012-05-24 Thread Gerriet M. Denkmann
I have an abstract class M with subclasses MAB, MAX, MXB. There are several lengthy methods A which are used in MAB and MAX, and others methods B which are used in MAB and MXB. Methods A use a property NSUInteger index. Class MXB has no such property, is has NSIndexSet *indices instead. Similar

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Conrad Shultz
Greetings Jason, On 5/24/12 12:49 AM, Jason Teagle wrote: > I have need of rendering text manually to a UIView, along with graphics. > I realise that I could probably use a UITextView as a subview and > position it, but for now I'd like to learn the right way to render it > manually. Please see t

Re: Multiple Inheritance

2012-05-24 Thread Graham Cox
Turn it into two separate protocols instead, and adopt whichever protocols are needed in the concrete implementations. Or if one protocol is a superset of the other, a protocol can extend another. --Graham On 24/05/2012, at 7:14 PM, Gerriet M. Denkmann wrote: > Other, better solutions?

Re: Multiple Inheritance

2012-05-24 Thread Thomas Davie
Implement abstract classes that implement the methods, then use the runtime to copy the methods into the classes that should have them in +initialize. Bob On 24 May 2012, at 10:14, Gerriet M. Denkmann wrote: > I have an abstract class M with subclasses MAB, MAX, MXB. > > There are several leng

Page number in UIWebView

2012-05-24 Thread Takeichi Kanzaki Cabrera
Hello everyone, I'm displaying a PDF in an UIWebView object, is there a way to access the page number displayed when scrolling? -- Regards, Takeichi Kanzaki Cabrera Linux Registered User #308138 If you want to be original, be your self. ___ Cocoa-dev

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Jason Teagle
Have a look at this doc-page: https://developer.apple.com/library/mac/ipad/#documentation/graphicsimaging/ >conceptual/drawingwithquartz2d/dq_text/dq_text.html It discusses your options when drawing text with Quartz2D, and also mentions >other techniques. >One option of note is the NSString ad

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Jason Teagle
You probably want UILabel. UITextView is a much more heavyweight class that supports editing as well as display. (My bad, a label is called a TextView on Android - got mixed up.) These both are just wasting CPU cycles and adding extraneous code. Simply use: NSString *textToDraw = @"my stri

NSWindowController subclasses, and retain cycles

2012-05-24 Thread Jonathan Taylor
I have been battling a retain cycle for a couple of hours, assuming I am at fault, but I am starting to think there is something fishy going on. Can anybody advise? - I have a window controller subclass (and associated window) A, and a separate window controller subclass (and associated window)

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Manfred Schwind
> CGContextShowTextAtPoint(contextRef, 0, 40, > [textToDraw UTF8String], [textToDraw length]); One bug I see here: you're passing a wrong length parameter. CGContextShowTextAtPoint expects the length of the char array (number of bytes of the UTF-8 encoded string), but you'e passing the numb

Re: NSWindowController subclasses, and retain cycles

2012-05-24 Thread Fritz Anderson
On 24 May 2012, at 9:26 AM, Jonathan Taylor wrote: > - I have a window controller subclass (and associated window) A, and a > separate window controller subclass (and associated window) B. B contains a > property, designated 'retain', that keeps a pointer to A. B is > programatically closed fir

Re: NSWindowController subclasses, and retain cycles

2012-05-24 Thread Charles Srstka
On May 24, 2012, at 10:21 AM, Fritz Anderson wrote: > On 24 May 2012, at 9:26 AM, Jonathan Taylor wrote: > >> - I have a window controller subclass (and associated window) A, and a >> separate window controller subclass (and associated window) B. B contains a >> property, designated 'retain', t

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread James Montgomerie
On 24 May 2012, at 15:36, Manfred Schwind wrote: >> CGContextShowTextAtPoint(contextRef, 0, 40, >> [textToDraw UTF8String], [textToDraw length]); > > One bug I see here: you're passing a wrong length parameter. > CGContextShowTextAtPoint expects the length of the char array (number of > byte

Re: Arc and autorelease

2012-05-24 Thread Ken Thomases
On May 24, 2012, at 3:14 AM, Gerriet M. Denkmann wrote: > Without Arc, this: > > NSString *s = [ [ NSString alloc ] initWithFormat: ...]; > [ someCollection addObject: s ]; > [ s release ]; > > is clearly more efficient (because not using autoreleasepools) than: > > NSString *s = [ NSString str

Re: NSWindowController subclasses, and retain cycles

2012-05-24 Thread Kyle Sluder
On May 24, 2012, at 10:26 AM, Jonathan Taylor wrote: > I have been battling a retain cycle for a couple of hours, assuming I am at > fault, but I am starting to think there is something fishy going on. Can > anybody advise? > > - I have a window controller subclass (and associated window) A, a

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread glenn andreas
On May 24, 2012, at 9:36 AM, Manfred Schwind wrote: >> CGContextShowTextAtPoint(contextRef, 0, 40, >> [textToDraw UTF8String], [textToDraw length]); > > One bug I see here: you're passing a wrong length parameter. > CGContextShowTextAtPoint expects the length of the char array (number of >

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Kyle Sluder
On May 24, 2012, at 10:36 AM, Manfred Schwind wrote: >> CGContextShowTextAtPoint(contextRef, 0, 40, >>[textToDraw UTF8String], [textToDraw length]); > > One bug I see here: you're passing a wrong length parameter. Another bug: CGContextShowztextAtPoint takes characters encoded in MacRoman,

Re: Multiple Inheritance

2012-05-24 Thread Ken Thomases
On May 24, 2012, at 4:14 AM, Gerriet M. Denkmann wrote: > I have an abstract class M with subclasses MAB, MAX, MXB. > > There are several lengthy methods A which are used in MAB and MAX, and others > methods B which are used in MAB and MXB. > > Methods A use a property NSUInteger index. > Class

Re: NSMutableData capacity

2012-05-24 Thread Jens Alfke
On May 24, 2012, at 12:43 AM, Andreas Grosam wrote: > While I experienced, that this approach is much faster than appending bytes > using NSMutableData methods, the above implementation could be still better > when having something like a -capacity method for a NSMutableData object > which is

Re: Multiple Inheritance

2012-05-24 Thread Jens Alfke
Implement both A and B in the base class M, but don't declare them in its @interface. Then MAB and MAX can both declare method A and have implementations that just call super. Likewise for B. Or, factor out A into a helper class, and similarly for B. Then have MAB and MAX instantiate an A helpe

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Jens Alfke
On May 24, 2012, at 5:50 AM, Jason Teagle wrote: > (I've since discovered that the %@ and @"xxx" way works just fine, so I'll > stick with that. Good :) The problem with using "%s" is that it doesn't work well with non-ASCII characters. Cocoa has to assume some character encoding to map the by

Re: NSWindowController subclasses, and retain cycles

2012-05-24 Thread Ken Thomases
On May 24, 2012, at 9:26 AM, Jonathan Taylor wrote: > There appears to be some weird runtime voodoo behind the scenes involving > NSAutounbinder, which I think is what should ultimately be sending the final > release to A. That is what sends the final release to B, but that final > release for

Re: NSWindowController subclasses, and retain cycles

2012-05-24 Thread Jonathan Taylor
On 24 May 2012, at 16:27, Kyle Sluder wrote: >> 1. If I do not set B's pointer to A, both A and B are deallocated correctly >> 2. If instead I set B's pointer to A, but reset it to nil just before B is >> closed, both A and B are deallocated correctly >> 3. If instead B still has a live pointer to

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Ken Thomases
On May 24, 2012, at 2:49 AM, Jason Teagle wrote: > First, a quick question about +stringWithFormat: If I want to have a literal > string as one of the parameters to the format, which is correct / best: > > NSString *textToDraw = [NSString stringWithFormat: @"%s", > "my string"]; > > or >

Re: Multiple Inheritance

2012-05-24 Thread Gerriet M. Denkmann
On 24 May 2012, at 17:37, Graham Cox wrote: > Turn it into two separate protocols instead, and adopt whichever protocols > are needed in the concrete implementations. Or if one protocol is a superset > of the other, a protocol can extend another. I thought that a protocol only declares methods

Re: Transforming UIImage (rotate, translate, scale) and then crop to constant size

2012-05-24 Thread David Duncan
On May 24, 2012, at 12:19 AM, Gustavo Adolfo Pizano wrote: > For the transformation I'm using gesture recognizers. > when I want to compose the image this is are the steps I'm doing > > UIGraphicsBeginImageContext(size) //size is a CGSize with 900x567 > CGContextRef ctx = UIGraphicsGetCurrentCon

Re: Page number in UIWebView

2012-05-24 Thread David Duncan
On May 24, 2012, at 4:05 AM, Takeichi Kanzaki Cabrera wrote: > Hello everyone, I'm displaying a PDF in an UIWebView object, is there a way > to access the page number displayed when scrolling? Nope. -- David Duncan ___ Cocoa-dev mailing list (Cocoa-

Re: Arc and autorelease

2012-05-24 Thread David Duncan
On May 24, 2012, at 1:14 AM, Gerriet M. Denkmann wrote: > Without Arc, this: > > NSString *s = [ [ NSString alloc ] initWithFormat: ...]; > [ someCollection addObject: s ]; > [ s release ]; > > is clearly more efficient (because not using autoreleasepools) than: > > NSString *s = [ NSString str

Re: Multiple Inheritance

2012-05-24 Thread Jens Alfke
On May 24, 2012, at 4:15 AM, Gerriet M. Denkmann wrote: > How do I avoid duplicating method implementations using a protocol? You don't, other than by using techniques like the ones I described. Protocols are just for the convenience (and type-safety) of the _users_ of a class; they don't real

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Jason Teagle
Thanks for all the replies regarding %s vs. %@, and the rather disastrous attempt at using CGContextXXX methods. Even if I had fixed all the other issues, I was using CGContextSelectFont incorrectly anyway. I didn't have a hope. That, unfortunately, is down to documentation not being complete /

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread Fritz Anderson
On 24 May 2012, at 1:57 PM, Jason Teagle wrote: > If the CGContextXXX methods shouldn't be used, then they shouldn't be in the > API - or should be marked as deprecated. There's nothing in the docs (with > Xcode 3.X, at least - maybe it's changed since) to indicate that these were > the worst w

NSEvent and postEvent:atStart

2012-05-24 Thread koko
How does one create and then receive a user defined event? I have read and find only what appears to me to be heavyweight processes. So if I create an NSEvent and then use postEvent:atStart what I am not getting is how is a method in an object associated with the NSEvent? Or should I just fuge

Re: NSEvent and postEvent:atStart

2012-05-24 Thread Graham Cox
On 25/05/2012, at 10:58 AM, koko wrote: > How does one create and then receive a user defined event? > > I have read and find only what appears to me to be heavyweight processes. > > So if I create an NSEvent and then use postEvent:atStart what I am not > getting is how is a method in an obje

Re: NSEvent and postEvent:atStart

2012-05-24 Thread koko
Can you point me to the docs that cover pulling events off the queue? Thanks. -koko On May 24, 2012, at 7:56 PM, Graham Cox wrote: > Another object will pull events off the queue. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not

Re: NSEvent and postEvent:atStart

2012-05-24 Thread Graham Cox
[NSWindow nextEventMatchingMask:untilDate:inMode:dequeue:] [NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] On 25/05/2012, at 12:40 PM, koko wrote: > Can you point me to the docs that cover pulling events off the queue? > > Thanks. > > -koko > > On May 24, 2012, at 7:56 PM

Re: NSEvent and postEvent:atStart

2012-05-24 Thread Ken Thomases
On May 24, 2012, at 11:53 PM, Graham Cox wrote: > On 25/05/2012, at 12:40 PM, koko wrote: > >> On May 24, 2012, at 7:56 PM, Graham Cox wrote: >> >>> Another object will pull events off the queue. >> >> Can you point me to the docs that cover pulling events off the queue? > > [NSWindow nextEve

Sending a list of path strings to the Finder via Scripting Bridge

2012-05-24 Thread Peter
Hi, I'd like to reveal/select multiple items in the Finder. NSWorkspace only handles single files as in [[NSWorkspace sharedWorkspace] selectFile:currentFilePath inFileViewerRootedAtPath:currentFilePath]; I searched Google and tried to pick up every scra