我在PHP中找到了en/decode字符串的示例.起初它看起来非常好,但它不会工作:-(
有谁知道问题是什么?
$Pass = "Passwort";
$Clear = "Klartext";
$crypted = fnEncrypt($Clear, $Pass);
echo "Encrypted: ".$crypted."</br>";
$newClear = fnDecrypt($crypted, $Pass);
echo "Decrypted: ".$newClear."</br>";
function fnEncrypt($sValue, $sSecretKey) {
return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $sSecretKey, $sDecrypted, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
}
function fnDecrypt($sValue, $sSecretKey) {
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $sSecretKey, base64_decode($sEncrypted), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)));
}
Run Code Online (Sandbox Code Playgroud)
结果是:
加密: boKRNTYYNp7AiOvY1CidqsAn9wX4ufz/D9XrpjAOPk8=
解密: —‚(ÑÁ ^ yË~F'¸®Ó–í œð2Á_B‰Â—
有人告诉我有关Cocoa语言识别的课程.有谁知道它是哪一个?
这不是工作:
NSSpellChecker *spellChecker = [NSSpellChecker sharedSpellChecker];
[spellChecker setAutomaticallyIdentifiesLanguages:YES];
NSString *spellCheckText = @"Guten Tag Herr Mustermann. Dies ist ein deutscher Text. Bitte löschen Sie diesen nicht.";
[spellChecker checkSpellingOfString:spellCheckText startingAt:0];
NSLog(@"%@", [spellChecker language]);
Run Code Online (Sandbox Code Playgroud)
结果是'en'但应该是'de'.
我有一个NSOpenPanel.但我想让它只能选择PDF文件.我正在寻找类似的东西:
// NOT WORKING
NSOpenPanel *panel;
panel = [NSOpenPanel openPanel];
[panel setFloatingPanel:YES];
[panel setCanChooseDirectories:YES];
[panel setCanChooseFiles:YES];
[panel setAllowsMultipleSelection:YES];
[panel setAllowedFileTypes:[NSArray arrayWithObject:@"pdf"]];
int i = [panel runModalForTypes:nil];
if(i == NSOKButton){
return [panel filenames];
}
Run Code Online (Sandbox Code Playgroud)
我希望someboby有一个解决方案.
我正在使用脚本桥从我的Mac App发送邮件.现在我需要沙盒应用程序,并且启用沙盒时发送邮件不再有效.
有人知道如何解决这个问题吗?
谢谢,安德烈亚斯
代码:`
/* create a Scripting Bridge object for talking to the Mail application */
MailApplication *mail = [SBApplication applicationWithBundleIdentifier:@"com.apple.Mail"];
/* create a new outgoing message object */
MailOutgoingMessage *emailMessage =
[[[mail classForScriptingClass:@"outgoing message"] alloc]
initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
[self.subjectField stringValue], @"subject",
[[self.messageContent textStorage] string], @"content",
nil]];
/* add the object to the mail app */
[[mail outgoingMessages] addObject: emailMessage];
...
Run Code Online (Sandbox Code Playgroud)
`
我写了一个特殊的UITableViewCell.现在我需要从文本字段中获取文本
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
CustomCell *custumCell = [tableView cellForRowAtIndexPath:indexPath];
//warning: incompatible Objective-C types initializing 'struct UITableViewCell *', expected 'struct CustomCell *'
NSString *title = [custumCell cellTitle].text;
[self setArticleReaded:title];
[title release];
Run Code Online (Sandbox Code Playgroud)
}
#import <UIKit/UIKit.h>
@interface CustomCell : UITableViewCell {
IBOutlet UILabel *cellTitle;
IBOutlet UILabel *cellSubTitle;
IBOutlet UILabel *cellPubDate;
}
@property (nonatomic, retain) IBOutlet UILabel *cellTitle;
@property (nonatomic, retain) IBOutlet UILabel *cellSubTitle;
@property (nonatomic, retain) IBOutlet UILabel *cellPubDate;
@end
Run Code Online (Sandbox Code Playgroud)
我希望有人知道解决方法.
<Error>: CGDataConsumer(url_close): write failed: -15.
<Error>: CFURLCreateDataAndPropertiesFromResource: failed with error code -15.
Run Code Online (Sandbox Code Playgroud)
有谁知道什么可能触发这个错误及其含义?
我正在寻找像PHP的爆炸函数一样的Objective-C方法:
$string = "Helle#world#!";
$delimiter = "#";
$array = explode ( $delimiter, $string);
Run Code Online (Sandbox Code Playgroud)
结果:$ array = {"Hello","world","!"}
谢谢,安德烈亚斯
Tell application "System Preferences"
set "default voice" to "Agnes"
end tell
Run Code Online (Sandbox Code Playgroud)
结果是:
无法将"默认语音"设置为"anna".不允许访问.
什么是__weak上的NSString和NSURL之间的区别?
我的例子:
__weak NSURL *myURL = [NSURL fileURLWithPath:@"/tmp"];
__weak NSString *myString = @"123";
NSLog(@"myURL: %@", myURL);
NSLog(@"myString: %@", myString);
Run Code Online (Sandbox Code Playgroud)
结果:
2012-07-10 19:23:49.858 myApp [56093:303] myURL :( null)
2012-07-10 19:23:49.859 myApp [56093:303] myString:123
为什么不是结果myString ==(null)
这段代码不再在Swift 3中运行.任何想法?
码:
public enum ErrorResponse : Error {
case Error(Int, Data?, Error)
}
Run Code Online (Sandbox Code Playgroud)
错误:
/Swaggers/Models.swift:13:29: Raw type 'Error' is not expressible by any literal
Run Code Online (Sandbox Code Playgroud) objective-c ×7
cocoa ×4
iphone ×2
php ×2
aes ×1
applescript ×1
cryptography ×1
encryption ×1
ios ×1
maximize ×1
nsopenpanel ×1
nswindow ×1
sandbox ×1
swift ×1
swift3 ×1
uiview ×1
voice ×1