Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sagarshivam

macrumors member
Original poster
May 24, 2011
51
0
Dear All

Being a newbie, I divided my application into small separate application and they all worked fine. now when I am trying to integrate, problem arises.

I am trying to post some part of the project's code where I am facing the real problem. May be my fundamentals are wrong. But plz help, I am ready to work on it.

SimpleTableViewAppDelegate.h
Code:
@class RootViewController;
@class DetailViewController;

@interface SimpleTableViewAppDelegate: NSObject <UIApplicationDelegate> {
 
    UIWindow *window;
    UISplitViewController *splitViewController;
    RootViewController *rootViewController;
    DetailViewController *detailViewController;
    UINavigationController *rootNav;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UISplitViewController *splitViewController;
@property (nonatomic, retain) IBOutlet RootViewController *rootViewController;
@property (nonatomic, retain) IBOutlet DetailViewController *detailViewController;
@property (nonatomic, retain) IBOutlet UINavigationController *rootNav;

@end


SimpleTableViewAppDelegate.m
Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {

rootViewController = [[RootViewController alloc] initWithStyle:UITableViewStylePlain];
rootNav=[[UINavigationController alloc]initWithRootViewController:rootViewController];
splitViewController.viewControllers=[NSArray arrayWithObjects:rootNav,detailViewController,nil];
splitViewController.delegate=detailViewController;
[window addSubview:splitViewController.view];
 XML_Parser *xmlp =[[XML_Parser alloc] init];
[xmlp xmlparse];
[window makeKeyAndVisible];
	
}

RootViewCOntroller.m

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
	if (cell == nil) {
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
	}
	
	// Set up the cell.
	NSString *timeZoneName = [timeZoneNames     objectAtIndex:indexPath.row]; // timeZoneNames is defined in this class.
	cell.textLabel.text = timeZoneName;
	cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 	
	return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
SubTable *r1 = [[SubTable alloc] initWithStyle:UITableViewStylePlain];
r1.timevalue = timeZoneNames; // timevalue is an array in SuBTable class
[self.navigationController pushViewController:r1 animated:YES];
[r1 release];

}


XML_Parse.m
Code:
@interface XML_Parse ()
- (void) xmlparse;
- (void) traverseElement:(TBXMLElement *)element;
- (void) list_of_sub_projects:(NSMutableArray *)list_array;
@end

@implementation XML_Parse
@synthesize data_array,sub_project_name,dict_storage;
@synthesize file_array,sub_project_array;

- (void) xmlparse {
	
	NSString *xml_name = @"dv_prescribed_format.xml";
	TBXML *tbxml = [[TBXML alloc] initWithXMLFile:xml_name];
	TBXMLElement *root = tbxml.rootXMLElement;
	data_array = [NSMutableArray array];
	[data_array retain];
	if (tbxml.rootXMLElement) {
		data_array=[self traverseElement:root];
		[tbxml release];
	}
	[self list_of_sub_projects:data_array];  //getting warning here //XML_Parse may not respond to list_of_sub_projects
	
	
}


- (void) traverseElement:(TBXMLElement *) element{
	do {
		
	if ([[TBXML elementName:element] isEqualToString:@"subproject"]){
	NSString *break_point=@"break";
	[data_array addObject:break_point];
        TBXMLElement *sub_project_name_xml = [TBXML childElementNamed:@"subprojectname" parentElement:element];
	NSString *detail1= [TBXML textForElement:sub_project_name_xml];
			[data_array addObject:detail1] ;
		}
		
	if (element->firstChild) 
			[self traverseElement:element->firstChild];
		
	if ([[TBXML elementName:element] isEqualToString:@"docid"]) {
	TBXMLElement *filename = [TBXML childElementNamed:@"Fname" parentElement:element];
	NSString *detail = [TBXML textForElement:filename];
	[data_array addObject:detail];
			}
	} while ((element = element->nextSibling));	
	
	
}


- (void) list_of_sub_projects:(NSMutableArray *) list_array {
	dict_storage = [[NSMutableDictionary alloc] initWithCapacity:10];
	file_array = [[NSMutableArray alloc] init];
	sub_project_array = [[NSMutableArray alloc] init];
	int j=0,temp=0,temp1,i=1;
	while (i< [list_array count]) {
		
	if ([[list_array objectAtIndex:i] isEqualToString:@"break"]) 
		{
			temp1=temp;
			temp=i;
			for (j=temp1+2; j<temp; j++) {
				[file_array addObject:[list_array objectAtIndex:j]];
			}
			sub_project_name = [list_array objectAtIndex:temp1+1];
			[sub_project_array addObject:sub_project_name];
			[dict_storage setObject:file_array forKey:sub_project_name];
			[dict_storage allKeys];
			[file_array removeAllObjects];
			
		}
		i++;
		
	}	
		
}


Queries:

1. In split view, navigation controller is not visible. Only root view and detail view are visible (and so even after pushing object of SubTable class, its not visible.).

2. I am trying to call 'xmlparse' method (which again invokes 2 nested methods) defined in XML_Parse class but Its not getting accessed from inside SimpleTableViewAppDelegate.m
(Getting warning as:"warning: 'XML_Parse' may not respond to '-xmlparse' ")


XMLparsing code is correct as it is working good when tested separately.
 
Dear All

Being a newbie, I divided my application into small separate application and they all worked fine. now when I am trying to integrate, problem arises.

I am trying to post some part of the project's code where I am facing the real problem. May be my fundamentals are wrong. But plz help, I am ready to work on it.

SimpleTableViewAppDelegate.h
Code:
@class RootViewController;
@class DetailViewController;

@interface SimpleTableViewAppDelegate: NSObject <UIApplicationDelegate> {
 
    UIWindow *window;
    UISplitViewController *splitViewController;
    RootViewController *rootViewController;
    DetailViewController *detailViewController;
    UINavigationController *rootNav;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UISplitViewController *splitViewController;
@property (nonatomic, retain) IBOutlet RootViewController *rootViewController;
@property (nonatomic, retain) IBOutlet DetailViewController *detailViewController;
@property (nonatomic, retain) IBOutlet UINavigationController *rootNav;

@end


SimpleTableViewAppDelegate.m
Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {

rootViewController = [[RootViewController alloc] initWithStyle:UITableViewStylePlain];
rootNav=[[UINavigationController alloc]initWithRootViewController:rootViewController];
splitViewController.viewControllers=[NSArray arrayWithObjects:rootNav,detailViewController,nil];
splitViewController.delegate=detailViewController;
[window addSubview:splitViewController.view];
 XML_Parser *xmlp =[[XML_Parser alloc] init];
[xmlp xmlparse];
[window makeKeyAndVisible];
	
}

RootViewCOntroller.m

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
	if (cell == nil) {
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
	}
	
	// Set up the cell.
	NSString *timeZoneName = [timeZoneNames     objectAtIndex:indexPath.row]; // timeZoneNames is defined in this class.
	cell.textLabel.text = timeZoneName;
	cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 	
	return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
SubTable *r1 = [[SubTable alloc] initWithStyle:UITableViewStylePlain];
r1.timevalue = timeZoneNames; // timevalue is an array in SuBTable class
[self.navigationController pushViewController:r1 animated:YES];
[r1 release];

}


XML_Parse.m
Code:
@interface XML_Parse ()
- (void) xmlparse;
- (void) traverseElement:(TBXMLElement *)element;
- (void) list_of_sub_projects:(NSMutableArray *)list_array;
@end

@implementation XML_Parse
@synthesize data_array,sub_project_name,dict_storage;
@synthesize file_array,sub_project_array;

- (void) xmlparse {
	
	NSString *xml_name = @"dv_prescribed_format.xml";
	TBXML *tbxml = [[TBXML alloc] initWithXMLFile:xml_name];
	TBXMLElement *root = tbxml.rootXMLElement;
	data_array = [NSMutableArray array];
	[data_array retain];
	if (tbxml.rootXMLElement) {
		data_array=[self traverseElement:root];
		[tbxml release];
	}
	[self list_of_sub_projects:data_array];  //getting warning here //XML_Parse may not respond to list_of_sub_projects
	
	
}


- (void) traverseElement:(TBXMLElement *) element{
	do {
		
	if ([[TBXML elementName:element] isEqualToString:@"subproject"]){
	NSString *break_point=@"break";
	[data_array addObject:break_point];
        TBXMLElement *sub_project_name_xml = [TBXML childElementNamed:@"subprojectname" parentElement:element];
	NSString *detail1= [TBXML textForElement:sub_project_name_xml];
			[data_array addObject:detail1] ;
		}
		
	if (element->firstChild) 
			[self traverseElement:element->firstChild];
		
	if ([[TBXML elementName:element] isEqualToString:@"docid"]) {
	TBXMLElement *filename = [TBXML childElementNamed:@"Fname" parentElement:element];
	NSString *detail = [TBXML textForElement:filename];
	[data_array addObject:detail];
			}
	} while ((element = element->nextSibling));	
	
	
}


- (void) list_of_sub_projects:(NSMutableArray *) list_array {
	dict_storage = [[NSMutableDictionary alloc] initWithCapacity:10];
	file_array = [[NSMutableArray alloc] init];
	sub_project_array = [[NSMutableArray alloc] init];
	int j=0,temp=0,temp1,i=1;
	while (i< [list_array count]) {
		
	if ([[list_array objectAtIndex:i] isEqualToString:@"break"]) 
		{
			temp1=temp;
			temp=i;
			for (j=temp1+2; j<temp; j++) {
				[file_array addObject:[list_array objectAtIndex:j]];
			}
			sub_project_name = [list_array objectAtIndex:temp1+1];
			[sub_project_array addObject:sub_project_name];
			[dict_storage setObject:file_array forKey:sub_project_name];
			[dict_storage allKeys];
			[file_array removeAllObjects];
			
		}
		i++;
		
	}	
		
}


Queries:

1. In split view, navigation controller is not visible. Only root view and detail view are visible (and so even after pushing object of SubTable class, its not visible.).

2. I am trying to call 'xmlparse' method (which again invokes 2 nested methods) defined in XML_Parse class but Its not getting accessed from inside SimpleTableViewAppDelegate.m
(Getting warning as:"warning: 'XML_Parse' may not respond to '-xmlparse' ")


XMLparsing code is correct as it is working good when tested separately.


Sorry I do not have much time otherwise I would give you more help. The ones I can address quickly are parsing xml syncronously in didFinishLoading this isn't a good way\place to parse xml data. It could also lead to design problems later on. Also check your header file does it declare -xmlparse?

Good luck. I will take a more in depth look later when I have a few minutes.
 
2. I am trying to call 'xmlparse' method (which again invokes 2 nested methods) defined in XML_Parse class but Its not getting accessed from inside SimpleTableViewAppDelegate.m
(Getting warning as:"warning: 'XML_Parse' may not respond to '-xmlparse' ")

Where is your header file for XML_Parse? Did you remember to declare the method "-xmlparse" in it?

Also... Shouldn't your root controller class header import the other class headers?
 
header file for XML_Parse is:

Code:
@interface XML_Parse : NSObject {
	
	NSMutableArray *data_array ,*file_array;
	NSString *sub_project_name;
	NSMutableDictionary *dict_storage;	
	NSMutableArray *sub_project_array;
		
}


@property (nonatomic, retain) NSMutableArray *data_array;
@property (nonatomic,retain) NSString *sub_project_name;
@property (nonatomic, retain) NSMutableDictionary *dict_storage;
@property (nonatomic ,retain) NSMutableArray *file_array;
@property (nonatomic ,retain) NSMutableArray *sub_project_array;

@end

and I think I have import all the class header in RootViweController.m
 
I am able to solve the second query..still no idea how to implement uinavigatiocontroller in root view controller of split view pane.

SimpleTableViewAppDelegate.m is :

Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {

rootViewController = [[RootViewController alloc] initWithStyle:UITableViewStylePlain];
rootNav=[[UINavigationController alloc]initWithRootViewController:rootViewController];
splitViewController.viewControllers=[NSArray arrayWithObjects:rootNav,detailViewController,nil];
splitViewController.delegate=detailViewController;
[window addSubview:splitViewController.view];
[window makeKeyAndVisible];
	
}


On tapping the disclosure button in root view, next view is not visible. (next view is uitableview)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.