Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add item class and use subtitle for table and disclosure button

  • Loading branch information...
commit ce146aab8232bd052b303ceb8c924271a0027977 1 parent 4e793b6
@phoet authored
View
21 Classes/Item.h
@@ -0,0 +1,21 @@
+//
+// Item.h
+// dzone
+//
+// Created by Peter Schröder on 12.07.10.
+// Copyright 2010 blau Mobilfunk GmbH. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@interface Item : NSObject {
+
+ NSString* title;
+ NSString* category;
+}
+
+@property(nonatomic, retain) NSString* title;
+@property(nonatomic, retain) NSString* category;
+
+@end
View
17 Classes/Item.m
@@ -0,0 +1,17 @@
+//
+// Item.m
+// dzone
+//
+// Created by Peter Schröder on 12.07.10.
+// Copyright 2010 blau Mobilfunk GmbH. All rights reserved.
+//
+
+#import "Item.h"
+
+
+@implementation Item
+
+@synthesize title;
+@synthesize category;
+
+@end
View
12 Classes/dzoneAppDelegate.m
@@ -8,8 +8,8 @@
#import "dzoneAppDelegate.h"
#import "dzoneViewController.h"
-#import "XMLParser.h"
#import "TBXML.h"
+#import "Item.h"
@implementation dzoneAppDelegate
@@ -31,7 +31,15 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application {
TBXMLElement* titleElement = [TBXML childElementNamed:@"title" parentElement:element];
NSString * title = [TBXML textForElement:titleElement];
NSLog(@"element has title %@", title);
- [viewController.listData addObject:[title stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
+
+ TBXMLElement* categoryElement = [TBXML childElementNamed:@"category" parentElement:element];
+ NSString * category = [TBXML textForElement:categoryElement];
+ NSLog(@"element has category %@", category);
+
+ Item * item = [[[Item alloc] init] autorelease];
+ item.title = [title stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ item.category = [category stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ [viewController.listData addObject:item];
} while ((element = element->nextSibling));
// Override point for customization after app launch
View
8 Classes/dzoneViewController.m
@@ -7,6 +7,7 @@
//
#import "dzoneViewController.h"
+#import "Item.h"
@implementation dzoneViewController
@@ -78,10 +79,13 @@ - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier];
if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Identifier] autorelease];
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:Identifier] autorelease];
+ cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
NSUInteger row = [indexPath row];
- cell.textLabel.text = [listData objectAtIndex:row];
+ Item* item = [listData objectAtIndex:row];
+ cell.textLabel.text = item.title;
+ cell.detailTextLabel.text = item.category;
return cell;
}
View
6 dzone.xcodeproj/project.pbxproj
@@ -18,6 +18,7 @@
4EA3EF3B11EB8BFD0040B8CD /* TBXML.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EA3EF3711EB8BFD0040B8CD /* TBXML.m */; };
4EA3EF3C11EB8BFD0040B8CD /* NSDataAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EA3EF3911EB8BFD0040B8CD /* NSDataAdditions.m */; };
4EA3EF3E11EB8C400040B8CD /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4EA3EF3D11EB8C400040B8CD /* libz.dylib */; };
+ 4EA3EFC011EB9D8F0040B8CD /* Item.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EA3EFBF11EB9D8F0040B8CD /* Item.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -39,6 +40,8 @@
4EA3EF3911EB8BFD0040B8CD /* NSDataAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSDataAdditions.m; sourceTree = "<group>"; };
4EA3EF3A11EB8BFD0040B8CD /* NSDataAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSDataAdditions.h; sourceTree = "<group>"; };
4EA3EF3D11EB8C400040B8CD /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
+ 4EA3EFBE11EB9D8F0040B8CD /* Item.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Item.h; sourceTree = "<group>"; };
+ 4EA3EFBF11EB9D8F0040B8CD /* Item.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Item.m; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* dzone-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "dzone-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -64,6 +67,8 @@
1D3623250D0F684500981E51 /* dzoneAppDelegate.m */,
28D7ACF60DDB3853001CB0EB /* dzoneViewController.h */,
28D7ACF70DDB3853001CB0EB /* dzoneViewController.m */,
+ 4EA3EFBE11EB9D8F0040B8CD /* Item.h */,
+ 4EA3EFBF11EB9D8F0040B8CD /* Item.m */,
);
path = Classes;
sourceTree = "<group>";
@@ -190,6 +195,7 @@
28D7ACF80DDB3853001CB0EB /* dzoneViewController.m in Sources */,
4EA3EF3B11EB8BFD0040B8CD /* TBXML.m in Sources */,
4EA3EF3C11EB8BFD0040B8CD /* NSDataAdditions.m in Sources */,
+ 4EA3EFC011EB9D8F0040B8CD /* Item.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Please sign in to comment.
Something went wrong with that request. Please try again.