c++


convert c++ vector to Objective-c


I currently have
vector<vector<cv::Point>> example;
and want to be able to pass it to a swift function, So I assume I should start by making it like this (or is there easier way?):
NSArray[NSArray[Int,Int]]
cv::Point is an object of two int properties.
I have tried
NSMutableArray *example1[example.size()];
for(i = 0;i< example.size();i++){
if(example[i].size() > 5){ //irrelevant
NSMutableArray *second[example[i].size()];
for(int p = 0;p<example[i].size();p++){
NSInteger p1 = example[i][p].x;
NSInteger p2 = example[i][p].y;
NSInteger point[2] = {p1,p2};
[second addObject: point];
}
[example addObject: second];
}
}
I have been spending ages and constantly getting different data type errors, etc. How would you do it, or correct this?
Thanks
You can use NSValue to store a simple struct into NSMutableArray:
NSMutableArray *example1 = [NSMutableArray arrayWithCapacity:example.size()];
for(int i = 0;i< example.size();i++){
if(example[i].size() > 5){ //irrelevant
NSMutableArray *second = [NSMutableArray arrayWithCapacity:example[i].size()];
for(int p = 0;p<example[i].size();p++){
NSValue *point = [[NSValue alloc] initWithBytes:&example[i][p] objCType:#encode(cv::Point)];
[second addObject:point];
}
[example1 addObject:second];
}
}

Related Links

Reading Credentials file fails with error 32
The mechanism of shared_ptr
C++ specialized function template
Compiler errors with cmath on Mac OS X
Array of fstream in C++
Error: (E107) bind interface to port failed: interface already bound to port: port 'MC8051_ALU().AM.port_27' (sc_in)
Error LINK2019 when I try to make a training for face detection [duplicate]
Quickest way to iterate in a C++ vector
How can I use snmp++ to enable/disable a switch port?
i wan't to use char* in this code instead of string how? [closed]
Using inRange() in OpenCV to detect colors in a range
The string.h 's function does not work in C++ but string does [on hold]
How to efficiently insert/merge into thrust::device_vector?
Change to transparent rectangle
Why addDays not working? [on hold]
OpenGL or GLFW renders ok only when moving the window

Categories

HOME
github
phpunit
bloomberg
zurb-foundation
powerbuilder
linux-device-driver
binary
visual-foxpro
purescript
javacard
url-rewriting
protege
slim
jspdf
httpresponse
video-processing
codecvt
watchkit
pixel
web-component
cpu-registers
jquery-animate
nattable
sitefinity
navigation-drawer
z80
pywavelets
lwip
jquery-ui-autocomplete
infowindow
slamdata
artoolkit
submenu
initializing
gobject
mapped-drive
khan-academy
falcor
google-truth
xunit.net
case-sensitive
dependency-properties
fuzzy
docker-registry
angularjs-service
vqmod
istanbul
voxel
jake
local-variables
z-order
ilmerge
jodconverter
virtual-directory
page-load-time
timedelta
nibble
grid-layout
oslo
cts
jquery-widgets
sparklines
eclipse-emf-ecore
pdl
sqlsrv
android-context
wordpress-4.5
sql-server-2008-express
ekeventstore
drilldown
treenode
interspire-shopping-cart
kismet-wireless
componentone
runscope
cxf-client
hasp
activator
commission-junction
rounded-corners
jbossws
stackmob
tandem
perl-critic
cvxopt
amber-smalltalk
xadisk
emacs-dirtree
strtotime
icefaces-1.8
ejbql
static-array
grit
objectiveflickr
springmockito
pubchem
scopes
layar
tunneling
windows-live-writer
test-environments
vtl
nscoder
windows-2000
asp.net-mvc-2-validation
html-rendering
moss2007enterprisesearch
laconica
google-notebook
maintaining-code
o3d

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile