任何人都可以帮助我理解如何存储另一种语言的cookie值,以及如何以该语言再次检索它.
在存储后检索时,我的外语cookie似乎变成了垃圾.
一些代码:
写cookie代码:
function writecook() {
document.cookie = "lboxcook=" + document.getElementsByTagName('input')[0].value;
//input[0] is the input box who's value is stored
}
Run Code Online (Sandbox Code Playgroud)
检索Cookie代码:
<script language="JavaScript">
function get_cookie ( cookie_name )
{
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
if ( results )
return ( unescape ( results[2] ) );
else
return null;
}
</script>
Run Code Online (Sandbox Code Playgroud)
谢谢.
我想知道是否有人可以帮助我了解如何将SSL证书处理添加到https服务的同步连接.
我知道如何使用异步连接但不同步.
NSString *URLpath = @"https://mydomain.com/";
NSURL *myURL = [[NSURL alloc] initWithString:URLpath];
NSMutableURLRequest *myURLRequest = [NSMutableURLRequest requestWithURL:myURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60];
[myURL release];
[myURLRequest setHTTPMethod:@"POST"];
NSString *httpBodystr = @"setting1=1";
[myURLRequest setHTTPBody:[httpBodystr dataUsingEncoding:NSUTF8StringEncoding]];
NSHTTPURLResponse* myURLResponse;
NSError* myError;
NSData* myDataResult = [NSURLConnection sendSynchronousRequest:myURLRequest returningResponse:&myURLResponse error:&myError];
//I guess I am meant to put some SSL handling code here
Run Code Online (Sandbox Code Playgroud)
谢谢.
我正在尝试使用AVAudioPlayer的实例播放6个单独的.mp3声音文件.声音同时播放,但它们似乎播放不同步或速度略有不同.有谁知道为什么会这样?
以下是我初始化声音的方法:
NSURL *musicurl = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource: @"SoundLoop" ofType: @"mp3"]];
music = [[AVAudioPlayer alloc] initWithContentsOfURL: musicurl error: nil];
[musicurl release];
music.numberOfLoops = -1; // Loop indefinately
music.currentTime = 0; // start at beginning
music.volume = 1.0;
music.meteringEnabled = YES;
Run Code Online (Sandbox Code Playgroud)
这是我的AudioSession代码:
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
audioSession.delegate = self;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setPreferredHardwareSampleRate:44100 error:nil];
[[AVAudioSession sharedInstance] setPreferredIOBufferDuration:30 error:nil];
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
Float32 hardvol = 1.0;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
AudioSessionSetProperty(kAudioSessionProperty_CurrentHardwareOutputVolume, sizeof(hardvol), &hardvol);
UInt32 doSetProperty = …Run Code Online (Sandbox Code Playgroud) 我有一个简单的POST方法连接到我的AWS API网关中的lambda函数.
当我执行测试时(通过Gateway API控制台)一切正常,测试得到我正在寻找的结果.它的简单 - 发布一个JSON,得到一个JSON.
但是,在部署API然后发送测试中使用的相同JSON(通过http post)之后,我得到'无法解析请求体到json'.
有谁知道我可能做错了什么?注意:我不打算使用模型,我只想传递JSON.我相信当亚马逊写"输入直通"之类的东西时,他们意味着输入可以传递给lambda函数.
以下是我的AWS Gateway API设置的图像:
我有一个我作为NSObject创建的类.这个类有许多不同类型和方法的属性等.
当我在我的应用程序中实例化这个类时(比如在主视图控制器中),当我使用它时,我立即发送一个释放调用.即:
MyObject *myObject = [[MyObject alloc] initWithParameters:parms];
[myObject doSomeMethodCall];
[myObject release];
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:当我释放myObject时,它会自动释放我在MyObject .h文件中声明的所有声明的对象,变量等吗?
要么
我是否需要创建一个自定义发布方法来释放所有这些?
我问因为内存管理问题.
谢谢.
嗨,我正在使用图形API发布到朋友的墙上.但是我不希望帖子在任何新闻源(发布用户,被发布的朋友或其他任何人)上可见.
我怎样才能做到这一点.这是我的墙贴代码:
function fb_post($to_uid,$acToken) {
$result = false;
global $fb;
$feed_dir = '/'.$to_uid.'/feed/';
$message_str = 'This is a message';
$msg_body = array('access_token' => $acToken,
'message' => $message_str,
'name' => 'Wall Post',
'caption' => "I posted to your wall",
'link' => 'http://www.wallpost.com',
'description' => 'Learn how to post to peoples walls',
'picture' => 'http://image.com/myimage.jpg',
'actions' => array(array('name' => 'Wall Post',
'link' => 'http://www.wallpost.com'))
);
try {
$result = $fb->api($feed_dir, 'post', $msg_body);
}
catch (Exception $e) {
echo "Not sent";
} …Run Code Online (Sandbox Code Playgroud) 我有一个UITextView,它设置了 UIKeyboardType 的 .emailAddress 我想用UITextContentType属性自动建议用户的电子邮件地址
我这样做:
if #available(iOS 10.0, *) {
myTextView.textContentType = UITextContentType.emailAddress
}
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用,我在 textview 的建议框中没有看到电子邮件。
我已经按照所有Apple文档为设置右键菜单列表和服务列表的服务:
尽管如此,我无法在任何菜单项中看到我的服务.
编辑**这是我的info.plist的服务部分:
<key>NSServices</key>
<array>
<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>MyApp/Send to MyApp</string>
</dict>
<key>NSMessage</key>
<string>contentService</string>
<key>NSPortName</key>
<string>MyApp</string>
<key>NSSendTypes</key>
<array>
<string>NSStringPboardType</string>
<string>NSFileContentsPboardType</string>
</array>
</dict>
</array>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?提前致谢.