NSURL max length?

霸气de小男生 提交于 2020-01-03 04:02:12

问题


I need to pass text string up to 20Kb (one NSURLQueryItem value) from one iOS app to another using schemes. I was able to pass not such long URL between the apps.

What is max NSURL length supported? Does it depend on iOS version? Is there any better approach to send text long string?


回答1:


NSURL can easily handle 20Kb.

The implementation limitation is around 2Gb (INT_MAX) for the URL string. The limitations you'll run into first with large URLs are memory and time. You'll run out of memory for the allocations at some point (For 32-bit executables, the limitation is a little over 1.1GB when your process runs out of address space; for 64-bit executables, the limitation depends on your system's available VM swap space). Creating very large URLs will take a lot of time to create and parse.




回答2:


Did you get a 414 (request too long) on your request? There is no formal limit, but systems have ad hoc limits which may be as low as 8k.

You should use a POST instead of putting all the data in the URL.



来源:https://stackoverflow.com/questions/34730218/nsurl-max-length

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!