├── .DS_Store ├── LICENSE ├── Podfile ├── Podfile.lock ├── Pods ├── Headers │ ├── Private │ │ └── Masonry │ │ │ ├── MASCompositeConstraint.h │ │ │ ├── MASConstraint+Private.h │ │ │ ├── MASConstraint.h │ │ │ ├── MASConstraintMaker.h │ │ │ ├── MASLayoutConstraint.h │ │ │ ├── MASUtilities.h │ │ │ ├── MASViewAttribute.h │ │ │ ├── MASViewConstraint.h │ │ │ ├── Masonry.h │ │ │ ├── NSArray+MASAdditions.h │ │ │ ├── NSArray+MASShorthandAdditions.h │ │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ │ ├── View+MASAdditions.h │ │ │ ├── View+MASShorthandAdditions.h │ │ │ └── ViewController+MASAdditions.h │ └── Public │ │ └── Masonry │ │ ├── MASCompositeConstraint.h │ │ ├── MASConstraint+Private.h │ │ ├── MASConstraint.h │ │ ├── MASConstraintMaker.h │ │ ├── MASLayoutConstraint.h │ │ ├── MASUtilities.h │ │ ├── MASViewAttribute.h │ │ ├── MASViewConstraint.h │ │ ├── Masonry.h │ │ ├── NSArray+MASAdditions.h │ │ ├── NSArray+MASShorthandAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ ├── View+MASAdditions.h │ │ ├── View+MASShorthandAdditions.h │ │ └── ViewController+MASAdditions.h ├── Manifest.lock ├── Masonry │ ├── LICENSE │ ├── Masonry │ │ ├── MASCompositeConstraint.h │ │ ├── MASCompositeConstraint.m │ │ ├── MASConstraint+Private.h │ │ ├── MASConstraint.h │ │ ├── MASConstraint.m │ │ ├── MASConstraintMaker.h │ │ ├── MASConstraintMaker.m │ │ ├── MASLayoutConstraint.h │ │ ├── MASLayoutConstraint.m │ │ ├── MASUtilities.h │ │ ├── MASViewAttribute.h │ │ ├── MASViewAttribute.m │ │ ├── MASViewConstraint.h │ │ ├── MASViewConstraint.m │ │ ├── Masonry.h │ │ ├── NSArray+MASAdditions.h │ │ ├── NSArray+MASAdditions.m │ │ ├── NSArray+MASShorthandAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.m │ │ ├── View+MASAdditions.h │ │ ├── View+MASAdditions.m │ │ ├── View+MASShorthandAdditions.h │ │ ├── ViewController+MASAdditions.h │ │ └── ViewController+MASAdditions.m │ └── README.md ├── Pods.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ │ ├── ardwang.xcuserdatad │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ │ └── rnd.xcuserdatad │ │ └── xcschemes │ │ ├── Masonry.xcscheme │ │ ├── Pods-YModemCs.xcscheme │ │ └── xcschememanagement.plist └── Target Support Files │ ├── Masonry │ ├── Masonry-dummy.m │ ├── Masonry-prefix.pch │ └── Masonry.xcconfig │ └── Pods-YModemCs │ ├── Pods-YModemCs-acknowledgements.markdown │ ├── Pods-YModemCs-acknowledgements.plist │ ├── Pods-YModemCs-dummy.m │ ├── Pods-YModemCs-frameworks.sh │ ├── Pods-YModemCs-resources.sh │ ├── Pods-YModemCs.debug.xcconfig │ └── Pods-YModemCs.release.xcconfig ├── README.md ├── YModemCs.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── rnd.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── ardwang.xcuserdatad │ └── xcschemes │ │ └── xcschememanagement.plist │ └── rnd.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── YModemCs.xcworkspace ├── contents.xcworkspacedata ├── xcshareddata │ └── IDEWorkspaceChecks.plist └── xcuserdata │ ├── ardwang.xcuserdatad │ └── UserInterfaceState.xcuserstate │ └── rnd.xcuserdatad │ ├── UserInterfaceState.xcuserstate │ └── xcdebugger │ └── Breakpoints_v2.xcbkptlist ├── YModemCs ├── Class │ ├── Cell │ │ ├── MainCell.h │ │ └── MainCell.m │ ├── Controller │ │ ├── MainController.h │ │ ├── MainController.m │ │ ├── ViewController.h │ │ └── ViewController.m │ ├── File(文件) │ │ ├── Cell │ │ │ ├── OTAFileCell.h │ │ │ └── OTAFileCell.m │ │ ├── Controller │ │ │ ├── FileOTAController.h │ │ │ └── FileOTAController.m │ │ └── View │ │ │ ├── FileOTAView.h │ │ │ └── FileOTAView.m │ ├── Utils │ │ ├── ble │ │ │ ├── BlueHelp.h │ │ │ └── BlueHelp.m │ │ ├── model │ │ │ ├── DeviceModel.h │ │ │ └── DeviceModel.m │ │ ├── util │ │ │ ├── BTAlertController.h │ │ │ ├── BTAlertController.m │ │ │ ├── CommonUtil.h │ │ │ ├── CommonUtil.m │ │ │ ├── Constants.h │ │ │ ├── OTAManager.h │ │ │ └── OTAManager.m │ │ └── view │ │ │ └── DownLoadView │ │ │ ├── DownLoadBtn.h │ │ │ ├── DownLoadBtn.m │ │ │ ├── DownLoadView.h │ │ │ ├── DownLoadView.m │ │ │ ├── NoteView.h │ │ │ └── NoteView.m │ ├── View │ │ ├── MainView.h │ │ └── MainView.m │ └── YModem │ │ ├── YModem.c │ │ ├── YModem.h │ │ ├── YModemUtil.h │ │ └── YModemUtil.m ├── Info.plist └── Main │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── CheckBox │ │ ├── Contents.json │ │ ├── checkbox.imageset │ │ │ ├── Contents.json │ │ │ ├── checkbox.png │ │ │ ├── checkbox@2x.png │ │ │ └── checkbox@3x.png │ │ └── checkbox_fill.imageset │ │ │ ├── Contents.json │ │ │ ├── checkbox_fill.png │ │ │ ├── checkbox_fill@2x.png │ │ │ └── checkbox_fill@3x.png │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ └── main.m ├── YModemCsTests ├── Info.plist └── YModemCsTests.m ├── YModemCsUITests ├── Info.plist └── YModemCsUITests.m └── YModemlib_iOS.podspec /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArdWang/YModemlib_iOS/94662b44ec051c60eef7d7f7e8c4f93f79781efb/.DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 RND 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | platform :ios, '9.0' 3 | 4 | target 'YModemCs' do 5 | pod 'Masonry' 6 | end 7 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (1.1.0) 3 | 4 | DEPENDENCIES: 5 | - Masonry 6 | 7 | SPEC CHECKSUMS: 8 | Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 9 | 10 | PODFILE CHECKSUM: 3edb27a4af6d020be5f9870b9f9c721390e0d574 11 | 12 | COCOAPODS: 1.2.1 13 | -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASCompositeConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint+Private.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraintMaker.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASLayoutConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASUtilities.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewAttribute.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/Masonry.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/ViewController+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASCompositeConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint+Private.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraintMaker.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASLayoutConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASUtilities.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewAttribute.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/Masonry.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/ViewController+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (1.1.0) 3 | 4 | DEPENDENCIES: 5 | - Masonry 6 | 7 | SPEC CHECKSUMS: 8 | Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 9 | 10 | PODFILE CHECKSUM: 3edb27a4af6d020be5f9870b9f9c721390e0d574 11 | 12 | COCOAPODS: 1.2.1 13 | -------------------------------------------------------------------------------- /Pods/Masonry/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | /** 13 | * A group of MASConstraint objects 14 | */ 15 | @interface MASCompositeConstraint : MASConstraint 16 | 17 | /** 18 | * Creates a composite with a predefined array of children 19 | * 20 | * @param children child MASConstraints 21 | * 22 | * @return a composite constraint 23 | */ 24 | - (id)initWithChildren:(NSArray *)children; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASCompositeConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASCompositeConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | 12 | @interface MASCompositeConstraint () 13 | 14 | @property (nonatomic, strong) id mas_key; 15 | @property (nonatomic, strong) NSMutableArray *childConstraints; 16 | 17 | @end 18 | 19 | @implementation MASCompositeConstraint 20 | 21 | - (id)initWithChildren:(NSArray *)children { 22 | self = [super init]; 23 | if (!self) return nil; 24 | 25 | _childConstraints = [children mutableCopy]; 26 | for (MASConstraint *constraint in _childConstraints) { 27 | constraint.delegate = self; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | #pragma mark - MASConstraintDelegate 34 | 35 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 36 | NSUInteger index = [self.childConstraints indexOfObject:constraint]; 37 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 38 | [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint]; 39 | } 40 | 41 | - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 42 | id strongDelegate = self.delegate; 43 | MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 44 | newConstraint.delegate = self; 45 | [self.childConstraints addObject:newConstraint]; 46 | return newConstraint; 47 | } 48 | 49 | #pragma mark - NSLayoutConstraint multiplier proxies 50 | 51 | - (MASConstraint * (^)(CGFloat))multipliedBy { 52 | return ^id(CGFloat multiplier) { 53 | for (MASConstraint *constraint in self.childConstraints) { 54 | constraint.multipliedBy(multiplier); 55 | } 56 | return self; 57 | }; 58 | } 59 | 60 | - (MASConstraint * (^)(CGFloat))dividedBy { 61 | return ^id(CGFloat divider) { 62 | for (MASConstraint *constraint in self.childConstraints) { 63 | constraint.dividedBy(divider); 64 | } 65 | return self; 66 | }; 67 | } 68 | 69 | #pragma mark - MASLayoutPriority proxy 70 | 71 | - (MASConstraint * (^)(MASLayoutPriority))priority { 72 | return ^id(MASLayoutPriority priority) { 73 | for (MASConstraint *constraint in self.childConstraints) { 74 | constraint.priority(priority); 75 | } 76 | return self; 77 | }; 78 | } 79 | 80 | #pragma mark - NSLayoutRelation proxy 81 | 82 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 83 | return ^id(id attr, NSLayoutRelation relation) { 84 | for (MASConstraint *constraint in self.childConstraints.copy) { 85 | constraint.equalToWithRelation(attr, relation); 86 | } 87 | return self; 88 | }; 89 | } 90 | 91 | #pragma mark - attribute chaining 92 | 93 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 94 | [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 95 | return self; 96 | } 97 | 98 | #pragma mark - Animator proxy 99 | 100 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 101 | 102 | - (MASConstraint *)animator { 103 | for (MASConstraint *constraint in self.childConstraints) { 104 | [constraint animator]; 105 | } 106 | return self; 107 | } 108 | 109 | #endif 110 | 111 | #pragma mark - debug helpers 112 | 113 | - (MASConstraint * (^)(id))key { 114 | return ^id(id key) { 115 | self.mas_key = key; 116 | int i = 0; 117 | for (MASConstraint *constraint in self.childConstraints) { 118 | constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]); 119 | } 120 | return self; 121 | }; 122 | } 123 | 124 | #pragma mark - NSLayoutConstraint constant setters 125 | 126 | - (void)setInsets:(MASEdgeInsets)insets { 127 | for (MASConstraint *constraint in self.childConstraints) { 128 | constraint.insets = insets; 129 | } 130 | } 131 | 132 | - (void)setInset:(CGFloat)inset { 133 | for (MASConstraint *constraint in self.childConstraints) { 134 | constraint.inset = inset; 135 | } 136 | } 137 | 138 | - (void)setOffset:(CGFloat)offset { 139 | for (MASConstraint *constraint in self.childConstraints) { 140 | constraint.offset = offset; 141 | } 142 | } 143 | 144 | - (void)setSizeOffset:(CGSize)sizeOffset { 145 | for (MASConstraint *constraint in self.childConstraints) { 146 | constraint.sizeOffset = sizeOffset; 147 | } 148 | } 149 | 150 | - (void)setCenterOffset:(CGPoint)centerOffset { 151 | for (MASConstraint *constraint in self.childConstraints) { 152 | constraint.centerOffset = centerOffset; 153 | } 154 | } 155 | 156 | #pragma mark - MASConstraint 157 | 158 | - (void)activate { 159 | for (MASConstraint *constraint in self.childConstraints) { 160 | [constraint activate]; 161 | } 162 | } 163 | 164 | - (void)deactivate { 165 | for (MASConstraint *constraint in self.childConstraints) { 166 | [constraint deactivate]; 167 | } 168 | } 169 | 170 | - (void)install { 171 | for (MASConstraint *constraint in self.childConstraints) { 172 | constraint.updateExisting = self.updateExisting; 173 | [constraint install]; 174 | } 175 | } 176 | 177 | - (void)uninstall { 178 | for (MASConstraint *constraint in self.childConstraints) { 179 | [constraint uninstall]; 180 | } 181 | } 182 | 183 | @end 184 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint+Private.h 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 29/04/14. 6 | // Copyright (c) 2014 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | 11 | @protocol MASConstraintDelegate; 12 | 13 | 14 | @interface MASConstraint () 15 | 16 | /** 17 | * Whether or not to check for an existing constraint instead of adding constraint 18 | */ 19 | @property (nonatomic, assign) BOOL updateExisting; 20 | 21 | /** 22 | * Usually MASConstraintMaker but could be a parent MASConstraint 23 | */ 24 | @property (nonatomic, weak) id delegate; 25 | 26 | /** 27 | * Based on a provided value type, is equal to calling: 28 | * NSNumber - setOffset: 29 | * NSValue with CGPoint - setPointOffset: 30 | * NSValue with CGSize - setSizeOffset: 31 | * NSValue with MASEdgeInsets - setInsets: 32 | */ 33 | - (void)setLayoutConstantWithValue:(NSValue *)value; 34 | 35 | @end 36 | 37 | 38 | @interface MASConstraint (Abstract) 39 | 40 | /** 41 | * Sets the constraint relation to given NSLayoutRelation 42 | * returns a block which accepts one of the following: 43 | * MASViewAttribute, UIView, NSValue, NSArray 44 | * see readme for more details. 45 | */ 46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation; 47 | 48 | /** 49 | * Override to set a custom chaining behaviour 50 | */ 51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 52 | 53 | @end 54 | 55 | 56 | @protocol MASConstraintDelegate 57 | 58 | /** 59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example 60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks 61 | */ 62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint; 63 | 64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * Enables Constraints to be created with chainable syntax 13 | * Constraint can represent single NSLayoutConstraint (MASViewConstraint) 14 | * or a group of NSLayoutConstraints (MASComposisteConstraint) 15 | */ 16 | @interface MASConstraint : NSObject 17 | 18 | // Chaining Support 19 | 20 | /** 21 | * Modifies the NSLayoutConstraint constant, 22 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 23 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 24 | */ 25 | - (MASConstraint * (^)(MASEdgeInsets insets))insets; 26 | 27 | /** 28 | * Modifies the NSLayoutConstraint constant, 29 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 30 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 31 | */ 32 | - (MASConstraint * (^)(CGFloat inset))inset; 33 | 34 | /** 35 | * Modifies the NSLayoutConstraint constant, 36 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 37 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 38 | */ 39 | - (MASConstraint * (^)(CGSize offset))sizeOffset; 40 | 41 | /** 42 | * Modifies the NSLayoutConstraint constant, 43 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 44 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 45 | */ 46 | - (MASConstraint * (^)(CGPoint offset))centerOffset; 47 | 48 | /** 49 | * Modifies the NSLayoutConstraint constant 50 | */ 51 | - (MASConstraint * (^)(CGFloat offset))offset; 52 | 53 | /** 54 | * Modifies the NSLayoutConstraint constant based on a value type 55 | */ 56 | - (MASConstraint * (^)(NSValue *value))valueOffset; 57 | 58 | /** 59 | * Sets the NSLayoutConstraint multiplier property 60 | */ 61 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy; 62 | 63 | /** 64 | * Sets the NSLayoutConstraint multiplier to 1.0/dividedBy 65 | */ 66 | - (MASConstraint * (^)(CGFloat divider))dividedBy; 67 | 68 | /** 69 | * Sets the NSLayoutConstraint priority to a float or MASLayoutPriority 70 | */ 71 | - (MASConstraint * (^)(MASLayoutPriority priority))priority; 72 | 73 | /** 74 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityLow 75 | */ 76 | - (MASConstraint * (^)(void))priorityLow; 77 | 78 | /** 79 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium 80 | */ 81 | - (MASConstraint * (^)(void))priorityMedium; 82 | 83 | /** 84 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh 85 | */ 86 | - (MASConstraint * (^)(void))priorityHigh; 87 | 88 | /** 89 | * Sets the constraint relation to NSLayoutRelationEqual 90 | * returns a block which accepts one of the following: 91 | * MASViewAttribute, UIView, NSValue, NSArray 92 | * see readme for more details. 93 | */ 94 | - (MASConstraint * (^)(id attr))equalTo; 95 | 96 | /** 97 | * Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual 98 | * returns a block which accepts one of the following: 99 | * MASViewAttribute, UIView, NSValue, NSArray 100 | * see readme for more details. 101 | */ 102 | - (MASConstraint * (^)(id attr))greaterThanOrEqualTo; 103 | 104 | /** 105 | * Sets the constraint relation to NSLayoutRelationLessThanOrEqual 106 | * returns a block which accepts one of the following: 107 | * MASViewAttribute, UIView, NSValue, NSArray 108 | * see readme for more details. 109 | */ 110 | - (MASConstraint * (^)(id attr))lessThanOrEqualTo; 111 | 112 | /** 113 | * Optional semantic property which has no effect but improves the readability of constraint 114 | */ 115 | - (MASConstraint *)with; 116 | 117 | /** 118 | * Optional semantic property which has no effect but improves the readability of constraint 119 | */ 120 | - (MASConstraint *)and; 121 | 122 | /** 123 | * Creates a new MASCompositeConstraint with the called attribute and reciever 124 | */ 125 | - (MASConstraint *)left; 126 | - (MASConstraint *)top; 127 | - (MASConstraint *)right; 128 | - (MASConstraint *)bottom; 129 | - (MASConstraint *)leading; 130 | - (MASConstraint *)trailing; 131 | - (MASConstraint *)width; 132 | - (MASConstraint *)height; 133 | - (MASConstraint *)centerX; 134 | - (MASConstraint *)centerY; 135 | - (MASConstraint *)baseline; 136 | 137 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 138 | 139 | - (MASConstraint *)firstBaseline; 140 | - (MASConstraint *)lastBaseline; 141 | 142 | #endif 143 | 144 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 145 | 146 | - (MASConstraint *)leftMargin; 147 | - (MASConstraint *)rightMargin; 148 | - (MASConstraint *)topMargin; 149 | - (MASConstraint *)bottomMargin; 150 | - (MASConstraint *)leadingMargin; 151 | - (MASConstraint *)trailingMargin; 152 | - (MASConstraint *)centerXWithinMargins; 153 | - (MASConstraint *)centerYWithinMargins; 154 | 155 | #endif 156 | 157 | 158 | /** 159 | * Sets the constraint debug name 160 | */ 161 | - (MASConstraint * (^)(id key))key; 162 | 163 | // NSLayoutConstraint constant Setters 164 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks 165 | 166 | /** 167 | * Modifies the NSLayoutConstraint constant, 168 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 169 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 170 | */ 171 | - (void)setInsets:(MASEdgeInsets)insets; 172 | 173 | /** 174 | * Modifies the NSLayoutConstraint constant, 175 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 176 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 177 | */ 178 | - (void)setInset:(CGFloat)inset; 179 | 180 | /** 181 | * Modifies the NSLayoutConstraint constant, 182 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 183 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 184 | */ 185 | - (void)setSizeOffset:(CGSize)sizeOffset; 186 | 187 | /** 188 | * Modifies the NSLayoutConstraint constant, 189 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 190 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 191 | */ 192 | - (void)setCenterOffset:(CGPoint)centerOffset; 193 | 194 | /** 195 | * Modifies the NSLayoutConstraint constant 196 | */ 197 | - (void)setOffset:(CGFloat)offset; 198 | 199 | 200 | // NSLayoutConstraint Installation support 201 | 202 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 203 | /** 204 | * Whether or not to go through the animator proxy when modifying the constraint 205 | */ 206 | @property (nonatomic, copy, readonly) MASConstraint *animator; 207 | #endif 208 | 209 | /** 210 | * Activates an NSLayoutConstraint if it's supported by an OS. 211 | * Invokes install otherwise. 212 | */ 213 | - (void)activate; 214 | 215 | /** 216 | * Deactivates previously installed/activated NSLayoutConstraint. 217 | */ 218 | - (void)deactivate; 219 | 220 | /** 221 | * Creates a NSLayoutConstraint and adds it to the appropriate view. 222 | */ 223 | - (void)install; 224 | 225 | /** 226 | * Removes previously installed NSLayoutConstraint 227 | */ 228 | - (void)uninstall; 229 | 230 | @end 231 | 232 | 233 | /** 234 | * Convenience auto-boxing macros for MASConstraint methods. 235 | * 236 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax. 237 | * A potential drawback of this is that the unprefixed macros will appear in global scope. 238 | */ 239 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__))) 240 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 241 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 242 | 243 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__))) 244 | 245 | 246 | #ifdef MAS_SHORTHAND_GLOBALS 247 | 248 | #define equalTo(...) mas_equalTo(__VA_ARGS__) 249 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__) 250 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__) 251 | 252 | #define offset(...) mas_offset(__VA_ARGS__) 253 | 254 | #endif 255 | 256 | 257 | @interface MASConstraint (AutoboxingSupport) 258 | 259 | /** 260 | * Aliases to corresponding relation methods (for shorthand macros) 261 | * Also needed to aid autocompletion 262 | */ 263 | - (MASConstraint * (^)(id attr))mas_equalTo; 264 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo; 265 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo; 266 | 267 | /** 268 | * A dummy method to aid autocompletion 269 | */ 270 | - (MASConstraint * (^)(id offset))mas_offset; 271 | 272 | @end 273 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.m 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 1/20/14. 6 | // 7 | 8 | #import "MASConstraint.h" 9 | #import "MASConstraint+Private.h" 10 | 11 | #define MASMethodNotImplemented() \ 12 | @throw [NSException exceptionWithName:NSInternalInconsistencyException \ 13 | reason:[NSString stringWithFormat:@"You must override %@ in a subclass.", NSStringFromSelector(_cmd)] \ 14 | userInfo:nil] 15 | 16 | @implementation MASConstraint 17 | 18 | #pragma mark - Init 19 | 20 | - (id)init { 21 | NSAssert(![self isMemberOfClass:[MASConstraint class]], @"MASConstraint is an abstract class, you should not instantiate it directly."); 22 | return [super init]; 23 | } 24 | 25 | #pragma mark - NSLayoutRelation proxies 26 | 27 | - (MASConstraint * (^)(id))equalTo { 28 | return ^id(id attribute) { 29 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 30 | }; 31 | } 32 | 33 | - (MASConstraint * (^)(id))mas_equalTo { 34 | return ^id(id attribute) { 35 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 36 | }; 37 | } 38 | 39 | - (MASConstraint * (^)(id))greaterThanOrEqualTo { 40 | return ^id(id attribute) { 41 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 42 | }; 43 | } 44 | 45 | - (MASConstraint * (^)(id))mas_greaterThanOrEqualTo { 46 | return ^id(id attribute) { 47 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 48 | }; 49 | } 50 | 51 | - (MASConstraint * (^)(id))lessThanOrEqualTo { 52 | return ^id(id attribute) { 53 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 54 | }; 55 | } 56 | 57 | - (MASConstraint * (^)(id))mas_lessThanOrEqualTo { 58 | return ^id(id attribute) { 59 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 60 | }; 61 | } 62 | 63 | #pragma mark - MASLayoutPriority proxies 64 | 65 | - (MASConstraint * (^)(void))priorityLow { 66 | return ^id{ 67 | self.priority(MASLayoutPriorityDefaultLow); 68 | return self; 69 | }; 70 | } 71 | 72 | - (MASConstraint * (^)(void))priorityMedium { 73 | return ^id{ 74 | self.priority(MASLayoutPriorityDefaultMedium); 75 | return self; 76 | }; 77 | } 78 | 79 | - (MASConstraint * (^)(void))priorityHigh { 80 | return ^id{ 81 | self.priority(MASLayoutPriorityDefaultHigh); 82 | return self; 83 | }; 84 | } 85 | 86 | #pragma mark - NSLayoutConstraint constant proxies 87 | 88 | - (MASConstraint * (^)(MASEdgeInsets))insets { 89 | return ^id(MASEdgeInsets insets){ 90 | self.insets = insets; 91 | return self; 92 | }; 93 | } 94 | 95 | - (MASConstraint * (^)(CGFloat))inset { 96 | return ^id(CGFloat inset){ 97 | self.inset = inset; 98 | return self; 99 | }; 100 | } 101 | 102 | - (MASConstraint * (^)(CGSize))sizeOffset { 103 | return ^id(CGSize offset) { 104 | self.sizeOffset = offset; 105 | return self; 106 | }; 107 | } 108 | 109 | - (MASConstraint * (^)(CGPoint))centerOffset { 110 | return ^id(CGPoint offset) { 111 | self.centerOffset = offset; 112 | return self; 113 | }; 114 | } 115 | 116 | - (MASConstraint * (^)(CGFloat))offset { 117 | return ^id(CGFloat offset){ 118 | self.offset = offset; 119 | return self; 120 | }; 121 | } 122 | 123 | - (MASConstraint * (^)(NSValue *value))valueOffset { 124 | return ^id(NSValue *offset) { 125 | NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset); 126 | [self setLayoutConstantWithValue:offset]; 127 | return self; 128 | }; 129 | } 130 | 131 | - (MASConstraint * (^)(id offset))mas_offset { 132 | // Will never be called due to macro 133 | return nil; 134 | } 135 | 136 | #pragma mark - NSLayoutConstraint constant setter 137 | 138 | - (void)setLayoutConstantWithValue:(NSValue *)value { 139 | if ([value isKindOfClass:NSNumber.class]) { 140 | self.offset = [(NSNumber *)value doubleValue]; 141 | } else if (strcmp(value.objCType, @encode(CGPoint)) == 0) { 142 | CGPoint point; 143 | [value getValue:&point]; 144 | self.centerOffset = point; 145 | } else if (strcmp(value.objCType, @encode(CGSize)) == 0) { 146 | CGSize size; 147 | [value getValue:&size]; 148 | self.sizeOffset = size; 149 | } else if (strcmp(value.objCType, @encode(MASEdgeInsets)) == 0) { 150 | MASEdgeInsets insets; 151 | [value getValue:&insets]; 152 | self.insets = insets; 153 | } else { 154 | NSAssert(NO, @"attempting to set layout constant with unsupported value: %@", value); 155 | } 156 | } 157 | 158 | #pragma mark - Semantic properties 159 | 160 | - (MASConstraint *)with { 161 | return self; 162 | } 163 | 164 | - (MASConstraint *)and { 165 | return self; 166 | } 167 | 168 | #pragma mark - Chaining 169 | 170 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute __unused)layoutAttribute { 171 | MASMethodNotImplemented(); 172 | } 173 | 174 | - (MASConstraint *)left { 175 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 176 | } 177 | 178 | - (MASConstraint *)top { 179 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 180 | } 181 | 182 | - (MASConstraint *)right { 183 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 184 | } 185 | 186 | - (MASConstraint *)bottom { 187 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 188 | } 189 | 190 | - (MASConstraint *)leading { 191 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 192 | } 193 | 194 | - (MASConstraint *)trailing { 195 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 196 | } 197 | 198 | - (MASConstraint *)width { 199 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 200 | } 201 | 202 | - (MASConstraint *)height { 203 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 204 | } 205 | 206 | - (MASConstraint *)centerX { 207 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 208 | } 209 | 210 | - (MASConstraint *)centerY { 211 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 212 | } 213 | 214 | - (MASConstraint *)baseline { 215 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 216 | } 217 | 218 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 219 | 220 | - (MASConstraint *)firstBaseline { 221 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline]; 222 | } 223 | - (MASConstraint *)lastBaseline { 224 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline]; 225 | } 226 | 227 | #endif 228 | 229 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 230 | 231 | - (MASConstraint *)leftMargin { 232 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 233 | } 234 | 235 | - (MASConstraint *)rightMargin { 236 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 237 | } 238 | 239 | - (MASConstraint *)topMargin { 240 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 241 | } 242 | 243 | - (MASConstraint *)bottomMargin { 244 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 245 | } 246 | 247 | - (MASConstraint *)leadingMargin { 248 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 249 | } 250 | 251 | - (MASConstraint *)trailingMargin { 252 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 253 | } 254 | 255 | - (MASConstraint *)centerXWithinMargins { 256 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 257 | } 258 | 259 | - (MASConstraint *)centerYWithinMargins { 260 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 261 | } 262 | 263 | #endif 264 | 265 | #pragma mark - Abstract 266 | 267 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); } 268 | 269 | - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); } 270 | 271 | - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); } 272 | 273 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); } 274 | 275 | - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); } 276 | 277 | - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); } 278 | 279 | - (void)setInset:(CGFloat __unused)inset { MASMethodNotImplemented(); } 280 | 281 | - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); } 282 | 283 | - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); } 284 | 285 | - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); } 286 | 287 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV) 288 | 289 | - (MASConstraint *)animator { MASMethodNotImplemented(); } 290 | 291 | #endif 292 | 293 | - (void)activate { MASMethodNotImplemented(); } 294 | 295 | - (void)deactivate { MASMethodNotImplemented(); } 296 | 297 | - (void)install { MASMethodNotImplemented(); } 298 | 299 | - (void)uninstall { MASMethodNotImplemented(); } 300 | 301 | @end 302 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintMaker.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | typedef NS_OPTIONS(NSInteger, MASAttribute) { 13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft, 14 | MASAttributeRight = 1 << NSLayoutAttributeRight, 15 | MASAttributeTop = 1 << NSLayoutAttributeTop, 16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom, 17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading, 18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing, 19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth, 20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight, 21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX, 22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY, 23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline, 24 | 25 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 26 | 27 | MASAttributeFirstBaseline = 1 << NSLayoutAttributeFirstBaseline, 28 | MASAttributeLastBaseline = 1 << NSLayoutAttributeLastBaseline, 29 | 30 | #endif 31 | 32 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 33 | 34 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, 35 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, 36 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, 37 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, 38 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, 39 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, 40 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, 41 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, 42 | 43 | #endif 44 | 45 | }; 46 | 47 | /** 48 | * Provides factory methods for creating MASConstraints. 49 | * Constraints are collected until they are ready to be installed 50 | * 51 | */ 52 | @interface MASConstraintMaker : NSObject 53 | 54 | /** 55 | * The following properties return a new MASViewConstraint 56 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 57 | */ 58 | @property (nonatomic, strong, readonly) MASConstraint *left; 59 | @property (nonatomic, strong, readonly) MASConstraint *top; 60 | @property (nonatomic, strong, readonly) MASConstraint *right; 61 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 62 | @property (nonatomic, strong, readonly) MASConstraint *leading; 63 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 64 | @property (nonatomic, strong, readonly) MASConstraint *width; 65 | @property (nonatomic, strong, readonly) MASConstraint *height; 66 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 67 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 68 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 69 | 70 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 71 | 72 | @property (nonatomic, strong, readonly) MASConstraint *firstBaseline; 73 | @property (nonatomic, strong, readonly) MASConstraint *lastBaseline; 74 | 75 | #endif 76 | 77 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 78 | 79 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin; 80 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin; 81 | @property (nonatomic, strong, readonly) MASConstraint *topMargin; 82 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; 83 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; 84 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; 85 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; 86 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; 87 | 88 | #endif 89 | 90 | /** 91 | * Returns a block which creates a new MASCompositeConstraint with the first item set 92 | * to the makers associated view and children corresponding to the set bits in the 93 | * MASAttribute parameter. Combine multiple attributes via binary-or. 94 | */ 95 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 96 | 97 | /** 98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 99 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 100 | * with the first item set to the makers associated view 101 | */ 102 | @property (nonatomic, strong, readonly) MASConstraint *edges; 103 | 104 | /** 105 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 106 | * which generates the appropriate MASViewConstraint children (width, height) 107 | * with the first item set to the makers associated view 108 | */ 109 | @property (nonatomic, strong, readonly) MASConstraint *size; 110 | 111 | /** 112 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 113 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 114 | * with the first item set to the makers associated view 115 | */ 116 | @property (nonatomic, strong, readonly) MASConstraint *center; 117 | 118 | /** 119 | * Whether or not to check for an existing constraint instead of adding constraint 120 | */ 121 | @property (nonatomic, assign) BOOL updateExisting; 122 | 123 | /** 124 | * Whether or not to remove existing constraints prior to installing 125 | */ 126 | @property (nonatomic, assign) BOOL removeExisting; 127 | 128 | /** 129 | * initialises the maker with a default view 130 | * 131 | * @param view any MASConstraint are created with this view as the first item 132 | * 133 | * @return a new MASConstraintMaker 134 | */ 135 | - (id)initWithView:(MAS_VIEW *)view; 136 | 137 | /** 138 | * Calls install method on any MASConstraints which have been created by this maker 139 | * 140 | * @return an array of all the installed MASConstraints 141 | */ 142 | - (NSArray *)install; 143 | 144 | - (MASConstraint * (^)(dispatch_block_t))group; 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * When you are debugging or printing the constraints attached to a view this subclass 13 | * makes it easier to identify which constraints have been created via Masonry 14 | */ 15 | @interface MASLayoutConstraint : NSLayoutConstraint 16 | 17 | /** 18 | * a key to associate with this constraint 19 | */ 20 | @property (nonatomic, strong) id mas_key; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASLayoutConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASLayoutConstraint.h" 10 | 11 | @implementation MASLayoutConstraint 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASUtilities.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 19/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | 13 | #if TARGET_OS_IPHONE || TARGET_OS_TV 14 | 15 | #import 16 | #define MAS_VIEW UIView 17 | #define MAS_VIEW_CONTROLLER UIViewController 18 | #define MASEdgeInsets UIEdgeInsets 19 | 20 | typedef UILayoutPriority MASLayoutPriority; 21 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; 22 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; 23 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; 24 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; 25 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; 26 | 27 | #elif TARGET_OS_MAC 28 | 29 | #import 30 | #define MAS_VIEW NSView 31 | #define MASEdgeInsets NSEdgeInsets 32 | 33 | typedef NSLayoutPriority MASLayoutPriority; 34 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; 35 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; 36 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; 37 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; 38 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; 39 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; 40 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; 41 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; 42 | 43 | #endif 44 | 45 | /** 46 | * Allows you to attach keys to objects matching the variable names passed. 47 | * 48 | * view1.mas_key = @"view1", view2.mas_key = @"view2"; 49 | * 50 | * is equivalent to: 51 | * 52 | * MASAttachKeys(view1, view2); 53 | */ 54 | #define MASAttachKeys(...) \ 55 | { \ 56 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ 57 | for (id key in keyPairs.allKeys) { \ 58 | id obj = keyPairs[key]; \ 59 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ 60 | @"Cannot attach mas_key to %@", obj); \ 61 | [obj setMas_key:key]; \ 62 | } \ 63 | } 64 | 65 | /** 66 | * Used to create object hashes 67 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html 68 | */ 69 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 70 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) 71 | 72 | /** 73 | * Given a scalar or struct value, wraps it in NSValue 74 | * Based on EXPObjectify: https://github.com/specta/expecta 75 | */ 76 | static inline id _MASBoxValue(const char *type, ...) { 77 | va_list v; 78 | va_start(v, type); 79 | id obj = nil; 80 | if (strcmp(type, @encode(id)) == 0) { 81 | id actual = va_arg(v, id); 82 | obj = actual; 83 | } else if (strcmp(type, @encode(CGPoint)) == 0) { 84 | CGPoint actual = (CGPoint)va_arg(v, CGPoint); 85 | obj = [NSValue value:&actual withObjCType:type]; 86 | } else if (strcmp(type, @encode(CGSize)) == 0) { 87 | CGSize actual = (CGSize)va_arg(v, CGSize); 88 | obj = [NSValue value:&actual withObjCType:type]; 89 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { 90 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); 91 | obj = [NSValue value:&actual withObjCType:type]; 92 | } else if (strcmp(type, @encode(double)) == 0) { 93 | double actual = (double)va_arg(v, double); 94 | obj = [NSNumber numberWithDouble:actual]; 95 | } else if (strcmp(type, @encode(float)) == 0) { 96 | float actual = (float)va_arg(v, double); 97 | obj = [NSNumber numberWithFloat:actual]; 98 | } else if (strcmp(type, @encode(int)) == 0) { 99 | int actual = (int)va_arg(v, int); 100 | obj = [NSNumber numberWithInt:actual]; 101 | } else if (strcmp(type, @encode(long)) == 0) { 102 | long actual = (long)va_arg(v, long); 103 | obj = [NSNumber numberWithLong:actual]; 104 | } else if (strcmp(type, @encode(long long)) == 0) { 105 | long long actual = (long long)va_arg(v, long long); 106 | obj = [NSNumber numberWithLongLong:actual]; 107 | } else if (strcmp(type, @encode(short)) == 0) { 108 | short actual = (short)va_arg(v, int); 109 | obj = [NSNumber numberWithShort:actual]; 110 | } else if (strcmp(type, @encode(char)) == 0) { 111 | char actual = (char)va_arg(v, int); 112 | obj = [NSNumber numberWithChar:actual]; 113 | } else if (strcmp(type, @encode(bool)) == 0) { 114 | bool actual = (bool)va_arg(v, int); 115 | obj = [NSNumber numberWithBool:actual]; 116 | } else if (strcmp(type, @encode(unsigned char)) == 0) { 117 | unsigned char actual = (unsigned char)va_arg(v, unsigned int); 118 | obj = [NSNumber numberWithUnsignedChar:actual]; 119 | } else if (strcmp(type, @encode(unsigned int)) == 0) { 120 | unsigned int actual = (unsigned int)va_arg(v, unsigned int); 121 | obj = [NSNumber numberWithUnsignedInt:actual]; 122 | } else if (strcmp(type, @encode(unsigned long)) == 0) { 123 | unsigned long actual = (unsigned long)va_arg(v, unsigned long); 124 | obj = [NSNumber numberWithUnsignedLong:actual]; 125 | } else if (strcmp(type, @encode(unsigned long long)) == 0) { 126 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 127 | obj = [NSNumber numberWithUnsignedLongLong:actual]; 128 | } else if (strcmp(type, @encode(unsigned short)) == 0) { 129 | unsigned short actual = (unsigned short)va_arg(v, unsigned int); 130 | obj = [NSNumber numberWithUnsignedShort:actual]; 131 | } 132 | va_end(v); 133 | return obj; 134 | } 135 | 136 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) 137 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewAttribute.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * An immutable tuple which stores the view and the related NSLayoutAttribute. 13 | * Describes part of either the left or right hand side of a constraint equation 14 | */ 15 | @interface MASViewAttribute : NSObject 16 | 17 | /** 18 | * The view which the reciever relates to. Can be nil if item is not a view. 19 | */ 20 | @property (nonatomic, weak, readonly) MAS_VIEW *view; 21 | 22 | /** 23 | * The item which the reciever relates to. 24 | */ 25 | @property (nonatomic, weak, readonly) id item; 26 | 27 | /** 28 | * The attribute which the reciever relates to 29 | */ 30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 31 | 32 | /** 33 | * Convenience initializer. 34 | */ 35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 36 | 37 | /** 38 | * The designated initializer. 39 | */ 40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; 41 | 42 | /** 43 | * Determine whether the layoutAttribute is a size attribute 44 | * 45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 46 | */ 47 | - (BOOL)isSizeAttribute; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASViewAttribute.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewAttribute.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | 11 | @implementation MASViewAttribute 12 | 13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { 14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute]; 15 | return self; 16 | } 17 | 18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { 19 | self = [super init]; 20 | if (!self) return nil; 21 | 22 | _view = view; 23 | _item = item; 24 | _layoutAttribute = layoutAttribute; 25 | 26 | return self; 27 | } 28 | 29 | - (BOOL)isSizeAttribute { 30 | return self.layoutAttribute == NSLayoutAttributeWidth 31 | || self.layoutAttribute == NSLayoutAttributeHeight; 32 | } 33 | 34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { 35 | if ([viewAttribute isKindOfClass:self.class]) { 36 | return self.view == viewAttribute.view 37 | && self.layoutAttribute == viewAttribute.layoutAttribute; 38 | } 39 | return [super isEqual:viewAttribute]; 40 | } 41 | 42 | - (NSUInteger)hash { 43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | #import "MASUtilities.h" 13 | 14 | /** 15 | * A single constraint. 16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view 17 | */ 18 | @interface MASViewConstraint : MASConstraint 19 | 20 | /** 21 | * First item/view and first attribute of the NSLayoutConstraint 22 | */ 23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute; 24 | 25 | /** 26 | * Second item/view and second attribute of the NSLayoutConstraint 27 | */ 28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute; 29 | 30 | /** 31 | * initialises the MASViewConstraint with the first part of the equation 32 | * 33 | * @param firstViewAttribute view.mas_left, view.mas_width etc. 34 | * 35 | * @return a new view constraint 36 | */ 37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; 38 | 39 | /** 40 | * Returns all MASViewConstraints installed with this view as a first item. 41 | * 42 | * @param view A view to retrieve constraints for. 43 | * 44 | * @return An array of MASViewConstraints. 45 | */ 46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | // 2 | // Masonry.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Masonry. 12 | FOUNDATION_EXPORT double MasonryVersionNumber; 13 | 14 | //! Project version string for Masonry. 15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; 16 | 17 | #import "MASUtilities.h" 18 | #import "View+MASAdditions.h" 19 | #import "View+MASShorthandAdditions.h" 20 | #import "ViewController+MASAdditions.h" 21 | #import "NSArray+MASAdditions.h" 22 | #import "NSArray+MASShorthandAdditions.h" 23 | #import "MASConstraint.h" 24 | #import "MASCompositeConstraint.h" 25 | #import "MASViewAttribute.h" 26 | #import "MASViewConstraint.h" 27 | #import "MASConstraintMaker.h" 28 | #import "MASLayoutConstraint.h" 29 | #import "NSLayoutConstraint+MASDebugAdditions.h" 30 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.h 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | typedef NS_ENUM(NSUInteger, MASAxisType) { 14 | MASAxisTypeHorizontal, 15 | MASAxisTypeVertical 16 | }; 17 | 18 | @interface NSArray (MASAdditions) 19 | 20 | /** 21 | * Creates a MASConstraintMaker with each view in the callee. 22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view 23 | * 24 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 25 | * 26 | * @return Array of created MASConstraints 27 | */ 28 | - (NSArray *)mas_makeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 29 | 30 | /** 31 | * Creates a MASConstraintMaker with each view in the callee. 32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 33 | * If an existing constraint exists then it will be updated instead. 34 | * 35 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 36 | * 37 | * @return Array of created/updated MASConstraints 38 | */ 39 | - (NSArray *)mas_updateConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 40 | 41 | /** 42 | * Creates a MASConstraintMaker with each view in the callee. 43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 44 | * All constraints previously installed for the views will be removed. 45 | * 46 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 47 | * 48 | * @return Array of created/updated MASConstraints 49 | */ 50 | - (NSArray *)mas_remakeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 51 | 52 | /** 53 | * distribute with fixed spacing 54 | * 55 | * @param axisType which axis to distribute items along 56 | * @param fixedSpacing the spacing between each item 57 | * @param leadSpacing the spacing before the first item and the container 58 | * @param tailSpacing the spacing after the last item and the container 59 | */ 60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 61 | 62 | /** 63 | * distribute with fixed item size 64 | * 65 | * @param axisType which axis to distribute items along 66 | * @param fixedItemLength the fixed length of each item 67 | * @param leadSpacing the spacing before the first item and the container 68 | * @param tailSpacing the spacing after the last item and the container 69 | */ 70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/NSArray+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.m 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | #import "View+MASAdditions.h" 11 | 12 | @implementation NSArray (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block { 15 | NSMutableArray *constraints = [NSMutableArray array]; 16 | for (MAS_VIEW *view in self) { 17 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 18 | [constraints addObjectsFromArray:[view mas_makeConstraints:block]]; 19 | } 20 | return constraints; 21 | } 22 | 23 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block { 24 | NSMutableArray *constraints = [NSMutableArray array]; 25 | for (MAS_VIEW *view in self) { 26 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 27 | [constraints addObjectsFromArray:[view mas_updateConstraints:block]]; 28 | } 29 | return constraints; 30 | } 31 | 32 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 33 | NSMutableArray *constraints = [NSMutableArray array]; 34 | for (MAS_VIEW *view in self) { 35 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 36 | [constraints addObjectsFromArray:[view mas_remakeConstraints:block]]; 37 | } 38 | return constraints; 39 | } 40 | 41 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 42 | if (self.count < 2) { 43 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 44 | return; 45 | } 46 | 47 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 48 | if (axisType == MASAxisTypeHorizontal) { 49 | MAS_VIEW *prev; 50 | for (int i = 0; i < self.count; i++) { 51 | MAS_VIEW *v = self[i]; 52 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 53 | if (prev) { 54 | make.width.equalTo(prev); 55 | make.left.equalTo(prev.mas_right).offset(fixedSpacing); 56 | if (i == self.count - 1) {//last one 57 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 58 | } 59 | } 60 | else {//first one 61 | make.left.equalTo(tempSuperView).offset(leadSpacing); 62 | } 63 | 64 | }]; 65 | prev = v; 66 | } 67 | } 68 | else { 69 | MAS_VIEW *prev; 70 | for (int i = 0; i < self.count; i++) { 71 | MAS_VIEW *v = self[i]; 72 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 73 | if (prev) { 74 | make.height.equalTo(prev); 75 | make.top.equalTo(prev.mas_bottom).offset(fixedSpacing); 76 | if (i == self.count - 1) {//last one 77 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 78 | } 79 | } 80 | else {//first one 81 | make.top.equalTo(tempSuperView).offset(leadSpacing); 82 | } 83 | 84 | }]; 85 | prev = v; 86 | } 87 | } 88 | } 89 | 90 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing { 91 | if (self.count < 2) { 92 | NSAssert(self.count>1,@"views to distribute need to bigger than one"); 93 | return; 94 | } 95 | 96 | MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews]; 97 | if (axisType == MASAxisTypeHorizontal) { 98 | MAS_VIEW *prev; 99 | for (int i = 0; i < self.count; i++) { 100 | MAS_VIEW *v = self[i]; 101 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 102 | make.width.equalTo(@(fixedItemLength)); 103 | if (prev) { 104 | if (i == self.count - 1) {//last one 105 | make.right.equalTo(tempSuperView).offset(-tailSpacing); 106 | } 107 | else { 108 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 109 | make.right.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 110 | } 111 | } 112 | else {//first one 113 | make.left.equalTo(tempSuperView).offset(leadSpacing); 114 | } 115 | }]; 116 | prev = v; 117 | } 118 | } 119 | else { 120 | MAS_VIEW *prev; 121 | for (int i = 0; i < self.count; i++) { 122 | MAS_VIEW *v = self[i]; 123 | [v mas_makeConstraints:^(MASConstraintMaker *make) { 124 | make.height.equalTo(@(fixedItemLength)); 125 | if (prev) { 126 | if (i == self.count - 1) {//last one 127 | make.bottom.equalTo(tempSuperView).offset(-tailSpacing); 128 | } 129 | else { 130 | CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1)); 131 | make.bottom.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset); 132 | } 133 | } 134 | else {//first one 135 | make.top.equalTo(tempSuperView).offset(leadSpacing); 136 | } 137 | }]; 138 | prev = v; 139 | } 140 | } 141 | } 142 | 143 | - (MAS_VIEW *)mas_commonSuperviewOfViews 144 | { 145 | MAS_VIEW *commonSuperview = nil; 146 | MAS_VIEW *previousView = nil; 147 | for (id object in self) { 148 | if ([object isKindOfClass:[MAS_VIEW class]]) { 149 | MAS_VIEW *view = (MAS_VIEW *)object; 150 | if (previousView) { 151 | commonSuperview = [view mas_closestCommonSuperview:commonSuperview]; 152 | } else { 153 | commonSuperview = view; 154 | } 155 | previousView = view; 156 | } 157 | } 158 | NSAssert(commonSuperview, @"Can't constrain views that do not share a common superview. Make sure that all the views in this array have been added into the same view hierarchy."); 159 | return commonSuperview; 160 | } 161 | 162 | @end 163 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand array additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface NSArray (MASShorthandAdditions) 18 | 19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 22 | 23 | @end 24 | 25 | @implementation NSArray (MASShorthandAdditions) 26 | 27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 28 | return [self mas_makeConstraints:block]; 29 | } 30 | 31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 32 | return [self mas_updateConstraints:block]; 33 | } 34 | 35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 36 | return [self mas_remakeConstraints:block]; 37 | } 38 | 39 | @end 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * makes debug and log output of NSLayoutConstraints more readable 13 | */ 14 | @interface NSLayoutConstraint (MASDebugAdditions) 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSLayoutConstraint+MASDebugAdditions.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | 13 | @implementation NSLayoutConstraint (MASDebugAdditions) 14 | 15 | #pragma mark - description maps 16 | 17 | + (NSDictionary *)layoutRelationDescriptionsByValue { 18 | static dispatch_once_t once; 19 | static NSDictionary *descriptionMap; 20 | dispatch_once(&once, ^{ 21 | descriptionMap = @{ 22 | @(NSLayoutRelationEqual) : @"==", 23 | @(NSLayoutRelationGreaterThanOrEqual) : @">=", 24 | @(NSLayoutRelationLessThanOrEqual) : @"<=", 25 | }; 26 | }); 27 | return descriptionMap; 28 | } 29 | 30 | + (NSDictionary *)layoutAttributeDescriptionsByValue { 31 | static dispatch_once_t once; 32 | static NSDictionary *descriptionMap; 33 | dispatch_once(&once, ^{ 34 | descriptionMap = @{ 35 | @(NSLayoutAttributeTop) : @"top", 36 | @(NSLayoutAttributeLeft) : @"left", 37 | @(NSLayoutAttributeBottom) : @"bottom", 38 | @(NSLayoutAttributeRight) : @"right", 39 | @(NSLayoutAttributeLeading) : @"leading", 40 | @(NSLayoutAttributeTrailing) : @"trailing", 41 | @(NSLayoutAttributeWidth) : @"width", 42 | @(NSLayoutAttributeHeight) : @"height", 43 | @(NSLayoutAttributeCenterX) : @"centerX", 44 | @(NSLayoutAttributeCenterY) : @"centerY", 45 | @(NSLayoutAttributeBaseline) : @"baseline", 46 | 47 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 48 | @(NSLayoutAttributeFirstBaseline) : @"firstBaseline", 49 | @(NSLayoutAttributeLastBaseline) : @"lastBaseline", 50 | #endif 51 | 52 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 53 | @(NSLayoutAttributeLeftMargin) : @"leftMargin", 54 | @(NSLayoutAttributeRightMargin) : @"rightMargin", 55 | @(NSLayoutAttributeTopMargin) : @"topMargin", 56 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin", 57 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin", 58 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin", 59 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins", 60 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins", 61 | #endif 62 | 63 | }; 64 | 65 | }); 66 | return descriptionMap; 67 | } 68 | 69 | 70 | + (NSDictionary *)layoutPriorityDescriptionsByValue { 71 | static dispatch_once_t once; 72 | static NSDictionary *descriptionMap; 73 | dispatch_once(&once, ^{ 74 | #if TARGET_OS_IPHONE || TARGET_OS_TV 75 | descriptionMap = @{ 76 | @(MASLayoutPriorityDefaultHigh) : @"high", 77 | @(MASLayoutPriorityDefaultLow) : @"low", 78 | @(MASLayoutPriorityDefaultMedium) : @"medium", 79 | @(MASLayoutPriorityRequired) : @"required", 80 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size", 81 | }; 82 | #elif TARGET_OS_MAC 83 | descriptionMap = @{ 84 | @(MASLayoutPriorityDefaultHigh) : @"high", 85 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window", 86 | @(MASLayoutPriorityDefaultMedium) : @"medium", 87 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put", 88 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window", 89 | @(MASLayoutPriorityDefaultLow) : @"low", 90 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size", 91 | @(MASLayoutPriorityRequired) : @"required", 92 | }; 93 | #endif 94 | }); 95 | return descriptionMap; 96 | } 97 | 98 | #pragma mark - description override 99 | 100 | + (NSString *)descriptionForObject:(id)obj { 101 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) { 102 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]]; 103 | } 104 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj]; 105 | } 106 | 107 | - (NSString *)description { 108 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"]; 109 | 110 | [description appendString:[self.class descriptionForObject:self]]; 111 | 112 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]]; 113 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) { 114 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.firstAttribute)]]; 115 | } 116 | 117 | [description appendFormat:@" %@", self.class.layoutRelationDescriptionsByValue[@(self.relation)]]; 118 | 119 | if (self.secondItem) { 120 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]]; 121 | } 122 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) { 123 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.secondAttribute)]]; 124 | } 125 | 126 | if (self.multiplier != 1) { 127 | [description appendFormat:@" * %g", self.multiplier]; 128 | } 129 | 130 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) { 131 | [description appendFormat:@" %g", self.constant]; 132 | } else { 133 | if (self.constant) { 134 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)]; 135 | } 136 | } 137 | 138 | if (self.priority != MASLayoutPriorityRequired) { 139 | [description appendFormat:@" ^%@", self.class.layoutPriorityDescriptionsByValue[@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]]; 140 | } 141 | 142 | [description appendString:@">"]; 143 | return description; 144 | } 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | /** 14 | * Provides constraint maker block 15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs 16 | */ 17 | @interface MAS_VIEW (MASAdditions) 18 | 19 | /** 20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute 21 | */ 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX; 31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY; 32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline; 33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr); 34 | 35 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_firstBaseline; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_lastBaseline; 39 | 40 | #endif 41 | 42 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 43 | 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 49 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 50 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 51 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 52 | 53 | #endif 54 | 55 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 56 | 57 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide API_AVAILABLE(ios(11.0),tvos(11.0)); 58 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop API_AVAILABLE(ios(11.0),tvos(11.0)); 59 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom API_AVAILABLE(ios(11.0),tvos(11.0)); 60 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft API_AVAILABLE(ios(11.0),tvos(11.0)); 61 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight API_AVAILABLE(ios(11.0),tvos(11.0)); 62 | 63 | #endif 64 | 65 | /** 66 | * a key to associate with this view 67 | */ 68 | @property (nonatomic, strong) id mas_key; 69 | 70 | /** 71 | * Finds the closest common superview between this view and another view 72 | * 73 | * @param view other view 74 | * 75 | * @return returns nil if common superview could not be found 76 | */ 77 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 78 | 79 | /** 80 | * Creates a MASConstraintMaker with the callee view. 81 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 82 | * 83 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 84 | * 85 | * @return Array of created MASConstraints 86 | */ 87 | - (NSArray *)mas_makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 88 | 89 | /** 90 | * Creates a MASConstraintMaker with the callee view. 91 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 92 | * If an existing constraint exists then it will be updated instead. 93 | * 94 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 95 | * 96 | * @return Array of created/updated MASConstraints 97 | */ 98 | - (NSArray *)mas_updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 99 | 100 | /** 101 | * Creates a MASConstraintMaker with the callee view. 102 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 103 | * All constraints previously installed for the view will be removed. 104 | * 105 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 106 | * 107 | * @return Array of created/updated MASConstraints 108 | */ 109 | - (NSArray *)mas_remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 110 | 111 | @end 112 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/View+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | #import 11 | 12 | @implementation MAS_VIEW (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block { 15 | self.translatesAutoresizingMaskIntoConstraints = NO; 16 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 17 | block(constraintMaker); 18 | return [constraintMaker install]; 19 | } 20 | 21 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block { 22 | self.translatesAutoresizingMaskIntoConstraints = NO; 23 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 24 | constraintMaker.updateExisting = YES; 25 | block(constraintMaker); 26 | return [constraintMaker install]; 27 | } 28 | 29 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 30 | self.translatesAutoresizingMaskIntoConstraints = NO; 31 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 32 | constraintMaker.removeExisting = YES; 33 | block(constraintMaker); 34 | return [constraintMaker install]; 35 | } 36 | 37 | #pragma mark - NSLayoutAttribute properties 38 | 39 | - (MASViewAttribute *)mas_left { 40 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft]; 41 | } 42 | 43 | - (MASViewAttribute *)mas_top { 44 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop]; 45 | } 46 | 47 | - (MASViewAttribute *)mas_right { 48 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight]; 49 | } 50 | 51 | - (MASViewAttribute *)mas_bottom { 52 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom]; 53 | } 54 | 55 | - (MASViewAttribute *)mas_leading { 56 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading]; 57 | } 58 | 59 | - (MASViewAttribute *)mas_trailing { 60 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing]; 61 | } 62 | 63 | - (MASViewAttribute *)mas_width { 64 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth]; 65 | } 66 | 67 | - (MASViewAttribute *)mas_height { 68 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight]; 69 | } 70 | 71 | - (MASViewAttribute *)mas_centerX { 72 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX]; 73 | } 74 | 75 | - (MASViewAttribute *)mas_centerY { 76 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY]; 77 | } 78 | 79 | - (MASViewAttribute *)mas_baseline { 80 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline]; 81 | } 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute 84 | { 85 | return ^(NSLayoutAttribute attr) { 86 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr]; 87 | }; 88 | } 89 | 90 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 91 | 92 | - (MASViewAttribute *)mas_firstBaseline { 93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeFirstBaseline]; 94 | } 95 | - (MASViewAttribute *)mas_lastBaseline { 96 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLastBaseline]; 97 | } 98 | 99 | #endif 100 | 101 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 102 | 103 | - (MASViewAttribute *)mas_leftMargin { 104 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin]; 105 | } 106 | 107 | - (MASViewAttribute *)mas_rightMargin { 108 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin]; 109 | } 110 | 111 | - (MASViewAttribute *)mas_topMargin { 112 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin]; 113 | } 114 | 115 | - (MASViewAttribute *)mas_bottomMargin { 116 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin]; 117 | } 118 | 119 | - (MASViewAttribute *)mas_leadingMargin { 120 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin]; 121 | } 122 | 123 | - (MASViewAttribute *)mas_trailingMargin { 124 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin]; 125 | } 126 | 127 | - (MASViewAttribute *)mas_centerXWithinMargins { 128 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 129 | } 130 | 131 | - (MASViewAttribute *)mas_centerYWithinMargins { 132 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 133 | } 134 | 135 | #endif 136 | 137 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 138 | 139 | - (MASViewAttribute *)mas_safeAreaLayoutGuide { 140 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 141 | } 142 | - (MASViewAttribute *)mas_safeAreaLayoutGuideTop { 143 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 144 | } 145 | - (MASViewAttribute *)mas_safeAreaLayoutGuideBottom { 146 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 147 | } 148 | - (MASViewAttribute *)mas_safeAreaLayoutGuideLeft { 149 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeLeft]; 150 | } 151 | - (MASViewAttribute *)mas_safeAreaLayoutGuideRight { 152 | return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeRight]; 153 | } 154 | 155 | #endif 156 | 157 | #pragma mark - associated properties 158 | 159 | - (id)mas_key { 160 | return objc_getAssociatedObject(self, @selector(mas_key)); 161 | } 162 | 163 | - (void)setMas_key:(id)key { 164 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 165 | } 166 | 167 | #pragma mark - heirachy 168 | 169 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 170 | MAS_VIEW *closestCommonSuperview = nil; 171 | 172 | MAS_VIEW *secondViewSuperview = view; 173 | while (!closestCommonSuperview && secondViewSuperview) { 174 | MAS_VIEW *firstViewSuperview = self; 175 | while (!closestCommonSuperview && firstViewSuperview) { 176 | if (secondViewSuperview == firstViewSuperview) { 177 | closestCommonSuperview = secondViewSuperview; 178 | } 179 | firstViewSuperview = firstViewSuperview.superview; 180 | } 181 | secondViewSuperview = secondViewSuperview.superview; 182 | } 183 | return closestCommonSuperview; 184 | } 185 | 186 | @end 187 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand view additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface MAS_VIEW (MASShorthandAdditions) 18 | 19 | @property (nonatomic, strong, readonly) MASViewAttribute *left; 20 | @property (nonatomic, strong, readonly) MASViewAttribute *top; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *right; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *bottom; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *leading; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *trailing; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *width; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *height; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *centerX; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *centerY; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *baseline; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr); 31 | 32 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 33 | 34 | @property (nonatomic, strong, readonly) MASViewAttribute *firstBaseline; 35 | @property (nonatomic, strong, readonly) MASViewAttribute *lastBaseline; 36 | 37 | #endif 38 | 39 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 40 | 41 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin; 42 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin; 43 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin; 44 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins; 49 | 50 | #endif 51 | 52 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 53 | 54 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideTop API_AVAILABLE(ios(11.0),tvos(11.0)); 55 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideBottom API_AVAILABLE(ios(11.0),tvos(11.0)); 56 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideLeft API_AVAILABLE(ios(11.0),tvos(11.0)); 57 | @property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideRight API_AVAILABLE(ios(11.0),tvos(11.0)); 58 | 59 | #endif 60 | 61 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 62 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 63 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 64 | 65 | @end 66 | 67 | #define MAS_ATTR_FORWARD(attr) \ 68 | - (MASViewAttribute *)attr { \ 69 | return [self mas_##attr]; \ 70 | } 71 | 72 | @implementation MAS_VIEW (MASShorthandAdditions) 73 | 74 | MAS_ATTR_FORWARD(top); 75 | MAS_ATTR_FORWARD(left); 76 | MAS_ATTR_FORWARD(bottom); 77 | MAS_ATTR_FORWARD(right); 78 | MAS_ATTR_FORWARD(leading); 79 | MAS_ATTR_FORWARD(trailing); 80 | MAS_ATTR_FORWARD(width); 81 | MAS_ATTR_FORWARD(height); 82 | MAS_ATTR_FORWARD(centerX); 83 | MAS_ATTR_FORWARD(centerY); 84 | MAS_ATTR_FORWARD(baseline); 85 | 86 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 87 | 88 | MAS_ATTR_FORWARD(firstBaseline); 89 | MAS_ATTR_FORWARD(lastBaseline); 90 | 91 | #endif 92 | 93 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 94 | 95 | MAS_ATTR_FORWARD(leftMargin); 96 | MAS_ATTR_FORWARD(rightMargin); 97 | MAS_ATTR_FORWARD(topMargin); 98 | MAS_ATTR_FORWARD(bottomMargin); 99 | MAS_ATTR_FORWARD(leadingMargin); 100 | MAS_ATTR_FORWARD(trailingMargin); 101 | MAS_ATTR_FORWARD(centerXWithinMargins); 102 | MAS_ATTR_FORWARD(centerYWithinMargins); 103 | 104 | #endif 105 | 106 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 107 | 108 | MAS_ATTR_FORWARD(safeAreaLayoutGuideTop); 109 | MAS_ATTR_FORWARD(safeAreaLayoutGuideBottom); 110 | MAS_ATTR_FORWARD(safeAreaLayoutGuideLeft); 111 | MAS_ATTR_FORWARD(safeAreaLayoutGuideRight); 112 | 113 | #endif 114 | 115 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 116 | return [self mas_attribute]; 117 | } 118 | 119 | - (NSArray *)makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 120 | return [self mas_makeConstraints:block]; 121 | } 122 | 123 | - (NSArray *)updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 124 | return [self mas_updateConstraints:block]; 125 | } 126 | 127 | - (NSArray *)remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { 128 | return [self mas_remakeConstraints:block]; 129 | } 130 | 131 | @end 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | #ifdef MAS_VIEW_CONTROLLER 14 | 15 | @interface MAS_VIEW_CONTROLLER (MASAdditions) 16 | 17 | /** 18 | * following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute 19 | */ 20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom; 26 | 27 | 28 | @end 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/ViewController+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "ViewController+MASAdditions.h" 10 | 11 | #ifdef MAS_VIEW_CONTROLLER 12 | 13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions) 14 | 15 | - (MASViewAttribute *)mas_topLayoutGuide { 16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 17 | } 18 | - (MASViewAttribute *)mas_topLayoutGuideTop { 19 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 20 | } 21 | - (MASViewAttribute *)mas_topLayoutGuideBottom { 22 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 23 | } 24 | 25 | - (MASViewAttribute *)mas_bottomLayoutGuide { 26 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 27 | } 28 | - (MASViewAttribute *)mas_bottomLayoutGuideTop { 29 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 30 | } 31 | - (MASViewAttribute *)mas_bottomLayoutGuideBottom { 32 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 33 | } 34 | 35 | 36 | 37 | @end 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/ardwang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Masonry.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 2 11 | 12 | Pods-YModemCs.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/rnd.xcuserdatad/xcschemes/Masonry.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/rnd.xcuserdatad/xcschemes/Pods-YModemCs.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/rnd.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Masonry.xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | Pods-YModemCs.xcscheme 15 | 16 | isShown 17 | 18 | orderHint 19 | 1 20 | 21 | 22 | SuppressBuildableAutocreation 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Masonry/Masonry-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Masonry : NSObject 3 | @end 4 | @implementation PodsDummy_Masonry 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Masonry/Masonry-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Masonry/Masonry.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Masonry 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Masonry" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry" 4 | OTHER_LDFLAGS = -framework "Foundation" -framework "UIKit" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Masonry 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YModemCs/Pods-YModemCs-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## Masonry 5 | 6 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | Generated by CocoaPods - https://cocoapods.org 26 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YModemCs/Pods-YModemCs-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | License 37 | MIT 38 | Title 39 | Masonry 40 | Type 41 | PSGroupSpecifier 42 | 43 | 44 | FooterText 45 | Generated by CocoaPods - https://cocoapods.org 46 | Title 47 | 48 | Type 49 | PSGroupSpecifier 50 | 51 | 52 | StringsTable 53 | Acknowledgements 54 | Title 55 | Acknowledgements 56 | 57 | 58 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YModemCs/Pods-YModemCs-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_YModemCs : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_YModemCs 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YModemCs/Pods-YModemCs-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" 63 | 64 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 65 | code_sign_cmd="$code_sign_cmd &" 66 | fi 67 | echo "$code_sign_cmd" 68 | eval "$code_sign_cmd" 69 | fi 70 | } 71 | 72 | # Strip invalid architectures 73 | strip_invalid_archs() { 74 | binary="$1" 75 | # Get architectures for current file 76 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 77 | stripped="" 78 | for arch in $archs; do 79 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 80 | # Strip non-valid architectures in-place 81 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 82 | stripped="$stripped $arch" 83 | fi 84 | done 85 | if [[ "$stripped" ]]; then 86 | echo "Stripped $binary of architectures:$stripped" 87 | fi 88 | } 89 | 90 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 91 | wait 92 | fi 93 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YModemCs/Pods-YModemCs-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | 3) 22 | TARGET_DEVICE_ARGS="--target-device tv" 23 | ;; 24 | 4) 25 | TARGET_DEVICE_ARGS="--target-device watch" 26 | ;; 27 | *) 28 | TARGET_DEVICE_ARGS="--target-device mac" 29 | ;; 30 | esac 31 | 32 | install_resource() 33 | { 34 | if [[ "$1" = /* ]] ; then 35 | RESOURCE_PATH="$1" 36 | else 37 | RESOURCE_PATH="${PODS_ROOT}/$1" 38 | fi 39 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 40 | cat << EOM 41 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 42 | EOM 43 | exit 1 44 | fi 45 | case $RESOURCE_PATH in 46 | *.storyboard) 47 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 48 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 49 | ;; 50 | *.xib) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.framework) 55 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 57 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 58 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 59 | ;; 60 | *.xcdatamodel) 61 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 62 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 63 | ;; 64 | *.xcdatamodeld) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 67 | ;; 68 | *.xcmappingmodel) 69 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 70 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 71 | ;; 72 | *.xcassets) 73 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 74 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 75 | ;; 76 | *) 77 | echo "$RESOURCE_PATH" 78 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 79 | ;; 80 | esac 81 | } 82 | 83 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 86 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 87 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | fi 89 | rm -f "$RESOURCES_TO_COPY" 90 | 91 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 92 | then 93 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 94 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 95 | while read line; do 96 | if [[ $line != "${PODS_ROOT}*" ]]; then 97 | XCASSET_FILES+=("$line") 98 | fi 99 | done <<<"$OTHER_XCASSETS" 100 | 101 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 102 | fi 103 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YModemCs/Pods-YModemCs.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Masonry" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/Masonry" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Masonry" -framework "Foundation" -framework "UIKit" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-YModemCs/Pods-YModemCs.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Masonry" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/Masonry" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Masonry" -framework "Foundation" -framework "UIKit" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /YModemCs.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YModemCs.xcodeproj/project.xcworkspace/xcuserdata/rnd.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArdWang/YModemlib_iOS/94662b44ec051c60eef7d7f7e8c4f93f79781efb/YModemCs.xcodeproj/project.xcworkspace/xcuserdata/rnd.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /YModemCs.xcodeproj/xcuserdata/ardwang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | YModemCs.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 1 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /YModemCs.xcodeproj/xcuserdata/rnd.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | YModemCs.xcscheme 8 | 9 | orderHint 10 | 2 11 | 12 | YModemCs.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 2 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /YModemCs.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /YModemCs.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /YModemCs.xcworkspace/xcuserdata/ardwang.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArdWang/YModemlib_iOS/94662b44ec051c60eef7d7f7e8c4f93f79781efb/YModemCs.xcworkspace/xcuserdata/ardwang.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /YModemCs.xcworkspace/xcuserdata/rnd.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArdWang/YModemlib_iOS/94662b44ec051c60eef7d7f7e8c4f93f79781efb/YModemCs.xcworkspace/xcuserdata/rnd.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /YModemCs/Class/Cell/MainCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainCell.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MainCell : UITableViewCell 12 | 13 | @property (strong, nonatomic) UILabel *txtDeviceName; 14 | 15 | @property (strong, nonatomic) UILabel *txtDeviceRssi; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /YModemCs/Class/Cell/MainCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainCell.m 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import "MainCell.h" 10 | 11 | #ifdef __OBJC__ 12 | //define this constant if you want to use Masonry without the 'mas_' prefix 13 | #define MAS_SHORTHAND 14 | //define this constant if you want to enable auto-boxing for default syntax 15 | #define MAS_SHORTHAND_GLOBALS 16 | #import "Masonry.h" 17 | #endif 18 | 19 | @implementation MainCell 20 | 21 | - (void)awakeFromNib { 22 | [super awakeFromNib]; 23 | // Initialization code 24 | } 25 | 26 | /* 27 | * 初始化布局 28 | */ 29 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ 30 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 31 | if(self){ 32 | //品牌 33 | UILabel *txtBrand = [[UILabel alloc] init]; 34 | txtBrand.textColor = [UIColor redColor]; 35 | txtBrand.font = [UIFont fontWithName:@"Helvetica" size:30]; 36 | txtBrand.text = @"BT"; 37 | txtBrand.textAlignment = NSTextAlignmentCenter; 38 | [self addSubview:txtBrand]; 39 | 40 | [txtBrand makeConstraints:^(MASConstraintMaker *make){ 41 | make.top.equalTo(self).offset(30); 42 | make.left.equalTo(self).offset(20); 43 | make.width.equalTo(@50); 44 | make.height.equalTo(@30); 45 | }]; 46 | 47 | //设备名称 48 | _txtDeviceName = [[UILabel alloc] init]; 49 | _txtDeviceName.textColor = [UIColor blackColor]; 50 | _txtDeviceName.font = [UIFont fontWithName:@"Helvetica" size:16]; 51 | _txtDeviceName.textAlignment = NSTextAlignmentCenter; 52 | [self addSubview:_txtDeviceName]; 53 | 54 | [_txtDeviceName makeConstraints:^(MASConstraintMaker *make){ 55 | make.top.equalTo(self).offset(10); 56 | make.left.equalTo(self).offset(55); 57 | make.width.equalTo(@150); 58 | make.height.equalTo(@30); 59 | }]; 60 | 61 | //设备地址 62 | _txtDeviceRssi = [[UILabel alloc] init]; 63 | _txtDeviceRssi.textColor = [UIColor blackColor]; 64 | _txtDeviceRssi.font = [UIFont fontWithName:@"Helvetica" size:14]; 65 | _txtDeviceRssi.textAlignment = NSTextAlignmentCenter; 66 | [self addSubview:_txtDeviceRssi]; 67 | 68 | [_txtDeviceRssi makeConstraints:^(MASConstraintMaker *make){ 69 | make.top.equalTo(_txtDeviceName).offset(40); 70 | make.left.equalTo(self).offset(58); 71 | make.width.equalTo(@160); 72 | make.height.equalTo(@30); 73 | }]; 74 | 75 | //提示是否连接 76 | UILabel *txtConnect = [[UILabel alloc] init]; 77 | txtConnect.textColor = [UIColor blackColor]; 78 | txtConnect.font = [UIFont fontWithName:@"Helvetica" size:18]; 79 | txtConnect.text = @"Connect"; 80 | txtConnect.textAlignment = NSTextAlignmentCenter; 81 | [self addSubview:txtConnect]; 82 | 83 | [txtConnect makeConstraints:^(MASConstraintMaker *make){ 84 | make.top.equalTo(self).offset(30); 85 | make.right.equalTo(self).offset(-5); 86 | make.width.equalTo(@100); 87 | make.height.equalTo(@30); 88 | }]; 89 | } 90 | return self; 91 | } 92 | 93 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 94 | [super setSelected:selected animated:animated]; 95 | 96 | // Configure the view for the selected state 97 | } 98 | 99 | @end 100 | 101 | -------------------------------------------------------------------------------- /YModemCs/Class/Controller/MainController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainController.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MainView.h" 11 | #import "BlueHelp.h" 12 | #import "YModemUtil.h" 13 | #import "FileOTAController.h" 14 | #import "ViewController.h" 15 | 16 | @interface MainController : UIViewController 17 | 18 | @property(strong,nonatomic) MainView *mainView; 19 | 20 | @property(strong,nonatomic) YModemUtil *ymodemUtil; 21 | 22 | @property(strong,nonatomic) NSArray *firmwareFilesArray, *firmWareRowDataArray; 23 | 24 | @property(strong,nonatomic) NSString *fileName; 25 | 26 | @property(strong,nonatomic) NSString *filePath; 27 | 28 | @property(nonatomic,assign) NSUInteger orderStatus; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /YModemCs/Class/Controller/MainController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainController.m 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import "MainController.h" 10 | 11 | @interface MainController () 12 | 13 | @end 14 | 15 | @implementation MainController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | self.view.backgroundColor = [UIColor whiteColor]; 20 | 21 | self.mainView = [MainView new]; 22 | [self.view addSubview:self.mainView]; 23 | self.mainView.frame = self.view.bounds; 24 | self.mainView.delegate = self; 25 | 26 | //默认为1024 27 | self.ymodemUtil = [[YModemUtil alloc] init:1024]; 28 | self.ymodemUtil.delegate = self; 29 | 30 | //连接OTA的时候发送广播 31 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(otaCompletion:) name:@"otaNofiction" object:nil]; 32 | //断开蓝牙连接的广播 33 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(disContentBle:) name:@"disNofiction" object:nil]; 34 | } 35 | 36 | /* 37 | 发送OTA数据的广播 38 | */ 39 | -(void)otaCompletion:(NSNotification*)notification{ 40 | NSDictionary *ota = [notification userInfo]; 41 | NSString *otadata = [ota objectForKey:@"otaData"]; 42 | if([otadata isEqual:OTAC]){ 43 | self.orderStatus = OrderStatusC; 44 | }else if([otadata isEqual:OTASTART]){ 45 | self.orderStatus = OrderStatusFirst; 46 | }else if([otadata isEqual:OTAACK]){ 47 | self.orderStatus = OrderStatusACK; 48 | }else if([otadata isEqual:OTANAK]){ 49 | self.orderStatus = OrderStatusNAK; 50 | } 51 | 52 | __weak typeof(self) weakSelf = self; 53 | 54 | [self.ymodemUtil setFirmwareHandleOTADataWithOrderStatus:self.orderStatus fileName:self.fileName completion:^(NSInteger current,NSInteger total,NSString *msg){ 55 | float much = (float)current/total; 56 | if(much<=1.0){ 57 | if(weakSelf.mainView.downLoadView.musicalProgress<=1.0){ 58 | weakSelf.mainView.downLoadView.musicalProgress=much; 59 | if ((int)(weakSelf.mainView.downLoadView.musicalProgress*100)%5==0) { 60 | [weakSelf.mainView.downLoadView startDownLoad]; 61 | } 62 | }else{ 63 | weakSelf.mainView.downLoadView.musicDownLoadLab.text = @"Upgrade Complete!"; 64 | } 65 | } 66 | 67 | if(![msg isEqualToString:@""]&&msg!=nil) 68 | weakSelf.mainView.downLoadView.musicDownLoadLab.text = msg; 69 | }]; 70 | 71 | 72 | // Use new method 73 | [self.ymodemUtil setFirmwareUpgrade:self.orderStatus fileName:self.fileName filePath:self.filePath completion:^(NSInteger current,NSInteger total, NSData *data, NSString *message){ 74 | 75 | float much = (float)current/total; 76 | if(much<=1.0){ 77 | if(weakSelf.mainView.downLoadView.musicalProgress<=1.0){ 78 | weakSelf.mainView.downLoadView.musicalProgress=much; 79 | if ((int)(weakSelf.mainView.downLoadView.musicalProgress*100)%5==0) { 80 | [weakSelf.mainView.downLoadView startDownLoad]; 81 | } 82 | }else{ 83 | weakSelf.mainView.downLoadView.musicDownLoadLab.text = @"Upgrade Complete!"; 84 | } 85 | } 86 | 87 | if(![message isEqualToString:@""] && message!=nil) 88 | weakSelf.mainView.downLoadView.musicDownLoadLab.text = message; 89 | 90 | // Writting bluetooth data 91 | // In this way, the agent can be removed 92 | if(data.length > 0){ 93 | [[BlueHelp sharedManager] wirteBleOTAData:data]; 94 | } 95 | }]; 96 | } 97 | 98 | /* 99 | 断开蓝牙的时候发送广播 100 | */ 101 | -(void)disContentBle:(NSNotification*)notification{ 102 | UIViewController *target = nil; 103 | for (UIViewController * controller in self.navigationController.viewControllers) { 104 | //遍历 105 | if ([controller isKindOfClass:[ViewController class]]) { 106 | //这里判断是否为你想要跳转的页面 107 | target = controller; 108 | } 109 | } 110 | if (target) { 111 | [self.navigationController popToViewController:target animated:YES]; //跳转 112 | } 113 | } 114 | 115 | 116 | /* 117 | 所有的代理 包含View里面代理 YModem代理 文件选择代理等 118 | */ 119 | -(void)otaOnClick{ 120 | //下面这个发送数据根据个人的需求去发送 通讯 121 | [[BlueHelp sharedManager] writeBlueOTA:@"0x05"]; 122 | } 123 | 124 | -(void)selectOnClick{ 125 | FileOTAController *file = [[FileOTAController alloc] init]; 126 | file.delegate = self; 127 | file.title = @"SelectFile"; 128 | [self.navigationController pushViewController:file animated:YES]; 129 | } 130 | 131 | 132 | /* 133 | 本次代理是从YModemUtil里面返回回来的 蓝牙写入数据代理 134 | */ 135 | -(void)onWriteBleData:(NSData*) data{ 136 | //发送数据到终端设备 137 | [[BlueHelp sharedManager] wirteBleOTAData:data]; 138 | } 139 | 140 | /* 141 | 文件选择的时候返回代理 142 | */ 143 | - (void)firmwareFilesSelected:(NSArray *)selectedFilesArray forUpgradeMode:(OTAModel)selectedMode 144 | { 145 | if (selectedFilesArray) { 146 | _firmwareFilesArray = [[NSArray alloc] initWithArray:selectedFilesArray]; 147 | [self startParsingFirmwareFile:[_firmwareFilesArray objectAtIndex:0]]; 148 | } 149 | } 150 | 151 | - (void) startParsingFirmwareFile:(NSDictionary *)firmwareFile{ 152 | self.fileName = [firmwareFile objectForKey:@"FileName"]; 153 | self.filePath = [firmwareFile objectForKey:@"FilePath"]; 154 | self.mainView.downLoadView.musicDownLoadLab.text = self.fileName; 155 | } 156 | 157 | - (BOOL)navigationShouldPopOnBackButton{ 158 | //断开蓝牙 结束升级 159 | [[BlueHelp sharedManager] disContentBle]; 160 | return YES; 161 | } 162 | 163 | @end 164 | -------------------------------------------------------------------------------- /YModemCs/Class/Controller/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MainCell.h" 11 | #import "BlueHelp.h" 12 | #import "DeviceModel.h" 13 | #import "CommonUtil.h" 14 | #import "BTAlertController.h" 15 | #import "MainController.h" 16 | 17 | @interface ViewController : UITableViewController 18 | 19 | @property (nonatomic,strong) NSMutableArray *deviceList; 20 | 21 | @property(strong,nonatomic) DeviceModel *deviceModel; 22 | 23 | @property (nonatomic,strong ) NSMutableArray *peripheralList; 24 | 25 | //获取设备定时器 26 | @property(strong,nonatomic) NSTimer *deviceTimer; 27 | 28 | @end 29 | 30 | -------------------------------------------------------------------------------- /YModemCs/Class/Controller/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | self.view.backgroundColor = [UIColor whiteColor]; 20 | [self customNav]; 21 | [self deviceList]; 22 | [self peripheralList]; 23 | 24 | if(_deviceTimer==nil){ 25 | _deviceTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(deviceTime) userInfo:nil repeats:YES]; 26 | } 27 | } 28 | 29 | -(void)customNav{ 30 | UIColor *blues = [[CommonUtil sharedManager] stringTOColor:@"#436EEE"]; 31 | self.navigationItem.title = @"Demo"; 32 | [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:20]}]; 33 | 34 | [self.navigationController.navigationBar setBarTintColor:blues]; 35 | self.navigationController.navigationBar.tintColor = [UIColor whiteColor]; 36 | NSString *back = NSLocalizedString(@"back", nil); 37 | 38 | UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:back style:UIBarButtonItemStylePlain target:nil action:nil]; 39 | self.navigationItem.backBarButtonItem = item; 40 | UIBarButtonItem *set = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"config"] style:UIBarButtonItemStylePlain target:self action:@selector(setOnClick)]; 41 | self.navigationItem.rightBarButtonItem = set; 42 | 43 | //创建下啦刷新 44 | NSString *dropscan = NSLocalizedString(@"dropscan", nil); 45 | UIRefreshControl *rc = [[UIRefreshControl alloc] init]; 46 | rc.attributedTitle = [[NSAttributedString alloc] initWithString:dropscan]; 47 | [rc addTarget:self action:@selector(redreshTableView) forControlEvents:UIControlEventValueChanged]; 48 | self.refreshControl = rc; 49 | 50 | } 51 | 52 | -(void)redreshTableView{ 53 | if(self.refreshControl.refreshing){ 54 | self.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"scanning", nil)]; 55 | if(self.deviceList!=nil&&self.deviceList.count>0){ 56 | [self.deviceList removeAllObjects]; 57 | } 58 | 59 | if(self.peripheralList.count>0&&self.peripheralList!=nil){ 60 | [self.peripheralList removeAllObjects]; 61 | } 62 | 63 | //扫描蓝牙 64 | [[BlueHelp sharedManager] startScan]; 65 | [self.refreshControl endRefreshing]; 66 | self.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"dropscan", nil)]; 67 | 68 | //扫描 69 | [self.tableView reloadData]; 70 | } 71 | } 72 | 73 | 74 | -(void) deviceTime{ 75 | if([[BlueHelp sharedManager] getDeviceList]!=nil&&[[BlueHelp sharedManager] getPeriperalList]!=nil){ 76 | _peripheralList = [[BlueHelp sharedManager] getPeriperalList]; 77 | _deviceList = [[BlueHelp sharedManager] getDeviceList]; 78 | [self.tableView reloadData]; 79 | } 80 | } 81 | 82 | - (void)viewDidAppear:(BOOL)animated{ 83 | [super viewDidAppear:animated]; 84 | 85 | //重新加载数据 86 | [self.tableView reloadData]; 87 | 88 | if (self.refreshControl.refreshing) { 89 | //TODO: 已经在刷新数据了 90 | //NSLog(@"12233"); 91 | } else { 92 | NSLog(@"y is %f",self.tableView.contentOffset.y); 93 | if (self.tableView.contentOffset.y == -64) { 94 | [UIView animateWithDuration:0.25 95 | delay:0 96 | options:UIViewAnimationOptionBeginFromCurrentState 97 | animations:^(void){ 98 | self.tableView.contentOffset = CGPointMake(0, -self.refreshControl.frame.size.height); 99 | } completion:^(BOOL finished){ 100 | [self.refreshControl beginRefreshing]; 101 | [self.refreshControl sendActionsForControlEvents:UIControlEventValueChanged]; 102 | }]; 103 | } 104 | } 105 | } 106 | 107 | //得到DeviceList 108 | -(NSMutableArray*)getDeviceList{ 109 | if(self.deviceList==nil){ 110 | self.deviceList = [NSMutableArray array]; 111 | } 112 | return self.deviceList; 113 | } 114 | 115 | -(NSMutableArray*)getPeripheralList{ 116 | if(self.peripheralList==nil){ 117 | self.peripheralList = [NSMutableArray array]; 118 | } 119 | return self.peripheralList; 120 | } 121 | 122 | 123 | -(void)setOnClick{ 124 | 125 | } 126 | 127 | 128 | #pragma mark - Navigation 129 | -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 130 | return self.deviceList.count; 131 | } 132 | 133 | -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 134 | static NSString *cellIdentifiter = @"DeviceCellIdentifiter"; 135 | MainCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifiter]; 136 | if (cell == nil) { 137 | cell = [[MainCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifiter]; 138 | } 139 | if([_deviceList count]>0){ 140 | NSUInteger row = [indexPath row]; 141 | if(row<_deviceList.count){ 142 | _deviceModel = [_deviceList objectAtIndex:indexPath.row]; 143 | cell.txtDeviceName.text = _deviceModel.deviceName; 144 | } 145 | } 146 | return cell; 147 | } 148 | 149 | #pragma tableView的点击事件 150 | -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 151 | { 152 | static NSString *cellIdentifiter = @"DeviceCellIdentifiter"; 153 | MainCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifiter]; 154 | if (cell == nil) { 155 | cell = [[MainCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifiter]; 156 | } 157 | 158 | if(_deviceList.count>0){ 159 | NSString *contentTips = NSLocalizedString(@"connectTips", nil); 160 | NSString *multiple = NSLocalizedString(@"multipleunit", nil); 161 | //NSString *multiple = @"Copy"; 162 | NSString *single = NSLocalizedString(@"singleunit", nil); 163 | //该方法响应列表中行的点击事件 164 | NSString *bleSelected=@""; 165 | //indexPath.row得到选中的行号,提取出在数组中的内容。 166 | BTAlertController *alertController = [BTAlertController alertControllerWithTitle:contentTips message:bleSelected preferredStyle:UIAlertControllerStyleAlert]; 167 | 168 | UIAlertAction *noAction = [UIAlertAction actionWithTitle:multiple style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){ 169 | 170 | }]; 171 | 172 | UIAlertAction *yesAction = [UIAlertAction actionWithTitle:single style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ 173 | //连接第一个扫描到的外设 174 | NSUInteger row = [indexPath row]; 175 | int rows =(int)row; 176 | //连接蓝牙 177 | [[BlueHelp sharedManager] contentBlue:rows]; 178 | 179 | MainController *mainView = [[MainController alloc] init]; 180 | mainView.title = @"ota升级"; 181 | [self.navigationController pushViewController:mainView animated:YES]; 182 | }]; 183 | 184 | [alertController addAction:noAction]; 185 | [alertController addAction:yesAction]; 186 | [self presentViewController:alertController animated:true completion:nil]; 187 | 188 | } 189 | } 190 | 191 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 192 | { 193 | return 90; 194 | } 195 | 196 | @end 197 | -------------------------------------------------------------------------------- /YModemCs/Class/File(文件)/Cell/OTAFileCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // OTAFileCell.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface OTAFileCell : UITableViewCell 12 | 13 | @property (strong, nonatomic) UILabel *fileLabel; 14 | 15 | @property (strong,nonatomic) UIButton *checkBoxBtn; 16 | 17 | @property (strong,nonatomic) UIImageView *checkImgView; 18 | 19 | @property (strong,nonatomic) UIImage *checkImg; 20 | 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /YModemCs/Class/File(文件)/Cell/OTAFileCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // OTAFileCell.m 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import "OTAFileCell.h" 10 | 11 | #ifdef __OBJC__ 12 | //define this constant if you want to use Masonry without the 'mas_' prefix 13 | #define MAS_SHORTHAND 14 | //define this constant if you want to enable auto-boxing for default syntax 15 | #define MAS_SHORTHAND_GLOBALS 16 | #import "Masonry.h" 17 | #endif 18 | 19 | @implementation OTAFileCell 20 | 21 | - (void)awakeFromNib { 22 | [super awakeFromNib]; 23 | // Initialization code 24 | } 25 | 26 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ 27 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 28 | if(self){ 29 | //设备名称 30 | _fileLabel = [[UILabel alloc] init]; 31 | _fileLabel.textColor = [UIColor blackColor]; 32 | _fileLabel.font = [UIFont fontWithName:@"Helvetica" size:14]; 33 | [self addSubview:_fileLabel]; 34 | 35 | [_fileLabel makeConstraints:^(MASConstraintMaker *make){ 36 | make.top.equalTo(self).offset(15); 37 | make.left.equalTo(self).offset(10); 38 | make.width.equalTo(@220); 39 | make.height.equalTo(@30); 40 | }]; 41 | 42 | //设备的按钮 43 | _checkBoxBtn = [[UIButton alloc] init]; 44 | //_checkImg = [UIImage imageNamed:@"checkbox"]; 45 | _checkImgView = [[UIImageView alloc] init]; 46 | [_checkImgView setImage:_checkImg]; 47 | [_checkBoxBtn addSubview:_checkImgView]; 48 | [self addSubview:_checkBoxBtn]; 49 | 50 | [_checkImgView makeConstraints:^(MASConstraintMaker *make){ 51 | make.top.equalTo(_checkBoxBtn).offset(0); 52 | make.left.equalTo(_checkBoxBtn).offset(0); 53 | make.right.equalTo(_checkBoxBtn).offset(0); 54 | make.bottom.equalTo(_checkBoxBtn).offset(0); 55 | }]; 56 | 57 | [_checkBoxBtn makeConstraints:^(MASConstraintMaker *make){ 58 | make.top.equalTo(self).offset(15); 59 | make.right.equalTo(self).offset(-10); 60 | make.width.offset(@25); 61 | make.height.offset(@25); 62 | }]; 63 | } 64 | return self; 65 | } 66 | 67 | 68 | @end 69 | 70 | -------------------------------------------------------------------------------- /YModemCs/Class/File(文件)/Controller/FileOTAController.h: -------------------------------------------------------------------------------- 1 | // 2 | // FileOTAController.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "FileOTAView.h" 11 | #import "OTAFileCell.h" 12 | #import "CommonUtil.h" 13 | #import "Constants.h" 14 | 15 | #define FILE_NAME @"FileName" 16 | #define FILE_PATH @"FilePath" 17 | 18 | typedef enum{ 19 | app_upgrade, 20 | app_stack_combined, 21 | app_stack_separate 22 | }OTAModel; 23 | 24 | @protocol FirmwareFileSelectionDelegate 25 | 26 | @required 27 | 28 | - (void)firmwareFilesSelected:(NSArray *)selectedFilesArray forUpgradeMode:(OTAModel)selectedMode; 29 | 30 | @end 31 | 32 | @interface FileOTAController : UIViewController 33 | 34 | @property (strong, nonatomic) id delegate; 35 | 36 | @property OTAModel selectedUpgradeMode; 37 | 38 | @property(strong,nonatomic) FileOTAView *fileOtaView; 39 | 40 | @property(strong,nonatomic) CommonUtil *commonUtil; 41 | 42 | @property(strong,nonatomic) NSMutableArray * selectedFirmwareFilesArray; 43 | 44 | @property(strong,nonatomic) NSArray * firmwareFilesListArray; 45 | 46 | @property(nonatomic) BOOL isFileSearchFinished, isStackFileSelected; 47 | 48 | ///------------------ 49 | 50 | 51 | @end 52 | 53 | -------------------------------------------------------------------------------- /YModemCs/Class/File(文件)/View/FileOTAView.h: -------------------------------------------------------------------------------- 1 | // 2 | // FileOTAView.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CommonUtil.h" 11 | 12 | @protocol FileOTAViewDelegate 13 | //加载头部刷新 14 | -(void)upgradeonClick; 15 | 16 | @end 17 | 18 | @interface FileOTAView : UIView 19 | 20 | //代理 21 | @property(assign,nonatomic) id delegate; 22 | 23 | @property(strong,nonatomic) CommonUtil *commonUtil; 24 | 25 | @property(strong,nonatomic) UITableView *filetableView; 26 | 27 | @property(strong,nonatomic) UIButton *upgradeButton; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /YModemCs/Class/File(文件)/View/FileOTAView.m: -------------------------------------------------------------------------------- 1 | // 2 | // FileOTAView.m 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import "FileOTAView.h" 10 | 11 | 12 | #ifdef __OBJC__ 13 | //define this constant if you want to use Masonry without the 'mas_' prefix 14 | #define MAS_SHORTHAND 15 | //define this constant if you want to enable auto-boxing for default syntax 16 | #define MAS_SHORTHAND_GLOBALS 17 | #import "Masonry.h" 18 | #endif 19 | 20 | @implementation FileOTAView 21 | 22 | //添加布局 23 | -(instancetype) init{ 24 | self = [super init]; 25 | if(self){ 26 | _commonUtil = [CommonUtil sharedManager]; 27 | [self initView]; 28 | [self initEvent]; 29 | } 30 | return self; 31 | } 32 | 33 | -(void)initView{ 34 | _filetableView = [[UITableView alloc] init]; 35 | [self addSubview:_filetableView]; 36 | //布局 37 | [_filetableView makeConstraints:^(MASConstraintMaker *make){ 38 | make.left.equalTo(self).offset(0); 39 | make.right.equalTo(self).offset(0); 40 | make.top.equalTo(self).offset(5); 41 | make.bottom.equalTo(self).offset(-55); 42 | }]; 43 | 44 | _upgradeButton = [[UIButton alloc] init]; 45 | _upgradeButton.backgroundColor = [_commonUtil stringTOColor:@"#6495ED"]; 46 | NSString *upgrade = NSLocalizedString(@"upgrade", nil); 47 | [_upgradeButton setTitle:upgrade forState:UIControlStateNormal]; 48 | [self addSubview:_upgradeButton]; 49 | 50 | [_upgradeButton makeConstraints:^(MASConstraintMaker *make){ 51 | make.right.equalTo(self).offset(0); 52 | make.left.equalTo(self).offset(0); 53 | make.bottom.equalTo(self).offset(0); 54 | make.height.offset(@55); 55 | }]; 56 | } 57 | 58 | -(void)initEvent{ 59 | [_upgradeButton addTarget:self action:@selector(upgradeonClick) forControlEvents:UIControlEventTouchUpInside]; 60 | } 61 | 62 | -(void)upgradeonClick{ 63 | if(self.delegate){ 64 | [self.delegate upgradeonClick]; 65 | } 66 | } 67 | 68 | 69 | @end 70 | 71 | 72 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/ble/BlueHelp.h: -------------------------------------------------------------------------------- 1 | // 2 | // BlueHelp.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "BlueHelp.h" 11 | #import 12 | #import "DeviceModel.h" 13 | #import "Constants.h" 14 | #import "CommonUtil.h" 15 | 16 | @interface BlueHelp : NSObject 17 | 18 | + (id)sharedManager; 19 | 20 | //蓝牙的设备搜索显示在列表中 21 | @property (nonatomic, strong) NSMutableArray *periperals; 22 | 23 | //连接peripheral 24 | @property(nonatomic,strong) CBPeripheral *peripheral; 25 | 26 | //中心管理者 27 | @property (nonatomic, strong) CBCentralManager *centerManager; 28 | 29 | //设备列表 30 | @property (nonatomic,strong) NSMutableArray *deviceList; 31 | 32 | @property (nonatomic,strong) DeviceModel *deviceModel; 33 | 34 | //发送OTA数据 35 | @property (nonatomic,strong) CBCharacteristic *sendotacharateristic; 36 | 37 | -(void)contentBlue:(int) row; 38 | 39 | -(void)startScan; 40 | 41 | -(void)stopScan; 42 | 43 | -(NSMutableArray *)getDeviceList; 44 | 45 | -(NSMutableArray *)getPeriperalList; 46 | 47 | -(void)writeBlueOTA:(NSString *)value; 48 | 49 | -(void)wirteBleOTAData:(NSData *)value; 50 | 51 | //断开蓝牙 52 | -(void)disContentBle; 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/ble/BlueHelp.m: -------------------------------------------------------------------------------- 1 | // 2 | // BlueHelp.m 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import "BlueHelp.h" 10 | 11 | 12 | @interface BlueHelp() 13 | 14 | @end 15 | 16 | @implementation BlueHelp 17 | 18 | + (id)sharedManager { 19 | static BlueHelp *sharedMyManager = nil; 20 | static dispatch_once_t onceToken; 21 | dispatch_once(&onceToken, ^{ 22 | sharedMyManager = [[self alloc] init]; 23 | }); 24 | return sharedMyManager; 25 | } 26 | 27 | -(id)init{ 28 | self = [super init]; 29 | if(self){ 30 | self.centerManager = [[CBCentralManager alloc] init]; 31 | self.centerManager.delegate = self; 32 | } 33 | return self; 34 | } 35 | 36 | #pragma 蓝牙代理 --- 37 | //程序运行后,会自动调用的检查蓝牙的方法 并扫描蓝牙的方法 38 | - (void)centralManagerDidUpdateState:(CBCentralManager *)central{ 39 | if (@available(iOS 10.0, *)) { 40 | if ([central state] == CBManagerStatePoweredOff) { 41 | NSLog(@"CoreBluetooth BLE hardware is powered off"); 42 | } 43 | else if ([central state] == CBManagerStatePoweredOn) { 44 | NSLog(@"CoreBluetooth BLE hardware is powered on and ready"); 45 | [self startScan]; 46 | } 47 | else if ([central state] == CBManagerStateUnauthorized) { 48 | NSLog(@"CoreBluetooth BLE state is unauthorized"); 49 | } 50 | else if ([central state] == CBManagerStateUnknown) { 51 | NSLog(@"CoreBluetooth BLE state is unknown"); 52 | } 53 | else if ([central state] == CBManagerStateUnsupported) { 54 | NSLog(@"CoreBluetooth BLE hardware is unsupported on this platform"); 55 | } 56 | } else { 57 | // Fallback on earlier versions 58 | } 59 | } 60 | 61 | /* 62 | * 获取设备的list 63 | */ 64 | -(NSMutableArray *)getDeviceList{ 65 | return self.deviceList; 66 | } 67 | 68 | /* 69 | * 获取设备的periperals 70 | */ 71 | -(NSMutableArray *)getPeriperalList{ 72 | return self.periperals; 73 | } 74 | 75 | /* 76 | * 连接蓝牙设备给外部调用的方法 77 | * 传入的是相对应的行数 78 | */ 79 | -(void)contentBlue:(int) row{ 80 | [self.centerManager connectPeripheral:self.periperals[row] options:nil]; 81 | } 82 | 83 | //断开蓝牙 84 | -(void)disContentBle{ 85 | //关键的断开蓝牙 通知也要停止掉 86 | if((_peripheral!=nil && self.sendotacharateristic!=nil)){ 87 | [_peripheral setNotifyValue:NO forCharacteristic:self.sendotacharateristic]; 88 | [self disconnectPeripheral:_peripheral]; 89 | } 90 | } 91 | 92 | - (void) disconnectPeripheral:(CBPeripheral*)peripheral 93 | { 94 | [_centerManager cancelPeripheralConnection:peripheral]; 95 | } 96 | 97 | /* 98 | * 程序运行的时候开始扫描 99 | */ 100 | -(void)startScan{ 101 | self.periperals = [[NSMutableArray alloc] init]; 102 | self.deviceList = [[NSMutableArray alloc] init]; 103 | //2.利用中心设备扫描外部设备 104 | [self.centerManager scanForPeripheralsWithServices:nil options:nil]; 105 | } 106 | 107 | /* 108 | * 停止扫描 109 | */ 110 | -(void)stopScan{ 111 | [_centerManager stopScan]; 112 | } 113 | 114 | 115 | 116 | - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSS{ 117 | NSString *deviceName; 118 | if (![self.periperals containsObject:peripheral]){ 119 | deviceName = peripheral.name; 120 | } 121 | 122 | self.deviceModel = [[DeviceModel alloc] init]; 123 | self.deviceModel.deviceName = deviceName; 124 | 125 | [self.periperals addObject:peripheral]; 126 | [self.deviceList addObject:self.deviceModel]; 127 | } 128 | 129 | //连接成功 130 | - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral{ 131 | if(peripheral!=nil){ 132 | //停止扫描 这个用于自动连接的时候 133 | [self.centerManager stopScan]; 134 | //设备名称 135 | //_deviceName = peripheral.name; 136 | //_selectperipheral = peripheral; 137 | 138 | peripheral.delegate = self; 139 | //再去扫描服务 140 | [peripheral discoverServices:nil]; 141 | 142 | } 143 | } 144 | 145 | //连接失败 146 | - (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(nullable NSError *)error{ 147 | NSLog(@"连接失败,失败原因:%@",error); 148 | NSString *disContentBlue = @"discontentblue"; 149 | NSDictionary *blueDiscontent = [NSDictionary dictionaryWithObject:disContentBlue forKey:@"disconnect"]; 150 | //发送广播 连接失败 151 | [[NSNotificationCenter defaultCenter] postNotificationName:@"disNofiction" object:nil userInfo:blueDiscontent]; 152 | } 153 | 154 | //断开连接 155 | - (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error{ 156 | NSLog(@"断开连接"); 157 | NSString *disContentBlue = @"discontentblue"; 158 | NSDictionary *blueDiscontent = [NSDictionary dictionaryWithObject:disContentBlue forKey:@"disconnect"]; 159 | //发送广播 连接失败 160 | [[NSNotificationCenter defaultCenter] postNotificationName:@"disNofiction" object:nil userInfo:blueDiscontent]; 161 | } 162 | 163 | #pragma mark - CBPeripheralDelegate 164 | //只要扫描到服务就会调用,其中的外设就是服务所在的外设 165 | - (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error{ 166 | if (error){ 167 | NSLog(@"扫描服务出现错误,错误原因:%@",error); 168 | }else{ 169 | //获取外设中所扫描到的服务 170 | for (CBService *service in peripheral.services){ 171 | //把所有的service打印出来 172 | //从需要的服务中查找需要的特征 173 | //从peripheral的services中扫描特征 174 | [peripheral discoverCharacteristics:nil forService:service]; 175 | } 176 | } 177 | } 178 | 179 | //只要扫描到特征就会调用,其中的外设和服务就是特征所在的外设和服务 180 | - (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(nonnull CBService *)service error:(nullable NSError *)error{ 181 | if (error){ 182 | NSLog(@"扫描特征出现错误,错误原因:%@",error); 183 | }else{ 184 | for (CBCharacteristic *characteristic in service.characteristics){ 185 | if([characteristic.UUID isEqual:BOOT_OTA_UUID]){ 186 | self.peripheral = peripheral; 187 | self.sendotacharateristic = characteristic; 188 | [peripheral setNotifyValue:YES forCharacteristic:characteristic]; 189 | } 190 | } 191 | } 192 | } 193 | 194 | //设置通知 195 | -(void)notifyCharacteristic:(CBPeripheral *)peripheral 196 | characteristic:(CBCharacteristic *)characteristic{ 197 | NSLog(@"发现通知!"); 198 | [peripheral setNotifyValue:YES forCharacteristic:characteristic]; 199 | [self.centerManager stopScan]; 200 | } 201 | 202 | //取消通知 203 | -(void)cancelNotifyCharacteristic:(CBPeripheral *)peripheral 204 | characteristic:(CBCharacteristic *)characteristic{ 205 | [peripheral setNotifyValue:NO forCharacteristic:characteristic]; 206 | } 207 | 208 | 209 | //获取所以的数据处理 210 | - (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error 211 | { 212 | //接受数据处理 213 | NSString *data = [self getOTAData:characteristic]; 214 | NSLog(@"data is %@",data); 215 | 216 | //发送广播 217 | //发送所有数据 要在清单中注册该广播 218 | NSDictionary *otaDict = [NSDictionary dictionaryWithObject:data forKey:@"otaData"]; 219 | [[NSNotificationCenter defaultCenter] postNotificationName:@"otaNofiction" object:nil userInfo:otaDict]; 220 | } 221 | 222 | 223 | -(NSString *)getOTAData:(CBCharacteristic *)characteristic{ 224 | NSData *data = characteristic.value; 225 | return [self convertDataToHexStr:data]; 226 | } 227 | 228 | -(NSString *)convertDataToHexStr:(NSData *)data 229 | { 230 | if (!data || [data length] == 0) { 231 | return @""; 232 | } 233 | NSMutableString *string = [[NSMutableString alloc] initWithCapacity:[data length]]; 234 | 235 | [data enumerateByteRangesUsingBlock:^(const void *bytes, NSRange byteRange, BOOL *stop) { 236 | unsigned char *dataBytes = (unsigned char*)bytes; 237 | for (NSInteger i = 0; i < byteRange.length; i++) { 238 | NSString *hexStr = [NSString stringWithFormat:@"%x", (dataBytes[i]) & 0xff]; 239 | if ([hexStr length] == 2) { 240 | [string appendString:hexStr]; 241 | } else { 242 | [string appendFormat:@"0%@", hexStr]; 243 | } 244 | } 245 | }]; 246 | return string; 247 | } 248 | 249 | 250 | 251 | - (NSData *)convertHexStrToData:(NSString *)str 252 | { 253 | if (!str || [str length] == 0) { 254 | return nil; 255 | } 256 | 257 | NSMutableData *hexData = [[NSMutableData alloc] initWithCapacity:20]; 258 | NSRange range; 259 | if ([str length] % 2 == 0) { 260 | range = NSMakeRange(0, 2); 261 | } else { 262 | range = NSMakeRange(0, 1); 263 | } 264 | for (NSInteger i = range.location; i < [str length]; i += 2) { 265 | unsigned int anInt; 266 | NSString *hexCharStr = [str substringWithRange:range]; 267 | NSScanner *scanner = [[NSScanner alloc] initWithString:hexCharStr]; 268 | 269 | [scanner scanHexInt:&anInt]; 270 | NSData *entity = [[NSData alloc] initWithBytes:&anInt length:1]; 271 | [hexData appendData:entity]; 272 | 273 | range.location += range.length; 274 | range.length = 2; 275 | } 276 | return hexData; 277 | } 278 | 279 | 280 | 281 | -(void)writeBlueOTA:(NSString *)value{ 282 | NSMutableData *data = [[CommonUtil sharedManager] dataFromHexString:[value stringByReplacingOccurrencesOfString:@"0x" withString:@""]]; 283 | NSLog(@"data is:%@",data); 284 | [self writeOTA:data forCharacteristic:self.sendotacharateristic]; 285 | } 286 | 287 | 288 | -(void)wirteBleOTAData:(NSData *)value{ 289 | [self writeOTA:value forCharacteristic:self.sendotacharateristic]; 290 | } 291 | 292 | //写入OTA的区块 293 | -(void)writeOTA:(NSData *)value forCharacteristic:(CBCharacteristic *)characteristic 294 | { 295 | //is no write bluetooth data 296 | if(self.sendotacharateristic.properties & CBCharacteristicPropertyWriteWithoutResponse) 297 | { 298 | //send phone on bluetooth data 299 | [self.peripheral writeValue:value forCharacteristic:characteristic type:CBCharacteristicWriteWithoutResponse]; 300 | }else 301 | { 302 | [self.peripheral writeValue:value forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse]; 303 | } 304 | NSLog(@"已经向外设%@的特征值%@写入数据",_peripheral.name,characteristic.description); 305 | } 306 | 307 | 308 | @end 309 | 310 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/model/DeviceModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // DeviceModel.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DeviceModel : NSObject 12 | //设备名称 13 | @property(copy,nonatomic) NSString *deviceName; 14 | //设备RSSI的值 15 | @property(copy,nonatomic) NSString *deviceRssi; 16 | 17 | @property(copy,nonatomic) NSString *deviceAddre; 18 | 19 | @property(assign,nonatomic) BOOL isselect; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/model/DeviceModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // DeviceModel.m 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import "DeviceModel.h" 10 | 11 | @implementation DeviceModel 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/util/BTAlertController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BTAlertController.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BTAlertController : UIAlertController 12 | 13 | @property(strong,nonatomic) UITapGestureRecognizer *closeGesture; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/util/BTAlertController.m: -------------------------------------------------------------------------------- 1 | // 2 | // BTAlertController.m 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | #import "BTAlertController.h" 9 | 10 | @interface BTAlertController () 11 | 12 | @end 13 | 14 | @implementation BTAlertController 15 | 16 | - (void)viewDidLoad { 17 | [super viewDidLoad]; 18 | self.closeGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(closeAlert:)]; 19 | } 20 | 21 | - (void)viewDidAppear:(BOOL)animated { 22 | [super viewDidAppear:animated]; 23 | UIView *superView = self.view.superview; 24 | if (![superView.gestureRecognizers containsObject:self.closeGesture]) { 25 | [superView addGestureRecognizer:self.closeGesture]; 26 | superView.userInteractionEnabled = YES; 27 | } 28 | } 29 | 30 | - (void)closeAlert:(UITapGestureRecognizer *) gesture{ 31 | [self dismissViewControllerAnimated:YES completion:nil]; 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/util/CommonUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // CommonUtil.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface CommonUtil : NSObject 13 | 14 | +(CommonUtil*)sharedManager; 15 | 16 | -(NSMutableData *)dataFromHexString:(NSString *)string; 17 | 18 | -(UIColor *) stringTOColor:(NSString *)str; 19 | 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/util/CommonUtil.m: -------------------------------------------------------------------------------- 1 | // 2 | // CommonUtil.m 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import "CommonUtil.h" 10 | 11 | @implementation CommonUtil 12 | 13 | static CommonUtil *sharedSingleton = nil; 14 | 15 | /* 16 | * 17 | 单列模式给外部调用 18 | */ 19 | +(CommonUtil*)sharedManager{ 20 | static dispatch_once_t once; 21 | dispatch_once(&once,^{ 22 | sharedSingleton = [[self alloc] init]; 23 | }); 24 | 25 | return sharedSingleton; 26 | } 27 | 28 | /* 29 | * 字符串转为颜色值 30 | */ 31 | -(UIColor *) stringTOColor:(NSString *)str 32 | { 33 | if (!str || [str isEqualToString:@""]) { 34 | return nil; 35 | } 36 | unsigned red,green,blue; 37 | NSRange range; 38 | range.length = 2; 39 | range.location = 1; 40 | [[NSScanner scannerWithString:[str substringWithRange:range]] scanHexInt:&red]; 41 | range.location = 3; 42 | [[NSScanner scannerWithString:[str substringWithRange:range]] scanHexInt:&green]; 43 | range.location = 5; 44 | [[NSScanner scannerWithString:[str substringWithRange:range]] scanHexInt:&blue]; 45 | UIColor *color= [UIColor colorWithRed:red/255.0f green:green/255.0f blue:blue/255.0f alpha:1]; 46 | return color; 47 | } 48 | 49 | 50 | /** 51 | * Method to convert hex to byteArray 52 | */ 53 | -(NSMutableData *)dataFromHexString:(NSString *)string 54 | { 55 | NSMutableData *data = [NSMutableData new]; 56 | NSCharacterSet *hexSet = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789ABCDEF "] invertedSet]; 57 | 58 | // Check whether the string is a valid hex string. Otherwise return empty data 59 | if ([string rangeOfCharacterFromSet:hexSet].location == NSNotFound) { 60 | 61 | string = [string lowercaseString]; 62 | unsigned char whole_byte; 63 | char byte_chars[3] = {'\0','\0','\0'}; 64 | int i = 0; 65 | int length = (int)string.length; 66 | 67 | while (i < length-1) 68 | { 69 | char c = [string characterAtIndex:i++]; 70 | 71 | if (c < '0' || (c > '9' && c < 'a') || c > 'f') 72 | continue; 73 | byte_chars[0] = c; 74 | byte_chars[1] = [string characterAtIndex:i++]; 75 | whole_byte = strtol(byte_chars, NULL, 16); 76 | [data appendBytes:&whole_byte length:1]; 77 | } 78 | } 79 | return data; 80 | } 81 | 82 | 83 | @end 84 | 85 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/util/Constants.h: -------------------------------------------------------------------------------- 1 | // 2 | // Constants.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 10/28/19. 6 | // Copyright © 2019 GoDream. All rights reserved. 7 | // 8 | 9 | #ifndef Constants_h 10 | #define Constants_h 11 | 12 | //OTA Constants 13 | #define BOOT_OTA_UUID [CBUUID UUIDWithString:@"4E8A02FE-BB42-452D-B573-E0645F03C230"] 14 | 15 | #define UPGRADE_BTN_TITLE_FOR_SEPERATE_SELECTION @"NEXT" 16 | #define UPGRADE_BTN_TITLE_DEFAULT @"UPGRADE" 17 | 18 | #define LOCALIZEDSTRING(string) NSLocalizedString(string, nil) 19 | 20 | 21 | #endif /* Constants_h */ 22 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/util/OTAManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // OTAManager.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef enum : NSUInteger { 12 | OTAStatusNONE, 13 | OTAStatusWaiting, 14 | OTAStatusFirstOrder, 15 | OTAStatusBinOrder, 16 | OTAStatusBinOrderDone, 17 | OTAStatusEnd, 18 | OTAStatusCAN, 19 | } OTAStatus; 20 | 21 | typedef enum : NSUInteger { 22 | OrderStatusNONE, 23 | OrderStatusC, 24 | OrderStatusACK, 25 | OrderStatusNAK, 26 | OrderStatusCAN, 27 | } OrderStatus; 28 | 29 | @interface OTAManager : NSObject 30 | 31 | @property (nonatomic, assign) OTAStatus status; 32 | 33 | /** 34 | * @brief 下位机进入OTA模式 35 | */ 36 | - (void)setFirmwareEnterOTAMode; 37 | 38 | /** 下位机进入Ymodem数据下载模式 39 | * 40 | */ 41 | - (void)setFirmwareEnterYmodemDataDownloadMode; 42 | 43 | /** 44 | * @brief 下位机退出OTA模式 45 | */ 46 | - (void)setFirmwareExitOTAMode; 47 | 48 | /** 49 | * @brief 处理OTA数据 50 | * @param status OTA指令 51 | * @param complete OTA状态回调 52 | */ 53 | - (void)setFirmwareHandleOTADataWithOrderStatus:(OrderStatus)status completion:(void(^)(NSString *message))complete; 54 | 55 | - (NSData *)prepareFirstPacketWithFileName:(NSString *)filename; 56 | 57 | - (NSArray *)preparePacketWithFileName:(NSString *)filename; 58 | 59 | - (NSData *)prepareEndPacket; 60 | 61 | @end 62 | 63 | 64 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/view/DownLoadView/DownLoadBtn.h: -------------------------------------------------------------------------------- 1 | // 2 | // DownLoadBtn.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/15. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DownLoadBtn : UIButton 12 | 13 | 14 | 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/view/DownLoadView/DownLoadBtn.m: -------------------------------------------------------------------------------- 1 | // 2 | // DownLoadBtn.m 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/15. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import "DownLoadBtn.h" 10 | 11 | @implementation DownLoadBtn 12 | 13 | //下载完成后,点击的Button 14 | -(instancetype)initWithFrame:(CGRect)frame 15 | { 16 | if (self=[super initWithFrame:frame]) { 17 | [self setUpChild]; 18 | } 19 | return self; 20 | } 21 | //TO DO 22 | -(void)setUpChild{ 23 | 24 | } 25 | 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/view/DownLoadView/DownLoadView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DownLoadView.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/15. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class DownLoadView; 12 | 13 | @protocol DownLoadViewDelegate ; 14 | 15 | -(void)ClickToStartTheDownLoadBtnInLoadView:(DownLoadView *)downLoadView ; 16 | 17 | @end; 18 | 19 | @interface DownLoadView : UIView 20 | 21 | /** MusicalProgress */ 22 | @property (nonatomic, assign) CGFloat musicalProgress; 23 | 24 | /** placeholderText */ 25 | @property (nonatomic, copy) NSString *placeholderText; 26 | 27 | /** placeholderBtnText */ 28 | @property (nonatomic, copy) NSString *placeholderBtnText; 29 | 30 | /** placeholderFont */ 31 | @property (nonatomic) UIFont *placeholderFont; 32 | 33 | /** placeholderBtnFont */ 34 | @property (nonatomic) UIFont *placeholderBtnFont; 35 | 36 | /** MusicalColor */ 37 | @property (nonatomic) UIColor *musicalColor; 38 | 39 | /** TitleColor */ 40 | @property (nonatomic) UIColor *titleColor; 41 | 42 | /** ZWMusicDownLoadLab */ 43 | @property (nonatomic, strong) UILabel *musicDownLoadLab; 44 | 45 | 46 | /** ZWMusicDownLoadViewDelegate */ 47 | @property (nonatomic, weak) id delegate; 48 | 49 | - (void)startDownLoad; 50 | - (void)endDownLoad; 51 | 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/view/DownLoadView/NoteView.h: -------------------------------------------------------------------------------- 1 | // 2 | // NoteView.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/15. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NoteView : UIView 12 | 13 | @property(nonatomic,assign)CGFloat scaleSize; 14 | @property(nonatomic,assign)BOOL isSingleOne; 15 | @property(nonatomic)UIColor *musicalColor; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /YModemCs/Class/Utils/view/DownLoadView/NoteView.m: -------------------------------------------------------------------------------- 1 | // 2 | // NoteView.m 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/15. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import "NoteView.h" 10 | 11 | #import 12 | #define ZWDistance 1.5 13 | #define ZWDistanceX 1.5 14 | #define ZWDistanceY 1.5 15 | #define Color(r,g,b,a) [UIColor colorWithRed:(r/255.0) green:(g/255.0) blue:(b/255.0) alpha:a] 16 | #define r 100 17 | 18 | 19 | @implementation NoteView 20 | 21 | -(void)drawRect:(CGRect)rect 22 | { 23 | 24 | // //An opaque type that represents a Quartz 2D drawing environment. 25 | //一个不透明类型的Quartz 2D绘画环境,相当于一个画布,你可以在上面任意绘画 26 | CGContextRef context = UIGraphicsGetCurrentContext(); 27 | CGContextScaleCTM(context, self.scaleSize ,self.scaleSize); 28 | 29 | //设置单双音符 30 | if (self.isSingleOne) { 31 | drawSingleBody1(context,rect,self.musicalColor); 32 | drawSingleBody2(context,rect,self.musicalColor); 33 | drawSingleBody3(context,rect,self.musicalColor); 34 | }else 35 | { 36 | 37 | drawDoulbeBody1(context,rect,self.musicalColor); 38 | drawDoulbeBody2(context,rect,self.musicalColor); 39 | drawDoulbeBody3(context,rect,self.musicalColor); 40 | } 41 | 42 | 43 | 44 | } 45 | void drawSingleBody1(CGContextRef context,CGRect rect,UIColor *musicalColor) 46 | { 47 | UIColor*aColor = musicalColor?musicalColor:Color(236, 93, 78, 1); 48 | CGContextSetLineWidth(context, 1); 49 | CGContextMoveToPoint(context, 8, 0); 50 | CGContextAddLineToPoint(context, 16, 3); 51 | CGContextAddLineToPoint(context, 16, 9); 52 | CGContextAddLineToPoint(context, 8, 6); 53 | CGContextSetRGBStrokeColor(context,248, 168, 42, 0);//画笔线的颜色 54 | 55 | CGContextSetFillColorWithColor(context, aColor.CGColor);//填充颜色 56 | CGContextClosePath(context); 57 | 58 | 59 | CGContextDrawPath(context, kCGPathFillStroke); 60 | CGContextSaveGState(context); 61 | 62 | } 63 | 64 | void drawSingleBody2 (CGContextRef context,CGRect rect,UIColor *musicalColor) 65 | { 66 | 67 | 68 | 69 | 70 | CGFloat startX = 8; 71 | CGFloat startY = 0; 72 | CGContextMoveToPoint(context, startX, startY); 73 | CGContextSetLineWidth(context, 2); 74 | 75 | CGFloat endX = 8; 76 | CGFloat endY = 20; 77 | CGContextAddLineToPoint(context, endX, endY); 78 | 79 | [musicalColor?musicalColor:Color(236, 93, 78, 1) set]; 80 | 81 | CGContextStrokePath(context); 82 | } 83 | 84 | void drawSingleBody3 (CGContextRef context,CGRect rect,UIColor *musicalColor) 85 | { 86 | 87 | [musicalColor?musicalColor:Color(236, 93, 78, 1) set]; 88 | CGContextAddArc(context, 6, 20, 4, 0, M_PI * 2, 1); 89 | CGContextFillPath(context); 90 | 91 | 92 | 93 | 94 | } 95 | 96 | void drawDoulbeBody1(CGContextRef context,CGRect rect,UIColor *musicalColor) 97 | { 98 | UIColor*aColor = musicalColor?musicalColor:Color(236, 93, 78, 1); 99 | CGContextSetLineWidth(context, 1); 100 | CGContextMoveToPoint(context, 8, 6); 101 | CGContextAddLineToPoint(context, 24, 0); 102 | CGContextAddLineToPoint(context, 24, 6); 103 | CGContextAddLineToPoint(context, 8, 12); 104 | CGContextSetRGBStrokeColor(context,248, 168, 42, 0);//画笔线的颜色 105 | 106 | CGContextSetFillColorWithColor(context, aColor.CGColor);//填充颜色 107 | CGContextClosePath(context); 108 | 109 | 110 | CGContextDrawPath(context, kCGPathFillStroke); 111 | CGContextSaveGState(context); 112 | 113 | } 114 | 115 | void drawDoulbeBody2 (CGContextRef context,CGRect rect,UIColor *musicalColor) 116 | { 117 | 118 | 119 | 120 | 121 | CGFloat startX = 8; 122 | CGFloat startY = 6; 123 | CGContextMoveToPoint(context, startX, startY); 124 | CGContextSetLineWidth(context, 2); 125 | 126 | CGFloat endX = 8; 127 | CGFloat endY = 26; 128 | CGContextAddLineToPoint(context, endX, endY); 129 | 130 | [musicalColor?musicalColor:Color(236, 93, 78, 1) set]; 131 | 132 | 133 | CGContextMoveToPoint(context, 23, 0); 134 | CGContextSetLineWidth(context, 2); 135 | 136 | 137 | CGContextAddLineToPoint(context, 23, 20); 138 | 139 | [musicalColor?musicalColor:Color(236, 93, 78, 1) set]; 140 | 141 | CGContextStrokePath(context); 142 | } 143 | 144 | void drawDoulbeBody3 (CGContextRef context,CGRect rect,UIColor *musicalColor) 145 | { 146 | 147 | [musicalColor?musicalColor:Color(236, 93, 78, 1) set]; 148 | CGContextAddArc(context, 6, 26, 4, 0, M_PI * 2, 1); 149 | CGContextFillPath(context); 150 | 151 | 152 | [musicalColor?musicalColor:Color(236, 93, 78, 1) set]; 153 | CGContextAddArc(context, 21, 20, 4, 0, M_PI * 2, 1); 154 | CGContextFillPath(context); 155 | 156 | 157 | } 158 | 159 | @end 160 | 161 | -------------------------------------------------------------------------------- /YModemCs/Class/View/MainView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainView.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CommonUtil.h" 11 | #import "DownLoadBtn.h" 12 | #import "DownLoadView.h" 13 | 14 | 15 | #define Color(r,g,b,a) [UIColor colorWithRed:(r/255.0) green:(g/255.0) blue:(b/255.0) alpha:a] 16 | 17 | //设置代理方法 18 | @protocol MainViewDelegate 19 | 20 | -(void)otaOnClick; 21 | -(void)selectOnClick; 22 | 23 | @end 24 | 25 | @interface MainView : UIView 26 | 27 | //制作delegate 28 | @property (nonatomic, weak) id delegate; 29 | 30 | @property(strong,nonatomic) UIButton *updateOTA; 31 | 32 | @property(strong,nonatomic) UIButton *selectFile; 33 | 34 | @property(strong,nonatomic) DownLoadBtn *downLoadBtn; 35 | 36 | @property(strong,nonatomic) DownLoadView *downLoadView; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /YModemCs/Class/View/MainView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainView.m 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import "MainView.h" 10 | 11 | #ifdef __OBJC__ 12 | //define this constant if you want to use Masonry without the 'mas_' prefix 13 | #define MAS_SHORTHAND 14 | //define this constant if you want to enable auto-boxing for default syntax 15 | #define MAS_SHORTHAND_GLOBALS 16 | #import "Masonry.h" 17 | #endif 18 | 19 | @implementation MainView 20 | 21 | //添加布局 22 | -(instancetype) init{ 23 | self = [super init]; 24 | if(self){ 25 | [self initView]; 26 | } 27 | return self; 28 | } 29 | 30 | -(void)initView{ 31 | //创建取消按钮 32 | self.updateOTA = [[UIButton alloc] init]; 33 | self.updateOTA.backgroundColor = [[CommonUtil sharedManager] stringTOColor:@"#6495ED"]; 34 | self.updateOTA.layer.cornerRadius = 15; 35 | NSString *cancel = @"开始OTA"; 36 | [self.updateOTA setTitle:cancel forState:UIControlStateNormal]; 37 | [self addSubview:self.updateOTA]; 38 | 39 | [self.updateOTA makeConstraints:^(MASConstraintMaker *make){ 40 | make.left.equalTo(self).offset(30); 41 | make.right.equalTo(self).offset(-30); 42 | make.top.equalTo(self).offset(85); 43 | make.height.equalTo(@55); 44 | }]; 45 | 46 | self.downLoadView = [[DownLoadView alloc] init]; 47 | //灰色 48 | self.downLoadView.backgroundColor = [UIColor grayColor]; 49 | self.downLoadView.musicalColor=[[CommonUtil sharedManager] stringTOColor:@"#6495ED"]; 50 | self.downLoadView.placeholderBtnFont=[UIFont fontWithName:@"Helvetica-Bold" size:14]; 51 | self.downLoadView.placeholderFont=[UIFont fontWithName:@"Helvetica-Bold" size:12]; 52 | self.downLoadView.musicDownLoadLab.text = @"请选择你的升级文件"; 53 | [self addSubview:self.downLoadView]; 54 | 55 | [self.downLoadView makeConstraints:^(MASConstraintMaker *make){ 56 | make.left.equalTo(self).offset(20); 57 | make.right.equalTo(self).offset(-20); 58 | make.top.equalTo(self).offset(250); 59 | make.height.equalTo(@55); 60 | }]; 61 | 62 | self.selectFile = [[UIButton alloc] init]; 63 | self.selectFile.backgroundColor = [[CommonUtil sharedManager] stringTOColor:@"#6495ED"]; 64 | self.selectFile.layer.cornerRadius = 0; 65 | NSString *select = @"选择文件"; 66 | [self.selectFile setTitle:select forState:UIControlStateNormal]; 67 | [self addSubview:self.selectFile]; 68 | 69 | [self.selectFile makeConstraints:^(MASConstraintMaker *make){ 70 | make.left.equalTo(self).offset(0); 71 | make.right.equalTo(self).offset(0); 72 | make.bottom.equalTo(self).offset(0); 73 | make.height.equalTo(@55); 74 | }]; 75 | 76 | 77 | 78 | //取消点击事件 79 | [self.updateOTA addTarget:self action:@selector(otaOnClick) forControlEvents:UIControlEventTouchUpInside]; 80 | 81 | [self.selectFile addTarget:self action:@selector(selectOnClick) forControlEvents:UIControlEventTouchUpInside]; 82 | 83 | 84 | } 85 | 86 | -(void)otaOnClick{ 87 | if(self.delegate){ 88 | [self.delegate otaOnClick]; 89 | } 90 | } 91 | 92 | -(void)selectOnClick{ 93 | if(self.delegate){ 94 | [self.delegate selectOnClick]; 95 | } 96 | } 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /YModemCs/Class/YModem/YModem.c: -------------------------------------------------------------------------------- 1 | // 2 | // YModem.c 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #include "YModem.h" 10 | #include 11 | #include 12 | #include 13 | #include 14 | #define SUCCESS 1 15 | 16 | #define FAIL 0 17 | 18 | int Status = SUCCESS; 19 | 20 | void PrepareIntialPacket(uint8_t *p_data, const uint8_t *p_file_name, uint32_t length) 21 | { 22 | uint32_t i, j = 0; 23 | char astring[10]; 24 | 25 | /* first 3 bytes are constant */ 26 | p_data[PACKET_START_INDEX] = SOH; 27 | p_data[PACKET_NUMBER_INDEX] = 0x00; 28 | p_data[PACKET_CNUMBER_INDEX] = 0xff; 29 | 30 | /* Filename written */ 31 | for (i = 0; (p_file_name[i] != '\0') && (i < FILE_NAME_LENGTH); i++) 32 | { 33 | p_data[i + PACKET_DATA_INDEX] = p_file_name[i]; 34 | } 35 | 36 | p_data[i + PACKET_DATA_INDEX] = 0x00; 37 | 38 | sprintf(astring,"%d", length); 39 | i = i + PACKET_DATA_INDEX + 1; 40 | 41 | for (int j=0; j> 8; 66 | 67 | p_data[j] = resultH; 68 | p_data[j+1] = resultL; 69 | 70 | } 71 | 72 | void PreparePacket(uint8_t *p_source, uint8_t *p_packet, uint32_t pack_size, uint8_t pkt_nr, uint32_t size_blk) 73 | { 74 | uint8_t *p_record; 75 | uint32_t i, size, packet_size; 76 | 77 | /* Make first three packet */ 78 | packet_size = pack_size;// ? PACKET_1K_SIZE : PACKET_SIZE; 79 | size = size_blk < packet_size ? size_blk : packet_size; 80 | if (packet_size == pack_size) 81 | { 82 | p_packet[PACKET_START_INDEX] = STX; 83 | } 84 | else 85 | { 86 | p_packet[PACKET_START_INDEX] = SOH; 87 | } 88 | p_packet[PACKET_NUMBER_INDEX] = pkt_nr; 89 | p_packet[PACKET_CNUMBER_INDEX] = (~pkt_nr); 90 | p_record = p_source; 91 | 92 | /* Filename packet has valid data */ 93 | for (i = PACKET_DATA_INDEX; i < size + PACKET_DATA_INDEX;i++) 94 | { 95 | p_packet[i] = *p_record++; 96 | } 97 | 98 | /* 空位补0x1A*/ 99 | if ( size <= packet_size) 100 | { 101 | for (i = size + PACKET_DATA_INDEX; i < packet_size + PACKET_DATA_INDEX; i++) 102 | { 103 | p_packet[i] = 0x1A; /* EOF (0x1A) or 0x00 */ 104 | } 105 | } 106 | 107 | /* CRC校验 */ 108 | uint8_t *crc_data; 109 | crc_data = (uint8_t *)malloc(sizeof(uint8_t)*packet_size); 110 | int index = 0; 111 | for (int j = 3; j<=packet_size+2; j++) { 112 | crc_data[index] = p_packet[j]; 113 | index++; 114 | } 115 | 116 | uint16_t result = Cccal_CRC16(crc_data, packet_size); 117 | // 低位 118 | uint16_t resultL=result & 0xFF; 119 | // 高位 120 | uint16_t resultH=result >> 8; 121 | 122 | p_packet[i] = resultH; 123 | p_packet[i+1] = resultL; 124 | } 125 | 126 | /* 127 | 发送最后一包的数据 采用 SOH 以及128包大小结束 128 | */ 129 | void PrepareEndPacket(uint8_t *p_packet) { 130 | uint32_t i, packet_size; 131 | /* Make first three packet */ 132 | packet_size = PACKET_SIZE;// ? PACKET_1K_SIZE : PACKET_SIZE; 133 | if (packet_size == PACKET_SIZE) 134 | { 135 | p_packet[PACKET_START_INDEX] = SOH; 136 | } 137 | else 138 | { 139 | p_packet[PACKET_START_INDEX] = STX; 140 | } 141 | p_packet[PACKET_NUMBER_INDEX] = 0x00; 142 | p_packet[PACKET_CNUMBER_INDEX] = 0xff; 143 | 144 | /* Filename packet has valid data */ 145 | for (i = PACKET_DATA_INDEX; i < packet_size + PACKET_DATA_INDEX;i++) 146 | { 147 | p_packet[i] = 0x00; 148 | } 149 | 150 | /* CRC校验 */ 151 | uint8_t *crc_data; 152 | crc_data = (uint8_t *)malloc(sizeof(uint8_t)*packet_size); 153 | int index = 0; 154 | for (int j = 3; j<=packet_size+2; j++) { 155 | crc_data[index] = p_packet[j]; 156 | index++; 157 | } 158 | 159 | uint16_t result = Cccal_CRC16(crc_data, packet_size); 160 | // 低位 161 | uint16_t resultL=result & 0xFF; 162 | // 高位 163 | uint16_t resultH=result >> 8; 164 | 165 | p_packet[i] = resultH; 166 | p_packet[i+1] = resultL; 167 | } 168 | 169 | /** 170 | * @brief Update CRC16 for input byte 171 | * @param crc_in input value 172 | * @param byte byte 173 | * @retval None 174 | */ 175 | uint16_t UpdateCRC16(uint16_t crc_in, uint8_t byte) 176 | { 177 | uint32_t crc = crc_in; 178 | uint32_t in = byte | 0x100; 179 | do 180 | { 181 | crc <<= 1; 182 | in <<= 1; 183 | if(in & 0x100) 184 | ++crc; 185 | if(crc & 0x10000) 186 | crc ^= 0x1021; 187 | } 188 | 189 | while(!(in & 0x10000)); 190 | return crc & 0xffffu; 191 | } 192 | 193 | /** 194 | * @brief Cal CRC16 for YModem Packet 195 | * @retval None 196 | */ 197 | uint16_t Cccal_CRC16(const uint8_t* p_data, uint32_t size) 198 | { 199 | uint32_t crc = 0; 200 | const uint8_t* dataEnd = p_data+size; 201 | 202 | while(p_data < dataEnd) 203 | crc = UpdateCRC16(crc, *p_data++); 204 | 205 | crc = UpdateCRC16(crc, 0); 206 | crc = UpdateCRC16(crc, 0); 207 | 208 | return crc&0xffffu; 209 | } 210 | 211 | 212 | -------------------------------------------------------------------------------- /YModemCs/Class/YModem/YModem.h: -------------------------------------------------------------------------------- 1 | // 2 | // YModem.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | 10 | /** 11 | * 传输数据规格 12 | * ======================================================================================== 13 | * THE YMODEM: 14 | * Send 0x05>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>* 发送0x05 15 | * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< C 16 | * SOH 00 FF "foo.c" "1064'' NUL[118] CRC CRC >>>>>>>>>>>>> 17 | * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ACK 18 | * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< C 19 | * STX 01 FE data[256] CRC CRC>>>>>>>>>>>>>>>>>>>>>>>> 20 | * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 21 | * ACK STX 02 FD data[256] CRC CRC>>>>>>>>>>>>>>>>>>>>>>> 22 | * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 23 | * ACK STX 03 FC data[256] CRC CRC>>>>>>>>>>>>>>>>>>>>>>> 24 | * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ACK 25 | * STX 04 FB data[256] CRC CRC>>>>>>>>>>>>>>>>>>>>>>> 26 | * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ACK 27 | * SOH 05 FA data[100] 1A[28] CRC CRC>>>>>>>>>>>>>>>>>> 28 | * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ACK 29 | * EOT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 30 | * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< NAK 31 | * EOT>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 32 | * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ACK 33 | * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< C 34 | * SOH 00 FF NUL[128] CRC CRC >>>>>>>>>>>>>>>>>>>>>>> 35 | * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ACK 36 | * =========================================================================================== 37 | **/ 38 | 39 | 40 | #ifndef YModem_h 41 | #define YModem_h 42 | 43 | #include 44 | 45 | 46 | #define PACKET_HEADER_SIZE ((uint32_t)3) 47 | #define PACKET_DATA_INDEX ((uint32_t)3) 48 | #define PACKET_START_INDEX ((uint32_t)0) 49 | #define PACKET_NUMBER_INDEX ((uint32_t)1) 50 | #define PACKET_CNUMBER_INDEX ((uint32_t)2) 51 | #define PACKET_TRAILER_SIZE ((uint32_t)2) 52 | #define PACKET_OVERHEAD_SIZE (PACKET_HEADER_SIZE + PACKET_TRAILER_SIZE - 1) 53 | #define PACKET_SIZE ((uint32_t)128) 54 | //默认为 1024大小 55 | #define PACKET_1K_SIZE ((uint32_t)1024) 56 | 57 | /* /-------- Packet in IAP memory ------------------------------------------\ 58 | * | 0 | 1 | 2 | 3 | 4 | ... | n+4 | n+5 | n+6 | 59 | * |------------------------------------------------------------------------| 60 | * | unused | start | number | !num | data[0] | ... | data[n] | crc0 | crc1 | 61 | * \------------------------------------------------------------------------/ 62 | * the first byte is left unused for memory alignment reasons */ 63 | 64 | #define FILE_NAME_LENGTH ((uint32_t)64) 65 | #define FILE_SIZE_LENGTH ((uint32_t)16) 66 | 67 | #define SOH ((uint8_t)0x01) /* start of 128-byte data packet */ 68 | #define STX ((uint8_t)0x02) /* start of 256-byte data packet */ 69 | #define EOT ((uint8_t)0x04) /* end of transmission */ 70 | #define ACK ((uint8_t)0x06) /* acknowledge */ 71 | #define NAK ((uint8_t)0x15) /* negative acknowledge */ 72 | #define CA ((uint32_t)0x18) /* two of these in succession aborts transfer */ 73 | #define CRC16 ((uint8_t)0x43) /* 'C' == 0x43, request 16-bit CRC */ 74 | #define NEGATIVE_BYTE ((uint8_t)0xFF) 75 | 76 | #define ABORT1 ((uint8_t)0x41) /* 'A' == 0x41, abort by user */ 77 | #define ABORT2 ((uint8_t)0x61) /* 'a' == 0x61, abort by user */ 78 | 79 | #define NAK_TIMEOUT ((uint32_t)0x100000) 80 | #define DOWNLOAD_TIMEOUT ((uint32_t)1000) /* One second retry delay */ 81 | #define MAX_ERRORS ((uint32_t)5) 82 | 83 | 84 | /*Send Data OTA Status*/ 85 | #define OTASOH @"01" 86 | #define OTASTX @"02" 87 | #define OTAEOT @"04" 88 | #define OTAACK @"06" 89 | #define OTANAK @"15" 90 | #define OTACA @"18" 91 | #define OTAC @"43" 92 | #define OTASTART @"0643" 93 | 94 | #define OTAUPEND 10000 95 | 96 | #endif /* YModem_h */ 97 | 98 | void PrepareIntialPacket(uint8_t *p_data, const uint8_t *p_file_name, uint32_t length); 99 | 100 | void PreparePacket(uint8_t *p_source, uint8_t *p_packet, uint32_t pack_size, uint8_t pkt_nr, uint32_t size_blk); 101 | 102 | void PrepareEndPacket(uint8_t *p_packet); 103 | 104 | uint16_t Cccal_CRC16(const uint8_t* p_data, uint32_t size); 105 | 106 | 107 | -------------------------------------------------------------------------------- /YModemCs/Class/YModem/YModemUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // YModemUtil.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "YModem.h" 11 | 12 | typedef enum : NSUInteger { 13 | OTAStatusNONE, 14 | OTAStatusWaiting, 15 | OTAStatusFirstOrder, 16 | OTAStatusBinOrder, 17 | OTAStatusBinOrderDone, 18 | OTAStatusEnd, 19 | OTAStatusCAN, 20 | OTAStatusEOT, 21 | } OTAStatus; 22 | 23 | typedef enum : NSUInteger { 24 | OrderStatusNONE, 25 | OrderStatusC, 26 | OrderStatusACK, 27 | OrderStatusNAK, 28 | OrderStatusCAN, 29 | OrderStatusFirst, 30 | } OrderStatus; 31 | 32 | @protocol YModemUtilDelegate 33 | 34 | //writing Bluetooth data 35 | -(void)onWriteBleData:(NSData*) data; 36 | 37 | @end 38 | 39 | @interface YModemUtil : NSObject 40 | 41 | @property (nonatomic, weak) id delegate; 42 | 43 | @property (nonatomic, strong) NSArray *packetArray; 44 | 45 | @property (nonatomic, assign) OTAStatus status; 46 | 47 | 48 | //file style 49 | -(void)setFirmwareHandleOTADataWithOrderStatus:(OrderStatus)status fileName:(NSString *)filename completion:(void(^)(NSInteger current,NSInteger total,NSString *msg))complete; 50 | 51 | 52 | //NSData style 53 | - (void)setFirmwareHandlerDFUDataWithOrderStatus:(OrderStatus)status fileData:(NSData *)data completion:(void(^)(NSInteger current,NSInteger total,NSString *msg))complete; 54 | 55 | /* 56 | fileName: file is name 57 | filePath: The real path where the file is located 58 | return current: Current file write progress, total: file total size, data: file is data, msg: return message 59 | */ 60 | -(void) setFirmwareUpgrade:(OrderStatus) status fileName:(NSString *) filename filePath:(NSString *) filepath completion:(void(^)(NSInteger current, NSInteger total, NSData *data, NSString *msg))complete; 61 | 62 | /* 63 | Stop upgrade 64 | */ 65 | -(void)stop; 66 | 67 | - (instancetype)init:(uint32_t)size; 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /YModemCs/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSBluetoothPeripheralUsageDescription 24 | Do you allow App to access your Bluetooth? 25 | NSLocationAlwaysUsageDescription 26 | Would you like LHTools to use your location information! 27 | NSLocationWhenInUseUsageDescription 28 | Would you like LHTools to use your location information! 29 | UIBackgroundModes 30 | 31 | bluetooth-central 32 | bluetooth-peripheral 33 | 34 | UIFileSharingEnabled 35 | 36 | UILaunchStoryboardName 37 | LaunchScreen 38 | UIMainStoryboardFile 39 | Main 40 | UIRequiredDeviceCapabilities 41 | 42 | armv7 43 | 44 | UISupportedInterfaceOrientations 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | UISupportedInterfaceOrientations~ipad 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationPortraitUpsideDown 54 | UIInterfaceOrientationLandscapeLeft 55 | UIInterfaceOrientationLandscapeRight 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /YModemCs/Main/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /YModemCs/Main/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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 state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /YModemCs/Main/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /YModemCs/Main/Assets.xcassets/CheckBox/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /YModemCs/Main/Assets.xcassets/CheckBox/checkbox.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "checkbox.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "checkbox@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "checkbox@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /YModemCs/Main/Assets.xcassets/CheckBox/checkbox.imageset/checkbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArdWang/YModemlib_iOS/94662b44ec051c60eef7d7f7e8c4f93f79781efb/YModemCs/Main/Assets.xcassets/CheckBox/checkbox.imageset/checkbox.png -------------------------------------------------------------------------------- /YModemCs/Main/Assets.xcassets/CheckBox/checkbox.imageset/checkbox@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArdWang/YModemlib_iOS/94662b44ec051c60eef7d7f7e8c4f93f79781efb/YModemCs/Main/Assets.xcassets/CheckBox/checkbox.imageset/checkbox@2x.png -------------------------------------------------------------------------------- /YModemCs/Main/Assets.xcassets/CheckBox/checkbox.imageset/checkbox@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArdWang/YModemlib_iOS/94662b44ec051c60eef7d7f7e8c4f93f79781efb/YModemCs/Main/Assets.xcassets/CheckBox/checkbox.imageset/checkbox@3x.png -------------------------------------------------------------------------------- /YModemCs/Main/Assets.xcassets/CheckBox/checkbox_fill.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "checkbox_fill.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "checkbox_fill@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "checkbox_fill@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /YModemCs/Main/Assets.xcassets/CheckBox/checkbox_fill.imageset/checkbox_fill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArdWang/YModemlib_iOS/94662b44ec051c60eef7d7f7e8c4f93f79781efb/YModemCs/Main/Assets.xcassets/CheckBox/checkbox_fill.imageset/checkbox_fill.png -------------------------------------------------------------------------------- /YModemCs/Main/Assets.xcassets/CheckBox/checkbox_fill.imageset/checkbox_fill@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArdWang/YModemlib_iOS/94662b44ec051c60eef7d7f7e8c4f93f79781efb/YModemCs/Main/Assets.xcassets/CheckBox/checkbox_fill.imageset/checkbox_fill@2x.png -------------------------------------------------------------------------------- /YModemCs/Main/Assets.xcassets/CheckBox/checkbox_fill.imageset/checkbox_fill@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArdWang/YModemlib_iOS/94662b44ec051c60eef7d7f7e8c4f93f79781efb/YModemCs/Main/Assets.xcassets/CheckBox/checkbox_fill.imageset/checkbox_fill@3x.png -------------------------------------------------------------------------------- /YModemCs/Main/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /YModemCs/Main/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /YModemCs/Main/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /YModemCs/Main/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // YModemCs 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /YModemCsTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YModemCsTests/YModemCsTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // YModemCsTests.m 3 | // YModemCsTests 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YModemCsTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation YModemCsTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /YModemCsUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YModemCsUITests/YModemCsUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // YModemCsUITests.m 3 | // YModemCsUITests 4 | // 5 | // Created by rnd on 2018/6/14. 6 | // Copyright © 2018年 GoDream. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YModemCsUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation YModemCsUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /YModemlib_iOS.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint YModemlib_iOS.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |spec| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | spec.name = "YModemlib_iOS" 19 | spec.version = "1.0.3" 20 | spec.summary = "A short description of YModemlib_iOS." 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | spec.description = <<-DESC 28 | This is quickly Bluetooth help connect, it is help quick more device connect. so you use very smart! 29 | DESC 30 | 31 | 32 | 33 | 34 | 35 | spec.homepage = "https://github.com/ArdWang/YModemlib_iOS" 36 | 37 | spec.license = { :type => "MIT", :file => "LICENSE" } 38 | 39 | 40 | spec.author = { "ArdWang" => "278161009@qq.com" } 41 | 42 | spec.platform = :ios, "9.0" 43 | 44 | spec.ios.deployment_target = "9.0" 45 | 46 | 47 | spec.source = { :git => "https://github.com/ArdWang/YModemlib_iOS.git", :tag => "#{spec.version}" } 48 | 49 | spec.swift_version = '5.0' 50 | 51 | 52 | 53 | spec.source_files = "YModemlib_iOS", "YModemCs/Class/YModem/*.{h,m}" 54 | 55 | spec.frameworks = "Foundation","UIKit","CoreBluetooth" 56 | 57 | 58 | 59 | end 60 | --------------------------------------------------------------------------------