Skip to content

Commit cfd044b

Browse files
author
Joey Lorich
committed
Add feedItems to user
1 parent a80a514 commit cfd044b

5 files changed

Lines changed: 35 additions & 7 deletions

File tree

EasyReader/Application/Controllers/Home/CSHomeViewController.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,13 @@ - (void) setupFeedItemObserver
9898

9999
- (void)setUpCollectionView
100100
{
101-
NSArray *feedItems = [FeedItem MR_findAll];
102-
101+
// User *current = [User current];
102+
//
103+
// NSSet *feedItems = current.feedItems;
104+
105+
NSArray *feedItems = [FeedItem MR_findAll];
106+
FeedItem *first = feedItems[0];
107+
NSLog(@"%@", first.name);
103108
feedCollectionViewDataSource =
104109
[[CSFeedItemCollectionViewDataSource alloc] initWithFeedItems:feedItems
105110
reusableCellIdentifier:@"feedItemCell"

EasyReader/Application/Models/User.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
/// The users feeds
2626
@property (nonatomic, retain) NSSet *feeds;
2727

28+
/// The items in a users feeds
29+
@property (nonatomic, readonly) NSSet *feedItems;
30+
2831

2932
#pragma mark - Methods
3033

EasyReader/Application/Models/User.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@
1313
@implementation User
1414

1515
@dynamic feeds;
16+
@dynamic feedItems;
17+
18+
/**
19+
* Gathers all the items in a users feeds
20+
*/
21+
- (NSSet *)feedItems
22+
{
23+
NSMutableSet *feedItems = [[NSMutableSet alloc] init];
24+
25+
for (Feed *feed in self.feeds)
26+
{
27+
[feedItems setByAddingObjectsFromSet:feed.feedItems];
28+
}
29+
30+
return feedItems;
31+
}
1632

1733
/**
1834
* Returns the current user.

EasyReader/Application/Views/Main_iPhone.storyboard

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
1818
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
1919
<subviews>
20-
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" bounces="NO" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EWA-9Z-pb1">
20+
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" bounces="NO" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EWA-9Z-pb1">
2121
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
2222
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
2323
<subviews>
@@ -141,6 +141,10 @@
141141
</constraints>
142142
</pageControl>
143143
</subviews>
144+
<constraints>
145+
<constraint firstAttribute="trailing" secondItem="vdW-Yb-aAb" secondAttribute="trailing" id="Bcm-5I-kx3"/>
146+
<constraint firstItem="vdW-Yb-aAb" firstAttribute="leading" secondItem="EWA-9Z-pb1" secondAttribute="leading" id="ct5-rK-kEl"/>
147+
</constraints>
144148
</scrollView>
145149
</subviews>
146150
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>

EasyReader/Resources/CoreData/EasyReader.xcdatamodeld/api_v2.xcdatamodel/contents

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="3401" systemVersion="12F45" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
2+
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="5063" systemVersion="13C64" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
33
<entity name="Feed" representedClassName="Feed" syncable="YES">
44
<attribute name="icon" optional="YES" attributeType="String" syncable="YES"/>
55
<attribute name="id" optional="YES" attributeType="Integer 16" defaultValueString="0" syncable="YES"/>
@@ -23,8 +23,8 @@
2323
<relationship name="feeds" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Feed" inverseName="user" inverseEntity="Feed" syncable="YES"/>
2424
</entity>
2525
<elements>
26-
<element name="Feed" positionX="0" positionY="0" width="0" height="0"/>
27-
<element name="FeedItem" positionX="0" positionY="0" width="0" height="0"/>
28-
<element name="User" positionX="0" positionY="0" width="0" height="0"/>
26+
<element name="Feed" positionX="0" positionY="0" width="128" height="135"/>
27+
<element name="FeedItem" positionX="0" positionY="0" width="128" height="178"/>
28+
<element name="User" positionX="0" positionY="0" width="128" height="58"/>
2929
</elements>
3030
</model>

0 commit comments

Comments
 (0)