# err **Repository Path**: yuyunzhang/err ## Basic Information - **Project Name**: err - **Description**: Ios经验总结,希望大家积极贡献 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2015-12-22 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### 1.数据请求下来, 但是界面没有刷新 1. 看一下block回调的位置,可能是这么写的 : // 这是错误的写法 { // 进入子线程 { 请求数据 解析 添加到数组 } // 会主线程 { block() } } // 应该这么写 { // 进入子线程 { 请求数据 解析 添加到数组 // 会主线程 { block() } } } ### 2. 代码冲突 1. 跟团队内部人员商量,然后手动解决, 再合并

3. 使用AFNetworking进行网络请求时报下面错误

    Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: application/x-javascript" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7fbddbc18350> { URL: http://api2.pianke.me/pub/today } { status code: 200, headers {
    "Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
    Connection = "keep-alive";
    "Content-Encoding" = gzip;
    "Content-Type" = "application/x-javascript; charset=utf-8";
    Date = "Wed, 02 Dec 2015 03:38:36 GMT";
    Etag = a8bc877f523a4096caa746bc2fa8d2a3;
    Expires = "Thu, 19 Nov 1981 08:52:00 GMT";
    Pragma = "no-cache";
    Server = nginx;
    "Set-Cookie" = "PHPSESSID=s0upj58k0ghbfj15r3fp8dcmm2; path=/; domain=pianke.me";
    "Transfer-Encoding" = Identity;
    Vary = "Accept-Encoding";
} }

原因: 后台返回的数据的文件格式是javascript的.AFNetworking 解析不了.所以需要我们告诉AndFNetworking返回数据时javascript格式的,这样AFNetworking就可以解析了(默认ANF 是按照json格式处理的,如果返回时html也会报错) 解决方案:

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/x-javascript"];

5. 为什么类方法里不能用self?

解决思路:

1,实例方法里面的self,是对象的首地址。 2,类方法里面的self,是Class. 尽管在同一个类里面的使用self,但是self却有着不同的解读。在类方法里面的self,可以翻译成class self;在实例方法里面的self,应该被翻译成为object self。在类方法里面的self和实例方法里面的self有着本质上的不同,尽管他们的名字都叫self

6. sourceTree 输入错误密码后,一直登陆不上?

1,去在sourceTree的偏好设置中删除账号
2,再推送

### 7.有些接口解析出来的数据是HTML格式的,需要用WebView展示,但是有时候内容可能太大 导致手机屏幕显示不全,还得左右滑动,影响体验。 1. 解决方案 : 把webview这个属性( scalesPageToFit ) 设置成 YES 2. 写一段代码包裹一下
		NSString *headPath = [[NSBundle mainBundle] pathForResource:@"head" ofType:@"html"];
		NSString *footPath = [[NSBundle mainBundle]pathForResource:@"foot" ofType:@"html"];
		NSString *strHead = [NSString stringWithContentsOfFile:headPath 	encoding:NSUTF8StringEncoding error:nil];
		NSString *strFoot = [NSString stringWithContentsOfFile:footPath 	encoding:NSUTF8StringEncoding error:nil];
		NSString *html = [NSString stringWithFormat:@"%@%@	%@",strHead,object[@"body"],strFoot];[self.webView1 loadHTMLString:html baseURL:nil];	
	
### 8. 出现这种错误情况处理 1.
错误

这个解决也比较简单,
在Build Setting 中的Other Linker Flags选项中加入$(OTHER_LDFLAGS) 如图:


解决错误

编译通过.........

9.错误一:

今天在服务器上git pull是出现以下错误:

error: Your local changes to the following files would be overwritten by merge:

        application/config/config.php

        application/controllers/home.php

Please, commit your changes or stash them before you can merge.

Aborting

不知道什么原因造成的代码冲突,处理方法如下:

如果希望保留生产服务器上所做的改动,仅仅并入新配置项:

git stash

git pull

git stash pop

然后可以使用git diff -w +文件名 来确认代码自动合并的情况.

如果希望用代码库中的文件完全覆盖本地工作版本. 方法如下:

git reset --hard

git pull


反过来,如果希望用代码库中的文件完全覆盖本地工作版本. 方法如下:

git reset --hard
git pull

其中git reset是针对版本,如果想针对文件回退本地修改,使用

git checkout HEAD file/to/restore


10.错误二:

git-updating-currently-checked-out-branch-warning

Counting objects: 3, done.
Writing objects: 100% (3/3), 226 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To git@192.168.45.42:teamwork.git
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'git@192.168.45.42:teamwork.git'

解决方法:

git config receive.denyCurrentBranch ignore 


这里详细记录下 

http://stackoverflow.com/questions/738154/what-does-git-updating-currently-checked-out-branch-warning-mean

根据stackoverflow上的讨论记录,默认的git init建立的仓库所处分支master的情况下不允许向自己的远程分支提交,

所以最终的解决方案是建立裸库 也就是 git init --bare 或者 git init --bare --share

11.错误三:

cannot-update-paths-and-switch-to-branch-at-the-same-time

$ git checkout -b test --track origin/master
fatal: Cannot update paths and switch to branch 'test' at the same time.
Did you intend to checkout 'origin/master' which can not be resolved as commit?
解决方案:


git remote -v
git fetch origin

然后重新执行刚才的track命令,成功

12.错误四


error: Malformed value for push.default: simple error: Must be one of nothing, matching, tracking or current.
解决方案:

git config --global push.default upstream


13.错误五

提交后提示
fatal: recursion detected in die handler
问题原因:
问题原因是http.postBuffer默认上限为1M所致。在git的配置里将http.postBuffer变量改大一些即可,比如将上限设为500M:
git config --global http.postBuffer 524288000

## block使用的注意事项 1.使用copy修饰词, block作为成员变量将栈上的block拷贝到堆区, 2.在使用block之前对block坐判空处理,不判控制街使用,一旦指针为空,直接崩溃 3.使用__weak修饰, 放置循环引用, 4.在block内部要判断一下weakself是否被释放,放置被释放导致奔溃 5.block使用之后做赋nil处理
参考链接 : [block使用注意事项](http://www.cnblogs.com/biosli/p/block_usage.html)