Yes, they are. Sorry, I was over selective in my first post in an attempt to 
just show the salient points. Here's a more complete excerpt from the code that 
sets up the text storage etc:

                // Get the string from the File entity
                NSError *error = nil;
                NSString *str = [[NSString alloc] initWithData:[file 
valueForKey:@"content"]
                                                      
encoding:NSUTF8StringEncoding];
                if (error) {
                        [NSApp presentError:error];
                        return nil;
                }
                
                // Setup undo manager for this file
                undoManager = [[NSUndoManager alloc] init];
                
                // Setup a text storage to hold this string
                NSMutableAttributedString *attStr = 
[[[NSMutableAttributedString alloc] initWithString:str] autorelease];
                
                textStorage = [[NSTextStorage alloc] 
initWithAttributedString:attStr];
                                                                                
        
                // Add a main layout manager
                NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
                [layoutManager setAllowsNonContiguousLayout:NO];
                [textStorage addLayoutManager:layoutManager];
                                
                // Now add the container to the layout manager
                NSTextContainer *textContainer = [[NSTextContainer alloc] init];
                [layoutManager addTextContainer:textContainer];
                                
                // Clean up
                [textContainer release];
                [layoutManager release];
                [str release];


I think that's all ok, but I could be wrong. Again, the main point seems to be 
that this works as long as "str" is not empty. If it is, then I get those 
exceptions when the first character is typed in the text view.

Thanks again,

Martin



On Apr 7, 2010, at 6:27 PM, Stephen J. Butler wrote:

> On Wed, Apr 7, 2010 at 1:31 AM, Martin Hewitson
> <[email protected]> wrote:
>>                // Clean up
>>                [textContainer release];
>>                [layoutManager release];
>>                [str release];
> 
> Are you sure that all these are balanced releases? The only one you
> show allocating is layoutManager. In particular, the [str release]
> concerns me.
> _______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/martin.hewitson%40aei.mpg.de
> 
> This email sent to [email protected]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
    Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: [email protected]
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





_______________________________________________

Cocoa-dev mailing list ([email protected])

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

Reply via email to