开发者

NSString, problem to create

开发者 https://www.devze.com 2023-01-02 13:05 出处:网络
I have a problem with creation to NSString. The error is: \"error: expected \']\' before numeric constant\".

I have a problem with creation to NSString. The error is: "error: expected ']' before numeric constant". The code is below. Can you help me to find a solution for create these?

NSStri开发者_开发技巧ng *titleXML = [NSString  stringWithFormat:@"<?xml version="1.0" encoding="UTF-8"?>"];


You need to escape the quotes in your string. Try it like this

NSString *titleXML = [NSString  stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"];


You have quote characters embedded in your string, you need to escape them with backslash like this:

NSString *titleXML = [NSString  stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"];


You have to escape your double quotes in the string using \":

NSString *titleXML = [NSString  stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"];


You'll need to escape those double quotes in the string for it to work. Like so:

NSString *titleXML = [NSString  stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"];
0

精彩评论

暂无评论...
验证码 换一张
取 消