如何在objective-cstd::deque@属性中push_back?

How to push_back in objective-c std::deque @property?

我试图 push_back 编号到@属性 std::deque,但是数据没有添加到双端队列并且它是空的

代码:

.h 文件

@interface HandTrackingViewController : CommonViewController

@property (readwrite, nonatomic) std::deque<double> vect;
@end

.mm 文件

#import "HandTrackingViewController.h"

@implementation HandTrackingViewController

- (void)mediapipeGraph:(MPPGraph*)graph
     didOutputPacket:(const ::mediapipe::Packet&)packet
          fromStream:(const std::string&)streamName {
    ...
    ...
    ...
    for (int handIndex = 0; handIndex < multiHandLandmarks.size(); ++handIndex) {
      ...
      for (int i = 0; i < landmarks.landmark_size(); ++i) {  
          self.vect.insert(self.vect.end(), {landmarks.landmark(i).x(), landmarks.landmark(i).y(), landmarks.landmark(i).z()});
      }
        for(int i=0; i < self.vect.size()-2; i+=3) {
            NSLog(@"(%f, %f, %f)", self.vect[i], self.vect[i+1], self.vect[i+2]); // deque is empty
        }        
    }
  }
}
@end

但是如果你制作一个中间双端队列并将其分配给 self.vect,那么它就可以工作

self.vect.insert(self.vect.end(), {landmarks.landmark(i).x(), landmarks.landmark(i).y(), landmarks.landmark(i).z()}); 替换为 _vect.insert(_vect.end(), {landmarks.landmark(i).x(), landmarks.landmark(i).y(), landmarks.landmark(i).z()});。不要在不需要的地方使用 self.