NSAlert get accessory view contents as string

Discussion in 'Mac Programming' started by RobRiley, Apr 29, 2009.

  1. RobRiley macrumors member

    Joined:
    Feb 4, 2009
    Location:
    London
    #1
    Hi,

    I'm sure someone will answer this in minutes :)

    I want to put the contents of an NSAlert accessory view into an NSString but don't know the correct syntax. Here's a broken down example of what I have:

    Code:
    NSTextView *accessory = [[NSTextView alloc] initWithFrame:NSMakeRect(0,0,200,40)];
    	[accessory insertText:[[NSAttributedString alloc] init]];
    	[accessory setEditable:YES];
    	[accessory setDrawsBackground:YES];
    NSAlert *alert = [[[NSAlert alloc] init] autorelease];
    [alert setAccessoryView:accessory];
    [alert addButtonWithTitle:NSLocalizedString(@"OK", nil)];
    NSInteger choice = [alert runModal];
    // get accessory view as string here!! 
    
    Thanks in advance!
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Code:
    NSString *text = [accessory string];
    Is that what you mean?
     
  3. RobRiley thread starter macrumors member

    Joined:
    Feb 4, 2009
    Location:
    London
    #3
    That's EXACTLY what I mean :)

    Thanks. That was literally minutes.
     

Share This Page