This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)createDB { | |
if(sqlite3_open([[self filePath] UTF8String], &database) != SQLITE_OK) { | |
sqlite3_close(database); | |
} | |
char *errorMsg; | |
NSString *createSQL = @"CREATE TABLE IF NOT EXISTS entry (entryID INTEGER PRIMARY KEY, entryDate TEXT, entryTitle TEXT, entryContext TEXT, entryImage TEXT);"; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// dummyAppViewController.h | |
// dummyApp | |
// | |
// Created by Mattias Hedman on 2010-08-14. | |
// Copyright Margin 2010. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
#import "SqlDB.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { | |
NSRange flash = [[newsArray objectAtIndex:indexPath.row] rangeOfString: @"FLASH:"]; | |
if(flash.length > 0) { | |
cell.backgroundColor = [UIColor yellowColor]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface MARStoreClass : NSObject { | |
NSString *title; | |
NSString *pubDate; | |
NSString *description; | |
NSURL *pictureLink; | |
NSURL *newsLink; | |
} | |
@property (nonatomic, strong) NSString *title; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(id)initWithAll:(NSDictionary*)storedNewsValues { | |
newsTitle = [storedNewsValues objectForKey:@"newsTitle"]; | |
publicationDate = [storedNewsValues objectForKey:@"publicationDate"]; | |
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; | |
[dateFormat setDateFormat:@"YYYY-MM-dd, HH:mm"]; | |
NSString *publicationDateString = [dateFormat stringFromDate:publicationDate]; | |
NSLog(@"tit: %@, pub: %@, original: %@", newsTitle, publicationDateString, publicationDate); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSMutableArray *)parseXMLUrl:(NSString *)url { | |
NSURL *xmlURL = [NSURL URLWithString:url]; | |
xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL]; | |
xmlParser.delegate = self; | |
[xmlParser parse]; | |
[currentArray removeObjectAtIndex:0]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSMutableArray*)getNews:(NSString*) rssurl { | |
MARXMLParser *parser = [[MARXMLParser alloc] init]; | |
NSMutableArray *newsTempArray = [parser parseXMLUrl:rssurl]; | |
NSMutableArray *returnArray = [[NSMutableArray alloc] initWithCapacity:(newsTempArray.count/2)]; | |
NSLog(@"%@",newsTempArray); | |
for (int i=1; i<(newsTempArray.count/2); i++) { | |
MARNewsObject *news = [[MARNewsObject alloc] init]; | |
news.newsTitle = [newsTempArray objectAtIndex:i]; | |
news.newsPubDate = [newsTempArray objectAtIndex:i+1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Inläsning: | |
-(NSMutableArray*)getNews:(NSString*) rssurl { | |
MARXMLParser *parser = [[MARXMLParser alloc] init]; | |
NSMutableArray *newsTempArray = [parser parseXMLUrl:rssurl]; | |
NSMutableArray *returnArray = [[NSMutableArray alloc] initWithCapacity:(newsTempArray.count/2)]; | |
for (int i=1; i<(newsTempArray.count/2); i++) { | |
MARNewsObject *news = [[MARNewsObject alloc] init]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSMutableArray*)getNews:(NSString*) rssurl { | |
MARXMLParser *parser = [[MARXMLParser alloc] init]; | |
NSMutableArray *newsTempArray = [parser parseXMLUrl:rssurl]; | |
returnArray = [[NSMutableArray alloc] initWithCapacity:(newsTempArray.count/2)]; | |
int a=1; | |
while (a<(newsTempArray.count/2)) { | |
news = [[MARNewsObject alloc] init]; | |
news.newsTitle = [newsTempArray objectAtIndex:a]; | |
news.newsPubDate = [newsTempArray objectAtIndex:a+1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { | |
if([elementName isEqual:@"title"] || [elementName isEqual:@"pubDate"] || [elementName isEqual:@"description"]) { | |
if([parseElement isEqualToString:@"title"]) { | |
[xmlDictionary setValue:xmlContent forKey:@"newsTitle"]; | |
} | |
if([parseElement isEqualToString:@"date"]) { | |
[xmlDictionary setValue:xmlContent forKey:@"newsPubDate"]; | |
} |
OlderNewer