diff --git a/AddEmployeeController.h b/AddEmployeeController.h new file mode 100644 index 0000000..16d539c --- /dev/null +++ b/AddEmployeeController.h @@ -0,0 +1,32 @@ +// +// AddEmployeeController.h +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import +#import "Employee.h" +#import "EmployeeTool.h" +#import "AppDelegate.h" + +@interface AddEmployeeController : UIViewController + +@property(strong,nonatomic) Employee *currEmp; + +@property (weak, nonatomic) IBOutlet UIScrollView *containScrollView; + +@property (weak, nonatomic) IBOutlet UIButton *headImageBTN; +@property (weak, nonatomic) IBOutlet UITextField *nameField; +@property (weak, nonatomic) IBOutlet UITextField *departmentField; +@property (weak, nonatomic) IBOutlet UITextField *positionField; +@property (weak, nonatomic) IBOutlet UITextField *identifierField; + +@property (weak, nonatomic) IBOutlet UIButton *addBTN; +@property (weak, nonatomic) IBOutlet UIButton *cancelBTN; +- (IBAction)getHeadImage:(id)sender; +- (IBAction)addBTNPress:(id)sender; + +- (IBAction)cancelBTNPress:(id)sender; +@end diff --git a/AddEmployeeController.m b/AddEmployeeController.m new file mode 100644 index 0000000..b576a18 --- /dev/null +++ b/AddEmployeeController.m @@ -0,0 +1,186 @@ +// +// AddEmployeeController.m +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import "AddEmployeeController.h" + +@interface AddEmployeeController () +{ + UIImage * selectImage; +} +@end + +@implementation AddEmployeeController + +-(AppDelegate *)appDelegate +{ + return [[UIApplication sharedApplication] delegate]; +} + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + [self.containScrollView setContentSize:self.view.frame.size]; + + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +-(BOOL)textFieldShouldReturn:(UITextField *)textField +{ + [textField resignFirstResponder]; + [UIView animateWithDuration:1.0 animations:^{ + [self.containScrollView setContentSize:CGSizeMake(self.containScrollView.frame.size.width, self.view.frame.size.height)]; + }]; + return YES; +} +-(void)textFieldDidBeginEditing:(UITextField *)textField +{ +// [self animateTextField:textField up:YES]; +// [self.containScrollView setContentOffset:CGPointMake(0, 0) animated:YES]; + [self.containScrollView setContentSize:CGSizeMake(self.containScrollView.frame.size.width, self.view.frame.size.height+200)]; +} + +-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField +{ + return YES; +} +-(void)textFieldDidEndEditing:(UITextField *)textField +{ + if (textField.tag == 1004) { + [UIView animateWithDuration:1.0 animations:^{ + [self.containScrollView setContentSize:CGSizeMake(self.containScrollView.frame.size.width, self.view.frame.size.height)]; + }]; + } + +// [self animateTextField:textField up:NO]; +// [self.containScrollView setContentOffset:CGPointMake(0, 0) animated:YES]; +} +-(void)animateTextField:(UITextField *)textField up:(BOOL)up +{ + const int movementDistance = 80; + const float movementDuration = 0.3f; + int movement = (up?-movementDistance:movementDistance); + [UIView beginAnimations:@"anim" context:nil]; + [UIView setAnimationBeginsFromCurrentState:YES]; + [UIView setAnimationDuration:movementDuration]; + self.view.frame = CGRectOffset(self.view.frame, 0, movement); + [UIView commitAnimations]; +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +- (IBAction)addBTNPress:(id)sender { + if (self.identifierField.text== nil || [self.identifierField.text isEqualToString:@""]) { + [self.identifierField becomeFirstResponder]; + return; + }else if (self.nameField.text == nil || [self.nameField.text isEqualToString:@""]){ + [self.identifierField becomeFirstResponder]; + return; + } + + NSString *name = self.nameField.text; + NSString *position = self.positionField.text; + NSString *department = self.departmentField.text; + int identifier =[self.identifierField.text intValue]; + + NSData * headImage; + if (selectImage == nil) { + UIImage *img = [self.headImageBTN backgroundImageForState:UIControlStateNormal]; + headImage = UIImagePNGRepresentation(img); + }else{ + headImage = UIImagePNGRepresentation(selectImage); + } + + Employee *employee = nil; + BOOL isExist = NO; + BOOL isSaveSuccess = NO; + + isExist = [[EmployeeTool sharedEmployeeTool] isEmployeeExist:identifier]; + + + if (isExist) { + employee = [[EmployeeTool sharedEmployeeTool] findEmployeeById:identifier]; + employee.headImage = headImage; + employee.name = name; + employee.position = position; + employee.department = department; + employee.identifier = [NSNumber numberWithInteger:identifier]; + isSaveSuccess = [[EmployeeTool sharedEmployeeTool] updateEmployee:employee]; + }else{ + employee = [NSEntityDescription insertNewObjectForEntityForName:@"Employee" inManagedObjectContext:[self appDelegate].managedObjectContext]; + employee.headImage = headImage; + employee.name = name; + employee.position = position; + employee.department = department; + employee.identifier = [NSNumber numberWithInteger:identifier]; + [EmployeeTool sharedEmployeeTool].curEmp = employee; + isSaveSuccess = [[EmployeeTool sharedEmployeeTool] addEmployee:employee]; + } + + if (isSaveSuccess) { + [self cancelBTNPress:nil]; + } +} + +- (IBAction)getHeadImage:(id)sender { + UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"编辑头像" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"拍照" otherButtonTitles:@"图片库", nil]; + [actionSheet showInView:self.view]; +} +-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex +{ + UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; + [imagePicker setDelegate:self]; + [imagePicker setAllowsEditing:YES]; + + if (buttonIndex == 0) { + [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera]; + }else if (buttonIndex == 1){ + [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; + }else{ + return; + } + [self presentViewController:imagePicker animated:YES completion:^{}]; +} + + + +-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info +{ + [self dismissViewControllerAnimated:YES completion:^{ + selectImage = info[@"UIImagePickerControllerEditedImage"]; + [self.headImageBTN setBackgroundImage:selectImage forState:UIControlStateNormal]; + }]; +} + +- (IBAction)cancelBTNPress:(id)sender { + [self dismissViewControllerAnimated:YES completion:^{}]; +} +@end diff --git a/CheckInBLE.xcodeproj/project.pbxproj b/CheckInBLE.xcodeproj/project.pbxproj new file mode 100644 index 0000000..cc02f63 --- /dev/null +++ b/CheckInBLE.xcodeproj/project.pbxproj @@ -0,0 +1,602 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + BE710CE519C181660055EBA0 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE710CE419C181660055EBA0 /* CoreData.framework */; }; + BE710CE919C190700055EBA0 /* EmployeeTool.m in Sources */ = {isa = PBXBuildFile; fileRef = BE710CE819C190700055EBA0 /* EmployeeTool.m */; }; + BE710CEF19C28B4F0055EBA0 /* EmployeeInfoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BE710CED19C28B4F0055EBA0 /* EmployeeInfoCell.m */; }; + BE710CF019C28B4F0055EBA0 /* EmployeeInfoCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = BE710CEE19C28B4F0055EBA0 /* EmployeeInfoCell.xib */; }; + BE710CF219C2D74B0055EBA0 /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE710CF119C2D74B0055EBA0 /* CoreBluetooth.framework */; }; + BEABF6B619C5D8B7001B9D5F /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEABF6B519C5D8B7001B9D5F /* CoreLocation.framework */; }; + BEADEDA119C685FA005805DB /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BEADEDA019C685FA005805DB /* Images.xcassets */; }; + BEC525B319C02290005D8EB4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC525B219C02290005D8EB4 /* Foundation.framework */; }; + BEC525B519C02290005D8EB4 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC525B419C02290005D8EB4 /* CoreGraphics.framework */; }; + BEC525B719C02290005D8EB4 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC525B619C02290005D8EB4 /* UIKit.framework */; }; + BEC525BD19C02290005D8EB4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = BEC525BB19C02290005D8EB4 /* InfoPlist.strings */; }; + BEC525BF19C02290005D8EB4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BEC525BE19C02290005D8EB4 /* main.m */; }; + BEC525C319C02290005D8EB4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = BEC525C219C02290005D8EB4 /* AppDelegate.m */; }; + BEC525C619C02290005D8EB4 /* Main_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BEC525C419C02290005D8EB4 /* Main_iPhone.storyboard */; }; + BEC525C919C02290005D8EB4 /* Main_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BEC525C719C02290005D8EB4 /* Main_iPad.storyboard */; }; + BEC525CC19C02290005D8EB4 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BEC525CB19C02290005D8EB4 /* ViewController.m */; }; + BEC525D519C02290005D8EB4 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC525D419C02290005D8EB4 /* XCTest.framework */; }; + BEC525D619C02290005D8EB4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC525B219C02290005D8EB4 /* Foundation.framework */; }; + BEC525D719C02290005D8EB4 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC525B619C02290005D8EB4 /* UIKit.framework */; }; + BEC525DF19C02290005D8EB4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = BEC525DD19C02290005D8EB4 /* InfoPlist.strings */; }; + BEC525E119C02290005D8EB4 /* CheckInBLETests.m in Sources */ = {isa = PBXBuildFile; fileRef = BEC525E019C02290005D8EB4 /* CheckInBLETests.m */; }; + BEC525EC19C03813005D8EB4 /* RootTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BEC525EB19C03813005D8EB4 /* RootTableViewController.m */; }; + BEC525EF19C0387D005D8EB4 /* AddEmployeeController.m in Sources */ = {isa = PBXBuildFile; fileRef = BEC525EE19C0387D005D8EB4 /* AddEmployeeController.m */; }; + BEC525F219C03895005D8EB4 /* EditEmployeeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BEC525F119C03895005D8EB4 /* EditEmployeeViewController.m */; }; + BEC525F519C038A5005D8EB4 /* CheckInViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BEC525F419C038A5005D8EB4 /* CheckInViewController.m */; }; + BEC525F819C0390D005D8EB4 /* SendDataViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BEC525F719C0390D005D8EB4 /* SendDataViewController.m */; }; + BEC525FB19C0394A005D8EB4 /* Employee.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = BEC525F919C0394A005D8EB4 /* Employee.xcdatamodeld */; }; + BEC525FE19C03A48005D8EB4 /* Employee.m in Sources */ = {isa = PBXBuildFile; fileRef = BEC525FD19C03A48005D8EB4 /* Employee.m */; }; + BEC89FE519C91A8D00814F2E /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC89FE419C91A8D00814F2E /* AVFoundation.framework */; }; + BEC89FE719C91A9F00814F2E /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEC89FE619C91A9F00814F2E /* MediaPlayer.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + BEC525D819C02290005D8EB4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = BEC525A719C02290005D8EB4 /* Project object */; + proxyType = 1; + remoteGlobalIDString = BEC525AE19C02290005D8EB4; + remoteInfo = CheckInBLE; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + BE710CE419C181660055EBA0 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; + BE710CE719C190700055EBA0 /* EmployeeTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmployeeTool.h; sourceTree = ""; }; + BE710CE819C190700055EBA0 /* EmployeeTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EmployeeTool.m; sourceTree = ""; }; + BE710CEA19C193080055EBA0 /* singleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = singleton.h; sourceTree = ""; }; + BE710CEC19C28B4F0055EBA0 /* EmployeeInfoCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmployeeInfoCell.h; sourceTree = ""; }; + BE710CED19C28B4F0055EBA0 /* EmployeeInfoCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EmployeeInfoCell.m; sourceTree = ""; }; + BE710CEE19C28B4F0055EBA0 /* EmployeeInfoCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = EmployeeInfoCell.xib; sourceTree = ""; }; + BE710CF119C2D74B0055EBA0 /* CoreBluetooth.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreBluetooth.framework; path = System/Library/Frameworks/CoreBluetooth.framework; sourceTree = SDKROOT; }; + BEABF6B519C5D8B7001B9D5F /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; + BEADEDA019C685FA005805DB /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + BEC525AF19C02290005D8EB4 /* CheckInBLE.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CheckInBLE.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC525B219C02290005D8EB4 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + BEC525B419C02290005D8EB4 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + BEC525B619C02290005D8EB4 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + BEC525BA19C02290005D8EB4 /* CheckInBLE-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CheckInBLE-Info.plist"; sourceTree = ""; }; + BEC525BC19C02290005D8EB4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + BEC525BE19C02290005D8EB4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + BEC525C019C02290005D8EB4 /* CheckInBLE-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CheckInBLE-Prefix.pch"; sourceTree = ""; }; + BEC525C119C02290005D8EB4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + BEC525C219C02290005D8EB4 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + BEC525C519C02290005D8EB4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main_iPhone.storyboard; sourceTree = ""; }; + BEC525C819C02290005D8EB4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main_iPad.storyboard; sourceTree = ""; }; + BEC525CA19C02290005D8EB4 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + BEC525CB19C02290005D8EB4 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + BEC525D319C02290005D8EB4 /* CheckInBLETests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CheckInBLETests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC525D419C02290005D8EB4 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; + BEC525DC19C02290005D8EB4 /* CheckInBLETests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CheckInBLETests-Info.plist"; sourceTree = ""; }; + BEC525DE19C02290005D8EB4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + BEC525E019C02290005D8EB4 /* CheckInBLETests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CheckInBLETests.m; sourceTree = ""; }; + BEC525EA19C03813005D8EB4 /* RootTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootTableViewController.h; sourceTree = ""; }; + BEC525EB19C03813005D8EB4 /* RootTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootTableViewController.m; sourceTree = ""; }; + BEC525ED19C0387D005D8EB4 /* AddEmployeeController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddEmployeeController.h; sourceTree = ""; }; + BEC525EE19C0387D005D8EB4 /* AddEmployeeController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddEmployeeController.m; sourceTree = ""; }; + BEC525F019C03895005D8EB4 /* EditEmployeeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditEmployeeViewController.h; sourceTree = ""; }; + BEC525F119C03895005D8EB4 /* EditEmployeeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EditEmployeeViewController.m; sourceTree = ""; }; + BEC525F319C038A5005D8EB4 /* CheckInViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CheckInViewController.h; sourceTree = ""; }; + BEC525F419C038A5005D8EB4 /* CheckInViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CheckInViewController.m; sourceTree = ""; }; + BEC525F619C0390D005D8EB4 /* SendDataViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SendDataViewController.h; sourceTree = ""; }; + BEC525F719C0390D005D8EB4 /* SendDataViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SendDataViewController.m; sourceTree = ""; }; + BEC525FA19C0394A005D8EB4 /* Employee.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Employee.xcdatamodel; sourceTree = ""; }; + BEC525FC19C03A48005D8EB4 /* Employee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Employee.h; sourceTree = ""; }; + BEC525FD19C03A48005D8EB4 /* Employee.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Employee.m; sourceTree = ""; }; + BEC89FE419C91A8D00814F2E /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; + BEC89FE619C91A9F00814F2E /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + BEC525AC19C02290005D8EB4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + BEC89FE719C91A9F00814F2E /* MediaPlayer.framework in Frameworks */, + BEC89FE519C91A8D00814F2E /* AVFoundation.framework in Frameworks */, + BEABF6B619C5D8B7001B9D5F /* CoreLocation.framework in Frameworks */, + BE710CF219C2D74B0055EBA0 /* CoreBluetooth.framework in Frameworks */, + BE710CE519C181660055EBA0 /* CoreData.framework in Frameworks */, + BEC525B519C02290005D8EB4 /* CoreGraphics.framework in Frameworks */, + BEC525B719C02290005D8EB4 /* UIKit.framework in Frameworks */, + BEC525B319C02290005D8EB4 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + BEC525D019C02290005D8EB4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + BEC525D519C02290005D8EB4 /* XCTest.framework in Frameworks */, + BEC525D719C02290005D8EB4 /* UIKit.framework in Frameworks */, + BEC525D619C02290005D8EB4 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + BE710CE619C1904F0055EBA0 /* Tool */ = { + isa = PBXGroup; + children = ( + BE710CEA19C193080055EBA0 /* singleton.h */, + BE710CE719C190700055EBA0 /* EmployeeTool.h */, + BE710CE819C190700055EBA0 /* EmployeeTool.m */, + ); + name = Tool; + sourceTree = ""; + }; + BE710CEB19C28AFF0055EBA0 /* View */ = { + isa = PBXGroup; + children = ( + BE710CEC19C28B4F0055EBA0 /* EmployeeInfoCell.h */, + BE710CED19C28B4F0055EBA0 /* EmployeeInfoCell.m */, + BE710CEE19C28B4F0055EBA0 /* EmployeeInfoCell.xib */, + ); + name = View; + sourceTree = ""; + }; + BEC525A619C02290005D8EB4 = { + isa = PBXGroup; + children = ( + BE710CEB19C28AFF0055EBA0 /* View */, + BE710CE619C1904F0055EBA0 /* Tool */, + BEC525FF19C03A54005D8EB4 /* Model */, + BEC525F619C0390D005D8EB4 /* SendDataViewController.h */, + BEC525F719C0390D005D8EB4 /* SendDataViewController.m */, + BEC525F319C038A5005D8EB4 /* CheckInViewController.h */, + BEC525F419C038A5005D8EB4 /* CheckInViewController.m */, + BEC525F019C03895005D8EB4 /* EditEmployeeViewController.h */, + BEC525F119C03895005D8EB4 /* EditEmployeeViewController.m */, + BEC525ED19C0387D005D8EB4 /* AddEmployeeController.h */, + BEC525EE19C0387D005D8EB4 /* AddEmployeeController.m */, + BEC525EA19C03813005D8EB4 /* RootTableViewController.h */, + BEC525EB19C03813005D8EB4 /* RootTableViewController.m */, + BEC525B819C02290005D8EB4 /* CheckInBLE */, + BEC525DA19C02290005D8EB4 /* CheckInBLETests */, + BEC525B119C02290005D8EB4 /* Frameworks */, + BEC525B019C02290005D8EB4 /* Products */, + ); + sourceTree = ""; + }; + BEC525B019C02290005D8EB4 /* Products */ = { + isa = PBXGroup; + children = ( + BEC525AF19C02290005D8EB4 /* CheckInBLE.app */, + BEC525D319C02290005D8EB4 /* CheckInBLETests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + BEC525B119C02290005D8EB4 /* Frameworks */ = { + isa = PBXGroup; + children = ( + BEC89FE619C91A9F00814F2E /* MediaPlayer.framework */, + BEC89FE419C91A8D00814F2E /* AVFoundation.framework */, + BEABF6B519C5D8B7001B9D5F /* CoreLocation.framework */, + BE710CF119C2D74B0055EBA0 /* CoreBluetooth.framework */, + BE710CE419C181660055EBA0 /* CoreData.framework */, + BEC525B219C02290005D8EB4 /* Foundation.framework */, + BEC525B419C02290005D8EB4 /* CoreGraphics.framework */, + BEC525B619C02290005D8EB4 /* UIKit.framework */, + BEC525D419C02290005D8EB4 /* XCTest.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + BEC525B819C02290005D8EB4 /* CheckInBLE */ = { + isa = PBXGroup; + children = ( + BEADEDA019C685FA005805DB /* Images.xcassets */, + BEC525C119C02290005D8EB4 /* AppDelegate.h */, + BEC525C219C02290005D8EB4 /* AppDelegate.m */, + BEC525C419C02290005D8EB4 /* Main_iPhone.storyboard */, + BEC525C719C02290005D8EB4 /* Main_iPad.storyboard */, + BEC525CA19C02290005D8EB4 /* ViewController.h */, + BEC525CB19C02290005D8EB4 /* ViewController.m */, + BEC525B919C02290005D8EB4 /* Supporting Files */, + ); + path = CheckInBLE; + sourceTree = ""; + }; + BEC525B919C02290005D8EB4 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + BEC525BA19C02290005D8EB4 /* CheckInBLE-Info.plist */, + BEC525BB19C02290005D8EB4 /* InfoPlist.strings */, + BEC525BE19C02290005D8EB4 /* main.m */, + BEC525C019C02290005D8EB4 /* CheckInBLE-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + BEC525DA19C02290005D8EB4 /* CheckInBLETests */ = { + isa = PBXGroup; + children = ( + BEC525E019C02290005D8EB4 /* CheckInBLETests.m */, + BEC525DB19C02290005D8EB4 /* Supporting Files */, + ); + path = CheckInBLETests; + sourceTree = ""; + }; + BEC525DB19C02290005D8EB4 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + BEC525DC19C02290005D8EB4 /* CheckInBLETests-Info.plist */, + BEC525DD19C02290005D8EB4 /* InfoPlist.strings */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + BEC525FF19C03A54005D8EB4 /* Model */ = { + isa = PBXGroup; + children = ( + BEC525F919C0394A005D8EB4 /* Employee.xcdatamodeld */, + BEC525FC19C03A48005D8EB4 /* Employee.h */, + BEC525FD19C03A48005D8EB4 /* Employee.m */, + ); + name = Model; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + BEC525AE19C02290005D8EB4 /* CheckInBLE */ = { + isa = PBXNativeTarget; + buildConfigurationList = BEC525E419C02290005D8EB4 /* Build configuration list for PBXNativeTarget "CheckInBLE" */; + buildPhases = ( + BEC525AB19C02290005D8EB4 /* Sources */, + BEC525AC19C02290005D8EB4 /* Frameworks */, + BEC525AD19C02290005D8EB4 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CheckInBLE; + productName = CheckInBLE; + productReference = BEC525AF19C02290005D8EB4 /* CheckInBLE.app */; + productType = "com.apple.product-type.application"; + }; + BEC525D219C02290005D8EB4 /* CheckInBLETests */ = { + isa = PBXNativeTarget; + buildConfigurationList = BEC525E719C02290005D8EB4 /* Build configuration list for PBXNativeTarget "CheckInBLETests" */; + buildPhases = ( + BEC525CF19C02290005D8EB4 /* Sources */, + BEC525D019C02290005D8EB4 /* Frameworks */, + BEC525D119C02290005D8EB4 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + BEC525D919C02290005D8EB4 /* PBXTargetDependency */, + ); + name = CheckInBLETests; + productName = CheckInBLETests; + productReference = BEC525D319C02290005D8EB4 /* CheckInBLETests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + BEC525A719C02290005D8EB4 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0510; + ORGANIZATIONNAME = CNPC; + TargetAttributes = { + BEC525D219C02290005D8EB4 = { + TestTargetID = BEC525AE19C02290005D8EB4; + }; + }; + }; + buildConfigurationList = BEC525AA19C02290005D8EB4 /* Build configuration list for PBXProject "CheckInBLE" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = BEC525A619C02290005D8EB4; + productRefGroup = BEC525B019C02290005D8EB4 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + BEC525AE19C02290005D8EB4 /* CheckInBLE */, + BEC525D219C02290005D8EB4 /* CheckInBLETests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + BEC525AD19C02290005D8EB4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BEC525C919C02290005D8EB4 /* Main_iPad.storyboard in Resources */, + BEADEDA119C685FA005805DB /* Images.xcassets in Resources */, + BE710CF019C28B4F0055EBA0 /* EmployeeInfoCell.xib in Resources */, + BEC525C619C02290005D8EB4 /* Main_iPhone.storyboard in Resources */, + BEC525BD19C02290005D8EB4 /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + BEC525D119C02290005D8EB4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BEC525DF19C02290005D8EB4 /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + BEC525AB19C02290005D8EB4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BEC525F219C03895005D8EB4 /* EditEmployeeViewController.m in Sources */, + BEC525CC19C02290005D8EB4 /* ViewController.m in Sources */, + BEC525F519C038A5005D8EB4 /* CheckInViewController.m in Sources */, + BEC525C319C02290005D8EB4 /* AppDelegate.m in Sources */, + BE710CE919C190700055EBA0 /* EmployeeTool.m in Sources */, + BE710CEF19C28B4F0055EBA0 /* EmployeeInfoCell.m in Sources */, + BEC525EF19C0387D005D8EB4 /* AddEmployeeController.m in Sources */, + BEC525FE19C03A48005D8EB4 /* Employee.m in Sources */, + BEC525BF19C02290005D8EB4 /* main.m in Sources */, + BEC525F819C0390D005D8EB4 /* SendDataViewController.m in Sources */, + BEC525FB19C0394A005D8EB4 /* Employee.xcdatamodeld in Sources */, + BEC525EC19C03813005D8EB4 /* RootTableViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + BEC525CF19C02290005D8EB4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BEC525E119C02290005D8EB4 /* CheckInBLETests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + BEC525D919C02290005D8EB4 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = BEC525AE19C02290005D8EB4 /* CheckInBLE */; + targetProxy = BEC525D819C02290005D8EB4 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + BEC525BB19C02290005D8EB4 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + BEC525BC19C02290005D8EB4 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + BEC525C419C02290005D8EB4 /* Main_iPhone.storyboard */ = { + isa = PBXVariantGroup; + children = ( + BEC525C519C02290005D8EB4 /* Base */, + ); + name = Main_iPhone.storyboard; + sourceTree = ""; + }; + BEC525C719C02290005D8EB4 /* Main_iPad.storyboard */ = { + isa = PBXVariantGroup; + children = ( + BEC525C819C02290005D8EB4 /* Base */, + ); + name = Main_iPad.storyboard; + sourceTree = ""; + }; + BEC525DD19C02290005D8EB4 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + BEC525DE19C02290005D8EB4 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + BEC525E219C02290005D8EB4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + BEC525E319C02290005D8EB4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + BEC525E519C02290005D8EB4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CheckInBLE/CheckInBLE-Prefix.pch"; + INFOPLIST_FILE = "CheckInBLE/CheckInBLE-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + BEC525E619C02290005D8EB4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CheckInBLE/CheckInBLE-Prefix.pch"; + INFOPLIST_FILE = "CheckInBLE/CheckInBLE-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + BEC525E819C02290005D8EB4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/CheckInBLE.app/CheckInBLE"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CheckInBLE/CheckInBLE-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = "CheckInBLETests/CheckInBLETests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = xctest; + }; + name = Debug; + }; + BEC525E919C02290005D8EB4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/CheckInBLE.app/CheckInBLE"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CheckInBLE/CheckInBLE-Prefix.pch"; + INFOPLIST_FILE = "CheckInBLETests/CheckInBLETests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = xctest; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + BEC525AA19C02290005D8EB4 /* Build configuration list for PBXProject "CheckInBLE" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BEC525E219C02290005D8EB4 /* Debug */, + BEC525E319C02290005D8EB4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + BEC525E419C02290005D8EB4 /* Build configuration list for PBXNativeTarget "CheckInBLE" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BEC525E519C02290005D8EB4 /* Debug */, + BEC525E619C02290005D8EB4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + BEC525E719C02290005D8EB4 /* Build configuration list for PBXNativeTarget "CheckInBLETests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BEC525E819C02290005D8EB4 /* Debug */, + BEC525E919C02290005D8EB4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCVersionGroup section */ + BEC525F919C0394A005D8EB4 /* Employee.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + BEC525FA19C0394A005D8EB4 /* Employee.xcdatamodel */, + ); + currentVersion = BEC525FA19C0394A005D8EB4 /* Employee.xcdatamodel */; + path = Employee.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ + }; + rootObject = BEC525A719C02290005D8EB4 /* Project object */; +} diff --git a/CheckInBLE.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/CheckInBLE.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..9bcf6f8 --- /dev/null +++ b/CheckInBLE.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/CheckInBLE.xcodeproj/project.xcworkspace/xcshareddata/CheckInBLE.xccheckout b/CheckInBLE.xcodeproj/project.xcworkspace/xcshareddata/CheckInBLE.xccheckout new file mode 100644 index 0000000..f33b30e --- /dev/null +++ b/CheckInBLE.xcodeproj/project.xcworkspace/xcshareddata/CheckInBLE.xccheckout @@ -0,0 +1,41 @@ + + + + + IDESourceControlProjectFavoriteDictionaryKey + + IDESourceControlProjectIdentifier + B58ACE6A-50F5-40A8-BC34-EBED2BFE742E + IDESourceControlProjectName + CheckInBLE + IDESourceControlProjectOriginsDictionary + + A24ECB4B8177D7A10C5E2C3A06F33B87B50273F1 + https://git.oschina.net/johnathan/CheckInBLE.git + + IDESourceControlProjectPath + CheckInBLE.xcodeproj + IDESourceControlProjectRelativeInstallPathDictionary + + A24ECB4B8177D7A10C5E2C3A06F33B87B50273F1 + ../.. + + IDESourceControlProjectURL + https://git.oschina.net/johnathan/CheckInBLE.git + IDESourceControlProjectVersion + 111 + IDESourceControlProjectWCCIdentifier + A24ECB4B8177D7A10C5E2C3A06F33B87B50273F1 + IDESourceControlProjectWCConfigurations + + + IDESourceControlRepositoryExtensionIdentifierKey + public.vcs.git + IDESourceControlWCCIdentifierKey + A24ECB4B8177D7A10C5E2C3A06F33B87B50273F1 + IDESourceControlWCCName + CheckInBLE + + + + diff --git a/CheckInBLE.xcodeproj/project.xcworkspace/xcuserdata/onemade.xcuserdatad/UserInterfaceState.xcuserstate b/CheckInBLE.xcodeproj/project.xcworkspace/xcuserdata/onemade.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..1fc15fe Binary files /dev/null and b/CheckInBLE.xcodeproj/project.xcworkspace/xcuserdata/onemade.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/CheckInBLE.xcodeproj/xcuserdata/onemade.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/CheckInBLE.xcodeproj/xcuserdata/onemade.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..caa1108 --- /dev/null +++ b/CheckInBLE.xcodeproj/xcuserdata/onemade.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CheckInBLE.xcodeproj/xcuserdata/onemade.xcuserdatad/xcschemes/CheckInBLE.xcscheme b/CheckInBLE.xcodeproj/xcuserdata/onemade.xcuserdatad/xcschemes/CheckInBLE.xcscheme new file mode 100644 index 0000000..0075316 --- /dev/null +++ b/CheckInBLE.xcodeproj/xcuserdata/onemade.xcuserdatad/xcschemes/CheckInBLE.xcscheme @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CheckInBLE.xcodeproj/xcuserdata/onemade.xcuserdatad/xcschemes/xcschememanagement.plist b/CheckInBLE.xcodeproj/xcuserdata/onemade.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..1408c3d --- /dev/null +++ b/CheckInBLE.xcodeproj/xcuserdata/onemade.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,27 @@ + + + + + SchemeUserState + + CheckInBLE.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + BEC525AE19C02290005D8EB4 + + primary + + + BEC525D219C02290005D8EB4 + + primary + + + + + diff --git a/CheckInBLE/AppDelegate.h b/CheckInBLE/AppDelegate.h new file mode 100644 index 0000000..adcb3ca --- /dev/null +++ b/CheckInBLE/AppDelegate.h @@ -0,0 +1,27 @@ +// +// AppDelegate.h +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import +#import + +@interface AppDelegate : UIResponder + +@property(strong, nonatomic) UIWindow *window; + +@property(strong, nonatomic) NSManagedObjectModel *managedObjectModel; +@property(strong, nonatomic) NSManagedObjectContext *managedObjectContext; +@property(strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; + +-(NSManagedObjectModel *)managedObjectModel; +-(NSManagedObjectContext *)managedObjectContext; +-(NSPersistentStoreCoordinator *)persistentStoreCoordinator; + +-(void)saveContext; +-(NSURL *)applicationDocumentDictionary; + +@end diff --git a/CheckInBLE/AppDelegate.m b/CheckInBLE/AppDelegate.m new file mode 100644 index 0000000..6032456 --- /dev/null +++ b/CheckInBLE/AppDelegate.m @@ -0,0 +1,118 @@ +// +// AppDelegate.m +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import "AppDelegate.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + // Override point for customization after application launch. + + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application +{ + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background/Users/onemade/work/CheckInBLE/CheckInBLE/Base.lproj/Main_iPhone.storyboard state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application +{ + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application +{ + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application +{ + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application +{ + [self saveContext]; + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +//设置数据库路径 +-(NSURL *)applicationDocumentDictionary +{ + return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; + // [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; +} + + +//初始化实体 +-(NSManagedObjectModel *)managedObjectModel +{ + if (_managedObjectModel != nil) { + return _managedObjectModel; + } + +// return _managedObjectModel =[NSManagedObjectModel mergedModelFromBundles:nil]; + + NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Employee" withExtension:@"momd"]; + _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; + return _managedObjectModel; +} + +//初始化数据库 +-(NSPersistentStoreCoordinator *)persistentStoreCoordinator +{ + if (_persistentStoreCoordinator != nil) { + return _persistentStoreCoordinator; + } + NSURL *store = [[self applicationDocumentDictionary] URLByAppendingPathComponent:@"Employee.sqlite"]; + + NSError *error = nil; + _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; + if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:store options:nil error:&error]) { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"错误" message:[NSString stringWithFormat:@"%@ \n %@",error,[error userInfo]] delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; + [alert show]; + } + + return _persistentStoreCoordinator; +} + +//初始化实体上下文 +-(NSManagedObjectContext *)managedObjectContext +{ + if (_managedObjectContext != nil) { + return _managedObjectContext; + } + + NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; + if (coordinator != nil) { + _managedObjectContext = [[NSManagedObjectContext alloc] init]; + [_managedObjectContext setPersistentStoreCoordinator:coordinator]; + } + return _managedObjectContext; +} + +//保存更改 +-(void)saveContext +{ + NSError *error = nil; + NSManagedObjectContext *context = [self managedObjectContext]; + if (context != nil) { + if ([context hasChanges] && ![context save:&error]) { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"保存失败" message:[NSString stringWithFormat:@"%@",error] delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; + [alert show]; + abort(); + } + } +} + + +@end diff --git a/CheckInBLE/Base.lproj/Main_iPad.storyboard b/CheckInBLE/Base.lproj/Main_iPad.storyboard new file mode 100644 index 0000000..4edef30 --- /dev/null +++ b/CheckInBLE/Base.lproj/Main_iPad.storyboard @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CheckInBLE/Base.lproj/Main_iPhone.storyboard b/CheckInBLE/Base.lproj/Main_iPhone.storyboard new file mode 100644 index 0000000..5c6d8a3 --- /dev/null +++ b/CheckInBLE/Base.lproj/Main_iPhone.storyboard @@ -0,0 +1,476 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CheckInBLE/CheckInBLE-Info.plist b/CheckInBLE/CheckInBLE-Info.plist new file mode 100644 index 0000000..7beb739 --- /dev/null +++ b/CheckInBLE/CheckInBLE-Info.plist @@ -0,0 +1,47 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + CNPC.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UIMainStoryboardFile + Main_iPhone + UIMainStoryboardFile~ipad + Main_iPad + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/CheckInBLE/CheckInBLE-Prefix.pch b/CheckInBLE/CheckInBLE-Prefix.pch new file mode 100644 index 0000000..b08c1da --- /dev/null +++ b/CheckInBLE/CheckInBLE-Prefix.pch @@ -0,0 +1,21 @@ +// +// Prefix header +// +// The contents of this file are implicitly included at the beginning of every source file. +// + +#import + +#ifndef __IPHONE_5_0 +#warning "This project uses features only available in iOS SDK 5.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import "singleton.h" + #import +#endif + +#define iBeacon_UUID @"14387083-80B0-4FE5-BBD8-3429661965D4" +#define iBeacon_Identifier @"com.roczhang" +#define svcType @"iBeacon-Service" diff --git a/CheckInBLE/Images.xcassets/AppIcon.appiconset/Contents.json b/CheckInBLE/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..91bf9c1 --- /dev/null +++ b/CheckInBLE/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,53 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CheckInBLE/Images.xcassets/LaunchImage.launchimage/Contents.json b/CheckInBLE/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000..6f870a4 --- /dev/null +++ b/CheckInBLE/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,51 @@ +{ + "images" : [ + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "subtype" : "retina4", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CheckInBLE/Images.xcassets/button/broadcastBtn.imageset/Contents.json b/CheckInBLE/Images.xcassets/button/broadcastBtn.imageset/Contents.json new file mode 100644 index 0000000..91698fc --- /dev/null +++ b/CheckInBLE/Images.xcassets/button/broadcastBtn.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "broadcastBtn.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "broadcastBtn@2x.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CheckInBLE/Images.xcassets/button/broadcastBtn.imageset/broadcastBtn.png b/CheckInBLE/Images.xcassets/button/broadcastBtn.imageset/broadcastBtn.png new file mode 100644 index 0000000..aec14c4 Binary files /dev/null and b/CheckInBLE/Images.xcassets/button/broadcastBtn.imageset/broadcastBtn.png differ diff --git a/CheckInBLE/Images.xcassets/button/broadcastBtn.imageset/broadcastBtn@2x.png b/CheckInBLE/Images.xcassets/button/broadcastBtn.imageset/broadcastBtn@2x.png new file mode 100644 index 0000000..379ed25 Binary files /dev/null and b/CheckInBLE/Images.xcassets/button/broadcastBtn.imageset/broadcastBtn@2x.png differ diff --git a/CheckInBLE/Images.xcassets/button/camera.imageset/Contents.json b/CheckInBLE/Images.xcassets/button/camera.imageset/Contents.json new file mode 100644 index 0000000..92c9f68 --- /dev/null +++ b/CheckInBLE/Images.xcassets/button/camera.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "camera.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "camera@2x.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CheckInBLE/Images.xcassets/button/camera.imageset/camera.png b/CheckInBLE/Images.xcassets/button/camera.imageset/camera.png new file mode 100644 index 0000000..45ce71a Binary files /dev/null and b/CheckInBLE/Images.xcassets/button/camera.imageset/camera.png differ diff --git a/CheckInBLE/Images.xcassets/button/camera.imageset/camera@2x.png b/CheckInBLE/Images.xcassets/button/camera.imageset/camera@2x.png new file mode 100644 index 0000000..45ce71a Binary files /dev/null and b/CheckInBLE/Images.xcassets/button/camera.imageset/camera@2x.png differ diff --git a/CheckInBLE/Images.xcassets/icon/getpics.imageset/Contents.json b/CheckInBLE/Images.xcassets/icon/getpics.imageset/Contents.json new file mode 100644 index 0000000..1d01524 --- /dev/null +++ b/CheckInBLE/Images.xcassets/icon/getpics.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "getpics.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "getpics@2x.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CheckInBLE/Images.xcassets/icon/getpics.imageset/getpics.png b/CheckInBLE/Images.xcassets/icon/getpics.imageset/getpics.png new file mode 100644 index 0000000..a877b21 Binary files /dev/null and b/CheckInBLE/Images.xcassets/icon/getpics.imageset/getpics.png differ diff --git a/CheckInBLE/Images.xcassets/icon/getpics.imageset/getpics@2x.png b/CheckInBLE/Images.xcassets/icon/getpics.imageset/getpics@2x.png new file mode 100644 index 0000000..a877b21 Binary files /dev/null and b/CheckInBLE/Images.xcassets/icon/getpics.imageset/getpics@2x.png differ diff --git a/CheckInBLE/Images.xcassets/icon/personal_head_default.imageset/Contents.json b/CheckInBLE/Images.xcassets/icon/personal_head_default.imageset/Contents.json new file mode 100644 index 0000000..fc00e1e --- /dev/null +++ b/CheckInBLE/Images.xcassets/icon/personal_head_default.imageset/Contents.json @@ -0,0 +1,17 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "personal_head_default@2x.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CheckInBLE/Images.xcassets/icon/personal_head_default.imageset/personal_head_default@2x.png b/CheckInBLE/Images.xcassets/icon/personal_head_default.imageset/personal_head_default@2x.png new file mode 100644 index 0000000..b9a04ba Binary files /dev/null and b/CheckInBLE/Images.xcassets/icon/personal_head_default.imageset/personal_head_default@2x.png differ diff --git a/CheckInBLE/Images.xcassets/icon/plus.imageset/Contents.json b/CheckInBLE/Images.xcassets/icon/plus.imageset/Contents.json new file mode 100644 index 0000000..d94f930 --- /dev/null +++ b/CheckInBLE/Images.xcassets/icon/plus.imageset/Contents.json @@ -0,0 +1,18 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "plus.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "plus@2x.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CheckInBLE/Images.xcassets/icon/plus.imageset/plus.png b/CheckInBLE/Images.xcassets/icon/plus.imageset/plus.png new file mode 100644 index 0000000..c6617e8 Binary files /dev/null and b/CheckInBLE/Images.xcassets/icon/plus.imageset/plus.png differ diff --git a/CheckInBLE/Images.xcassets/icon/plus.imageset/plus@2x.png b/CheckInBLE/Images.xcassets/icon/plus.imageset/plus@2x.png new file mode 100644 index 0000000..c6617e8 Binary files /dev/null and b/CheckInBLE/Images.xcassets/icon/plus.imageset/plus@2x.png differ diff --git a/CheckInBLE/Images.xcassets/icon/predicate.imageset/Contents.json b/CheckInBLE/Images.xcassets/icon/predicate.imageset/Contents.json new file mode 100644 index 0000000..91fc99d --- /dev/null +++ b/CheckInBLE/Images.xcassets/icon/predicate.imageset/Contents.json @@ -0,0 +1,17 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "predicate.png" + }, + { + "idiom" : "universal", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CheckInBLE/Images.xcassets/icon/predicate.imageset/predicate.png b/CheckInBLE/Images.xcassets/icon/predicate.imageset/predicate.png new file mode 100644 index 0000000..af37519 Binary files /dev/null and b/CheckInBLE/Images.xcassets/icon/predicate.imageset/predicate.png differ diff --git a/CheckInBLE/ViewController.h b/CheckInBLE/ViewController.h new file mode 100644 index 0000000..d09f668 --- /dev/null +++ b/CheckInBLE/ViewController.h @@ -0,0 +1,13 @@ +// +// ViewController.h +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + +@end diff --git a/CheckInBLE/ViewController.m b/CheckInBLE/ViewController.m new file mode 100644 index 0000000..22c74d1 --- /dev/null +++ b/CheckInBLE/ViewController.m @@ -0,0 +1,29 @@ +// +// ViewController.m +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import "ViewController.h" + +@interface ViewController () + +@end + +@implementation ViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view, typically from a nib. +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +@end diff --git a/CheckInBLE/en.lproj/InfoPlist.strings b/CheckInBLE/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/CheckInBLE/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/CheckInBLE/main.m b/CheckInBLE/main.m new file mode 100644 index 0000000..a6a054a --- /dev/null +++ b/CheckInBLE/main.m @@ -0,0 +1,18 @@ +// +// main.m +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import + +#import "AppDelegate.h" + +int main(int argc, char * argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/CheckInBLETests/CheckInBLETests-Info.plist b/CheckInBLETests/CheckInBLETests-Info.plist new file mode 100644 index 0000000..db40a23 --- /dev/null +++ b/CheckInBLETests/CheckInBLETests-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + CNPC.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/CheckInBLETests/CheckInBLETests.m b/CheckInBLETests/CheckInBLETests.m new file mode 100644 index 0000000..10b77a7 --- /dev/null +++ b/CheckInBLETests/CheckInBLETests.m @@ -0,0 +1,34 @@ +// +// CheckInBLETests.m +// CheckInBLETests +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import + +@interface CheckInBLETests : XCTestCase + +@end + +@implementation CheckInBLETests + +- (void)setUp +{ + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown +{ + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample +{ + XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); +} + +@end diff --git a/CheckInBLETests/en.lproj/InfoPlist.strings b/CheckInBLETests/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/CheckInBLETests/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/CheckInViewController.h b/CheckInViewController.h new file mode 100644 index 0000000..6e1a8eb --- /dev/null +++ b/CheckInViewController.h @@ -0,0 +1,29 @@ +// +// CheckInViewController.h +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import +#import +#import +#import + +@interface CheckInViewController : UIViewController +@property (weak, nonatomic) IBOutlet UIView *containerView; +@property (weak, nonatomic) IBOutlet UIScrollView *containerScroll; + +@property (weak, nonatomic) IBOutlet UITextField *nameTextField; +@property (weak, nonatomic) IBOutlet UITextField *identifierTextField; +@property (weak, nonatomic) IBOutlet UILabel *checkStatusLabel; +@property (weak, nonatomic) IBOutlet UIButton *checkInBTN; + +@property (strong, nonatomic) CBPeripheralManager * peripheralManager; +@property (strong, nonatomic) CLBeaconRegion * beaconRegion; +@property (strong, nonatomic) NSDictionary * beaconData; + + +- (IBAction)checkInBTNPress:(id)sender; +@end diff --git a/CheckInViewController.m b/CheckInViewController.m new file mode 100644 index 0000000..7093f23 --- /dev/null +++ b/CheckInViewController.m @@ -0,0 +1,120 @@ +// +// CheckInViewController.m +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import "CheckInViewController.h" + +@interface CheckInViewController () + +@end + +@implementation CheckInViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; +// [self.containerScroll setContentSize:self.view.frame.size-self.navigationController.navigationBar.frame.size]; + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +-(void)initPeripheralBeaconWithMajor:(int)major withMinor:(int)minor +{ + NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:iBeacon_UUID]; + self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid major:major minor:minor identifier:iBeacon_Identifier]; + self.beaconData = [self.beaconRegion peripheralDataWithMeasuredPower:@-59]; + self.peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil options:nil]; +} + + +#pragma mark - CBPeripheralManagerDelegate +-(void)peripheralManagerDidStartAdvertising:(CBPeripheralManager *)peripheral error:(NSError *)error +{ + NSLog(@"start advertising"); +} + +-(void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral +{ + if (peripheral.state == CBPeripheralManagerStatePoweredOn) { + self.checkStatusLabel.text = @"签到中。。。"; + [self.peripheralManager startAdvertising:self.beaconData]; + }else if (peripheral.state == CBPeripheralManagerStatePoweredOff){ + self.checkStatusLabel.text = @"请检查蓝牙状态"; + }else if (peripheral.state == CBPeripheralManagerStateUnsupported){ + self.checkStatusLabel.text = @"该设备不支持"; + } +} + + + +#pragma mark - UITextFieldDelegate +-(BOOL)textFieldShouldReturn:(UITextField *)textField +{ + [textField resignFirstResponder]; + [UIView animateWithDuration:1.0 animations:^{ + [self.containerScroll setContentSize:CGSizeMake(self.containerScroll.frame.size.width, self.view.frame.size.height-70)]; + }]; + return YES; +} + +-(void)textFieldDidBeginEditing:(UITextField *)textField +{ + [self.containerScroll setContentSize:CGSizeMake(self.containerScroll.frame.size.width, self.view.frame.size.height+200)]; +} + +-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField +{ + return YES; +} +-(void)textFieldDidEndEditing:(UITextField *)textField +{ + if (textField.tag == 1004) { + [UIView animateWithDuration:1.0 animations:^{ + [self.containerScroll setContentSize:CGSizeMake(self.containerScroll.frame.size.width, self.view.frame.size.height-70)]; + }]; + } +} + +-(void)broadcasting +{ + [self.peripheralManager stopAdvertising]; +} + + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +- (IBAction)checkInBTNPress:(id)sender { + if (self.identifierTextField.text == nil || self.identifierTextField.text.length==0) { + [self.identifierTextField becomeFirstResponder]; + return; + } + [self initPeripheralBeaconWithMajor:1 withMinor:[self.identifierTextField.text intValue]]; +} +@end diff --git a/EditEmployeeViewController.h b/EditEmployeeViewController.h new file mode 100644 index 0000000..6156a68 --- /dev/null +++ b/EditEmployeeViewController.h @@ -0,0 +1,32 @@ +// +// EditEmployeeViewController.h +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import +#import "Employee.h" +#import "EmployeeTool.h" + +@interface EditEmployeeViewController : UIViewController + +@property(strong,nonatomic) Employee *currEmp; +@property (weak, nonatomic) IBOutlet UIScrollView *containScrollView; + +@property (weak, nonatomic) IBOutlet UIButton *headImageBTN; +@property (weak, nonatomic) IBOutlet UITextField *nameField; +@property (weak, nonatomic) IBOutlet UITextField *departmentField; +@property (weak, nonatomic) IBOutlet UITextField *positionField; +@property (strong, nonatomic) IBOutlet UITextField *identifierField; +@property (weak, nonatomic) IBOutlet UIButton *updataBTN; +@property (weak, nonatomic) IBOutlet UIButton *deleteBTN; +@property (weak, nonatomic) IBOutlet UIButton *cancelBTN; + +- (IBAction)updateHeadImage:(id)sender; +- (IBAction)updateBTNPress:(id)sender; +- (IBAction)deleteBTNPress:(id)sender; +- (IBAction)cancelBTNPress:(id)sender; + +@end diff --git a/EditEmployeeViewController.m b/EditEmployeeViewController.m new file mode 100644 index 0000000..aacb67b --- /dev/null +++ b/EditEmployeeViewController.m @@ -0,0 +1,152 @@ +// +// EditEmployeeViewController.m +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import "EditEmployeeViewController.h" + +@interface EditEmployeeViewController () +{ + UIImage *selectImage; +} +@end + +@implementation EditEmployeeViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +- (IBAction)updateHeadImage:(id)sender { + UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"编辑头像" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"拍照" otherButtonTitles:@"图片库", nil]; + [actionSheet showInView:self.view]; +} + +- (IBAction)updateBTNPress:(id)sender { + NSString *name = self.nameField.text; + NSString *position = self.positionField.text; + NSData *headImage= nil; + NSString *department = self.departmentField.text; + NSInteger identifier = [self.identifierField.text intValue]; + if (selectImage != nil) { + headImage = UIImagePNGRepresentation(selectImage); + }else{ + headImage = UIImagePNGRepresentation([self.headImageBTN backgroundImageForState:UIControlStateNormal]); + } + + self.currEmp.name = name; + self.currEmp.headImage = headImage; + self.currEmp.position = position; + self.currEmp.department = department; + self.currEmp.identifier = [NSNumber numberWithInteger:identifier]; + + [EmployeeTool sharedEmployeeTool].curEmp = self.currEmp; + BOOL isUpdateSuccess = [[EmployeeTool sharedEmployeeTool] updateEmployee:self.currEmp]; + if (isUpdateSuccess) { + [self cancelBTNPress:nil]; + } +} + +- (IBAction)deleteBTNPress:(id)sender { + UIAlertView* alert = [[UIAlertView alloc]initWithTitle:@"警告" message:@"删除该员工信息" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; + [alert show]; +} + +-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ + if (buttonIndex == 1) { + [EmployeeTool sharedEmployeeTool].curEmp = self.currEmp ; + BOOL isDeleteSuccess = [[EmployeeTool sharedEmployeeTool] deleteEmployee:self.currEmp]; + if (isDeleteSuccess) { + [self cancelBTNPress:nil]; + } + } +} + +-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex +{ + UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; + [imagePicker setDelegate:self]; + [imagePicker setEditing:YES]; + + if (buttonIndex == 0) { + [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera]; + }else if (buttonIndex == 1){ + [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; + }else{ + return; + } + [self presentViewController:imagePicker animated:YES completion:^{}]; +} + + + +-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info +{ + [self dismissViewControllerAnimated:YES completion:^{ + selectImage = info[@"UIImagePickerControllerOriginalImage"]; + [self.headImageBTN setBackgroundImage:selectImage forState:UIControlStateNormal]; + }]; +} + +-(BOOL)textFieldShouldReturn:(UITextField *)textField +{ + [textField resignFirstResponder]; + [UIView animateWithDuration:1.0 animations:^{ + [self.containScrollView setContentSize:CGSizeMake(self.containScrollView.frame.size.width, self.view.frame.size.height)]; + }]; + return YES; +} + +-(void)textFieldDidBeginEditing:(UITextField *)textField +{ + [self.containScrollView setContentSize:CGSizeMake(self.containScrollView.frame.size.width, self.view.frame.size.height+200)]; +} + +-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField +{ + return YES; +} +-(void)textFieldDidEndEditing:(UITextField *)textField +{ + if (textField.tag == 1004) { + [UIView animateWithDuration:1.0 animations:^{ + [self.containScrollView setContentSize:CGSizeMake(self.containScrollView.frame.size.width, self.view.frame.size.height)]; + }]; + } +} + +- (IBAction)cancelBTNPress:(id)sender { + [self dismissViewControllerAnimated:YES completion:^{}]; +} +@end diff --git a/Employee.h b/Employee.h new file mode 100644 index 0000000..4a71fc1 --- /dev/null +++ b/Employee.h @@ -0,0 +1,21 @@ +// +// Employee.h +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import +#import + + +@interface Employee : NSManagedObject + +@property (nonatomic, retain) NSData * headImage; +@property (nonatomic, retain) NSString * name; +@property (nonatomic, retain) NSString * position; +@property (nonatomic, retain) NSString * department; +@property (nonatomic, retain) NSNumber * identifier; + +@end diff --git a/Employee.m b/Employee.m new file mode 100644 index 0000000..a24ed43 --- /dev/null +++ b/Employee.m @@ -0,0 +1,20 @@ +// +// Employee.m +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import "Employee.h" + + +@implementation Employee + +@dynamic headImage; +@dynamic name; +@dynamic position; +@dynamic department; +@dynamic identifier; + +@end diff --git a/Employee.xcdatamodeld/Employee.xcdatamodel/contents b/Employee.xcdatamodeld/Employee.xcdatamodel/contents new file mode 100644 index 0000000..ed34e3d --- /dev/null +++ b/Employee.xcdatamodeld/Employee.xcdatamodel/contents @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/EmployeeInfoCell.h b/EmployeeInfoCell.h new file mode 100644 index 0000000..14f59c5 --- /dev/null +++ b/EmployeeInfoCell.h @@ -0,0 +1,17 @@ +// +// EmployeeInfoCell.h +// CheckInBLE +// +// Created by onemade on 14-9-12. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import + +@interface EmployeeInfoCell : UITableViewCell +@property (strong, nonatomic) IBOutlet UIImageView *headImage; +@property (strong, nonatomic) IBOutlet UILabel *name; +@property (strong, nonatomic) IBOutlet UILabel *position; +@property (strong, nonatomic) IBOutlet UILabel *identifier; + +@end diff --git a/EmployeeInfoCell.m b/EmployeeInfoCell.m new file mode 100644 index 0000000..ae56720 --- /dev/null +++ b/EmployeeInfoCell.m @@ -0,0 +1,26 @@ +// +// EmployeeInfoCell.m +// CheckInBLE +// +// Created by onemade on 14-9-12. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import "EmployeeInfoCell.h" + +@implementation EmployeeInfoCell + + +- (void)awakeFromNib +{ + // Initialization code +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated +{ + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/EmployeeInfoCell.xib b/EmployeeInfoCell.xib new file mode 100644 index 0000000..015c2c4 --- /dev/null +++ b/EmployeeInfoCell.xib @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EmployeeTool.h b/EmployeeTool.h new file mode 100644 index 0000000..df733b6 --- /dev/null +++ b/EmployeeTool.h @@ -0,0 +1,27 @@ +// +// EmployeeTool.h +// CheckInBLE +// +// Created by onemade on 14-9-11. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import +#import "AppDelegate.h" +#import "Employee.h" + +@interface EmployeeTool : NSObject + +//单例 +singleton_for_interface(EmployeeTool) + +@property(strong,nonatomic) Employee *curEmp; + +-(BOOL)isEmployeeExist:(int)identifier; +-(BOOL)addEmployee:(Employee *)emp; +-(BOOL)updateEmployee:(Employee *)curEmp; +-(BOOL)deleteEmployee:(Employee *)curEmp; +-(NSMutableArray *)fetchAllEmployees; +-(Employee *)findEmployeeById:(int)indentifier; + +@end diff --git a/EmployeeTool.m b/EmployeeTool.m new file mode 100644 index 0000000..4f33e39 --- /dev/null +++ b/EmployeeTool.m @@ -0,0 +1,124 @@ + // +// EmployeeTool.m +// CheckInBLE +// +// Created by onemade on 14-9-11. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import "EmployeeTool.h" + +@implementation EmployeeTool +single_for_implementation(EmployeeTool) + +-(AppDelegate *)appDelegate +{ + return [[UIApplication sharedApplication] delegate]; +} + +-(BOOL)isEmployeeExist:(int)identifier +{ + NSError *error = nil; + + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"identifier = %@",[NSNumber numberWithInteger:identifier]]; + NSFetchRequest *request = [self requestWithPredicate:predicate]; + [request setFetchLimit:1]; + + NSUInteger existCount = [[[self appDelegate] managedObjectContext] countForFetchRequest:request error:&error]; + if (existCount > 0) { + return YES; + } + return NO; +} + +-(BOOL)addEmployee:(Employee *)emp +{ + NSError *error = nil; + + BOOL isSaveSuccess = [[[self appDelegate] managedObjectContext] save:&error]; + if (!isSaveSuccess) { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"添加失败" message:[NSString stringWithFormat:@"%@",[error localizedDescription]] delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; + [alert show]; + } + return isSaveSuccess; +} + +-(BOOL)updateEmployee:(Employee *)curEmp +{ + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"identifier = %@",curEmp.identifier]; + NSFetchRequest *request = [self requestWithPredicate:predicate]; + [request setFetchLimit:1]; + + NSError * error = nil; + NSMutableArray *mutableFetchResult = [[[self appDelegate].managedObjectContext executeFetchRequest:request error:&error] mutableCopy]; + + if (mutableFetchResult == nil) { + NSLog(@"Error: %@,%@",error,[error userInfo]); + return NO; + } + + for (Employee *employee in mutableFetchResult) { + employee.identifier = curEmp.identifier; + [[self appDelegate].managedObjectContext save:&error]; + return YES; + } + + return NO; +} + +#pragma mark - 返回一个查询请求 +-(NSFetchRequest *)requestWithPredicate:(NSPredicate *)predicate +{ + NSFetchRequest *request = [[NSFetchRequest alloc] init]; + NSEntityDescription * entity = [NSEntityDescription entityForName:@"Employee" inManagedObjectContext:[self appDelegate].managedObjectContext]; + [request setEntity:entity]; + [request setPredicate:predicate]; + return request; +} + +-(BOOL)deleteEmployee:(Employee *)curEmp +{ + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"identifier = %@", curEmp.identifier]; + NSFetchRequest *request = [self requestWithPredicate:predicate]; + [request setPredicate:predicate]; + [request setFetchLimit:1]; + + NSError * error = nil; + + NSMutableArray * mutableFetchResult = [[[self appDelegate].managedObjectContext executeFetchRequest:request error:&error] mutableCopy]; + if (mutableFetchResult == nil) { + NSLog(@"Error: %@,%@",error,[error userInfo]); + return NO; + } + for (Employee * employee in mutableFetchResult) { + [[self appDelegate].managedObjectContext deleteObject:employee]; + [[self appDelegate].managedObjectContext save:&error]; + return YES; + } + + return NO; +} + +-(NSMutableArray *)fetchAllEmployees +{ + NSEntityDescription *entity = [NSEntityDescription entityForName:@"Employee" inManagedObjectContext:[self appDelegate].managedObjectContext]; + NSFetchRequest *request = [[NSFetchRequest alloc] init]; + [request setEntity:entity]; + + NSError * error = nil; + + return [[[self appDelegate].managedObjectContext executeFetchRequest:request error:&error] mutableCopy]; +} + +-(Employee *)findEmployeeById:(int)identifier +{ + NSMutableArray *allEmployees = [self fetchAllEmployees]; + for (Employee *employee in allEmployees) { + if ([employee.identifier intValue] == identifier) { + return employee; + } + } + return nil; +} + +@end diff --git a/README.md b/README.md new file mode 100644 index 0000000..1dae905 --- /dev/null +++ b/README.md @@ -0,0 +1,132 @@ +#说明 +>本程序是基于ios低功耗蓝牙技术iBeacon,实现无网状态下通过蓝牙模拟简单的签到小程序 + +##程序概要 +首页面展示员工信息、签到状态和一些操作按钮,用户可以点击 ***+*** 添加员工;点击 ***签到*** 按钮签到;点击 ***资料*** 按钮选择发送/接收端;点击 ***单元格*** 实现用户编辑。主要有一下几个页面实现: +1. 首页显示员工信息和签到状态列表 +签到状态 +2. 添加员工 +添加员工 +3. 删除员工 +删除员工 +4. 编辑员工 +>![编辑员工](previewers/update.png){:.some-css-class width="200"} +编辑员工 +5. 签到 +签到 +6. 发送选项 +发送选项 +7. 发送和接收信息 +接收/发送信息 + +##技术实现步骤及注意事项 +*** *注意:* ***本程序界面全部通过storyboard添加,并且取消自动布局选项(自动布局的constraint会影响UIScrollView显示) + +###数据库操作代理类 +把数据库实例信息放在系统的AppDelegate类中,方便其他控制器统一调用,在此之前要先创建数据库中的实体,New file 》Core Data 》 Data model;然后点击左下角的Add Entity,添加数据库员工信息表字段;最后右键Entity选择对Entity的实现类,此处时全自动的,避免实体和实现类不同名,初始化实体失败的现象 + + @property(strong, nonatomic) NSManagedObjectModel *managedObjectModel; + @property(strong, nonatomic) NSManagedObjectContext *managedObjectContext; + @property(strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; + + -(NSManagedObjectModel *)managedObjectModel; //初始化数据库实体 + -(NSManagedObjectContext *)managedObjectContext; //初始化数据库上下文,方便控制器中对数据的CRUD + -(NSPersistentStoreCoordinator *)persistentStoreCoordinator;//初始化数据库 + +在控制器viewController中调用上下文操作数据库时可以调用以下代码 + + [UIApplication sharedApplication] delegate].managedObjectContext + +###首页面RootViewController +1. 是UINavigationViewController + UITableViewController实现。其中table的style选择***plain***时,section会有推拉似的的效果,选择group则类似于静态背景文字 + 在右侧中添加UIBarButtonItem修改Identifer为Add,通过segue连接到AddEmplyeeController,此时可以设置segue切换viewController时的转换方式,一般是***push或者modal***(在xcode6.0以后增加了popover),在选择modal时可以选择转换时的动画效果; + 在左侧的navBar中加入了UISegmentButton,并在didViewAppear中,设置selectedSegmentIndex=-1取消选中状态,通过addTarget为segment添加点击事件方法; + [self.optionSegmentControl addTarget:self action:@selector(changeOptions:) forControlEvents:UIControlEventValueChanged]; + + -(void)changeOptions:(UISegmentedControl *)seg + { + if (seg.selectedSegmentIndex == 0) {...} + } + + >*注:*storyboard中的UITableViewController默认添加对delegate的实现和设置了 + self.tableview.delegage=self; + self.tableview.dataSource=self; + +2. 定义三个可变数组,为了存储所有员工、签到员工和未签到员工信息 + + NSMutableArray *allEmployees; + NSMutableArray *laterEmployees; + NSMutableArray *checkInEmployees; + + 在viewDidAppear中装载allEmployees,同时根据实际情况设置checkInEmployees和laterEmployyes,然后重新加载表格数据 +3. 实现tableView的delegate和datasource + - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView + { + return 2; //返回2,分别是0签到员工,1迟到员工 + } + + //可以返回两个UILabel或是UIButton,显示签到和迟到员工section标头 + -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section; + + //必须实现,可以通过判断section动态返回签到和迟到数组的count + - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; + + //必须实现,此处根据自定义的EmployeeInfoCell类获取xib显示相应的员工信息 + - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath + { + ... + + //以下是通过代码获取xib方法 + static BOOL nibsRegistered = NO; + if (!nibsRegistered) { + UINib *nib = [UINib nibWithNibName:@"EmployeeInfoCell" bundle:nil]; + [tableView registerNib:nib forCellReuseIdentifier:@"EmployeeInfoCell"]; + nibsRegistered = YES; + } + + ... + } + + //设计section的高度,默认的高度太低,不美观 + -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section; + + //设计每个员工信息row的高度,可根据头像设置 + - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; + + //设置每个员工信息是否可编辑 + -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath + + //返回编辑时row的style,可以选择delete和insert,此处只涉及到员工删除 + -(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath + { + return UITableViewCellEditingStyleDelete; + } + + //设计点击row中编辑按钮时间,此处是点击删除按钮后从员工列表中删除数据,并且从数据中删除 + -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath; + + //设计当点击某一条用户信息时的操作,此处当点击时跳转到员工更新页面,并将员工信息传递到更新页面 + -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; +可以根据情况自由定制 +4. iBeacon分两部分——广播端和接收端; ***广播端*** 发送一个UUID和一个identifier,还可以同时广播一个major值和minor值来区分同一区域不同的分类信息; ***接收端***通过设置一个监听器监听广播,*监听端的UUID必须和广播端的uuid保持一致* ,才能监听到广播,并且通过接收到的不同的major和minor值做不同的操作 +此程序的重要部分就是通过iBeacon实现签到的,让承载员工列表设备作为信号接收端,员工签到设备作为信号发送端。员工签到时广播自己的工号,接收端接收到员工编号进行筛选如有匹配的员工,则将员工放到签到的section处,同时从迟到的section中删除 +RootViewController作为接收端,CLBeaconRegion初始化监听域,CLLocationManager实施监听,接收端主要要实现CLLocationMamagerDelegate代理的三个方法 + -(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region + { + //当接收端进入到广播域时要进行的操作,此方法是在后台由ios管理,会默认唤醒程序 + } + + -(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region + { + //当接收端离开广播域是执行的操作,会默认唤醒程序 + } + + -(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region + { + //当接收端进入域,并开启应用,可以通过接受到的beacon进行筛选,并且对筛选出的beacon通过接收的信号强度(rssi)和虚拟广播端的距离(accuracy)进行操作 + } +>***注:***CLLoactionManagerDelegate中常用方法的执行顺序 +didStartMonitoringForRegion>didRangeBeacons>didDetermineState>didRangeBeacons>didEnterRegion>didStartMonitoringForRegion>didDetermineState>didRangeBeacons>didExistRegion + +###签到页面CheckInController + \ No newline at end of file diff --git a/RootTableViewController.h b/RootTableViewController.h new file mode 100644 index 0000000..a5c5495 --- /dev/null +++ b/RootTableViewController.h @@ -0,0 +1,29 @@ +// +// RootTableViewController.h +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import +#import "AddEmployeeController.h" +#import "EditEmployeeViewController.h" +#import "CheckInViewController.h" +#import "SendDataViewController.h" +#import "EmployeeTool.h" +#import "EmployeeInfoCell.h" +#import "AppDelegate.h" +#import +#import +#import + +@interface RootTableViewController : UITableViewController +@property (weak, nonatomic) IBOutlet UISegmentedControl *optionSegmentControl; +@property (strong, nonatomic) CLLocationManager *locationManager; +@property (strong, nonatomic) CBCentralManager *centralManager; +@property (strong, nonatomic) CLBeaconRegion *beaconRegion; +@property (strong, nonatomic) NSDictionary * beaconData; +@property (strong, nonatomic) NSMutableArray * employees; + +@end diff --git a/RootTableViewController.m b/RootTableViewController.m new file mode 100644 index 0000000..b0ecef7 --- /dev/null +++ b/RootTableViewController.m @@ -0,0 +1,430 @@ +// +// RootTableViewController.m +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import "RootTableViewController.h" + +@interface RootTableViewController () +{ + NSMutableArray *allEmployees; + NSMutableArray *laterEmployees; + NSMutableArray *checkInEmployees; + NSInteger currCount; +} + +@end + +@implementation RootTableViewController + +- (id)initWithStyle:(UITableViewStyle)style +{ + self = [super initWithStyle:style]; + if (self) { + // Custom initialization + } + return self; +} +-(void)initLocationManager +{ + NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:iBeacon_UUID]; + self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:iBeacon_Identifier]; + self.beaconData = [[NSDictionary alloc] init]; + self.locationManager = [CLLocationManager new]; + self.locationManager.delegate = self; + self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; +} + + +-(void)startCallTheRoll +{ + [self.locationManager startMonitoringForRegion:self.beaconRegion]; + [self.locationManager startRangingBeaconsInRegion:self.beaconRegion]; +} + +-(void)stopCallTheRoll +{ + [self.locationManager stopRangingBeaconsInRegion:self.beaconRegion]; + [self.locationManager stopMonitoringForRegion:self.beaconRegion]; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; +// [self loadAllEmployees]; + [self initLocationManager]; + [self startCallTheRoll]; + + [self.optionSegmentControl addTarget:self action:@selector(changeOptions:) forControlEvents:UIControlEventValueChanged]; +} + +-(void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + self.optionSegmentControl.selectedSegmentIndex = -1; + [self loadAllEmployees]; + [self.tableView reloadData]; +// dispatch_async(dispatch_get_main_queue(), ^{ +// [self loadAllEmployees]; +// [self initLocationManager]; +// [self startCallTheRoll]; +// [self.tableView reloadData]; +// }); +} + +-(void)changeOptions:(UISegmentedControl *)seg +{ + if (seg.selectedSegmentIndex == 0) { + [self stopCallTheRoll]; + CheckInViewController *checkInCOntroller = [self.storyboard instantiateViewControllerWithIdentifier:@"checkin"]; + [self.navigationController pushViewController:checkInCOntroller animated:YES]; + } + else{ + + UIMenuItem *broadcast = [[UIMenuItem alloc] initWithTitle:@"服务器端"action:@selector(advertiser:)]; + UIMenuItem *reciever = [[UIMenuItem alloc] initWithTitle:@"客户端"action:@selector(browser:)]; + UIMenuController *menu = [UIMenuController sharedMenuController]; + [menu setMenuItems:[NSArray arrayWithObjects:broadcast, reciever, nil]]; + [menu setTargetRect:self.optionSegmentControl.frame inView:self.optionSegmentControl]; + [menu setMenuVisible:YES animated:YES]; +// SendDataViewController *sendDataController = [self.storyboard instantiateViewControllerWithIdentifier:@"sendData"]; +// [self.navigationController pushViewController:sendDataController animated:YES]; + } +} +- (void)advertiser:(id)sender { + SendDataViewController *sendDataController = [self.storyboard instantiateViewControllerWithIdentifier:@"sendData"]; + [self.navigationController presentViewController:sendDataController animated:YES completion:^{ + [sendDataController initAdvertiser]; + }]; +} + +- (void)browser:(id)sender { + SendDataViewController *sendDataController = [self.storyboard instantiateViewControllerWithIdentifier:@"sendData"]; + +// [self.navigationController pushViewController:sendDataController animated:YES]; +// [sendDataController initBrowser]; + + [self.navigationController presentViewController:sendDataController animated:YES completion:^{ + [sendDataController initBrowser]; + }]; +} + +-(BOOL)canBecomeFirstResponder +{ + return YES; +} +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 2; +} +-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section +{ + UIButton *headerLabel = [[UIButton alloc] initWithFrame:CGRectZero]; + if (section == 0) { +// headerLabel.font = [UIFont boldSystemFontOfSize:18.0f]; +// headerLabel.backgroundColor = [UIColor lightGrayColor]; +// headerLabel.text = @" 签到人员"; +// headerLabel.textColor = [UIColor blackColor]; + +// headerLabel.font = [UIFont boldSystemFontOfSize:18.0f]; + [headerLabel setBackgroundColor:[UIColor lightGrayColor]]; + [headerLabel setTitle:@" 签到人员" forState:UIControlStateNormal]; + [headerLabel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; + [headerLabel addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside]; + return headerLabel; + }else if (section==1){ +// headerLabel.font = [UIFont boldSystemFontOfSize:18.0f]; +// headerLabel.backgroundColor = [UIColor redColor]; +// headerLabel.text = @" 未到人员"; +// headerLabel.textColor = [UIColor blackColor]; +// headerLabel.font = [UIFont boldSystemFontOfSize:18.0f]; + + [headerLabel setBackgroundColor:[UIColor redColor]]; + [headerLabel setTitle:@" 未到人员" forState:UIControlStateNormal]; + [headerLabel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; + return headerLabel; + } + return headerLabel; +} +-(void)click:(UIButton *)btn +{ + NSLog(@"click"); + laterEmployees = [allEmployees mutableCopy]; + checkInEmployees = [NSMutableArray array]; + [self.tableView reloadData]; +} +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + if (section == 0) { + return checkInEmployees.count; + }else if (section == 1){ + return laterEmployees.count; + } + return 0; +} + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + NSInteger row = [indexPath row]; + NSInteger section = [indexPath section]; +// NSString *cellIdentifier = @"employeeInfo"; +// UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; +// if (cell == nil) { +// cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:cellIdentifier]; +// } +// +// Employee *emp =[allEmployees objectAtIndex:[indexPath row]]; +// cell.textLabel.text = emp.name; +// cell.detailTextLabel.text = emp.position; +// cell.imageView.image = [UIImage imageWithData:emp.headImage]; + + static BOOL nibsRegistered = NO; + if (!nibsRegistered) { + UINib *nib = [UINib nibWithNibName:@"EmployeeInfoCell" bundle:nil]; + [tableView registerNib:nib forCellReuseIdentifier:@"EmployeeInfoCell"]; + nibsRegistered = YES; + } + + + EmployeeInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"EmployeeInfoCell" forIndexPath:indexPath]; + Employee *emp = nil; + + if (section == 1) { + emp =[laterEmployees objectAtIndex:row]; + }else{ + if (checkInEmployees.count>0) { + emp = [checkInEmployees objectAtIndex:row]; + } + } + cell.name.text = emp.name; + cell.position.text = emp.position; + cell.headImage.image = [UIImage imageWithData:emp.headImage]; + cell.identifier.text = [emp.identifier stringValue]; + return cell; +} + +-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section +{ + return 44.0; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + return 80.0; +} + + +-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath +{ + return YES; +} +-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (!self.tableView.isEditing) { + return UITableViewCellEditingStyleDelete; + } + return UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert; +} +-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath +{ + NSUInteger row = [indexPath row]; + NSUInteger section = [indexPath section]; + Employee *emp = nil; + if (section == 0&&checkInEmployees.count>0) { + + emp = [checkInEmployees objectAtIndex:row]; + [checkInEmployees removeObject:emp]; + + }else if(laterEmployees.count>0){ + + emp = [laterEmployees objectAtIndex:row]; + [laterEmployees removeObject:emp]; + } + + + if (emp != nil) { + + [allEmployees removeObject:emp]; + [[EmployeeTool sharedEmployeeTool] deleteEmployee:emp]; + + [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] + withRowAnimation:UITableViewRowAnimationAutomatic]; + } +} + +-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + Employee *emp = nil; + NSUInteger row = [indexPath row]; + NSUInteger section = [indexPath section]; + if (section == 0&&checkInEmployees.count>0) { + emp = [checkInEmployees objectAtIndex:row]; + }else if(laterEmployees.count>0){ + emp = [laterEmployees objectAtIndex:row]; + } + + if (emp != nil) { + EditEmployeeViewController *editEmployeeController = [self.storyboard instantiateViewControllerWithIdentifier:@"editEmployee"]; + [self.navigationController presentViewController:editEmployeeController animated:YES completion:^{ + editEmployeeController.currEmp = emp; + [editEmployeeController.headImageBTN setBackgroundImage:[UIImage imageWithData:emp.headImage] forState:UIControlStateNormal]; + editEmployeeController.nameField.text = emp.name; + editEmployeeController.positionField.text = emp.position; + editEmployeeController.departmentField.text = emp.department; + editEmployeeController.identifierField.text = [emp.identifier stringValue]; + }]; + } + +} + +#pragma mark - centralManager delegate +-(void)centralManagerDidUpdateState:(CBCentralManager *)central +{ + if (central.state != CBCentralManagerStatePoweredOn) { + UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"请打开蓝牙" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"设置" otherButtonTitles:nil,nil]; + [actionSheet showInView:self.view]; + } +} + +-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex +{ + + if (buttonIndex == 0) { +// [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; //for ios8 only + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Bluetooth"]]; + } +} + +#pragma mark - LocationManager delegate +-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region +{ + [self startCallTheRoll]; +} + +-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region +{ + + [self stopCallTheRoll]; +} + + + +-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region +{ +// for (CLBeacon * beacon in beacons) { +// for (Employee* emp in allEmployees) { +// if ([emp.identifier intValue] == [beacon.minor intValue]) { +// [checkInEmployees addObject:emp]; +//// [laterEmployees removeObject:emp]; +// +// if (beacon.proximity == CLProximityFar||beacon.proximity == CLProximityUnknown) { +// [checkInEmployees removeObject:emp]; +// }} +// } +// } +//// laterEmployees = allEmployees; +// [laterEmployees removeObjectsInArray:checkInEmployees]; +// [self.tableView reloadData]; + NSMutableArray* employeesToDelete = [NSMutableArray array]; + for (CLBeacon* beacon in beacons) { + for (Employee* emp in allEmployees) { + if ([beacon.minor intValue] == [emp.identifier intValue]) { + for (Employee* emp in laterEmployees) { + if ([emp.identifier intValue] == [beacon.minor intValue]) { + [employeesToDelete addObject:emp]; + } + } + } + } + } + if (employeesToDelete.count>0) { + [laterEmployees removeObjectsInArray:employeesToDelete]; + checkInEmployees = [allEmployees mutableCopy] ; + [checkInEmployees removeObjectsInArray:laterEmployees]; + [self.tableView reloadData]; + } + +} + + +//- (NSIndexPath *)tableView:(UITableView *)tableView +// willSelectRowAtIndexPath:(NSIndexPath *)indexPath { +// return nil; +//} + + +/* +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath +{ + // Return NO if you do not want the specified item to be editable. + return YES; +} +*/ + +/* +// Override to support editing the table view. +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } +} +*/ + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath +{ +} +*/ + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath +{ + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +-(void)loadAllEmployees +{ + allEmployees = [[EmployeeTool sharedEmployeeTool] fetchAllEmployees]; + currCount = allEmployees.count; + if (checkInEmployees == nil) { + checkInEmployees = [NSMutableArray array]; + } + if (laterEmployees == nil||checkInEmployees.count==0) { + laterEmployees = [allEmployees mutableCopy]; + } + + [self.tableView reloadData]; +} + +@end diff --git a/SendDataViewController.h b/SendDataViewController.h new file mode 100644 index 0000000..1230438 --- /dev/null +++ b/SendDataViewController.h @@ -0,0 +1,33 @@ +// +// SendDataViewController.h +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import +#import +#import +#import +#import + +@interface SendDataViewController : UIViewController +@property (strong, nonatomic) MCPeerID * advertiserPeerID; +@property (strong, nonatomic) MCSession * dataSession; +@property (strong, nonatomic) MCNearbyServiceAdvertiser * advertiser; +@property (strong, nonatomic) NSMutableArray * mutableBlockPeers; + +@property (strong, nonatomic) MCPeerID *browserPeerID; +@property (strong, nonatomic) MCNearbyServiceBrowser *brower; + +@property (strong, nonatomic) IBOutlet UISegmentedControl *optionSegment; +@property (strong, nonatomic) IBOutlet UITextView *stringToSend; + +@property (weak, nonatomic) IBOutlet UIButton *resourceBTN; + + +-(void)initAdvertiser; +-(void)initBrowser; + +@end diff --git a/SendDataViewController.m b/SendDataViewController.m new file mode 100644 index 0000000..cb9c56f --- /dev/null +++ b/SendDataViewController.m @@ -0,0 +1,324 @@ +// +// SendDataViewController.m +// CheckInBLE +// +// Created by onemade on 14-9-10. +// Copyright (c) 2014年 CNPC. All rights reserved. +// + +#import "SendDataViewController.h" + +@interface SendDataViewController () +{ + UIImage *selectImage; +} +@end + +@implementation SendDataViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + [self.optionSegment addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged]; + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} +-(void)viewDidAppear:(BOOL)animated +{ + self.optionSegment.selectedSegmentIndex = -1; + [super viewDidAppear:animated]; +} +-(void)viewDidDisappear:(BOOL)animated +{ +// [self stopAdvertising]; +// [self stopBrowser]; + [super viewDidDisappear:animated]; +} + + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +#pragma mark - UITextView Delegate +-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text +{ + if ([text isEqualToString:@"\n"]) { + [textView resignFirstResponder]; + return NO; + } + return YES; +} +-(BOOL)textViewShouldBeginEditing:(UITextView *)textView +{ + //定义一个toolBar + UIToolbar * topView = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 30)]; + + //设置style + [topView setBarStyle:UIBarStyleDefault]; + + //定义两个flexibleSpace的button,放在toolBar上,这样完成按钮就会在最右边 + UIBarButtonItem * button1 =[[UIBarButtonItem alloc]initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace target:self action:nil]; + + UIBarButtonItem * button2 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace target:self action:nil]; + + //定义完成按钮 + UIBarButtonItem * doneButton = [[UIBarButtonItem alloc]initWithTitle:@"完成" style:UIBarButtonItemStyleDone target:self action:@selector(resignKeyboard)]; + + //在toolBar上加上这些按钮 + NSArray * buttonsArray = [NSArray arrayWithObjects:button1,button2,doneButton,nil]; + [topView setItems:buttonsArray]; + + [textView setInputAccessoryView:topView]; + return YES; +} + +//隐藏键盘 +- (void)resignKeyboard { + [self.stringToSend resignFirstResponder]; +} + +#pragma mark - UISegmentControl target +-(void)valueChanged:(UISegmentedControl *)seg +{ + [self.resourceBTN setHidden:YES]; + [self.stringToSend setHidden:NO]; + NSData *data = nil; + NSError *error = nil; + if (seg.selectedSegmentIndex==0) { + [self.stringToSend setText:@""]; + UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"编辑头像" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"拍照" otherButtonTitles:@"图片库", nil]; + [actionSheet showInView:self.view]; + }else if (seg.selectedSegmentIndex == 1){ + if ([self.stringToSend.text isEqualToString:@""]) { + [self.stringToSend becomeFirstResponder]; + } + data = [self.stringToSend.text dataUsingEncoding:NSUTF8StringEncoding]; + [self.dataSession sendData:data toPeers:self.dataSession.connectedPeers withMode:MCSessionSendDataReliable error:&error]; + }else if (seg.selectedSegmentIndex == 2){ + + MPMediaPickerController *mpc = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMovie]; + mpc.delegate = self;//委托 + mpc.prompt =@"请选择文件";//提示文字 + mpc.allowsPickingMultipleItems=NO;//是否允许一次选择多个 + [self presentViewController:mpc animated:YES completion:^{ + + }]; + + }else{ + [self dismissViewControllerAnimated:YES completion:^{ + [self stopAdvertising]; + [self stopBrowser]; + }]; + } + self.optionSegment.selectedSegmentIndex = -1; +} + +- (IBAction)getResource:(id)sender { + +} +-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex +{ + + UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; + [imagePicker setDelegate:self]; + [imagePicker setEditing:YES]; + + if (buttonIndex == 0) { + [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera]; + }else if (buttonIndex == 1){ + [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; + }else{ + return; + } + [self presentViewController:imagePicker animated:YES completion:^{}]; +} + + +#pragma mark - UIImagePickerControllerDelegate +-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info +{ + [self dismissViewControllerAnimated:YES completion:^{ + selectImage = info[@"UIImagePickerControllerOriginalImage"]; + [self.resourceBTN setHidden:NO]; + [self.stringToSend setHidden:YES]; + [self.resourceBTN setBackgroundImage:selectImage forState:UIControlStateNormal]; + +// UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; + +// UIImage *smallerPhoto = [self rescaleImage:image toSize:CGSizeMake(600,800)]; + NSData *jpeg = UIImageJPEGRepresentation(selectImage, 0.2); + NSError *error = nil; + [self.dataSession sendData:jpeg toPeers:[self.dataSession connectedPeers] withMode:MCSessionSendDataReliable error:&error]; + }]; +} + +#pragma mark - MPMediaPickerController Delegate +- (void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection{ + /*insert your code*/ + for ( MPMediaItem* item in [mediaItemCollection items]) { + + } + [self dismissViewControllerAnimated:YES completion:^{}]; +} +-(void)mediaPickerDidCancel:(MPMediaPickerController *)mediaPicker{ + /*insert your code*/ + [self dismissViewControllerAnimated:YES completion:^{}]; +} +- (IBAction)sendInfo:(id)sender { + +} + +#pragma mark - init advertiser +-(void)initAdvertiser +{ + self.advertiserPeerID = [[MCPeerID alloc] initWithDisplayName:[[UIDevice currentDevice] name]]; + self.advertiser = [[MCNearbyServiceAdvertiser alloc] initWithPeer:self.advertiserPeerID discoveryInfo:nil serviceType:svcType]; + self.advertiser.delegate = self; + self.dataSession = [[MCSession alloc] initWithPeer:self.advertiserPeerID]; + self.dataSession.delegate = self; + + [self.advertiser startAdvertisingPeer]; +} +-(void)stopAdvertising +{ + [self.advertiser stopAdvertisingPeer]; +} + +#pragma mark - init browser +-(void)initBrowser +{ + self.browserPeerID = [[MCPeerID alloc] initWithDisplayName:[[UIDevice currentDevice] name]]; + self.dataSession = [[MCSession alloc] initWithPeer:self.browserPeerID]; + self.dataSession.delegate = self; + self.brower = [[MCNearbyServiceBrowser alloc] initWithPeer:self.browserPeerID serviceType:svcType]; + self.brower.delegate = self; + + [self.brower startBrowsingForPeers]; +} + +-(void)stopBrowser +{ + [self.brower stopBrowsingForPeers]; +} + +#pragma mark - MCNearbyServiceBrowserDelegate +-(void)browser:(MCNearbyServiceBrowser *)browser foundPeer:(MCPeerID *)peerID withDiscoveryInfo:(NSDictionary *)info +{ + [browser invitePeer:peerID + toSession:self.dataSession + withContext:nil + timeout:1000000.0]; +} +-(void)browser:(MCNearbyServiceBrowser *)browser lostPeer:(MCPeerID *)peerID +{ + +} +#pragma mark - MCNearByServiceAdvertiserDelegate +-(void)advertiser:(MCNearbyServiceAdvertiser *)advertiser didReceiveInvitationFromPeer:(MCPeerID *)peerID withContext:(NSData *)context invitationHandler:(void (^)(BOOL, MCSession *))invitationHandler +{ + if ([self.mutableBlockPeers containsObject:peerID]) { + invitationHandler(NO,nil); + } + invitationHandler(YES,self.dataSession); +} +-(void)advertiser:(MCNearbyServiceAdvertiser *)advertiser didNotStartAdvertisingPeer:(NSError *)error +{ + NSLog(@"%@",error); +} + +#pragma mark - MCSessionDelegate +-(void)session:(MCSession *)session peer:(MCPeerID *)peerID didChangeState:(MCSessionState)state +{ + NSString * status = nil; + switch (state) { + case MCSessionStateConnected: + status = @"Connected"; + break; + case MCSessionStateConnecting: + status=@"Connecting"; + break; + case MCSessionStateNotConnected: + status = @"DisConnected"; + break; + + default: + break; + } + + NSLog(@"%@",status); +} +-(void)session:(MCSession *)session didReceiveData:(NSData *)data fromPeer:(MCPeerID *)peerID +{ + NSString * message = [[NSString alloc ] initWithData:data encoding:NSUTF8StringEncoding]; + UIImage *image = [UIImage imageWithData:data]; + + dispatch_async(dispatch_get_main_queue(), ^{ + if (image) { + [self.resourceBTN setHidden:NO]; + [self.stringToSend setHidden:YES]; + [self.resourceBTN setBackgroundImage:image forState:UIControlStateNormal]; + }else{ + [self.resourceBTN setHidden:YES]; + [self.stringToSend setHidden:NO]; + [self.stringToSend setText:message]; + } + }); +} +-(void)session:(MCSession *)session didReceiveStream:(NSInputStream *)stream withName:(NSString *)streamName fromPeer:(MCPeerID *)peerID +{ + +} +-(void)session:(MCSession *)session didFinishReceivingResourceWithName:(NSString *)resourceName fromPeer:(MCPeerID *)peerID atURL:(NSURL *)localURL withError:(NSError *)error +{ + +} +-(void)session:(MCSession *)session didStartReceivingResourceWithName:(NSString *)resourceName fromPeer:(MCPeerID *)peerID withProgress:(NSProgress *)progress +{ + +} +-(void)session:(MCSession *)session didReceiveCertificate:(NSArray *)certificate fromPeer:(MCPeerID *)peerID certificateHandler:(void (^)(BOOL))certificateHandler +{ + certificateHandler(YES); +} + +#pragma mark - Send Data Option +-(void)sendMessage +{ + +} +-(void)sendImage +{ + +} +-(UIImage*)rescaleImage:(UIImage*)image toSize:(CGSize)newSize +{ + UIGraphicsBeginImageContext(newSize); + [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; + UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + return newImage; +} +@end diff --git a/previewers/add.png b/previewers/add.png new file mode 100644 index 0000000..2e946ce Binary files /dev/null and b/previewers/add.png differ diff --git a/previewers/checkin.png b/previewers/checkin.png new file mode 100644 index 0000000..c14e656 Binary files /dev/null and b/previewers/checkin.png differ diff --git a/previewers/delete.png b/previewers/delete.png new file mode 100644 index 0000000..c0d94c5 Binary files /dev/null and b/previewers/delete.png differ diff --git a/previewers/message.png b/previewers/message.png new file mode 100644 index 0000000..ba84c0c Binary files /dev/null and b/previewers/message.png differ diff --git a/previewers/sendmessage.png b/previewers/sendmessage.png new file mode 100644 index 0000000..a36ddef Binary files /dev/null and b/previewers/sendmessage.png differ diff --git a/previewers/status.png b/previewers/status.png new file mode 100644 index 0000000..c6ee7f5 Binary files /dev/null and b/previewers/status.png differ diff --git a/previewers/update.png b/previewers/update.png new file mode 100644 index 0000000..19c24d2 Binary files /dev/null and b/previewers/update.png differ diff --git a/singleton.h b/singleton.h new file mode 100755 index 0000000..0dedc8e --- /dev/null +++ b/singleton.h @@ -0,0 +1,38 @@ +// +// singleton.h +// RegisterWithIBeacon +// +// Created by Zhu Lizhe on 14-2-22. +// Copyright (c) 2014年 HuiBei. All rights reserved. +// + +#ifndef RegisterWithIBeacon_singleton_h +#define RegisterWithIBeacon_singleton_h + +#define singleton_for_interface(className) +(className*)shared##className ; + + + +#define single_for_implementation(className) static className* _instance ;\ ++(id)allocWithZone:(NSZone *)zone{ \ + static dispatch_once_t onceToken; \ + dispatch_once(&onceToken, ^{ \ + _instance = [super allocWithZone:zone];\ + });\ + return _instance;\ +}\ ++(className *)shared##className{\ + static dispatch_once_t onceToken;\ + dispatch_once(&onceToken, ^{\ + _instance = [[className alloc]init];\ + });\ + return _instance ;\ +} + + + + + + + +#endif