Guest User

Untitled

a guest
Jul 30th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. how to get the modelClass objects and store it into an array in RssFeedParsing
  2. NSLog(@"parserDidStartDocument");
  3.  
  4. if ([elementName isEqualToString:@"item"]) {
  5. modClass = [[ModalClass alloc] init];
  6. boolItem = YES;
  7. }
  8.  
  9. if(boolItem)
  10. {
  11. if([elementName isEqualToString:@"title"])
  12. {
  13. boolTitle = TRUE;
  14. titleString = [[NSMutableString alloc]init ];
  15. }
  16.  
  17. if([elementName isEqualToString:@"description"])
  18. {
  19. boolDescription = TRUE;
  20. descriptionString = [[NSMutableString alloc]init ];
  21. }
  22.  
  23.  
  24. if([elementName isEqualToString:@"link"])
  25. {
  26. boolLink = TRUE;
  27. linkString = [[NSMutableString alloc]init ];
  28. }
  29.  
  30. if([elementName isEqualToString:@"pubDate"])
  31. {
  32. boolPubDate = TRUE;
  33. pubDateString = [[NSMutableString alloc]init ];
  34. }
  35. }
  36.  
  37. if(boolTitle)
  38. {
  39. [titleString appendString:string];
  40. NSLog(@"the titles is %@",titleString);
  41. }
  42.  
  43. if(boolDescription)
  44. {
  45. [descriptionString appendString:string];
  46. }
  47.  
  48. if(boolLink)
  49. {
  50. [linkString appendString:string];
  51.  
  52. }
  53.  
  54. if(boolPubDate)
  55. {
  56. [pubDateString appendString:string];
  57. }
  58.  
  59. if([elementName isEqualToString:@"title"])
  60. {
  61. if(titleString){
  62. modClass.title = [[NSString alloc]initWithString:titleString];
  63. }
  64. NSLog(@"the value in modclass.title is %@",modClass.title);
  65. boolTitle = FALSE;
  66. }
  67. if([elementName isEqualToString:@"description"])
  68. {
  69. if(descriptionString) {
  70. // modClass.description = [[NSString alloc]initWithString:descriptionString];
  71. }
  72. boolDescription = FALSE;
  73. }
  74. if([elementName isEqualToString:@"link"])
  75. {
  76. if(linkString) {
  77. modClass.link = [[NSString alloc]initWithString:linkString];
  78. }
  79. boolLink = FALSE;
  80. }
  81. if([elementName isEqualToString:@"pubDate"])
  82. {
  83. if (pubDateString) {
  84. modClass.pubDate = [[NSString alloc]initWithString:pubDateString];
  85. NSLog(@"the value in modclass.published date is %@",modClass.pubDate);
  86. }
  87. boolPubDate = FALSE;
  88. }
  89. if([elementName isEqualToString:@"item"])
  90. {
  91. boolItem = FALSE;
  92. [array addObject:modClass];
  93.  
  94. }
  95.  
  96. int nodeCount=[array count];
  97. NSLog(@"the array count is %i",nodeCount);
  98. for(int i=0;i<nodeCount;i++)
  99. {
  100. NSLog(@"title %@",modClass.title);
  101. NSLog(@"link %@",modClass.link);
  102. NSLog(@"description %@",modClass.description);
  103. NSLog(@"pubDate %@",modClass.pubDate);
  104. }
Add Comment
Please, Sign In to add comment