有没有办法在swift中编写协议扩展来实现另一个协议,比如UIPickerViewDataSource?我想为UIPickerViewDataSource创建一种mixin(注意MyProtocol中的2个方法是UIPickerViewDataSource中的必需方法)例如:
class MyClass: MyProtocol, UIPickerViewDataSource {}
然后我会将协议添加到我的班级:
public class PushTokenRegister {
public static void registerPushToken(Context context) {
RequestQueue queue = Volley.newRequestQueue(context);
String url = "http://app.MYAPP.com/api/v2/pushtokens";
StringRequest strRequest = new StringRequest(Request.Method.POST, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.i("onResponse", response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("device_uuid", String.valueOf(FragmentedUser.getUniquePsuedoID()));
params.put("device_type", "android");
params.put("push_token",String.valueOf(Batch.Push.getLastKnownPushToken()));
return params;
}
};
queue.add(strRequest);
queue.start();
}
}
似乎它应该工作,但它一直告诉我,我的类不符合协议UIPickerViewDataSource。这种事情不可能吗?