ViewController에서 PFFile의 하위 클래스로 전송할 때 데이터가 손실되는 데 현재 문제가 있습니다. 전달되는 데이터는 사용자 프로필에 업로드 할 이미지 데이터입니다.싱글 톤 iOS에 데이터 전달
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Access the uncropped image from info dictionary
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
// Dismiss controller
[picker dismissViewControllerAnimated:YES completion:nil];
// Resize image
_focusedImage.image = image;
NSData *imageData = UIImageJPEGRepresentation(image, 0.05f);
PFFile *imageFile = [PFFile fileWithName:@"Image.jpg" data:imageData];
[[imageUpload uploadImage] setImagePFFile:imageFile];
}
이보기에 imageFile
에 로그가 올바르게 인쇄됩니다 : 여기에 이미지를 선택하는 코드이다. 나는이 점에 도착하면
+ (imageUpload *) uploadImage
{
static imageUpload*_sharedImageUpload = nil;
_sharedImageUpload = [[self alloc] init];
_sharedImageUpload.imageData = [[NSData alloc] init];
PFUser *user = [PFUser currentUser];
_sharedImageUpload.imagePFFile = [[PFFile alloc] init];
PFFile *imageFile = [PFFile fileWithName:@"Image.jpg" data:_sharedImageUpload.imageData];
[imageFile saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error)
{
[user setObject:imageFile forKey:@"image"];
[user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error)
{
NSLog(@"This should be the profile image upload");
}
else
{
NSLog(@"Something went wrong: %@", error);
}
}];
}
}];
return _sharedImageUpload;
}
, 시스템은 단지 빈 파일 (0 바이트)를 구문 분석에 업로드되는 동영상 : 내 싱글 톤 클래스 imageUpload uploadImage
을 통해 데이터를 전달 그러나,이 같은 데이터 구조가 모습입니다. 이름 지정은 올바르며 데이터베이스의 올바른 위치에 있지만 파일 자체의 데이터가 손실되는 선상의 어딘가에 있습니다. 나는 이유를 알 수 없다. 누구든지 어떤 제안이 있습니까?
@jefflovejapan 나는 아직도 비교적 새로운 편이다. 무슨 말이에요? –