Rashid Asgari
Rashid Asgari

Reputation: 75

How to put escape sequence in Objective C?

I have this small code:

NSString *size = [LabelNewContent stringByEvaluatingJavaScriptFromString:@"return     Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight
);"];

the problem is xcode doesnt recognize the parentheses and commas as a whole string.

Upvotes: 0

Views: 306

Answers (3)

Tamnna
Tamnna

Reputation: 250

Replace you code by

NSString *size = [LabelNewContent stringByEvaluatingJavaScriptFromString:@"return %f",Math.max(
                      document.body.scrollHeight, document.documentElement.scrollHeight,
                      document.body.offsetHeight, document.documentElement.offsetHeight,
                      document.body.clientHeight, document.documentElement.clientHeight
                      )];

hope it will help you.

Upvotes: -2

BhavikKama
BhavikKama

Reputation: 8800

NSString *size = [LabelNewContent stringByEvaluatingJavaScriptFromString:@"return     Math.max/(document.body.scrollHeight, document.documentElement.scrollHeight,document.body.offsetHeight, document.documentElement.offsetHeight,   document.body.clientHeight, document.documentElement.clientHeight);"];

try above thing

Upvotes: 0

Inder Kumar Rathore
Inder Kumar Rathore

Reputation: 40018

Use \ to make it multi line string

NSString *size = [LabelNewContent stringByEvaluatingJavaScriptFromString:@"return     Math.max(\
document.body.scrollHeight, document.documentElement.scrollHeight,\
document.body.offsetHeight, document.documentElement.offsetHeight,\
document.body.clientHeight, document.documentElement.clientHeight\
);"];

Upvotes: 8

Related Questions