-1

I am trying to integrate Quickblox chat into an existing Objective C (Xcode) application. The method below which had worked in another application is meant to send attachment to the chat dialog.

dispatch_async(dispatch_get_main_queue(), ^{

            [QBRequest TUploadFile:imageData
                          fileName:@"test.png"
                       contentType:@"image/png"
                          isPublic:NO
                      successBlock:^( QBResponse * _Nonnull response, QBCBlob * _Nonnull uploadedBlob )
                        {

                          QBChatAttachment *attachment = [[QBChatAttachment alloc] init];

                          attachment.url = uploadedBlob.privateUrl ? uploadedBlob.privateUrl : uploadedBlob.publicUrl;

                          attachment.ID = uploadedBlob.UID;
                          attachment.name = uploadedBlob.name;
                          attachment.type = @"image";

                          if ([strongSelf.delegate respondsToSelector:@selector(attachmentBar:didUpLoadAttachment:)]) {
                              [strongSelf.delegate attachmentBar:strongSelf didUpLoadAttachment:attachment];
                          }

                      } statusBlock:^(QBRequest * _Nonnull request, QBRequestStatus * _Nonnull status) {

                          CGFloat progress = status.percentOfCompletion;
                          [strongSelf updateLoadingProgress:progress];

                      } errorBlock:^(QBResponse * _Nonnull response) {
                          if ([strongSelf.delegate respondsToSelector:@selector(attachmentBarFailedUpLoadImage:)]) {
                              [strongSelf.delegate attachmentBarFailedUpLoadImage:strongSelf];
                          }

                      }];
        });

but the succesBlock callback kept throwing expected ')' error

successBlock:^( QBResponse * _Nonnull response, QBCBlob * _Nonnull uploadedBlob )

The full error is as shown in the screenshot below

enter image description here

What am I doing wrong.

kplus
  • 694
  • 8
  • 31
  • 1
    Just a guess, but may be you have missed to import something and hence compiler is not recognizing QBResponse. – Pankaj Gaikar Aug 01 '19 at 10:32
  • @Pankaj The QBResponse is referenced in the headers of QuickBlox framework. a command click links to the reference – kplus Aug 01 '19 at 10:38
  • I said so bcz there is already an error suggesting forward class object, which clearly suggests you still have to import something. – Pankaj Gaikar Aug 01 '19 at 11:21
  • @kplus -- what happens if you remove the `_Nonnull` keywords? – DonMag Aug 01 '19 at 13:55
  • @DonMag removing _Nonnull makes no difference – kplus Aug 01 '19 at 15:47
  • 1
    @kplus - the image you posted appears to indicate there are 3 issues with that `successBlock:` line... maybe the `Expected )` is caused by another error? – DonMag Aug 01 '19 at 16:12

1 Answers1

-1

Expected ')' error was actually caused by another error as suspected by @DonMag and @Pankaj Gaikar.

The error was

"use of undeclared identifier QBRequest"

Even though a command click on the said QBRequest takes links to the Quickblox.h reference, I realised the ChatAttachment Class is not really the Quickblox.h .

so the solution was to import Quickblox.h in the prefix.pch file.

Here is the step to creating a prefix.pch file if your application does not have one yet.

  1. From your Xcode menu, select File > New > File...

  2. From iOS template options, select Other > PCH file.

  3. Name the file -Prefix.pch, and then select Create.

  4. From your target’s Build settings, select All, and then add the following to the Prefix Header field

    $(SRCROOT)/-Prefix.pch

I hope this helps someone.

kplus
  • 694
  • 8
  • 31