Posts

Showing posts with the label objective-c

Creating a private 2D float array - Objective C

Creating a private 2D float array - Objective C I am tring to create a private 2D float array and initialize it in constructor. I am getting "Expected Expression" error. I searched for a long while and couldn't find anything. Here is my code: @interface SampleClass : NSObject{ @private float stops[2][2]; } @end @implementation SampleClass - (id) init{ self = [super init]; // Edited stops = { {1.0, 1.0}, {1.0, 2.0} }; // It gives "Expected Expression" at this line return self; } @end I tried different versions like: stops = { {1.0, 1.0}, {1.0, 2.0} }; stops = { 1.0, 1.0, 1.0, 2.0 }; stops = { {1.0, 1.0}, {1.0, 2.0} }; Non of them seems to work. I am new to Objective C so any recommendation is appreciated. Not related to the issue but you must call super in init . Take a look at init. – Willeke Jul 2 at 10:38 ...

React Native and Objective C delegates

React Native and Objective C delegates I am quite new to react native and and the bridging mechanism with native code, especially when the framework has delegates. Assume I am trying to bridge the following framework: @protocol BRPtouchNetworkDelegate; @class PLNetworkModule; @interface BRPtouchNetworkManager : NSObject <NSNetServiceBrowserDelegate,NSNetServiceDelegate> @property(retain, nonatomic) NSMutableArray* registeredPrinterNames; @property(assign, nonatomic) BOOL isEnableIPv6Search; - (int)startSearch: (int)searchTime; - (NSArray*)getPrinterNetInfo; - (BOOL)setPrinterNames:(NSArray*)strPrinterNames; - (BOOL)setPrinterName:(NSString*)strPrinterName; - (id)initWithPrinterNames:(NSArray*)strPrinterNames; - (id)initWithPrinterName:(NSString*)strPrinterName; @property (nonatomic, assign) id <BRPtouchNetworkDelegate> delegate; @end @protocol BRPtouchNetworkDelegate <NSObject> -(void) didFinishSearch:(id)sender; @end The following is the bridge module I implemented: ...

Is there a way to ask user for Camera access after they have already denied it on iOS?

Is there a way to ask user for Camera access after they have already denied it on iOS? I am using this code, but unfortunately it doesn't work. After a user has denied camera access, I want to ask them for permission to use the camera again the next time they try to load it (in this case it's a barcode scanner using the camera view). I always get AVAuthorizationStatusDenied and then granted always automatically returns NO even though I ask for it again in code. AVAuthorizationStatusDenied granted NO Many of my users are e-mailing me saying "my screen is black when I try to barcode scan" and it's because they have denied camera access for some reason. I want to be able to prompt them again because most likely the denial was a mistake. Is there a possible way to do this? AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; if(authStatus == AVAuthorizationStatusAuthorized) { NSLog(@"%@...

Unable to use Swift object's variables in Objective-C View Controller

Unable to use Swift object's variables in Objective-C View Controller I am facing a problem accessing variables of a class written in Swift from a view controller written in Objective-C. I have already created the Bridging Header and I have successfully sent the Swift object from a view controller written in Swift to another one written in Objective-C. The problem is that I want to access the variables of the object but I get the following error: Property 'variableName' cannot be found in forward class object 'className' . Here is the class which I am trying to access its variables: import Foundation import UIKit import SwiftyJSON @objcMembers class SwiftObject: NSObject { // MARK: - Variables var id: String var name: String var contact: SwiftSubObjectA var location: SwiftSubObjectB var categories: [SwiftSubObjectC] = // MARK: - Initializers init(withJSON json: JSON) { self.id = json["id"].stringValue self.na...