• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
AddressBook/NSTableView Signal 11 crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AddressBook/NSTableView Signal 11 crash


  • Subject: AddressBook/NSTableView Signal 11 crash
  • From: Josh Kritner <email@hidden>
  • Date: Fri, 7 Oct 2005 02:56:44 -0400

I've just started using Cocoa and Objective-C in the past few days,
running through some of the ADC tutorials, and in this case.
experimenting with the AddressBook Framework in Tiger.

Essentially my little App just displays my name in an NSTextField,
then all the people in my Address Book in an NSTableView. I use the
same Class to populate the Text field, and act as a Data Source for
the NSTableView.  This seems to work, code compiles without warnings,
and everything displays as it should, but when I try to resize the
window, or if I just click on any of the names in the table, the app
crashes with a "Signal 11 (SIGSEGV)".  Using the debugger, I have
tracked the offending line to the one I have marked in the code below,
I have included the contents of both the header and implementation
files in case my error isn't where I think it is. :-)

//Header
/* NameViewerController */

#import <Cocoa/Cocoa.h>
#import <AddressBook/AddressBook.h>

@interface NameViewerController : NSObject
{
    IBOutlet NSTextField *nameField;
    @private ABAddressBook *book;
    @private NSArray *myBuddies;
}
@end

//Implementation
#import "NameViewerController.h"

@implementation NameViewerController
-(void)awakeFromNib
{
    book = [ABAddressBook sharedAddressBook];
    myBuddies = [book people];

    ABPerson *josh = [book me];

    NSString *fname = [josh valueForProperty:kABFirstNameProperty];
    NSString *lname = [josh valueForProperty:kABLastNameProperty];
    NSString *myName = [NSString stringWithFormat:@"%@ %@", fname, lname];

    [nameField setStringValue:myName];
}

//Added so this class can act as a Data Source for NSTableView
-(int)numberOfRowsInTableView:(NSTableView *)aTableView
{
    return [myBuddies count];
}

-(id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
    ABPerson *person = [myBuddies objectAtIndex:rowIndex]; //<---  App
dies when it hits this line

    NSString *fname = [person valueForProperty:kABFirstNameProperty];
    NSString *lname = [person valueForProperty:kABLastNameProperty];
    NSString *pName;
    if(fname != nil)
    {
        pName = [NSString stringWithFormat:@"%@ %@", fname, lname];
    }
    else
    {
       //Really isn't a person, just a company...
        pName = @"Company";
    }
    return pName;
}

@end


>From searching around, It seems that Signal 11 is some sort of Memory
error, but I can't find enough info to know what I'm doing wrong and
how to fix it :-)

If anyone has any suggestions, ideas, or even just sarcastic jabs at
the newbie, I'd appreciate any help you can offer.

Thanks,
--
Josh Krtitner
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: AddressBook/NSTableView Signal 11 crash
      • From: Yann Bizeul <email@hidden>
  • Prev by Date: NSOutlineView as drag destination
  • Next by Date: Re: AddressBook/NSTableView Signal 11 crash
  • Previous by thread: Re: NSOutlineView as drag destination
  • Next by thread: Re: AddressBook/NSTableView Signal 11 crash
  • Index(es):
    • Date
    • Thread