AFJSONRequestOperation不支持”text/html”问题

问题描述:输入法用AFJSONRequestOperation获取服务器更新消息。发现AFNetworking示例可以使用,换了服务器访问地址就不行了。

问题分析:打印出错误消息,如下:

Error Domain=AFNetworkingErrorDomain Code=-1016 "Expected content type {(
"text/json",
"application/json",
"text/javascript"
)}, got text/html"

看来是AFJSONRequestOperation只支持3种META,而服务器返回的是"text/html"。

问题解决:增加如下代码,让AFJSONRequestOperation支持"text/html"。

[AFJSONRequestOperationaddAcceptableContentTypes:[NSSetsetWithObjects:@"text/html", nil]];

UITableView的insert和delete操作与numberOfRowsInSection同步问题

问题描述:通过CrashRepoter得到如下报错信息:
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (0) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (0 inserted, 3 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'

问题解决:在[self.tableView insertRowsAtIndexPaths:withRowAnimation:]和[tableView deleteRowsAtIndexPaths:withRowAnimation:]进行修改的操作前后加保护:
[tableView beginUpdates]和[self.tableView endUpdates]

NSInvalidArgumentException’, reason: ‘Cannot create an NSPersistentStoreCoordinator with a nil model’

问题描述:NSInvalidArgumentException', reason: 'Cannot create an NSPersistentStoreCoordinator with a nil model'
问题解决:原因是缺少.momd文件,即缺少.xcdatamodeld文件,在工程中加上就行

Xcode创建动态库

1.用Xcode打开如下2个xcspec文件:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/iPhoneOSPackageTypes.xcspec
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/MacOSX Package Types.xcspec

2.把MacOSX Package Types.xcspec中Identifier为com.apple.package-type.mach-o-dylib的item复制到iPhoneOSPackageTypes.xcspec

3.把MacOSX Product Types.xcspec中Identifier为com.apple.product-type.library.dynamic的item复制到iPhoneOSProductTypes.xcspec

以上为真机,模拟器类似,路径在:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Specifications/

 

1.把/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/Framework & Library/Cocoa Touch Static Library.xctemplate整个文件夹复制并改名为Cocoa Touch Dynamic Library.xctemplate

2.修改Description中的"a static library"为"a dynamic library"
修改Identifier中的"cocoaTouchStaticLibrary"为"cocoaTouchDynamicLibrary"
修改Description中的".static"为".dynamic"

 

1.Installation Directory设置为@executable_path/

UIWebView与CRITTERCISM冲突

问题描述:
今天做TAG,UIWebView有时正常。有时无任何显示,并报如下错误:

2013-12-05 14:49:49.028 TAG[2680:c817] void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode:

问题解决:
网上搜了一圈。原因是UIKit不支持多线程,必须在主线程上修改。具体原因是UIWebView是CRITTERCISM冲突,UIWebView需要在CRITTERCISM前初始化,但是项目里办不到。因为项目用了Segment.io,所以直接off了。

CocoaPods编译link错误Bug

问题描述:使用CocoaPods加了TestFlight类库:pod 'TestFlightSDK', '~> 2.0.2'

报如下错误:"_OBJC_CLASS_$_TestFlight", referenced from:

问题解决:先是觉得会不会和Crashlytics冲突,结果Google了很多,试了很多,最后试了如下方子成功!

In the Build Settings, do not override "Other Linker Flags". If it is bold, select it press backspace, it should be back to its normal state. If it is not fixed, delete all flags, remove and reinstall Pods and that should fix it.

可能是Other Linker Flags自定义的时候CocoaPods就不更新的关系。