2014-02-06 3 views
0

내 wordpress 웹 사이트에 Social Plugin이 게시되어 있습니다.iOS에서 Javascript Plugin 코드를 제거하는 방법은 무엇입니까?

웹 사이트에서 JSON을 얻을 때 해당 플러그인 javascript 코드는 다음과 같이 포함됩니다.

(function(d, s, id) { 
    var js, fjs = d.getElementsByTagName(s)[0]; 
    if (d.getElementById(id)) return; 
    js = d.createElement(s); js.id = id; 
    js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=226488567527811"; 
    fjs.parentNode.insertBefore(js, fjs); 
}(document, "script", "facebook-jssdk")); 

다음 코드없이 UITextView에 텍스트를 표시하고 싶습니다.

어떻게 제거 할 수 있습니까?

답변

1

만 검색하고 텍스트에서 코드의 조각을 제거하려는 경우, 여기 당신을위한 snipper입니다 ...

- (NSString *) removeSubstring:(NSString *)fromString thatStartsWith:(NSString *)startsWith andEndsWith:(NSString *)endsWith 
{ 

    NSArray *splitByStartsWith = [fromString componentsSeparatedByString:startsWith]; 
    if ([splitByStartsWith count] > 1) { 
     NSArray *splitByEndsWith = [splitByStartsWith[1] componentsSeparatedByString:endsWith]; 
     if ([splitByEndsWith count] > 1) { 
      NSString *replaceThis = [startsWith stringByAppendingFormat:@"%@%@",splitByEndsWith[0],endsWith]; 
      return [fromString stringByReplacingOccurrencesOfString:replaceThis withString:@""]; 
     } 
    } 
    return fromString; 
} 
다음

이처럼 호출 할 수 있습니다

NSString *removedString = [yourObjectThatHasThatCodeAbove removeSubstring:stringDataThatYouGotFromServer thatStartsWith:@"(function(" andEndsWith:@"facebook-jssdk\"));"]); 

문자열의 제거 된 버전을 반환합니다.

관련 문제