Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions iOSStudy/Bean/FavouriteBean.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSInteger, FAVOURITE_TYPE) {
BLOG_TYPE = 1,
WEB_TYPE = 2,
VIDEO_TYPE = 3
};

@interface FavouriteBean : NSObject
/**
* 标题
Expand All @@ -34,5 +28,5 @@ typedef NS_ENUM(NSInteger, FAVOURITE_TYPE) {
/**
* 类型 1 博客 2 网站 3 视频
*/
@property(nonatomic,copy)NSString* type;
@property(nonatomic,assign)NSInteger *type;
@end
2 changes: 1 addition & 1 deletion iOSStudy/Tools/NetWorkTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ +(void)checkNetworking{
{
NSLog(@"网络断开!");

SharedApp.isNetworking = YES;
SharedApp.isNetworking = NO;

dispatch_async(dispatch_get_main_queue(), ^{

Expand Down
21 changes: 0 additions & 21 deletions iOSStudy/iOSStudy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@
18D908A71A8A205600B42A42 /* ThirdTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18D908A61A8A205600B42A42 /* ThirdTableViewController.m */; };
18DF6D3D1A80D3BC005751E8 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 18DF6D3C1A80D3BC005751E8 /* Reachability.m */; };
18DF6D3F1A80D40D005751E8 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18DF6D3E1A80D40D005751E8 /* SystemConfiguration.framework */; };
18E016AA1ACAA898002A6E59 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18E016A91ACAA898002A6E59 /* CoreData.framework */; };
18E016E51ACAAB35002A6E59 /* iOSStudy.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 18E016E31ACAAB35002A6E59 /* iOSStudy.xcdatamodeld */; };
54A0444849F1931415392FC1 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E83ED1B8EA89BC57ACF91BA5 /* libPods.a */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -164,8 +162,6 @@
18DF6D3B1A80D3BC005751E8 /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reachability.h; sourceTree = "<group>"; };
18DF6D3C1A80D3BC005751E8 /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = "<group>"; };
18DF6D3E1A80D40D005751E8 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
18E016A91ACAA898002A6E59 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
18E016E41ACAAB35002A6E59 /* iOSStudy.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = iOSStudy.xcdatamodel; sourceTree = "<group>"; };
2E2CC00A58FD0A745C574BAD /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
E83ED1B8EA89BC57ACF91BA5 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
Expand All @@ -175,7 +171,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
18E016AA1ACAA898002A6E59 /* CoreData.framework in Frameworks */,
18DF6D3F1A80D40D005751E8 /* SystemConfiguration.framework in Frameworks */,
54A0444849F1931415392FC1 /* libPods.a in Frameworks */,
);
Expand Down Expand Up @@ -308,7 +303,6 @@
18B23B321A7A14D100E80854 /* Images.xcassets */,
18B23B341A7A14D100E80854 /* LaunchScreen.xib */,
18B23B221A7A14D000E80854 /* Supporting Files */,
18E016E31ACAAB35002A6E59 /* iOSStudy.xcdatamodeld */,
);
path = iOSStudy;
sourceTree = "<group>";
Expand Down Expand Up @@ -445,7 +439,6 @@
910A021243EF9C731476BCA9 /* Frameworks */ = {
isa = PBXGroup;
children = (
18E016A91ACAA898002A6E59 /* CoreData.framework */,
18DF6D3E1A80D40D005751E8 /* SystemConfiguration.framework */,
E83ED1B8EA89BC57ACF91BA5 /* libPods.a */,
);
Expand Down Expand Up @@ -625,7 +618,6 @@
buildActionMask = 2147483647;
files = (
18AB47981A99A51200E4C030 /* BaseTableViewCell.m in Sources */,
18E016E51ACAAB35002A6E59 /* iOSStudy.xcdatamodeld in Sources */,
18AB479F1A9C5E3300E4C030 /* VideoCell.m in Sources */,
18B23B2E1A7A14D100E80854 /* SecondViewController.m in Sources */,
18B23B4D1A7A234800E80854 /* BaseViewController.m in Sources */,
Expand Down Expand Up @@ -861,19 +853,6 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCVersionGroup section */
18E016E31ACAAB35002A6E59 /* iOSStudy.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
18E016E41ACAAB35002A6E59 /* iOSStudy.xcdatamodel */,
);
currentVersion = 18E016E41ACAAB35002A6E59 /* iOSStudy.xcdatamodel */;
path = iOSStudy.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
};
/* End XCVersionGroup section */
};
rootObject = 18B23B171A7A14D000E80854 /* Project object */;
}
10 changes: 1 addition & 9 deletions iOSStudy/iOSStudy/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,11 @@
//

#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property(nonatomic,assign)__block BOOL isNetworking;
@property(nonatomic,copy)NSString *str;

#pragma mark --coreData
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;

- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;
@end

82 changes: 0 additions & 82 deletions iOSStudy/iOSStudy/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,86 +88,4 @@ - (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}



#pragma mark - Core Data stack

@synthesize managedObjectContext = _managedObjectContext;
@synthesize managedObjectModel = _managedObjectModel;
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;

- (NSURL *)applicationDocumentsDirectory {
// The directory the application uses to store the Core Data store file. This code uses a directory named "---.test" in the application's documents directory.
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}

- (NSManagedObjectModel *)managedObjectModel {
// The managed object model for the application. It is a fatal error for the application not to be able to find and load its model.
if (_managedObjectModel != nil) {
return _managedObjectModel;
}
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"iOSStudy" withExtension:@"momd"];
_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return _managedObjectModel;
}

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
// The persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it.
if (_persistentStoreCoordinator != nil) {
return _persistentStoreCoordinator;
}

// Create the coordinator and store

_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"iOSStudy.sqlite"];
NSError *error = nil;
NSString *failureReason = @"There was an error creating or loading the application's saved data.";
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
// Report any error we got.
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
dict[NSLocalizedDescriptionKey] = @"Failed to initialize the application's saved data";
dict[NSLocalizedFailureReasonErrorKey] = failureReason;
dict[NSUnderlyingErrorKey] = error;
error = [NSError errorWithDomain:@"YOUR_ERROR_DOMAIN" code:9999 userInfo:dict];
// Replace this with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}

return _persistentStoreCoordinator;
}


- (NSManagedObjectContext *)managedObjectContext {
// Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.)
if (_managedObjectContext != nil) {
return _managedObjectContext;
}

NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
if (!coordinator) {
return nil;
}
_managedObjectContext = [[NSManagedObjectContext alloc] init];
[_managedObjectContext setPersistentStoreCoordinator:coordinator];
return _managedObjectContext;
}

#pragma mark - Core Data Saving support

- (void)saveContext {
NSManagedObjectContext *managedObjectContext = self.managedObjectContext;
if (managedObjectContext != nil) {
NSError *error = nil;
if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
}
}

@end
2 changes: 1 addition & 1 deletion iOSStudy/iOSStudy/Constants .h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@

#define PATH_OF_DOCUMENT [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]

#define CD_FAVOURITE_BEAN @"FavouriteBean"

#endif
10 changes: 2 additions & 8 deletions iOSStudy/iOSStudy/FirstViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,10 @@ - (void)swipeableTableViewCellDidEndScrolling:(SWTableViewCell *)cell{
- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index{
switch (index) {
case 0:
NSLog(@"不喜欢");
{
NSIndexPath *indexPath = [_tableView indexPathForCell:cell];
[_viewModel saveFavourite:indexPath];

}
NSLog(@"unlove");
break;
case 1:
NSLog(@"收藏");

NSLog(@"love");
break;

default:
Expand Down
7 changes: 0 additions & 7 deletions iOSStudy/iOSStudy/ViewModel/FirstViewControllerViewModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,4 @@ typedef void (^modelNetWorking)(BOOL isNetWorking);
* @return cell的数据
*/
-(BlogBean*)getBlogBean:(NSIndexPath *)indexPath;




-(void)saveFavourite:(NSIndexPath*)indexPath;

-(BOOL)isExistURL:(NSString*)url;
@end
Loading