The iOS code that you have added in your question is perfectly correct for converting UIImage to Mat(Without making it Grayscale)....
input_image=imread(filename,1);
The above line of code is used to load image from filename(It is path of image) and 1 is used to make it grayscale,
so for, loading image from filename, in ios we uses it as:
UIImage *image=[UIImage imagenamed:@"Hello.png"];
and pass this image to your method will do your work, now for making grayscale Mat, Make following changes in your code as:
Replace following lines:
CGColorSpaceRef colorSpace = CGImageGetColorSpace(image.CGImage);
cv::Mat cvMat(rows, cols, CV_8UC4);
With
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
cv::Mat cvMat = cv::Mat(rows, cols, CV_8UC1);
and add this line at end
CGColorSpaceRelease(colorSpace);