Got an a question for you all here, what I trying to a do is I want to add "?tmpl=component&print=0&layout=default&page=" and to the end of a articleURL, I’ve looked on google and came across something about NSMutableString but my articleURL is using a NSString.
How do I go about add this text on to my articleURL in real-time or should I do it before the webView loads the page.
The webView is in a different view too.
Below is where I think my app is getting the URL for a RSS XML but I just can’t figure out how to amend it to include the above for all the articles.
code
- (void)parseAtom:(GDataXMLElement *)rootElement entries:(NSMutableArray *)entries {
NSString *blogTitle = [rootElement valueForChild:@"title"];
NSArray *items = [rootElement elementsForName:@"entry"];
for (GDataXMLElement *item in items) {
NSString *articleTitle = [item valueForChild:@"title"];
NSString *articleDescription = [item valueForChild:@"description"];
NSString *articleUrl = nil;
NSArray *links = [item elementsForName:@"link"];
for(GDataXMLElement *link in links) {
NSString *rel = [[link attributeForName:@"rel"] stringValue];
NSString *type = [[link attributeForName:@"type"] stringValue];
if ([rel compare:@"alternate"] == NSOrderedSame &&
[type compare:@"text/html"] == NSOrderedSame) {
articleUrl = [[link attributeForName:@"href"] stringValue];
}
}
NSString *articleDateString = [item valueForChild:@"updated"];
NSDate *articleDate = [NSDate dateFromInternetDateTimeString:articleDateString formatHint:DateFormatHintRFC3339];
RSSEntry *entry = [[[RSSEntry alloc] initWithBlogTitle:blogTitle
articleTitle:articleTitle
articleDescription:articleDescription
articleUrl:articleUrl
articleDate:articleDate] autorelease];
[entries addObject:entry];
}
}
You can also
NSMutableStringinstead ofNSString.You can use like –
Primary difference between using
NSMutableStringinstead ofNSStringis –If you use
NSString[NSString stringByAppendingString:], it will generates a new immutable NSString object, so cause memory leak. However, withNSMutableStringit will append string in same object.