관계 구문 분석 [오류] : 관계에 비 포인터를 추가 할 수 없습니다 (코드 : 111, 버전 : 1.7.5).

user4203956

사용자가 작업을 볼 수있는 작업 앱이 있습니다. Jobs는 내 Parse 백엔드의 클래스입니다. 사용자가 특정 작업을 표시 할 수있는 즐겨 찾기 탭을 만들고 싶습니다.

내 사용자 클래스에서 내 작업 클래스를 참조하는 관계 열을 만들었습니다.

그러나 사용자가 작업을 즐겨 찾기로 만들기 위해 탭할 때이 문제가 발생했습니다. [오류] : 관계에 비 포인터를 추가 할 수 없습니다 (코드 : 111, 버전 : 1.7.5).

내 PFRelation 코딩이 제대로 된 것 같습니다. 이 오류를 조사했지만 내 문제와 관련된 주제를 찾을 수없는 것 같습니다. 어딘가에서 실수 한 게 분명하지만

@interface JobDetailViewController ()

@end

@implementation JobDetailViewController

@synthesize jobPhoto;
@synthesize RotationLabel;
@synthesize QualificationsTextView;
@synthesize Job_DescriptionTextView;
@synthesize TypeLabel;
@synthesize LocationLabel;
@synthesize ClearanceLabel;
@synthesize PositionLabel;
@synthesize job;
@synthesize POC;
@synthesize Email;
@synthesize Phone;
@synthesize Apply;



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

- (void)viewDidLoad
{
    [super viewDidLoad];

    [_Scroller setScrollEnabled:YES];
    [_Scroller setContentSize:CGSizeMake(320, 2200)];

    [self dismissKeyboard];
    self.PositionLabel.text = job.position;
    self.RotationLabel.text = job.rotation;
    self.LocationLabel.text = job.location;
    self.TypeLabel.text = job.type;
    self.ClearanceLabel.text = job.clearance;
    jobPhoto.file = (PFFile *)job.imageFile;
    [jobPhoto loadInBackground];

    NSMutableString *pocText = [NSMutableString string];
    for (NSString* poc in job.poc) {
        [pocText appendFormat:@"%@\n", poc];
    }
    self.POC.text = pocText;

    NSMutableString *emailText = [NSMutableString string];
    for (NSString* email in job.email) {
        [emailText appendFormat:@"%@\n", email];
    }
    self.Email.text = emailText;


    NSMutableString *phoneText = [NSMutableString string];
    for (NSString* phone in job.phone) {
        [phoneText appendFormat:@"%@\n", phone];
    }
    self.Phone.text = phoneText;

    NSMutableString *applyText = [NSMutableString string];
    for (NSString* apply in job.apply) {
        [applyText appendFormat:@"%@\n", apply];
    }
    self.Apply.text = applyText;

    NSMutableString *qualificationsText = [NSMutableString string];
    for (NSString* qualifications in job.qualifications) {
        [qualificationsText appendFormat:@"%@\n", qualifications];
    }
        self.QualificationsTextView.text = qualificationsText;

    NSMutableString *job_descriptionText = [NSMutableString string];
    for (NSString* job_description in job.job_description) {
        [job_descriptionText appendFormat:@"%@\n", job_description];
    }
    self.Job_DescriptionTextView.text = job_descriptionText;
}



- (IBAction)favoriteButtonAction:(id)sender {
    PFObject *jobs = [PFObject objectWithClassName:@"Jobs"];
    PFUser *user = [PFUser currentUser];
    PFRelation *relation = [user relationForKey:@"Favorites"];
    [relation addObject:jobs];

    [user saveInBackground];



}


- (void)viewDidUnload
{
    [self setJobPhoto:nil];
    [self setPositionLabel:nil];
    [self setRotationLabel:nil];
    [self setLocationLabel:nil];
    [self setTypeLabel:nil];
    [self setQualificationsTextView:nil];
    [self setJob_DescriptionTextView:nil];
    [self setPOC: nil];
    [self setPhone:nil];
    [self setEmail:nil];
    [self setApply:nil];
    [self dismissKeyboard];

    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

-(void) dismissKeyboard {
    [Email resignFirstResponder];
    [POC resignFirstResponder];
    [Phone resignFirstResponder];
    [Job_DescriptionTextView resignFirstResponder];
    [QualificationsTextView resignFirstResponder];
}

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
 return NO;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void) favoriteSuccess {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Success!" message:@"Added job to Favorites!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
}


- (void) favoriteFailed {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Ooooops!" message:@"Error occurred while adding to Favorites!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
}



@end

JobDetailViewController 이전에 작업을 채우는 JobListViewController :

#import "JobDetailViewController.h"
#import "JobListViewController.h"
#import "Job.h"
#import "SearchedResultCell.h"
#import <Parse/Parse.h>



@interface JobListViewController () <UISearchDisplayDelegate, UISearchBarDelegate> {

}

@property (nonatomic, weak) IBOutlet UISearchBar *searchedBar;
@property (nonatomic, strong) NSString *mainTitle;
@property (nonatomic, strong) NSString *subTitle;
@property (nonatomic, assign) BOOL canSearch;

@end

    @interface JobListViewController ()

    @end

    @implementation JobListViewController
    {}
    @synthesize searchedBar;
    @synthesize mainTitle;
    @synthesize subTitle;
    @synthesize canSearch;


    - (id)initWithCoder:(NSCoder *)aCoder
    {
        self = [super initWithCoder:aCoder];
        if (self) {
            // Custom the table

            // The className to query on
            self.parseClassName = @"Jobs";

            // The key of the PFObject to display in the label of the default cell style
            self.textKey = @"Position";

            // Whether the built-in pull-to-refresh is enabled
            self.pullToRefreshEnabled = YES;

            // Whether the built-in pagination is enabled
            self.paginationEnabled = YES;

            // The number of objects to show per page
            self.objectsPerPage = 20;
        }
        return self;
    }

    - (void)viewDidLoad
    {
        [super viewDidLoad];



    }

    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];

        self.canSearch = 0;

    }

    - (void)viewDidAppear:(BOOL)animated {
        [super viewDidAppear:animated];
    }

    - (void)viewWillDisappear:(BOOL)animated {
        [super viewWillDisappear:animated];
    }

    - (void)viewDidDisappear:(BOOL)animated {
        [super viewDidDisappear:animated];
    }

    - (void)viewDidUnload
    {
        [super viewDidUnload];
        // Release any retained subviews of the main view.
    }

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    }

    - (void)objectsWillLoad {
        [super objectsWillLoad];

        // This method is called before a PFQuery is fired to get more objects
    }


    - (PFQuery *)queryForTable
    {
        PFQuery *query1 = [PFQuery queryWithClassName:@"Jobs"];
        NSString *searchThis = [searchedBar.text capitalizedString];
        [query1 whereKey:@"Position" containsString:searchThis];
        PFQuery *query2 = [PFQuery queryWithClassName:@"Jobs"];
        [query2 whereKey:@"Type" containsString:searchThis];
        PFQuery *query = [PFQuery orQueryWithSubqueries:@[query1,query2]];
            [query orderByDescending:@"createdAt"];

        if (self.pullToRefreshEnabled) {
            query.cachePolicy = kPFCachePolicyNetworkOnly;
        }

        // If no objects are loaded in memory, we look to the cache first to fill the table
        // and then subsequently do a query against the network.

        return query;
    }







    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object: (PFObject *)object
    {
        static NSString *simpleTableIdentifier = @"JobCell";
            static NSString *pimpleTableIdentifier = @"JobCell";

        UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];

        SearchedResultCell *bell = [self.tableView dequeueReusableCellWithIdentifier:pimpleTableIdentifier];

        if (bell == nil) {
            bell = [[SearchedResultCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:pimpleTableIdentifier];

            }

            [self configureSearchResult:bell atIndexPath:indexPath object:object];


        }

        // Configure the cell
        PFFile *thumbnail = [object objectForKey:@"imageFile"];
        PFImageView *thumbnailImageView = (PFImageView*)[cell viewWithTag:100];
        thumbnailImageView.image = [UIImage imageNamed:@"AppIcon.png"];
        thumbnailImageView.file = thumbnail;
        [thumbnailImageView loadInBackground];

        UILabel *positionLabel = (UILabel*) [cell viewWithTag:101];
        positionLabel.text = [object objectForKey:@"Position"];
        UILabel *rotationLabel = (UILabel*) [cell viewWithTag:102];
        rotationLabel.text = [object objectForKey:@"Rotation"];
        UILabel *locationLabel = (UILabel*) [cell viewWithTag:103];
        locationLabel.text = [object objectForKey:@"Location"];
        UILabel *typeLabel = (UILabel*) [cell viewWithTag:104];
        typeLabel.text = [object objectForKey:@"Type"];


    return cell;
    }


    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        if ([segue.identifier isEqualToString:@"showJobDetail"]) {
            NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];

            Job *job = [[Job alloc] init];

            JobDetailViewController *destViewController = segue.destinationViewController;

            PFObject *object = [self.objects objectAtIndex:indexPath.row];
            job.position = [object objectForKey:@"Position"];
            job.poc = [object objectForKey:@"POC"];
            job.email = [object objectForKey:@"Email"];
            job.phone = [object objectForKey:@"Phone"];
            job.apply = [object objectForKey:@"Apply"];
            job.imageFile = [object objectForKey:@"imageFile"];
            job.rotation = [object objectForKey:@"Rotation"];
            job.location = [object objectForKey:@"Location"];
              job.type = [object objectForKey:@"Type"];
            job.clearance = [object objectForKey:@"Clearance"];
            job.job_description = [object objectForKey:@"Job_Description"];
            job.qualifications = [object objectForKey:@"Qualifications"];
            destViewController.job = job;

        }

    }

    - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
    {

        [self clear];

        self.canSearch = 1;

        [self.searchedBar resignFirstResponder];

        [self queryForTable];
        [self loadObjects];

    }



    - (void)configureSearchResult:(SearchedResultCell *)cell atIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
    {
        mainTitle = [object objectForKey:@"Position"];
        cell.mainTitle.text = mainTitle;

        subTitle = [object objectForKey:@"Type"];
        cell.detail.text = subTitle;

         // Implement this if you want to Show image
         cell.showImage.image = [UIImage imageNamed:@"AppIcon.png"];

         PFFile *imageFile = [object objectForKey:@"imageFile"];

         if (imageFile) {
         cell.showImage.file = imageFile;
         [cell.showImage loadInBackground];
         }
    }


    #pragma mark - UITableViewDelegate

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {



        [tableView deselectRowAtIndexPath:indexPath animated:YES];

        [searchedBar resignFirstResponder];

        if ([self.objects count] == indexPath.row) {
            [self loadNextPage];
        } else {
            PFObject *photo = [self.objects objectAtIndex:indexPath.row];
            NSLog(@"%@", photo);

            // Do something you want after selected the cell
        }
    }



    #pragma mark - UIScrollViewDelegate


    - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
        [self.searchedBar resignFirstResponder];
    }

    - (void)searchBarCancelButtonClicked:(UISearchBar *) searchBar {
        [self.searchedBar resignFirstResponder];
        [self queryForTable];
        [self loadObjects];

    }







    @end
마흐무드 아담

코드가 기존 작업 개체를 가리 키지 않습니다.

PFObject *jobs = [PFObject objectWithClassName:@"Jobs"];

관계에 개체를 추가하려면 해당 테이블의 기존 개체 여야합니다 (새 개체 인 경우 먼저 저장해야 함).

최신 정보:

코드는 job뷰 컨트롤러 의 속성 사용 하고 다음과 같이 현재 사용자 관계에 추가해야합니다.

- (IBAction)favoriteButtonAction:(id)sender {
    PFUser *user = [PFUser currentUser];
    PFRelation *relation = [user relationForKey:@"Favorites"];
    [relation addObject:job];
    [user saveInBackground];
}

Job 객체에 대해 Parse 하위 클래스사용하면 더 좋을 것입니다.

#import <Parse/Parse.h>
#import <Parse/PFObject+Subclass.h>

@interface Job : PFObject<PFSubclassing>
@property (nonatomic, strong) NSString *rotation;
@property (nonatomic, strong) NSString *location;
@property (nonatomic, strong) NSString *type;
..
.
.
.
@end


@implementation Tracker

@dynamic rotation, location, type,....;
+ (void)load {
    [self registerSubclass];
}

+ (NSString *)parseClassName {
    return @"Job";
}
@end

그런 다음 코드를 다음과 같이 수정하십시오.

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"showJobDetail"]) {


        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        Job *job = [self.objects objectAtIndex:indexPath.row];

        JobDetailViewController *destViewController = segue.destinationViewController;
        destViewController.job = job;

    }

}

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

관계를 추가 할 수없는 클라우드 코드 구문 분석

분류에서Dev

PyQt-builder 오류 " 'PyQt5-5.14.2'를 버전 번호로 구문 분석 할 수 없습니다."

분류에서Dev

Swift에서 클라우드 코드 오류를 구문 분석하여 관계 가져 오기

분류에서Dev

Android : Dex에서 버전 52 바이트 코드를 구문 분석 할 수 없습니다.

분류에서Dev

Android studio (2.1.1 April 28-2016) 바이트 코드를 dex로 변환하는 동안 이상한 오류가 발생했습니다. Dex는 버전 52 바이트 코드를 구문 분석 할 수 없습니다.

분류에서Dev

구문 분석 : 하위 클래스와의 관계를 할당 할 수 없습니다.

분류에서Dev

JSON 구문 분석 오류 : 인식 할 수없는 토큰 '!' -Sentry가 오류를 포착했습니다.

분류에서Dev

Android 다운로드 파일이 패키지 구문 분석 오류를 구문 분석 할 수 없습니다.

분류에서Dev

Pearson 상관 관계 분석을 수행 할 때 R에서 아래 오류를 어떻게 해결합니까?

분류에서Dev

Django는 내부 서버 오류에서 WSGIRequest의 POST 매개 변수를 구문 분석 할 수 없습니다.

분류에서Dev

'{1}'유형을 사용할 수 없기 때문에 '{0}'관계가로드되지 않았습니다.

분류에서Dev

Blackberry Development 버전 7 이상, 서명 키 오류 : 현재 서버를 사용할 수 없습니다. 시스템 관리자에게 문의하십시오

분류에서Dev

구문 분석 서버에 추가 논리를 추가 할 수 있습니까?

분류에서Dev

작성기 오류 : 버전 제약 조건> = ~ 2를 구문 분석 할 수 없습니다.

분류에서Dev

단계에서 오류 가져 오기 : DOWNLOAD_SOURCE 비밀 관리자가 키를 찾을 수 없습니다.

분류에서Dev

Laravel Passport에서 '키를 구문 분석 할 수 없습니다. 이유 : PHP8.0으로 업그레이드 한 후 ""'오류가 발생합니다.

분류에서Dev

오류 : db 'multilib'를 읽을 수 없습니다 (1 행을 구문 분석 할 수 없음).

분류에서Dev

JSON 구문 분석 오류 :`com.dto.IdDTO`의 인스턴스를 생성 할 수 없습니다 (크리에이터가 하나 이상 존재하지만).

분류에서Dev

'charmap'코덱이 HTML을 구문 분석하는 동안 Python에서 문자 오류를 인코딩 할 수 없습니다.

분류에서Dev

서버에서 JSON 데이터를 구문 분석 할 수 없습니다.

분류에서Dev

Django에서 Many-To-Many 관계를 추가 할 수 없습니다.

분류에서Dev

코드는 구문 분석 오류를 제공합니다. 오류가 무엇인지 찾을 수 없습니다.

분류에서Dev

이 코드에서 ':'expected.eslint 구문 분석 오류가 발생하지만 위치를 볼 수 없습니다.

분류에서Dev

Ember canary "발견되지 않은 오류 : 어설 션 실패 :이 관계에 '마일스톤'레코드 만 추가 할 수 있습니다."

분류에서Dev

PHP 에코가 "구문 분석 오류 : 구문 오류"를 생성합니다.

분류에서Dev

gawk의 시작 부분에 빈 필드가있는 CSV를 구문 분석 할 수 없습니다.

분류에서Dev

내 파이썬 코드에 오류 관련 % 계산기가 있는데 찾을 수 없습니다.

분류에서Dev

관련 쿼리를 수행 할 때 Mysql 상수 필드 오류가 발생했습니다. [Err] 1064-SQL 구문에 오류가 있습니다.

분류에서Dev

계산 된 필드를 새 레코드에 추가 할 수 없습니다.

Related 관련 기사

  1. 1

    관계를 추가 할 수없는 클라우드 코드 구문 분석

  2. 2

    PyQt-builder 오류 " 'PyQt5-5.14.2'를 버전 번호로 구문 분석 할 수 없습니다."

  3. 3

    Swift에서 클라우드 코드 오류를 구문 분석하여 관계 가져 오기

  4. 4

    Android : Dex에서 버전 52 바이트 코드를 구문 분석 할 수 없습니다.

  5. 5

    Android studio (2.1.1 April 28-2016) 바이트 코드를 dex로 변환하는 동안 이상한 오류가 발생했습니다. Dex는 버전 52 바이트 코드를 구문 분석 할 수 없습니다.

  6. 6

    구문 분석 : 하위 클래스와의 관계를 할당 할 수 없습니다.

  7. 7

    JSON 구문 분석 오류 : 인식 할 수없는 토큰 '!' -Sentry가 오류를 포착했습니다.

  8. 8

    Android 다운로드 파일이 패키지 구문 분석 오류를 구문 분석 할 수 없습니다.

  9. 9

    Pearson 상관 관계 분석을 수행 할 때 R에서 아래 오류를 어떻게 해결합니까?

  10. 10

    Django는 내부 서버 오류에서 WSGIRequest의 POST 매개 변수를 구문 분석 할 수 없습니다.

  11. 11

    '{1}'유형을 사용할 수 없기 때문에 '{0}'관계가로드되지 않았습니다.

  12. 12

    Blackberry Development 버전 7 이상, 서명 키 오류 : 현재 서버를 사용할 수 없습니다. 시스템 관리자에게 문의하십시오

  13. 13

    구문 분석 서버에 추가 논리를 추가 할 수 있습니까?

  14. 14

    작성기 오류 : 버전 제약 조건> = ~ 2를 구문 분석 할 수 없습니다.

  15. 15

    단계에서 오류 가져 오기 : DOWNLOAD_SOURCE 비밀 관리자가 키를 찾을 수 없습니다.

  16. 16

    Laravel Passport에서 '키를 구문 분석 할 수 없습니다. 이유 : PHP8.0으로 업그레이드 한 후 ""'오류가 발생합니다.

  17. 17

    오류 : db 'multilib'를 읽을 수 없습니다 (1 행을 구문 분석 할 수 없음).

  18. 18

    JSON 구문 분석 오류 :`com.dto.IdDTO`의 인스턴스를 생성 할 수 없습니다 (크리에이터가 하나 이상 존재하지만).

  19. 19

    'charmap'코덱이 HTML을 구문 분석하는 동안 Python에서 문자 오류를 인코딩 할 수 없습니다.

  20. 20

    서버에서 JSON 데이터를 구문 분석 할 수 없습니다.

  21. 21

    Django에서 Many-To-Many 관계를 추가 할 수 없습니다.

  22. 22

    코드는 구문 분석 오류를 제공합니다. 오류가 무엇인지 찾을 수 없습니다.

  23. 23

    이 코드에서 ':'expected.eslint 구문 분석 오류가 발생하지만 위치를 볼 수 없습니다.

  24. 24

    Ember canary "발견되지 않은 오류 : 어설 션 실패 :이 관계에 '마일스톤'레코드 만 추가 할 수 있습니다."

  25. 25

    PHP 에코가 "구문 분석 오류 : 구문 오류"를 생성합니다.

  26. 26

    gawk의 시작 부분에 빈 필드가있는 CSV를 구문 분석 할 수 없습니다.

  27. 27

    내 파이썬 코드에 오류 관련 % 계산기가 있는데 찾을 수 없습니다.

  28. 28

    관련 쿼리를 수행 할 때 Mysql 상수 필드 오류가 발생했습니다. [Err] 1064-SQL 구문에 오류가 있습니다.

  29. 29

    계산 된 필드를 새 레코드에 추가 할 수 없습니다.

뜨겁다태그

보관