Skip to content

Instantly share code, notes, and snippets.

View XiaoYulong's full-sized avatar

Xiao Yulong XiaoYulong

View GitHub Profile
@numist
numist / selector_belongsToProtocol.m
Last active April 26, 2022 07:16
Detect if a selector belongs to a protocol
/*
* Copyright © 2012 Scott Perry (http://numist.net)
*
* Released under the MIT License; its terms are at the end of this file.
*/
#import <objc/runtime.h>
/**
* `selector_belongsToProtocol` solves a common problem in proxy objects for delegates where selectors that are not part of the protocol may be unintentionally forwarded to the actual delegate.
@y0unghe
y0unghe / GoogleTTS.m
Created August 29, 2013 06:28
用google tts api发音
/*
q 要发音的中文或英文词语、句子
tl 发音语言
http://translate.google.com/translate_tts?ie=UTF-8&q=你好&tl=zh-CN&total=1&idx=0&textlen=11&prev=input
*/
NSString* userAgent = @"Mozilla/5.0";
NSURL *url = [NSURL URLWithString:[@"http://translate.google.com/translate_tts?ie=UTF-8&q=你好&tl=zh-CN&total=1&idx=0&textlen=11&prev=input"
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:url];