EditorSkillsController.m 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. //
  2. // EditorSkillsController.m
  3. // model
  4. //
  5. // Created by zuxiukuan on 2018/7/17.
  6. // Copyright © 2018年 Mine. All rights reserved.
  7. // 编辑技能
  8. #import "EditorSkillsController.h"
  9. @interface EditorSkillsController () <UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate>
  10. @property(nonatomic, strong) UIScrollView *bgScrollView;
  11. @property(nonatomic, strong) UITextField *workTypeTF; //工作类型
  12. @property(nonatomic, strong) UIImageView *workPicView; //工作照片
  13. @property(nonatomic, strong) UITextField *priceTF; //价格
  14. //
  15. @property(nonatomic, copy) NSString *imageStr; //图片url
  16. @end
  17. @implementation EditorSkillsController
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. self.view.backgroundColor = [UIColor whiteColor];
  21. UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHide:)];
  22. tapGestureRecognizer.cancelsTouchesInView = NO;
  23. [self.view addGestureRecognizer:tapGestureRecognizer];
  24. [self creatNavBar];
  25. [self creatSubViews];
  26. }
  27. - (void)viewWillAppear:(BOOL)animated {
  28. [super viewWillAppear:animated];
  29. [self.navigationController setNavigationBarHidden:NO animated:YES];
  30. }
  31. #pragma mark -- 收起键盘
  32. - (void)keyboardHide:(UITapGestureRecognizer *)tap {
  33. [self.view endEditing:YES];
  34. }
  35. - (void)didReceiveMemoryWarning {
  36. [super didReceiveMemoryWarning];
  37. // Dispose of any resources that can be recreated.
  38. }
  39. - (void)creatNavBar {
  40. self.title = @"编辑技能";
  41. //
  42. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  43. btn.frame = CGRectMake(0, 0, 40, 40);
  44. [btn setImage:[UIImage imageNamed:@"fanhui2"] forState:UIControlStateNormal];
  45. btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
  46. [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
  47. UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
  48. UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
  49. // nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
  50. self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
  51. }
  52. - (void)backClick {
  53. [self.navigationController popViewControllerAnimated:YES];
  54. }
  55. - (void)creatSubViews {
  56. //
  57. UIScrollView *scrollView = [[UIScrollView alloc] init];
  58. scrollView.frame = self.view.bounds;
  59. scrollView.showsVerticalScrollIndicator = NO;
  60. scrollView.backgroundColor = [UIColor whiteColor];
  61. CGFloat height = ScreenHeight < 667 ? 697 : ScreenHeight;
  62. scrollView.contentSize = CGSizeMake(ScreenWidth, height);
  63. [self.view addSubview:scrollView];
  64. self.bgScrollView = scrollView;
  65. //
  66. UILabel *workTypeTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 80, 15)];
  67. workTypeTitleLabel.text = @"工作类型:";
  68. workTypeTitleLabel.font = [UIFont systemFontOfSize:15];
  69. workTypeTitleLabel.textColor = RGBValueColor(0x333333, 1.0);
  70. [scrollView addSubview:workTypeTitleLabel];
  71. UITextField *workTypeTF = [[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(workTypeTitleLabel.frame), 20, ScreenWidth / 2, 15)];
  72. // workTypeTF.placeholder = @"选择您的工作类型";
  73. workTypeTF.text = self.skilldic[@"name"];
  74. workTypeTF.userInteractionEnabled = NO;
  75. workTypeTF.font = [UIFont systemFontOfSize:15];
  76. workTypeTF.textColor = RGBValueColor(0x333333, 1.0);
  77. [scrollView addSubview:workTypeTF];
  78. self.workTypeTF = workTypeTF;
  79. //
  80. UIView *upLineView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(workTypeTitleLabel.frame) + 20, ScreenWidth, 0.5)];
  81. upLineView.backgroundColor = RGBValueColor(0xdfdfdf, 1.0);
  82. [scrollView addSubview:upLineView];
  83. UILabel *workPicTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, CGRectGetMaxY(upLineView.frame) + 20, 80, 15)];
  84. workPicTitleLabel.text = @"工作照片:";
  85. workPicTitleLabel.font = [UIFont systemFontOfSize:15];
  86. workPicTitleLabel.textColor = RGBValueColor(0x333333, 1.0);
  87. [scrollView addSubview:workPicTitleLabel];
  88. self.workPicView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(workPicTitleLabel.frame), CGRectGetMaxY(upLineView.frame) + 20, 80, 80)];
  89. NSString *skillphoto = self.skilldic[@"skillphoto"];
  90. NSString *urlStr;
  91. if ([skillphoto containsString:@"http"]) {
  92. urlStr = [NSString stringWithFormat:@"%@", skillphoto];
  93. } else {
  94. urlStr = [NSString stringWithFormat:@"%@/%@", PublicUrl, skillphoto];
  95. }
  96. [self.workPicView sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:[UIImage imageNamed:@"tianjiajineng"]];
  97. [scrollView addSubview:self.workPicView];
  98. UIButton *addPicBtn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(workPicTitleLabel.frame), CGRectGetMaxY(upLineView.frame) + 20, 80, 80)];
  99. addPicBtn.backgroundColor = [UIColor clearColor];
  100. [addPicBtn addTarget:self action:@selector(addPicBtnAction) forControlEvents:UIControlEventTouchUpInside];
  101. [scrollView addSubview:addPicBtn];
  102. UIView *downLineView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.workPicView.frame) + 20, ScreenWidth, 0.5)];
  103. downLineView.backgroundColor = RGBValueColor(0xdfdfdf, 1.0);
  104. [scrollView addSubview:downLineView];
  105. //
  106. UILabel *priceTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, CGRectGetMaxY(downLineView.frame) + 20, 50, 15)];
  107. priceTitleLabel.text = @"价格:";
  108. priceTitleLabel.font = [UIFont systemFontOfSize:15];
  109. priceTitleLabel.textColor = RGBValueColor(0x333333, 1.0);
  110. [scrollView addSubview:priceTitleLabel];
  111. UITextField *priceTF = [[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(priceTitleLabel.frame), CGRectGetMaxY(downLineView.frame) + 20, 100, 15)];
  112. priceTF.textAlignment = NSTextAlignmentLeft;
  113. priceTF.keyboardType = UIKeyboardTypeDecimalPad;
  114. priceTF.font = [UIFont systemFontOfSize:15];
  115. priceTF.textColor = RGBValueColor(0x333333, 1.0);
  116. priceTF.placeholder = @"请填写价格";
  117. priceTF.text = self.skilldic[@"price"];
  118. priceTF.tag = 700;
  119. priceTF.delegate = self;
  120. [scrollView addSubview:priceTF];
  121. self.priceTF = priceTF;
  122. UILabel *unitLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.priceTF.frame), CGRectGetMaxY(downLineView.frame) + 20, 100, 15)];
  123. unitLabel.textAlignment = NSTextAlignmentLeft;
  124. unitLabel.text = @"元/小时";
  125. unitLabel.font = [UIFont systemFontOfSize:15];
  126. unitLabel.textColor = RGBValueColor(0x333333, 1.0);
  127. [scrollView addSubview:unitLabel];
  128. //
  129. UIButton *postBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  130. postBtn.frame = CGRectMake(20, CGRectGetMaxY(priceTitleLabel.frame) + 70, ScreenWidth - 40, 45);
  131. [postBtn setBackgroundImage:[UIImage imageNamed:@"anniu"] forState:UIControlStateNormal];
  132. [postBtn setTitle:@"确认修改" forState:UIControlStateNormal];
  133. [postBtn setTitleColor:RGBValueColor(0xffffff, 1.0) forState:UIControlStateNormal];
  134. [postBtn addTarget:self action:@selector(postBtnAction) forControlEvents:UIControlEventTouchUpInside];
  135. [scrollView addSubview:postBtn];
  136. //
  137. UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  138. deleteBtn.frame = CGRectMake(20, CGRectGetMaxY(postBtn.frame) + 19, ScreenWidth - 40, 45);
  139. [deleteBtn setBackgroundImage:[UIImage imageNamed:@"chakan"] forState:UIControlStateNormal];
  140. [deleteBtn setTitle:@"删除" forState:UIControlStateNormal];
  141. [deleteBtn setTitleColor:RGBValueColor(0xfe4086, 1.0) forState:UIControlStateNormal];
  142. [deleteBtn addTarget:self action:@selector(deleteBtnAction) forControlEvents:UIControlEventTouchUpInside];
  143. [scrollView addSubview:deleteBtn];
  144. //
  145. UILabel *instructionsLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, CGRectGetMaxY(deleteBtn.frame) + 16, ScreenWidth - 40, 12)];
  146. instructionsLabel.text = @"说明:请勿发布违反国家法规的内容";
  147. instructionsLabel.font = [UIFont systemFontOfSize:12];
  148. instructionsLabel.textColor = RGBValueColor(0x333333, 1.0);
  149. [scrollView addSubview:instructionsLabel];
  150. }
  151. #pragma mark -- 确认修改
  152. - (void)postBtnAction {
  153. NSLog(@"确认修改");
  154. //修改没有图片
  155. [self updateSkillFromNetworking];
  156. }
  157. - (void)deleteBtnAction {
  158. NSLog(@"删除");
  159. [self getRemoveModelSkillFromNetworking];
  160. }
  161. #pragma mark -- 确认修改
  162. - (void)updateSkillFromNetworking {
  163. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  164. NSString *modelpk = self.skilldic[@"modelpk"];
  165. NSString *skillpk = self.skilldic[@"skillpk"];
  166. NSString *pk = self.skilldic[@"modelpricepk"];
  167. NSString *price = [NSString stringWithFormat:@"%@", self.priceTF.text];
  168. NSMutableDictionary *parameterDic = [NSMutableDictionary dictionaryWithCapacity:0];
  169. [parameterDic setObject:modelpk forKey:@"modelpk"];
  170. [parameterDic setObject:skillpk forKey:@"skillpk"];
  171. [parameterDic setObject:pk forKey:@"pk"];
  172. if (self.imageStr.length > 0) {
  173. [parameterDic setObject:self.imageStr forKey:@"skillphoto"]; //返回的url
  174. }
  175. [parameterDic setObject:price forKey:@"price"];
  176. [parameterDic setObject:@"元" forKey:@"unit"];
  177. NSLog(@"%@", parameterDic);
  178. [YanCNetWorkManager requestPostWithURLStr:Url_updateSkill(PublicUrl) parameters:parameterDic finish:^(id dataDic) {
  179. [MBProgressHUD hideHUDForView:self.view animated:YES];
  180. NSString *issuccess = dataDic[@"msg"];
  181. if ([issuccess isEqualToString:@"success"]) {
  182. [MBProgressHUD showInfo:@"修改成功!"];
  183. } else {
  184. [MBProgressHUD showInfo:@"请求失败!"];
  185. }
  186. } enError:^(NSError *error) {
  187. [MBProgressHUD hideHUDForView:self.view animated:YES];
  188. }];
  189. }
  190. #pragma mark -- 删除
  191. - (void)getRemoveModelSkillFromNetworking {
  192. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  193. // ModelUser *modelUser = [ModelUser user];
  194. NSString *modelpk = self.skilldic[@"modelpk"];
  195. NSString *skillpk = self.skilldic[@"modelpricepk"];
  196. NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:modelpk, @"modelpk", skillpk, @"skillpk", nil];
  197. [YanCNetWorkManager requestPostWithURLStr:Url_removemodelskill(PublicUrl) parameters:dic finish:^(id dataDic) {
  198. [MBProgressHUD hideHUDForView:self.view animated:YES];
  199. NSString *issuccess = dataDic[@"msg"];
  200. if ([issuccess isEqualToString:@"success"]) {
  201. [MBProgressHUD showInfo:@"删除成功!"];
  202. [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(backClick) userInfo:nil repeats:NO];
  203. } else {
  204. [MBProgressHUD showInfo:@"操作失败!"];
  205. }
  206. } enError:^(NSError *error) {
  207. [MBProgressHUD hideHUDForView:self.view animated:YES];
  208. }];
  209. }
  210. #pragma mark -- 添加工作照
  211. - (void)addPicBtnAction {
  212. NSLog(@"添加工作照");
  213. [self changeHeaderPicture];
  214. }
  215. - (void)changeHeaderPicture {
  216. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:nil preferredStyle:(UIAlertControllerStyleActionSheet)];
  217. // 设置按钮
  218. UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"从相册中选择" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction *_Nonnull action) {
  219. NSLog(@"选择相册");
  220. [self pickerPictureFromPhotoLibrary];
  221. }];
  222. UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"使用相机拍摄" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction *_Nonnull action) {
  223. NSLog(@"请选择相机");
  224. [self pickerPictureFromCamera];
  225. }];
  226. UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:nil];
  227. [alertController addAction:action1];
  228. [alertController addAction:action2];
  229. [alertController addAction:action3];
  230. [self presentViewController:alertController animated:YES completion:nil];
  231. }
  232. // 从相册中选择图片
  233. - (void)pickerPictureFromPhotoLibrary {
  234. // UIImagePickerController 图片选择控制器
  235. UIImagePickerController *pickerVC = [[UIImagePickerController alloc] init];
  236. // 设置图片选择控制器从哪种资源类型中获取图片
  237. [pickerVC setSourceType:(UIImagePickerControllerSourceTypePhotoLibrary)];
  238. // 是否允许编辑获取到的图片
  239. pickerVC.allowsEditing = YES;
  240. // 设置代理
  241. pickerVC.delegate = self;
  242. [self presentViewController:pickerVC animated:YES completion:nil];
  243. }
  244. // 从相机中获取图片
  245. - (void)pickerPictureFromCamera {
  246. // 1.先判断设备摄像头是否可用
  247. BOOL isCan = [UIImagePickerController isCameraDeviceAvailable:(UIImagePickerControllerCameraDeviceRear)];
  248. if (!isCan) { // 相机不可使用提前结束方法
  249. NSLog(@"设备不可用,提前结束");
  250. return;
  251. }
  252. // 初始化图片选择视图控制器
  253. UIImagePickerController *pickerVC = [[UIImagePickerController alloc] init];
  254. // 设置获取资源的类型
  255. pickerVC.sourceType = UIImagePickerControllerSourceTypeCamera;
  256. // 设置是否允许编辑图片
  257. pickerVC.allowsEditing = YES;
  258. // 设置代理
  259. pickerVC.delegate = self;
  260. [self presentViewController:pickerVC animated:YES completion:nil];
  261. }
  262. #pragma mark - UIImagePickerControllerDelegate的代理方法
  263. - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *, id> *)info {
  264. // // info存储的是我们要的图片, 而图片是编辑后要得到的, 所以使用UIImagePickerControllerEditedImage
  265. //先要把头像上传,若上传成功了,就把这个图片给显示出来
  266. //先要把头像上传,若上传成功了,就把这个图片给显示出来
  267. [self dismissViewControllerAnimated:YES completion:^{
  268. NSString *mediaType = info[UIImagePickerControllerMediaType];
  269. if ([mediaType isEqualToString:@"public.image"]) {
  270. NSLog(@"image...");
  271. //获取图片原图
  272. UIImage *original = [info objectForKey:UIImagePickerControllerEditedImage];
  273. //设置压缩的image的尺寸
  274. CGSize imagesize = original.size;
  275. imagesize.width = 100;
  276. imagesize.height = 100;
  277. //对图片大小进行压缩
  278. UIImage *newImg = [self imageWithImage:original scaledToSize:imagesize];
  279. NSData *imageData = UIImageJPEGRepresentation(newImg, 1);
  280. UIImage *selectImg = [UIImage imageWithData:imageData];
  281. // NSLog(@"selectImg:%@",selectImg);
  282. self.workPicView.image = selectImg;
  283. [self postPicDataWithNetworkingWith:newImg];
  284. }
  285. }];
  286. }
  287. //用户取消退出picker时候调用
  288. - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
  289. NSLog(@"picker = %@", picker);
  290. [self dismissViewControllerAnimated:YES completion:^{
  291. }];
  292. }
  293. //对图片尺寸进行压缩--
  294. - (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize {
  295. // Create a graphics image context
  296. UIGraphicsBeginImageContext(newSize);
  297. // Tell the old image to draw in this new context, with the desired
  298. // new size
  299. [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
  300. // Get the new image from the context
  301. UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
  302. // End the context
  303. UIGraphicsEndImageContext();
  304. // Return the new image.
  305. return newImage;
  306. }
  307. #pragma mark -- 上传图片
  308. - (void)postPicDataWithNetworkingWith:(UIImage *)image {
  309. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  310. [YanCNetWorkManager requestPostWithURLStr:Url_skillphoto(PublicUrl) fileData:image name:@"img" fileName:@"111.png" mimeType:@"image/jpg/png" parameters:nil finish:^(id dataDic) {
  311. [MBProgressHUD hideHUDForView:self.view animated:YES];
  312. NSString *issuccess = dataDic[@"msg"];
  313. if ([issuccess isEqualToString:@"success"]) {
  314. self.imageStr = [NSString stringWithFormat:@"%@", dataDic[@"img"]];
  315. } else {
  316. [MBProgressHUD showInfo:@"请求失败!"];
  317. }
  318. } enError:^(NSError *error) {
  319. [MBProgressHUD hideHUDForView:self.view animated:YES];
  320. }];
  321. }
  322. /*
  323. {
  324. img = "upload/photo/20180720/A47B4B53E849FE2F92F90C93FAD4F1C4.jpg";
  325. msg = success;
  326. }
  327. */
  328. #pragma mark ----- UITextFieldDelegate
  329. - (void)textFieldDidEndEditing:(UITextField *)textField {
  330. NSLog(@"textField.text = %@", textField.text);
  331. }
  332. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  333. if (textField.tag == 700) {
  334. if (![self isValidAboutInputText:textField shouldChangeCharactersInRange:range replacementString:string decimalNumber:2]) {
  335. return NO;
  336. }
  337. }
  338. return YES;
  339. }
  340. //输入框中只能输入数字和小数点,且小数点只能输入一位,参数number 可以设置小数的位数,该函数在-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string调用;
  341. - (BOOL)isValidAboutInputText:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string decimalNumber:(NSInteger)number {
  342. NSScanner *scanner = [NSScanner scannerWithString:string];
  343. NSCharacterSet *numbers;
  344. NSRange pointRange = [textField.text rangeOfString:@"."];
  345. if ((pointRange.length > 0) && (pointRange.location < range.location || pointRange.location > range.location + range.length)) {
  346. numbers = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
  347. } else {
  348. numbers = [NSCharacterSet characterSetWithCharactersInString:@"0123456789."];
  349. }
  350. if ([textField.text isEqualToString:@""] && [string isEqualToString:@"."]) {
  351. return NO;
  352. }
  353. short remain = number; //保留 number位小数
  354. NSString *tempStr = [textField.text stringByAppendingString:string];
  355. NSUInteger strlen = [tempStr length];
  356. if (pointRange.length > 0 && pointRange.location > 0) { //判断输入框内是否含有“.”。
  357. if ([string isEqualToString:@"."]) { //当输入框内已经含有“.”时,如果再输入“.”则被视为无效。
  358. return NO;
  359. }
  360. if (strlen > 0 && (strlen - pointRange.location) > remain + 1) { //当输入框内已经含有“.”,当字符串长度减去小数点前面的字符串长度大于需要要保留的小数点位数,则视当次输入无效。
  361. return NO;
  362. }
  363. }
  364. NSRange zeroRange = [textField.text rangeOfString:@"0"];
  365. if (zeroRange.length == 1 && zeroRange.location == 0) { //判断输入框第一个字符是否为“0”
  366. if (![string isEqualToString:@"0"] && ![string isEqualToString:@"."] && [textField.text length] == 1) { //当输入框只有一个字符并且字符为“0”时,再输入不为“0”或者“.”的字符时,则将此输入替换输入框的这唯一字符。
  367. textField.text = string;
  368. return NO;
  369. } else {
  370. if (pointRange.length == 0 && pointRange.location > 0) { //当输入框第一个字符为“0”时,并且没有“.”字符时,如果当此输入的字符为“0”,则视当此输入无效。
  371. if ([string isEqualToString:@"0"]) {
  372. return NO;
  373. }
  374. }
  375. }
  376. }
  377. NSString *buffer;
  378. if (![scanner scanCharactersFromSet:numbers intoString:&buffer] && ([string length] != 0)) {
  379. return NO;
  380. } else {
  381. return YES;
  382. }
  383. }
  384. @end