Guest User

Untitled

a guest
Aug 14th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.87 KB | None | 0 0
  1. crashed while i switching between viewcontrollers in navigationcontroller?
  2. Thread 9 Crashed:
  3. 0 libsystem_c.dylib 0x365f3096 __abort + 138
  4. 1 libsystem_c.dylib 0x365f3006 abort + 122
  5. 2 libc++abi.dylib 0x31abbf64 abort_message + 40
  6. 3 libc++abi.dylib 0x31ab9346 _ZL17default_terminatev + 18
  7. 4 libobjc.A.dylib 0x37fc32dc _objc_terminate + 140
  8. 5 libc++abi.dylib 0x31ab93be _ZL19safe_handler_callerPFvvE + 70
  9. 6 libc++abi.dylib 0x31ab944a std::terminate() + 14
  10. 7 libc++abi.dylib 0x31aba798 __cxa_throw + 116
  11. 8 libobjc.A.dylib 0x37fc321c objc_exception_throw + 88
  12. 9 CoreFoundation 0x30d73208 -[__NSArrayM insertObject:atIndex:] + 180
  13. 10 UIKit 0x32e17abe -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1098
  14. 11 UIKit 0x32e1722c -[UITableView layoutSubviews] + 200
  15. 12 UIKit 0x32dbbd22 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 142
  16. 13 CoreFoundation 0x30d7d224 -[NSObject performSelector:withObject:] + 36
  17. 14 QuartzCore 0x324d137a -[CALayer layoutSublayers] + 210
  18. 15 QuartzCore 0x324d0f92 CA::Layer::layout_if_needed(CA::Transaction*) + 210
  19. 16 QuartzCore 0x324d5114 CA::Context::commit_transaction(CA::Transaction*) + 220
  20. 17 QuartzCore 0x324d4e50 CA::Transaction::commit() + 308
  21. 18 QuartzCore 0x3251b8ae CA::Transaction::release_thread(void*) + 30
  22. 19 libsystem_c.dylib 0x365ad6c8 _pthread_tsd_cleanup + 164
  23. 20 libsystem_c.dylib 0x365ad344 _pthread_exit + 116
  24. 21 libsystem_c.dylib 0x365bf5c4 pthread_exit + 24
  25. 22 Foundation 0x37e40384 +[NSThread exit] + 4
  26. 23 Foundation 0x37ec45b8 __NSThread__main__ + 1072
  27. 24 libsystem_c.dylib 0x365bbc16 _pthread_start + 314
  28. 25 libsystem_c.dylib 0x365bbad0 thread_start + 0
  29.  
  30. //
  31. // RootViewController.m
  32. // Q8f
  33. //
  34. // Created by Abdulaziz Hamdan on 10/26/11.
  35. // Copyright (c) 2011 __MyCompanyName__. All rights reserved.
  36. //
  37.  
  38. #import "RootViewController.h"
  39. #import "SubCategoryViewController.h"
  40. #import "DestorViewController.h"
  41.  
  42. @implementation RootViewController
  43. - (id)initWithStyle:(UITableViewStyle)style
  44. {
  45. self = [super initWithStyle:style];
  46. if (self) {
  47. // Custom initialization
  48. }
  49. return self;
  50.  
  51. }
  52. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  53. {
  54. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  55. if (self) {
  56. self.title = NSLocalizedString(@"RootView", @"First");
  57. self.tabBarItem.image = [UIImage imageNamed:@"first"];
  58. }
  59. return self;
  60. }
  61.  
  62. - (void)didReceiveMemoryWarning
  63. {
  64. // Releases the view if it doesn't have a superview.
  65. [super didReceiveMemoryWarning];
  66.  
  67. // Release any cached data, images, etc that aren't in use.
  68. }
  69. -(void)dealloc{
  70. self.tableView.delegate = nil;
  71. self.tableView.dataSource = nil;
  72. [category release];
  73. [cid release];
  74. category = nil;
  75.  
  76. cid = nil;
  77. [super dealloc];
  78.  
  79. }
  80. #pragma mark - View lifecycle
  81. - (void)viewDidLoad
  82. {
  83. if ([[UINavigationBar class]respondsToSelector:@selector(appearance)]) {
  84. [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar2.png"] forBarMetrics:UIBarMetricsDefault];
  85. }
  86. [super viewDidLoad];
  87. self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"back.png"]];
  88. category = [[NSMutableArray alloc] init];
  89. cid = [[NSMutableArray alloc] init];
  90. [category addObject:@"a"];
  91. [category addObject:@"b"];
  92. [category addObject:@"c"];
  93. [category addObject:@"d"];
  94. [category addObject:@"e"];
  95. [category addObject:@"f"];
  96. [category addObject:@"g"];
  97. [category addObject:@"h"];
  98. [cid addObject:@"1"];
  99. [cid addObject:@"2"];
  100. [cid addObject:@"3"];
  101. [cid addObject:@"4"];
  102. [cid addObject:@"5"];
  103. [cid addObject:@"6"];
  104. [cid addObject:@"7"];
  105. [cid addObject:@"8"];
  106.  
  107.  
  108.  
  109. }
  110.  
  111. - (void)viewDidUnload
  112. {
  113. [super viewDidUnload];
  114. // Release any retained subviews of the main view.
  115. // e.g. self.myOutlet = nil;
  116. }
  117.  
  118. - (void)viewWillAppear:(BOOL)animated
  119. {
  120. [super viewWillAppear:animated];
  121. }
  122.  
  123. - (void)viewDidAppear:(BOOL)animated
  124. {
  125. [super viewDidAppear:animated];
  126. }
  127.  
  128. - (void)viewWillDisappear:(BOOL)animated
  129. {
  130. [super viewWillDisappear:animated];
  131. }
  132.  
  133. - (void)viewDidDisappear:(BOOL)animated
  134. {
  135. [super viewDidDisappear:animated];
  136. }
  137.  
  138. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  139. {
  140. // Return YES for supported orientations
  141. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  142. }
  143.  
  144. #pragma mark - Table view data source
  145.  
  146. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  147. {
  148. // Return the number of sections.
  149. return 1;
  150. }
  151.  
  152. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  153. {
  154. // Return the number of rows in the section.
  155. return [category count];
  156. }
  157.  
  158. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  159. {
  160. static NSString *CellIdentifier = @"Cell";
  161.  
  162. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  163. if (cell == nil) {
  164. cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
  165. }
  166.  
  167. // Configure the cell...
  168. /* UIView *backView = [[UIView alloc] initWithFrame:CGRectZero];
  169. backView.backgroundColor = [UIColor clearColor];
  170. cell.backgroundColor = [UIColor clearColor];
  171. cell.backgroundView = backView;
  172. [backView release];
  173. */
  174. // cell.backgroundColor = [UIColor groupTableViewBackgroundColor];
  175. cell.textLabel.text = [category objectAtIndex:indexPath.row];
  176. [[cell textLabel] setTextAlignment:UITextAlignmentCenter];
  177. cell.selectionStyle = UITableViewCellSelectionStyleGray;
  178.  
  179. return cell;
  180. }
  181.  
  182.  
  183. #pragma mark - Table view delegate
  184.  
  185. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  186. {
  187.  
  188.  
  189. if (indexPath.row > 0) {
  190.  
  191. SubCategoryViewController *SubCategoryView = [[[SubCategoryViewController alloc] initWithNibName:@"SubCategoryViewController" bundle:nil] autorelease];
  192. SubCategoryView.title = [category objectAtIndex:indexPath.row];
  193. SubCategoryView->cid = [cid objectAtIndex:indexPath.row];
  194.  
  195. [self.navigationController pushViewController:SubCategoryView animated:NO];
  196.  
  197. }else{
  198.  
  199. DestorViewController *DestorView = [[[DestorViewController alloc] initWithNibName:@"DestorViewController" bundle:nil] autorelease];
  200. DestorView.title = [category objectAtIndex:indexPath.row];
  201. [self.navigationController pushViewController:DestorView animated:NO];
  202.  
  203.  
  204.  
  205. }
  206.  
  207. }
  208.  
  209. @end
  210.  
  211. //
  212. // SubCategoryViewController.m
  213. // Q8f
  214. //
  215. // Created by Abdulaziz Hamdan on 10/26/11.
  216. // Copyright (c) 2011 __MyCompanyName__. All rights reserved.
  217. //
  218.  
  219. #import "SubCategoryViewController.h"
  220.  
  221.  
  222. @implementation SubCategoryViewController
  223. @synthesize cid;
  224. - (id)initWithStyle:(UITableViewStyle)style
  225. {
  226. self = [super initWithStyle:style];
  227. if (self) {
  228. // Custom initialization
  229. }
  230. return self;
  231. }
  232.  
  233. - (void)didReceiveMemoryWarning
  234. {
  235. // Releases the view if it doesn't have a superview.
  236. [super didReceiveMemoryWarning];
  237.  
  238. // Release any cached data, images, etc that aren't in use.
  239. }
  240.  
  241. #pragma mark - View lifecycle
  242.  
  243. -(void)dealloc{
  244. self.tableView.delegate = nil;
  245. self.tableView.dataSource = nil;
  246. [cid release];
  247. cid = nil;
  248. [xmlParser release];
  249. [subCate release];
  250. [hud release];
  251. hud.delegate = nil;
  252. xmlParser = nil;
  253. subCate = nil;
  254. [super dealloc];
  255.  
  256.  
  257.  
  258. }
  259. - (void)viewDidLoad
  260. {
  261. [super viewDidLoad];
  262. xmlParser = [[XMLParser alloc] init];
  263. subCate = [[subCategory alloc] init];
  264. self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"back.png"]];
  265. [NSThread detachNewThreadSelector:@selector(startmethod) toTarget:self withObject:nil];
  266. [self performSelectorOnMainThread:@selector(startIt) withObject:nil waitUntilDone:FALSE];
  267.  
  268.  
  269.  
  270.  
  271. // Uncomment the following line to preserve selection between presentations.
  272. // self.clearsSelectionOnViewWillAppear = NO;
  273.  
  274. // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
  275. // self.navigationItem.rightBarButtonItem = self.editButtonItem;
  276. }
  277. - (void)myTask {
  278. // Do something usefull in here instead of sleeping ...
  279. // Labels can be changed during the execution
  280. //HUD.detailsLabelText = @"Something";
  281. //sleep(3);
  282. }
  283.  
  284. -(void)stopIt{
  285. [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
  286. [hud hide:YES];
  287. cid = nil;
  288.  
  289. }
  290.  
  291. -(void)startmethod {
  292. [xmlParser loadXMLByURL:cid];
  293. [self.tableView reloadData];
  294. [self stopIt];
  295.  
  296.  
  297. }
  298.  
  299.  
  300. -(void)startIt{
  301. [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
  302. hud = [[MBProgressHUD alloc] initWithView:self.view];
  303. [self.view addSubview:hud];
  304.  
  305. hud.delegate = self;
  306. hud.labelText = @"loading";
  307. [hud show:YES];
  308.  
  309.  
  310.  
  311. }
  312.  
  313.  
  314. - (void)viewDidUnload
  315. {
  316. [super viewDidUnload];
  317. // Release any retained subviews of the main view.
  318. // e.g. self.myOutlet = nil;
  319. }
  320.  
  321. - (void)viewWillAppear:(BOOL)animated
  322. {
  323. [super viewWillAppear:animated];
  324. }
  325.  
  326. - (void)viewDidAppear:(BOOL)animated
  327. {
  328. [super viewDidAppear:animated];
  329. }
  330.  
  331. - (void)viewWillDisappear:(BOOL)animated
  332. {
  333. [super viewWillDisappear:animated];
  334. }
  335.  
  336. - (void)viewDidDisappear:(BOOL)animated
  337. {
  338. [super viewDidDisappear:animated];
  339. }
  340.  
  341. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  342. {
  343. // Return YES for supported orientations
  344. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  345. }
  346.  
  347. #pragma mark - Table view data source
  348.  
  349. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  350. {
  351. // Return the number of sections.
  352. return 1;
  353. }
  354.  
  355. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  356. {
  357. // Return the number of rows in the section.
  358. return [[xmlParser list] count];
  359. }
  360.  
  361. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  362. {
  363. static NSString *CellIdentifier = @"Cell";
  364.  
  365. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  366. if (cell == nil) {
  367. cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
  368. }
  369.  
  370. // Configure the cell...
  371.  
  372.  
  373. subCate = [[xmlParser list] objectAtIndex:indexPath.row];
  374.  
  375. cell.textLabel.text = [subCate name];
  376. // cell.textLabel.numberOfLines = 5; //Change this value to show more or less lines.
  377.  
  378. cell.textLabel.textAlignment = UITextAlignmentRight;
  379. //[[cell textLabel] setTextAlignment:UITextAlignmentCenter];
  380. //cell.selectionStyle = UITableViewCellSelectionStyleGray;
  381.  
  382.  
  383.  
  384. return cell;
  385. }
  386.  
  387. #pragma mark - Table view delegate
  388.  
  389. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  390. {
  391.  
  392. subCate = [[xmlParser list] objectAtIndex:indexPath.row];
  393. if ([[subCate father] isEqualToString:@"1"]) {
  394. SubCategoryViewController *SubCategoryView = [[[SubCategoryViewController alloc] initWithNibName:@"SubCategoryViewController" bundle:nil] autorelease];
  395. SubCategoryView.title = [subCate name];
  396. SubCategoryView->cid = [subCate cid];
  397.  
  398. [self.navigationController pushViewController:SubCategoryView animated:NO];
  399. }else{
  400. EntryViewController *EntryView = [[[EntryViewController alloc] initWithNibName:@"EntryViewController" bundle:nil] autorelease];
  401. EntryView.title = [subCate name];
  402. EntryView->cid = [subCate cid];
  403.  
  404. [self.navigationController pushViewController:EntryView animated:NO];
  405.  
  406.  
  407.  
  408. }
  409.  
  410.  
  411. }
  412.  
  413. @end
Add Comment
Please, Sign In to add comment