working so far

This commit is contained in:
relikd
2018-07-28 11:27:40 +02:00
parent db3ef5a22a
commit 1de26a7a88
8 changed files with 92 additions and 30 deletions

View File

@@ -41,9 +41,6 @@
printf("will init\n");
[PyHandler prepare];
printf("done\n");
NSDictionary * obj = [PyHandler getFeed:@"https://feeds.feedburner.com/simpledesktops" withEtag:nil andModified:nil];
NSLog(@"obj = %@", obj);
[self quitClicked:nil];
}
@@ -60,7 +57,7 @@
// The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.
@synchronized (self) {
if (_persistentContainer == nil) {
_persistentContainer = [[NSPersistentContainer alloc] initWithName:@"baRSS"];
_persistentContainer = [[NSPersistentContainer alloc] initWithName:@"DBv1"];
[_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
if (error != nil) {
// Replace this implementation with code to handle the error appropriately.

View File

@@ -21,7 +21,6 @@
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="he0-Eb-PDA" customClass="NewsController">
<connections>
<outlet property="managedObjectContext" destination="ESi-qE-Dj9" id="Nnv-1A-WLk"/>
<outlet property="openUnreadItem" destination="Qqw-Xj-oA5" id="8df-is-Qop"/>
<outlet property="pauseItem" destination="D7r-Vb-9eO" id="o7e-jD-3Yj"/>
<outlet property="updateAllItem" destination="wgp-fa-8Wj" id="edP-bQ-bIM"/>
@@ -447,7 +446,6 @@
</subviews>
<point key="canvasLocation" x="350" y="903.5"/>
</customView>
<managedObjectContext id="ESi-qE-Dj9"/>
<userDefaultsController representsSharedInstance="YES" id="K8S-BW-Na6"/>
</objects>
<resources>

View File

@@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>baRRS.xcdatamodel</string>
<string>DBv1.xcdatamodel</string>
</dict>
</plist>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14135" systemVersion="17G65" minimumToolsVersion="Automatic" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="v1">
<entity name="Feed" representedClassName="Feed" syncable="YES" codeGenerationType="class">
<attribute name="author" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="date" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="etag" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="icon" optional="YES" attributeType="Binary" customClassName="NSImage" syncable="YES"/>
<attribute name="link" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="modified" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="published" optional="YES" attributeType="Transformable" customClassName="NSArray" syncable="YES"/>
<attribute name="subtitle" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="title" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="items" optional="YES" toMany="YES" deletionRule="Cascade" ordered="YES" destinationEntity="FeedItem" inverseName="feed" inverseEntity="FeedItem" syncable="YES"/>
</entity>
<entity name="FeedItem" representedClassName="FeedItem" syncable="YES" codeGenerationType="class">
<attribute name="author" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="link" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="published" optional="YES" attributeType="Transformable" customClassName="NSArray" syncable="YES"/>
<attribute name="subtitle" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="summary" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="title" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="feed" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Feed" inverseName="items" inverseEntity="Feed" syncable="YES"/>
<relationship name="tags" optional="YES" toMany="YES" deletionRule="Cascade" ordered="YES" destinationEntity="FeedTag" inverseName="feedItem" inverseEntity="FeedTag" syncable="YES"/>
</entity>
<entity name="FeedTag" representedClassName="FeedTag" syncable="YES" codeGenerationType="class">
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="feedItem" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="FeedItem" inverseName="tags" inverseEntity="FeedItem" syncable="YES"/>
</entity>
<elements>
<element name="FeedItem" positionX="-36" positionY="-36" width="128" height="165"/>
<element name="FeedTag" positionX="0" positionY="54" width="128" height="75"/>
<element name="Feed" positionX="27" positionY="9" width="128" height="195"/>
</elements>
</model>

View File

@@ -21,33 +21,66 @@
// SOFTWARE.
#import "NewsController.h"
#import "PyHandler.h"
#import "AppDelegate.h"
#import "DBv1+CoreDataModel.h"
@interface NewsController ()
@property (weak) IBOutlet NSMenuItem *pauseItem;
@property (weak) IBOutlet NSMenuItem *updateAllItem;
@property (weak) IBOutlet NSMenuItem *openUnreadItem;
@property (weak) IBOutlet NSManagedObjectContext *managedObjectContext;
@property (retain) NSManagedObjectContext *managedContext;
@end
@implementation NewsController
- (void)viewDidLoad {
[super viewDidLoad];
// Do view setup here.
- (void)awakeFromNib {
[super awakeFromNib];
self.managedContext = [((AppDelegate*)[NSApp delegate]) persistentContainer].viewContext;
}
- (IBAction)pauseUpdates:(NSMenuItem *)sender {
NSLog(@"pause");
NSLog(@"%@", self.managedObjectContext);
NSLog(@"%@", self.managedContext);
}
- (IBAction)updateAllFeeds:(NSMenuItem *)sender {
NSLog(@"update all");
NSDictionary * obj = [PyHandler getFeed:@"https://feeds.feedburner.com/simpledesktops" withEtag:nil andModified:nil];
NSLog(@"obj = %@", obj);
// TODO: check status code
/*
Feed *a = [[Feed alloc] initWithEntity:Feed.entity insertIntoManagedObjectContext:self.managedContext];
a.title = obj[@"feed"][@"title"];
a.subtitle = obj[@"feed"][@"subtitle"];
a.author = obj[@"feed"][@"author"];
a.link = obj[@"feed"][@"link"];
a.published = obj[@"feed"][@"published"];
a.icon = obj[@"feed"][@"icon"];
a.etag = obj[@"header"][@"etag"];
a.date = obj[@"header"][@"date"];
a.modified = obj[@"header"][@"modified"];
for (NSDictionary *entry in obj[@"entries"]) {
FeedItem *b = [[FeedItem alloc] initWithEntity:FeedItem.entity insertIntoManagedObjectContext:self.managedContext];
b.title = entry[@"title"];
b.subtitle = entry[@"subtitle"];
b.author = entry[@"author"];
b.link = entry[@"link"];
b.published = entry[@"published"];
b.summary = entry[@"summary"];
for (NSString *tag in entry[@"tags"]) {
FeedTag *c = [[FeedTag alloc] initWithEntity:FeedTag.entity insertIntoManagedObjectContext:self.managedContext];
c.name = tag;
[b addTagsObject:c];
}
[a addItemsObject:b];
}*/
}
- (IBAction)openAllUnread:(NSMenuItem *)sender {
NSLog(@"all unread");
}
- (IBAction)addFeed:(NSButton *)sender {
NSLog(@"add feed");
NSLog(@"%@", self.managedObjectContext);
NSLog(@"%@", self.managedContext);
}
- (IBAction)removeFeed:(NSButton *)sender {
NSLog(@"del feed");

View File

@@ -31,11 +31,12 @@
@end
@implementation Preferences
- (void)windowDidLoad {
[super windowDidLoad];
NSLog(@"%@", @"hi");
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
- (void)awakeFromNib {
[super awakeFromNib];
if (self.window.contentView.subviews.count == 0) {
self.window.contentView = self.viewGeneral;
self.toolbar.selectedItemIdentifier = self.toolbar.items.firstObject.itemIdentifier;
}
}
- (IBAction)clickGeneral:(NSToolbarItem *)sender {

View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="">
<elements/>
</model>