晚上,我正在开发基于SWAPI的应用程序(星球大战api:https://swapi.co/documentation)
我得到了 ATS错误:struct node{
int key;
vector<int> values;
};
class key_value_sequences {
public:
key_value_sequences() { }
~key_value_sequences() { }
key_value_sequences(const key_value_sequences& A) {
myList = A.myList;
v = A.v;
}
key_value_sequences& operator=(const key_value_sequences& A) {
if (this == &A) return *this;
myList = A.myList;
v = A.v;
return *this;
}
// YOU SHOULD USE C++ CONTAINERS TO AVOID RAW POINTERS
// IF YOU DECIDE TO USE POINTERS, MAKE SURE THAT YOU MANAGE MEMORY PROPERLY
// IMPLEMENT ME: SHOULD RETURN SIZE OF A SEQUENCE FOR GIVEN KEY
// IF NO SEQUENCE EXISTS FOR A GIVEN KEY RETURN -1
int size(int key) const {
if (find(v.begin(), v.end(), key)!=v.end()) {
for(list<node>::iterator it = myList.begin(); it != myList.end(); it++) {
if (it->key == key) {
return it->values.size();
}
}
}
else return -1;
}
// IMPLEMENT ME: SHOULD RETURN POINTER TO A SEQUENCE FOR GIVEN KEY
// IF NO SEQUENCE EXISTS FOR A GIVEN KEY RETURN nullptr
const int* data(int key) const {
if (find(v.begin(), v.end(), key)!=v.end()) {
for(list<node>::iterator it = myList.begin(); it != myList.end(); it++) {
if (it->key == key) {
return it->values.data();
break;
}
}
}
else return nullptr;
}
// IMPLEMENT ME: INSERT VALUE INTO A SEQUENCE IDENTIFIED BY GIVEN KEY
void insert(int key, int value) {
if(v.size() == 0) { //empty list
v.push_back(key);
node n;
n.key = key;
n.values.push_back(value);
myList.push_back(n);
}
else if((find(v.begin(), v.end(), key)!=v.end())) { //if key exists already
for(list<node>::iterator it = myList.begin(); it != myList.end(); it++) {
if (it->key == key) {
it->values.push_back(value);
break;
}
}
}
else { //if theres no existing key
v.push_back(key);
node n;
n.key = key;
n.values.push_back(value);
myList.push_back(n);
}
}
private:
vector<int> v;
list<node> myList;
}; // class key_value_sequences
我无法理解原因。我的App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
位于 https格式
baseURL
请给我并提示!! 我只是一个新手,我猜测SWAPI只支持http协议。