objective-c++

Objective-C++ 11 - Why can't we assign a block to a lambda?

别来无恙 提交于 2021-02-06 02:07:49
问题 So, I just upgraded to Xcode 4.4, and I noticed in the changelog: Apple LLVM compiler supports additional C++11 features, including lambdas Which is awesome! So I got around to coding, and I found a few things out: Lambdas are assignable to Objective-C blocks: void (^block)() = []() -> void { NSLog(@"Inside Lambda called as block!"); }; block(); std::function can hold an Objective-C block: std::function<void(void)> func = ^{ NSLog(@"Block inside std::function"); }; func(); We cant assign an

Objective-C++ 11 - Why can't we assign a block to a lambda?

馋奶兔 提交于 2021-02-06 02:02:05
问题 So, I just upgraded to Xcode 4.4, and I noticed in the changelog: Apple LLVM compiler supports additional C++11 features, including lambdas Which is awesome! So I got around to coding, and I found a few things out: Lambdas are assignable to Objective-C blocks: void (^block)() = []() -> void { NSLog(@"Inside Lambda called as block!"); }; block(); std::function can hold an Objective-C block: std::function<void(void)> func = ^{ NSLog(@"Block inside std::function"); }; func(); We cant assign an

Objective-C++ 11 - Why can't we assign a block to a lambda?

和自甴很熟 提交于 2021-02-06 02:00:38
问题 So, I just upgraded to Xcode 4.4, and I noticed in the changelog: Apple LLVM compiler supports additional C++11 features, including lambdas Which is awesome! So I got around to coding, and I found a few things out: Lambdas are assignable to Objective-C blocks: void (^block)() = []() -> void { NSLog(@"Inside Lambda called as block!"); }; block(); std::function can hold an Objective-C block: std::function<void(void)> func = ^{ NSLog(@"Block inside std::function"); }; func(); We cant assign an

addPresentedHandler not being triggered in Metal on iOS

白昼怎懂夜的黑 提交于 2021-01-28 07:54:39
问题 I've been trying to set up a addPresentedHandler for some time now, but without luck. I've got a addCompletedHandler working on the command buffers that contain the rendering work to be executed every frame. I've verified that the addCompletedHandler is working by seeing setting breakpoints within the code block. These are triggered when running the app. For the addPresentedHandler however, no breakpoint within the code block is triggered (I've also verified through modifying variables from

Using a std::vector<> as an Objective-C property

只愿长相守 提交于 2021-01-04 11:58:10
问题 I have an Objective-C++ class that I wish to have a property which is a C++ std::vector<std::string> . I've declared it like this: @interface WordModel : NSObject @property std::vector<std::string> words; @end When I attempt to add words to the vector nothing happens. For example, in the -init method, I'm doing this: std::string nextLine; while(wordsFile.good()) { std::getline(wordsFile, nextLine); if (nextLine.length() > 0) { self.words.push_back(nextLine); } } After calling push_back() the

Using a std::vector<> as an Objective-C property

蹲街弑〆低调 提交于 2021-01-04 11:56:09
问题 I have an Objective-C++ class that I wish to have a property which is a C++ std::vector<std::string> . I've declared it like this: @interface WordModel : NSObject @property std::vector<std::string> words; @end When I attempt to add words to the vector nothing happens. For example, in the -init method, I'm doing this: std::string nextLine; while(wordsFile.good()) { std::getline(wordsFile, nextLine); if (nextLine.length() > 0) { self.words.push_back(nextLine); } } After calling push_back() the

iOS中连接混编C++库的编译问题

戏子无情 提交于 2020-03-03 21:44:27
问题 重新封装画板内核库后,所有的混编文件(.mm)都被打包到了库中,外面应用层代码全部都是 OC 文件(.m)。这时候编译工程会出现如下连接错误: Undefined symbols for architecture arm64: "vtable for __cxxabiv1::__vmi_class_type_info", referenced from: ... NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::assign(char const*)", referenced from: ... "___cxa_pure_virtual", referenced from: ... "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::operator=(std::__1::basic_string<char, std::__1:

autoreleasepool was not declared in this scope error

 ̄綄美尐妖づ 提交于 2020-01-22 02:55:08
问题 My project is in XCode 4.2. This project compiles for a regular debug build. But when I change the build type to profile (I want to profile memory usage), I get the error from this objective-c++ c++ class: /Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm:53: error: stray '@' in program /Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm: In member function 'void FilterAudioMixer::WriteToBuffer(SInt16*, int)': /Volumes/mchinen/scm/Voicer/FilterAudioMixer.mm:53: error: 'autoreleasepool' was not

'opencv2/opencv.hpp' file not found in my private pod

走远了吗. 提交于 2020-01-17 07:10:31
问题 I'm making a private pod which include opencv and some other algorithm cpp files.But now I get a problem, it is said 'opencv2/opencv.hpp' file not found. My podspec file is like: # # Be sure to run `pod lib lint podOpenCV.podspec' to ensure this is a # valid spec before submitting. # # Any lines starting with a # are optional, but their use is encouraged # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html # Pod::Spec.new do |s| s.name = 'podOpenCV' s.version =

How to make std::vector from other vector with specific filter?

点点圈 提交于 2020-01-11 04:23:04
问题 I have a std::vector filled with objects. I want to filter and copy all the elements for which some predicate returns true in to a new std::vector . I've looked at find and search functions but they only return iterators. I'm using ObjC++ so I can use block functions as well as functors, if it helps. Can't use C++11 functions though. 回答1: If you have C++11 then use std::copy_if as suggested in Eugen's answer. Otherwise, you can use std::remove_copy_if with appropriate modifications to your