• 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
Need Help Creating an OutlineView for TabView selection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need Help Creating an OutlineView for TabView selection


  • Subject: Need Help Creating an OutlineView for TabView selection
  • From: James Housley <email@hidden>
  • Date: Wed, 31 Aug 2005 09:48:09 -0400

I would like to use an NSOutlineView to drive my preferences for selecting the tabs. I am having some trouble creating my datasource for this. I have attached a code attempt that used CFXMLTree, that worked except for I ended up with a root node that only had a subnode, which isn't what I really wanted. I want it to look more like

▼ Group 1
     division 1
     division 2
▼ Group 2
     area 1
     area 2
     area 3
     area 4

I have search but have not been able to really find much on this. Since I probably missed this searching with a wrong search term, any pointers would be appreciated.

Jim

=================================================

@implementation OutlineTab

- (id)init
{
	self = [super init];

NSString *XMLTreeString = @"<node name=\"Group 1\"><node name=\"division 1\"/><node name=\"division 2\"/></node><node name=\"Group 2\"><node name=\"area 1\"/><node name=\"area 2\"/><node name=\"area 3\"/><node name=\"area 4"/></node>";
root = CFXMLTreeCreateFromData(kCFAllocatorDefault, (CFDataRef)[XMLTreeString dataUsingEncoding:NSUnicodeStringEncoding], NULL, kCFXMLParserSkipWhitespace, kCFXMLNodeCurrentVersion);


	return self;
}

// data source methods
- (int)outlineView:(NSOutlineView*)outlineView numberOfChildrenOfItem:(id)item
{
if (root == nil) return 0;

if (item == nil)
{
return CFTreeGetChildCount(root);
}
else
{
return CFTreeGetChildCount((CFXMLTreeRef)item);
}
}


- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
if (item == nil)
return NO;

return (CFTreeGetChildCount((CFXMLTreeRef)item) != 0);
}


- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
{
if (item == nil)
{
return (id)root;
}
else
{
if (item == nil)
{
return nil;
}
if (CFTreeGetChildCount((CFXMLTreeRef)item) == 0)
{
return nil;
}
else
{
if (index >= CFTreeGetChildCount((CFXMLTreeRef)item))
{
return nil;
}
return (id)CFTreeGetChildAtIndex((CFXMLTreeRef)item, index);
}
return nil;
}
}


- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
if (item == nil)
{
return @"/";
}
else
{
CFXMLNodeRef treeNode;
const CFXMLElementInfo *elementInfo;


        if ((CFXMLTreeRef)item == nil)
			return @"";

treeNode = CFXMLTreeGetNode((CFXMLTreeRef)item);
elementInfo = CFXMLNodeGetInfoPtr(treeNode);
if ([(NSDictionary *)(*elementInfo).attributes objectForKey:@"name"] == nil)
return @"";
return [(NSDictionary *)(*elementInfo).attributes objectForKey:@"name"];
}
}


@end

--

/"\   ASCII Ribbon Campaign  .
\ / - NO HTML/RTF in e-mail  .
 X  - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------
email@hidden      http://www.FreeBSD.org     The Power to Serve
email@hidden  http://www.TheHousleys.net
---------------------------------------------------------------------
Q: Because it reverses the logical flow of conversation.
A: Why is putting a reply at the top of the message frowned upon?

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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: Need Help Creating an OutlineView for TabView selection
      • From: Jeff LaMarche <email@hidden>
  • Prev by Date: Re: RTFD file corruption
  • Next by Date: Re: Need Help Creating an OutlineView for TabView selection
  • Previous by thread: Re: RTFD file corruption
  • Next by thread: Re: Need Help Creating an OutlineView for TabView selection
  • Index(es):
    • Date
    • Thread