objective-c++

UIView subclass ignores second touch

浪尽此生 提交于 2020-01-07 06:47:40
问题 I'm making an iOS game, and I've written a UIView subclass that's supposed to catch touch events, and it works as intended for a single touch. However, if I'm already touching the screen with one finger then touch it with a second finger elsewhere, "touchesBegan" doesn't get called for the second touch. Here's the implementation of the class: (Objective-C++) #import "BATouchInput.h" #include "BotsApp.h" @implementation BATouchInput - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *

Trouble with Objective-C++ and Interface Builder

ぃ、小莉子 提交于 2020-01-06 15:10:14
问题 My view controller class utilizes an Objective-C++ class. I discovered that I must name it with an .mm extension for C++ imports/includes to work properly. However, I am using Interface Builder, and it does not want to play nicely with my view controller being a .mm file. I get compiler segmented errors. Any suggestions for such a use case? 回答1: First, as Akaru suggested in one of his comments: rename all implementataion files imported to the .mm (entire chain). Another possibilities of

Objective C and Objective C++

痴心易碎 提交于 2020-01-05 08:19:09
问题 C files can be modified from .c to .m files and can be called from other Objective C files ( .m files). C++ files can be modified from .cpp to .mm files and can be called from other Objective C++ files ( .mm files). .m files can be called from .mm files . But .mm files cannot be called from .m files . Is Objective C++ coding necessary in iPhone development as UI will be in Objective C and any other protocols implemented can't be Objective C++ as this (protocols written) will be called from

Cocoa Socket Programming NSInputStream read returns 0

拟墨画扇 提交于 2020-01-03 04:45:13
问题 In my App, have setup the stream like this, (void)connectStream:(NSString *)pHostName PortNo:(int)inPortNo HasInput:(bool)bInput HasOutput:(bool)bOutput{ NSHost *host = [NSHost hostWithName:pHostName]; //host = [NSHost hostWithAddress:pHostName]; [NSStream getStreamsToHost:host port:inPortNo inputStream:&pInputStream outputStream:&pOutputStream]; [pInputStream retain]; [pOutputStream retain]; [pInputStream setDelegate:self]; [pOutputStream setDelegate:self]; bool bUseSSL = YES; if (bUseSSL) {

boost::shared_ptr in Objective-C++

依然范特西╮ 提交于 2020-01-02 09:27:23
问题 This is a better understanding of a question I had earlier. I have the following Objective-C++ object @interface OCPP { MyCppobj * cppobj; } @end @implementation OCPP -(OCPP *) init { cppobj = new MyCppobj; } @end Then I create a completely differently obj which needs to use cppobj in a boost::shared_ptr (I have no choice in this matter, it's part of a huge library which I cannot change) @interface NOBJ -(void) use_cppobj_as_shared_ptr { //get an OCPP obj called occ from somewhere.. /

How much of C++ is supported in Objective-C++

≯℡__Kan透↙ 提交于 2020-01-01 10:12:27
问题 I want to make an iPhone app, but I am planning to make the framework in C++. Is it possible to use things like templates in Objective-C++. I guess really the question is, can I use boost? 回答1: All of C++ is supported in Objective C++. It should be possible to use boost, but you might have to port some of the platform dependant things. 回答2: Is it possible to use things like templates in Objective-C++. Yes, but you need to take care how you mix types and interfaces between the pure C++ layers

How much of C++ is supported in Objective-C++

我的梦境 提交于 2020-01-01 10:11:41
问题 I want to make an iPhone app, but I am planning to make the framework in C++. Is it possible to use things like templates in Objective-C++. I guess really the question is, can I use boost? 回答1: All of C++ is supported in Objective C++. It should be possible to use boost, but you might have to port some of the platform dependant things. 回答2: Is it possible to use things like templates in Objective-C++. Yes, but you need to take care how you mix types and interfaces between the pure C++ layers

Import .CPP files from a working iOS project and rename to .mm issue

拟墨画扇 提交于 2019-12-31 05:59:07
问题 I have copied a .CPP and its .h file from a working project to a new one. I renamed the ending from .CPP to .mm but it still gives me errors. In the .h file, near the class definition class MeterTable , it says it expect the ; In the .mm file, there are all kinds of errors. I thought by changing the ending of the implementation file .mm it would clean all those errors. And yes, the original .CPP file compiled under the old project. 回答1: Looks like you're including that .h file into some other

Import .CPP files from a working iOS project and rename to .mm issue

佐手、 提交于 2019-12-31 05:58:04
问题 I have copied a .CPP and its .h file from a working project to a new one. I renamed the ending from .CPP to .mm but it still gives me errors. In the .h file, near the class definition class MeterTable , it says it expect the ; In the .mm file, there are all kinds of errors. I thought by changing the ending of the implementation file .mm it would clean all those errors. And yes, the original .CPP file compiled under the old project. 回答1: Looks like you're including that .h file into some other

How to add an observer to NSNotificationCenter in a C++ class using Objective-C++?

一曲冷凌霜 提交于 2019-12-30 09:41:54
问题 Hey guys I have a C++ class that I recently renamed from *.cpp to *.mm to support objective-c. So I can add the following objective-c code. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationHandler:) name:@"notify" object:nil]; How do/Can I write the notificationHandler method in c++? Will setting addObserver:self property work? 回答1: You'd need an Objective-C class to handle Objective-C notifications. Core Foundation to the rescue! In.. wherever you start