English 中文(简体)
我该如何为MacApp 储存两个字符串?
原标题:How should I store two strings for a Mac App?

我正在制作一个网络应用程序, 它需要存储用户的电子邮件和密码, 用于网络服务, 然后连接到网络服务。 与其每次输入, 不如每次输入, 我希望当应用程序关闭时保存它 。

我该怎么做呢?我需要用核心数据还是SQLite 做两个字符串,还是有另一个更好的方法?

谢谢

最佳回答

不要将密码存储为纯文本 。 即使它应该是“ 无关紧要”和“ 不安全” 。 如果可能的话, 也考虑不将其全部存储( 例如, shore hash ), 或者先从网络服务处获取饼干 。 在这种情况下, < code> NSUIDR Defaults 将是存储这些数据的标准和简易方式 。

如果您需要保存密码, 系统键链是安全的地方 。 查找 < code> SecKeyclanceAddGenericPassword API 函数, 它将导致您找到 < a href=> https:// developler. appl. com/ library/mac/ # documentation/security/ conceptual/ keycleckets/ keynessConcepts/ 03tasks/ tasks. html" rel=" no folpol" > Keynage Services 指南 和示例 。

问题回答

创建 nsobject Global 类 -- --

全球.h

#import <Foundation/Foundation.h>
@interface Global : NSObject 
extern NSString *gStrEmail;
extern NSString *gStrPassword;

@ end

全球m.m

#import "全球.h"

@implementation Global
NSString *gStrEmail=@"";
NSString *gStrPassword=@"";
@ end

import this class in to App_Prefix.pch

 #import "全球.h"

用户对帐日志( V) 主计长. m

 gStrEmail=txtEmail.text;
 gStrPassword==txtEmail.text;

和密码字符串





相关问题
2 mysql instances in MAC

i recently switched to mac. first and foremost i installed xampp. then for django-python-mysql connectivity, i "somehow" ended up installing a seperate MySQL. now the seperate mysql installation is ...

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

Switching J2SE versions on Mac OS (SnowLeopard)

My current JDK on Mac OS (10.6) is set to 1.6 and I d like to switch to 1.5. A listing of /System/Library/Frameworks/JavaVM.framework/Versions/ shows: lrwxr-xr-x 1 root wheel 10 Nov 3 18:34 ...

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

export to MP3 from quicktime API

A question for Apple,QT programmers. Would like to know if it s possible to export a Movie object to MP3 using the QuickTime API. Preferably the ConvertMovieToFile function. I ve looked at ...

热门标签