美文网首页
iOS开发记录

iOS开发记录

作者: 清雪飘香 | 来源:发表于2016-06-21 11:15 被阅读58次

总结iOS 开发中遇到的问题和解决方法


NSString
去掉 NSString中的空格和换行,stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet] 但是这只能去掉头部和尾部的空格和换行符,中间的没法去掉。

如果去掉两端的空格和换行后,需要将中间的去掉,结合下面的方法。

NSArray *components = [string  componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

string = [components componentsJoinedByString:@""];

参考nshipster NSCharacter​Set

替换NSString 中指定的字符,

  [string stringByReplacingOccurrencesOfString:@"-" withString:@""];

NSNotificationCenter

NSNotificationCenter 使用顺序,addObserver在先, 而后postNotificationName
可能crash 的原因,

  1. 使用后没有removeObserver,在升级xcode 7.3后遇到过,从而导致crash;
  2. post操作的线程和addObserver的线程不一致而引发的。南峰子博客 Notification与多线程
      dispatch_async(dispatch_get_main_queue(), ^{
            [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo];
        });

修改UITextFieldplaceholder 的字体大小和颜色

[textField setValue:placeHolderColor forKeyPath:@"_placeholderLabel.textColor"];        
[textField setValue:placeHolderFont forKeyPath:@"_placeholderLabel.font"];   

相关文章

  • iOS 学习心得记录之:拿到了ViewController就等于

    iOS 开发心得记录之:拿到了ViewController就等于拿到了view 在学习开发 iOS 的时候,我有时...

  • **iOS OC** 转 **Swift**开发问题记录

    iOS OC 转 Swift开发问题记录 之前一直使用OC语言开发iOS应用,时代在进步,使用Swift语言开发已...

  • IOS 生成证书

    第一次接触 IOS 开发,将遇到的问题做记录。 前提: 1、已经注册 IOS 开发者(付费) ...

  • iOS开发笔记

    原文请见github上iOS开发笔记 iOS开发笔记 记录了在iOS开发中踩过的坑和一些问题解决 微信的openi...

  • iOS 开发中的Tips

    iOS Tips 这里将记录iOS开发中的技巧,不定期更新内容 reloadData 调用 reloadData ...

  • iOS 开发记录

    打印方法名 类、方法判断 emoji表情转换 数组和字典与NSData互转 字典、JSON互转 自定义结构体(类似...

  • iOS开发记录

    总结iOS 开发中遇到的问题和解决方法 NSString 去掉 NSString中的空格和换行,string...

  • iOS开发记录

    本文记录ios开发中的一些需要知道的细节,后期会持续更新,有需要请关注。 入口函数int main(int arg...

  • iOS逆向学习

    参考文章:iOS逆向开发记录:iOS逆向之手机越狱iOS逆向之介绍iOS逆向之文件系统结构iOS逆向之文件权限及类...

  • iOS开发进阶

    接触iOS开发已经2年有余,年前开发需求并不高,空闲下来了,准备把知识整理整理。 首先把iOS开发进阶详细的记录下...

网友评论

      本文标题:iOS开发记录

      本文链接:https://www.haomeiwen.com/subject/qrkgdttx.html