【问题标题】:Sending specific PFUsers images from Parse从 Parse 发送特定的 PFUsers 图像
【发布时间】:2014-07-29 15:26:48
【问题描述】:

我希望能够直接从 Parse 向特定用户发送不同的照片。解决此问题的最佳方法是什么?

我已经完全设置了用户登录和注册。我还有一个 UIViewController 归档为“Concepts”,一个 PFImageView 归档为“Progress”。

类名是“UserPhoto” 我有一个名为“imageFile”的文件列和一个名为“user”的指针<_user> 列。我将在“Image.jpg”下存储“imageFile”名称

我觉得我在任何类型的进步中都偏离了轨道,所以任何帮助都将不胜感激。截至目前,经过两周的研究来实现这一目标,我还没有找到适合我的解决方案。

ViewController.h

#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import "Progress.h"

@interface Concepts : UIViewController

@property (weak, nonatomic) IBOutlet Progress *image1;

@end

ViewController.m

#import "Concepts.h"
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import "Progress.h"

@interface Concepts ()

@end

@implementation Concepts
@synthesize image1;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    PFQuery *query = [PFQuery queryWithClassName:@"UserPhoto"];

    [query getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) {

        NSLog(@"Retrieved data");

        if (!error) {
            PFFile *image1 = [object objectForKey:@"imageFile"];


        }
    }];
    }

PFImageView.h

#import "Progress.h"
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import "Concepts.h"


@interface Progress : PFImageView

@end

PFImageView.m

#import "Progress.h"
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import "Concepts.h"

@implementation Progress

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

【问题讨论】:

    标签: ios objective-c image file parse-platform


    【解决方案1】:

    要获取任何特定用户的图像,您需要在查询中放入 where 子句,Parse 提供了很多选项:

    然后只需通过以下方式获取结果:

     [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    
        //result
    
       }];
    

    【讨论】:

    • 谢谢!我会在(NSString *)和(NSArray *)中放什么? @shrejas
    • 这取决于您的要求,根据您查询表的内容,例如假设有一个水果表并且您需要红色或黄色的水果,在这种情况下 NSString 将包含列名 "fruit_color" 和数组值将是 @[ @"red", @"yellow"]
    • 如何声明 NSString,在我的例子中是“imageFile”?除了您提供的信息之外,我在顶部发布的代码是我目前拥有的所有信息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-21
    • 1970-01-01
    • 2015-05-17
    • 1970-01-01
    相关资源
    最近更新 更多