点击图片进入Windows 8专区
解压Win8镜像文件到D盘
图1 Win8安装只需点几下鼠标
2Win7 Win8双系统安装(二)创建VHD回顶部
选择“是”
安装Win8到VHD的过程是全自动的
5秒左右,操作完成!
准备重启吧
3Win7 Win8双系统安装(三)安装
Win8中的比目鱼开机画面
Win8中文版安装成功
4Win7 Win8双系统安装不成功的原因?回顶部
Parse使用的中文资料比较少,我翻译了一点内容,大家一起学习!
了解数据类型是学习使用Parse的基础。
Data & Security
数据和安全
Data
数据
Valid Data Types
有效的数据类型
We've designed theParse SDKs so that you typically don't need to worry about how data is savedwhile using the iOS or Android SDKs. Simply add data to the PFObject or ParseObject, and it'll besaved correctly.
Nevertheless,there are some cases where it's useful to be aware of how data is stored on theParse platform.
利用我们设计的ParseSDK,在使用iOSsdk和AndroidSDK的时候,你不需要担心数据是如何存储的。用PFObject或者ParseObject进行数据添加,数据就会被安全的存储起来。
但是有些场合,了解一下Parse平台上数据是如何被存储的只是是非常有用的。
Internally, Parsestores data as JSON, so any datatype that can be converted to JSON can bestored on Parse. The framework can also handle Date, Bytes, and File types. Overall,the following types are allowed for each field in your object:
在Parse平台内部,数据是按照JSON格式来保存的。所以任何类型的数据类型都能被转换为JSON进行存储。Parse的框架也可以处理像日期,字节和文件类型。总之,下面的类型允许你在用来定一个对象的字段类型。
· String字符串
· Number数字
· Boolean布尔类型
· Array数组
· Object对象
· Date日期
· Bytes字节
· File文件
· Null空
The type Object simply denotesthat each value can be composed of nested objects that are JSON-encodable. Keysincluding the characters $ or ., along with thekey __type key, are reservedfor the framework to handle additional types, so don't use those yourself.
Object类型表示变量的值可以由嵌套的对象组成,这些对象是可以基于JSON格式解码的。
包含$ 或 .的键值(key),以及__type这样的键值是保留下来,用于在Parse框架中处理额外的类型的,所以不要用这些类型的值作为键值。
Our SDK handlestranslating native Objective-C and Java types to JSON. For example, if you saveanNSString object, it will be translated into a String type in oursystem.
我们的SDK负责把Objective-c和java类型翻译为Json类型。比如当你保存NSString对象时,它会被转为String类型存入Parse系统。
There are two waysto store binary data. The Bytes type allows you toassociate NSData/bytes[] types directly ona PFObject. This is recommended only for small pieces of binary-encoded data.For actual files (images, documents, etc.), the File type can be usedby instantiating a PFFile/ParseFile and setting it ona field.
这里有两种方式来存储二进制数据数据。Bytes类型允许你直接在PFObject上使用NSData/bytes[]类型。File类型会被实例化为PFfile/ParseFile对象,然后被存储到字段里去。
Data Type Lock-in
数据类型锁定
When a class isinitially created, it doesn't have an inherent schema defined. This means thatfor the first object, it could have any types of fields you want.
当一个Class当初被创建的时候,它不会有一个固有的定义模式。这意味着这个对象可以拥有任何你想要的类型的字段。
However, after afield has been set at least once, that field is locked into the particular typethat was saved. For example, if a User object is savedwith field name of type String, that field willbe restricted to the String type only (our SDKwill return an error if you try to save anything else).
One special caseis that any field can be set to null, no matter whattype it is.
但是,当一个字段一旦被设值之后,这个字段会被锁定为一个具体的类型,不能再改变。例如,User对象中的Name字段被保存为String,那么这个字段就会被限制为String类型了(如果你想保存为其他类型,SDK都会返回错误)。
一个特例是,一个字段如果被设置为null,是无所谓字段是何种类型的。
The Data Browser
数据浏览器
The Data Browseris the web UI where you can update and create objects in each of your apps.Here, you can see the raw JSON values that are saved that represents eachobject in your class.
数据浏览器是一个基于Web UI的,你可以为你的app更新和创建对象。这里你可以看到元生JSON数值会被存储起来,它们就是类(class)中的所有对象的体现和呈现。
When using theinterface, keep in mind the following:
使用这个交互界面时,请注意下面的内容:
· Entering "null" will setthe value to the special null value, not the string"null".
· 输入"null"时,保存的实际值是null,而不是字符串"null"
· The objectId, createdAt, updatedAt fields cannot be edited (these areset automatically).
· objecdtId,createdAt,updatedAt这些字段不可以编辑,它们会被自动设置。
· The value "(empty)"denotes that the field has not been set for that particular object (this isdifferent than null).
值"(empty)"表示,这个字段还没有被设置为具体的对象。这个和null是有区别的。
Importing Data
导入数据
In addition to theREST api, we also offer data import through CSV or JSON files.
除了REST API,我们提供了从CSV或JSON文件中导入数据的功能。
To create a newclass with data from a CSV or JSON file, go to the Data Browser and click the"Import" button on the left hand column.
为了通过CSV或JSON文件创建一个新的Class,到数据浏览器上,点击左手栏中的导入按钮。
The JSON format isan array of objects in our REST format or a JSON object with a results that contains anarray of objects. In addition to the exposed fields, objects in the Parse Userclass can also have the bcryptPassword field set. Thevalue of this field is a String that is the bcrypthashed password + salt in the modular crypt format described in this StackOverflow answer.Most OpenSSL based bcrypt implementations should have built-in methods toproduce these strings.
JSON格式是一个拥有REST格式的对象的数组,或者是有一个results的JSON对象,results里面包含了一个对象的数组。除了那些暴露出来的字段,Parse的用户类(User Class)中的对象也可以拥有加密密码字段。这个字段是String类型,它的值是基于bcrypt实现的加密算法。很多基于bcrypt 实现的OpenSSL都提供内置的方法来处理这些字符串。
A file containingregular objects could look like:一个包含常规对象的文件看起来如下:
{ “results”: [
{
"score": 1337,
"playerName": "Sean Plott",
"cheatMode": false,
"createdAt": "2012-07-11T20:56:12.347Z",
"updatedAt": "2012-07-11T20:56:12.347Z",
"objectId": "fchpZwSuGG"
}]
}
A file containinga User object could looklike:包含一个User对象的文件看起来如下
{ "results": [{
"username": "cooldude",
"createdAt": "2012-08-27T22:42:30.548Z",
"updatedAt": "2012-09-05T23:23:40.636Z",
"objectId": "ttttSEpfXm",
"sessionToken": "dfwfq3dh0zwe5y2sqv514p4ib",
"bcryptPassword": "$2a$10$ICV5UeEf3lICfnE9W9pN9.O9Ved/ozNo7G83Qbdk5rmyvY8l16MIK"
}]
}
Security
安全
For any mobileapplication, since the client code runs on a mobile device, it's possible thatan untrustworthy client could edit that code and issue malicious requests.Choosing the right way to secure your application is important, but the right wayto do it depends on your application and the types of data it stores.
对很多手机应用,由于客户端的代码运行在手机装置上,这个客户端可能是不值得信任,可能会编辑代码并发出恶意的请求。选择正确的方式来确保应用的安全是非常重要的。但是正确的方法依靠你的应用程序和数据存储的类型。
Parse offersseveral ways to use permissions to enforce security. If you have questionsaround how best to secure your application, we encourage you to contact support.
Parse提供了用权限来强化安全的几种方法。围绕如何能够最好的确保应用的安全,有任何问题可以联系我们。
Object-LevelPermissions
对象层次上的许可
The most flexibleway to secure application data is through access control lists,commonly known as ACLs. The idea behind an ACL is that each object has a listof users and roles along with what permissions that user or role has. A userneeds read permissions (or must belong to a role that has read permissions) inorder to retrieve an object's data, and a user needs write permissions (or mustbelong to a role that has write permissions) in order to update or delete thatobject.
最灵活的方法是通过ACCESS CONTROL LISTS,通常称为ACLs。ACL的思路是每一个对象有一个用户和角色的列表,以及这些用户和角色拥有什么样的许可权限。一个用户需要读的许可(或者必须属于一个有读写权限的角色)为了获取对象的数据。一个用户需要一个写的权限(或者必须属于一个有写权限的角色)为了能够更新或者删除那个对象。
Most applicationscan enforce their access patterns through ACLs. For example:
需要应用可以通过ACLs来强化访问模式。
· For private data, "read"and "write" access can be restricted to the owner.
· 对于私有数据,读写访问可以只局限于数据的所有者。
· For a post on a message board, theauthor and members of the "Moderators" role can have"write" access, and the general public can have "read"access.
· 对于一个留言版的发布,作者和属于“主持人”角色的会员有些的权限,一般的游客有读的权限。
· For logging data that will only beaccessed by the developer through the REST API, the ACL can deny allpermissions.
· 对于日志数据只有开发者才能够访问,ACL可以拒绝所有的访问许可。
· Data created by a privileged groupof users or the developer, like a global message of the day, can have public"read" access but restrict "write" access to an"Administrators" role.
· 属于一个被授权组的用户或者开发者创建的数据,可以有公共的读权限,但是写入权限仅限于管理者角色。
· A message sent from one user toanother can give "read" and "write" access just to thoseusers.
· 一个用户发送给另外一个用户的消息,可以只给这些用户赋予读写的权限。
Using the ParseSDKs, you can set a default ACL for all of the objects your application clientscreates. If you also enable automatic anonymous user creation for yourapplication, you can ensure that your data has ACLs restricted to individualusers by default. See the iOS and Android guides for moreinformation about choosing secure defaults.
All operations arestill possible when authenticating with the master key via the REST API. As adeveloper, this lets you manage any aspect of the data. For example, you candelete private messages via the REST API even if they are private based on theACL.
用Parse SDK,你可以对所有应用客户端创建的对象设置一个默认的ACL。如果想设置自动匿名用户创建,你需要确保系统是默认数据对于个人用户有ACLS限制的。参考iOS和Android的指导资料已获取更多的信息。当通过REST API用主键(master key)进行授权的时候,所有的操作仍然是可能的。作为一个开发者,这可以让你管理数据的所有方面。例如,你可以通过REST api删除私有信息如果他们是基于ACL的私有信息。
For code exampleson how to use ACLs, see the ACL section of the iOSGuide and the ACL section of the AndroidGuide.
Class-LevelPermissions
类级别的许可
For somesituations, it is more natural to specify for an entire class which permissionsare allowed. For example, you might want an entire class to be read-only, orwrite-only.
对于一些场合,给整个Class设置访问许可是非常自然的。例如你可以对整个Class设置只读或者只写。
To make thiseasier, Parse lets you specify what operations are allowed per class. To accessthese settings, go to the Data Browser, select a class, and click the"Settings" button on the right hand side.
为了让这些变得更容易,Parse允许你设置每个类那些操作是允许的。这些设定可以通过数据浏览器进行,选中一个class,点击setting按钮进行设置。
You can disable theclient's ability to perform each of the following operations for the selectedclass:
你可以取消客户端执行下列操作的能力。
· Get - fetching an object by itsobjectId.通过objectId获取一个对象
· Find - issuing a query to fetch objects.发起一个查询来获取对象。
· Update - saving an object that alreadyexists and has been modified.保存一个已经存在的和被修改过的对象
· Create - saving an object that is new andhasn't been created yet.创建一个新的对象
· Delete - deleting an object.删除一个对象
· Add fields - adding fields to the class.给Class添加字段
You can alsodisable creation of new classes altogether by going to the "Settings"panel, and turning off "Allow client class creation" on the"General Settings" tab.
你也可以取消创建新class的能力,通过设置面板,关闭“允许客户端创建class”的选项。
之前项目中有用到这块的东西,现在在拿来用,觉得还是写下来比较好。
言简意赅,主界面有个listview:
<ListView
android:id="@+id/list_food"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/food_bottom"
android:layout_below="@id/input_1"
android:divider="@color/voice_bg"
android:cacheColorHint="@color/transparent"
android:dividerHeight="1dip" >
在adapter中有一个checkbox:(可选择状态都设为false)
<CheckBox
android:id="@+id/food_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/radiobutton"
android:layout_alignParentRight="true"
android:button="@null"
android:focusable="false"
android:focusableInTouchMode="false"
android:clickable="false"
android:paddingRight="@dimen/margin_max"
android:layout_marginRight="@dimen/margin_max" />
在adapter中进行标记和赋值:
private LayoutInflater mInflater;
/**the the food data list */
private List<FoodBean> mData;
/*the context*/
Context context;
int k=0;
public static Map<Integer, Boolean> isSelected= new HashMap<Integer, Boolean>();
public FoodChooseAdapter(Context context, List<FoodBean> list) {
mInflater = LayoutInflater.from(context);
this.context = context;
mData = list;
init();
}
// 初始化
private void init() {
// mData=new ArrayList<Map<String, Object>>();
// 这儿定义isSelected这个map是记录每个listitem的状态,初始状态全部为false。
for (int i = 0; i < mData.size(); i++) {
isSelected.put(i, false);
}
}
public View getView(int position, View convertView, ViewGroup parent) {
HistoryWeightHolder holder = null;
if (convertView == null) {
// init convertView if convertView is null
convertView = mInflater.inflate(R.layout.food_choose,null);
holder = new HistoryWeightHolder();
holder.radio=(CheckBox) convertView.findViewById(R.id.food_add);
holder.name = (TextView) convertView
.findViewById(R.id.name);
holder.unit = (TextView) convertView
.findViewById(R.id.food_unit);
holder.energy = (TextView) convertView
.findViewById(R.id.energy);
convertView.setTag(holder);
} else {
holder = (HistoryWeightHolder) convertView.getTag();
}
holder.name.setText(mData.get(position).getName());
holder.unit.setText(String.valueOf(mData.get(position).getUnit()));
holder.energy.setText(String.valueOf(mData.get(position).getEnergy())+context.getResources().getText(R.string.unit_1).toString());
holder.radio.setChecked(isSelected.get(position));
return convertView;
}
public static final class HistoryWeightHolder {
public CheckBox radio;
public TextView name;
public TextView unit;
public TextView energy;
}
public int getCount() {
return mData.size();
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
最后是activity中的代码:
fca = new FoodChooseAdapter(CalerySearchActivity.this, mListCount);
mList.setAdapter(fca);
mList.setItemsCanFocus(false);
mList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
HistoryWeightHolder holder = (HistoryWeightHolder) view
.getTag();
holder.radio.toggle();
/* click of last enable all left;inverse is all the same */
for (int i = 0; i < mList.getCount(); i++) {
if (i == position) {
FoodChooseAdapter.isSelected.put(position,
holder.radio.isChecked());
} else {
FoodChooseAdapter.isSelected.put(i, false);
}
}
}
});
擦~主要就是这样了,效果就是点击list的一项,这项被选中,有checkbox的状态,其他选项都被置为未选中状态。
大概就是这个效果了