Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 正在从目标C传递self.request.get(“profile”pic)Null_Python_Objective C_Webapp2 - Fatal编程技术网

Python 正在从目标C传递self.request.get(“profile”pic)Null

Python 正在从目标C传递self.request.get(“profile”pic)Null,python,objective-c,webapp2,Python,Objective C,Webapp2,我不知道如何通过POST检查Objective-C是否传递空值 在目标C中: NSData *profile_pic_data = nil; (this does not change) ... //Profile Pic Data [body appendData:[[NSString stringWithFormat:@"--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[@"Cont

我不知道如何通过POST检查Objective-C是否传递空值

在目标C中:

NSData *profile_pic_data = nil; (this does not change)
...
//Profile Pic Data
[body appendData:[[NSString stringWithFormat:@"--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Disposition: form-data; name=\"profile_pic\"; filename=\"profile_pic.jpg\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:profile_pic_data]];
...
NSLog(@"profile_pic_data = %@", profile_pic_data); //RETURNS (null)
在Python中:

...
user_profile_pic_data = self.request.get("profile_pic")
...
if user_profile_pic_data:
   #IT RUNS THIS CODE
else:
   #IT SHOULD RUN THIS CODE
如果我在self.request.get(“profile\u pic”)设置后打印出用户\u profile\u pic\u数据,它不会显示任何内容

我试过:

if user_profile_pic_data:
if user_profile_pic_data is not NONE:
if user_profile_pic_data is not NONE and != '':
似乎什么都不管用


有人经历过这种情况吗?

不确定你在这里到底想实现什么,但在这里:

NSData *profile_pic_data = nil;
您正在将
profile\u pic\u data
设置为
nil
。然后,您将POST数据附加到
正文
,然后再次记录
profile\u pic\u数据
。由于您实际上从未将其设置为除
nil
之外的任何值,因此它输出为nothing

也许你想要
profile\u pic\u data
真正拥有内容?您可以使用

NSData *profile_pic_data = UIImageJPEGRepresentation(anImage);