objective-c-2.0

__strong and __weak keyword placement - Objective-C

◇◆丶佛笑我妖孽 提交于 2020-02-13 02:25:50
问题 The compiler seems to have no problem with the two following declarations: NSObject * __weak weakThing; __weak NSObject *anotherWeakThing; Is there a difference between the two? Is the behavior like the const keyword? I ask because Xcode's warning generally suggest ... SomeDataType * __weak / __strong ... when you've goofed something up. So I've tried to follow this pattern, but wondered if there was a difference at all. 回答1: No, there is no difference. With the const keyword, there are

__strong and __weak keyword placement - Objective-C

耗尽温柔 提交于 2020-02-13 02:25:29
问题 The compiler seems to have no problem with the two following declarations: NSObject * __weak weakThing; __weak NSObject *anotherWeakThing; Is there a difference between the two? Is the behavior like the const keyword? I ask because Xcode's warning generally suggest ... SomeDataType * __weak / __strong ... when you've goofed something up. So I've tried to follow this pattern, but wondered if there was a difference at all. 回答1: No, there is no difference. With the const keyword, there are

Core plot-Add OutOfRange to draw graph that changes dynamically with label “OL”

梦想的初衷 提交于 2020-01-06 15:59:11
问题 Currently I am working on already established application which uses Core plot and in specific its using ScatterPlot to draw a graph. This graph is drawn with values obtained from connected bluetooth device so the graph is dynamically drawn. XY graph with X axis having time value and Y axis having value from BLE device. Now the requirement is to add an out of range value with a label "OL" in the graph and its not a fixed constant value for the bluetooth device(Its more of a state set in model

How to get indexPath from one class to another

懵懂的女人 提交于 2020-01-06 15:15:58
问题 I have an app where my primary view is a tableview. where each cell loads another view containing certain data. Now, each cell is different so the data in the view loaded by each cell should be different. For that I need the indexPath. I've created a class for the TableView and another class for a simple UIView. How do I forward the indexPath value from one class to the other. Thanks in advance Nik 回答1: If I understand what you are asking you have a TableView (TableView1) in which each cell

Replacing nulls with empty string from JSON response not working in iOS

我与影子孤独终老i 提交于 2020-01-06 12:38:01
问题 I used below code to replace nulls from json response with empty string, but it is not working. Please help me out to fix this issue, i am getting nulls from server response in lot of scenarios and App crashes. Code: - (NSMutableDictionary *)recursive:(NSMutableDictionary *)dictionaryResponse { NSMutableDictionary *dictionary=[[NSMutableDictionary alloc]initWithDictionary:dictionaryResponse]; for (NSString *key in [dictionary allKeys]) { id nullString = [dictionary objectForKey:key]; if (

Replacing nulls with empty string from JSON response not working in iOS

久未见 提交于 2020-01-06 12:37:01
问题 I used below code to replace nulls from json response with empty string, but it is not working. Please help me out to fix this issue, i am getting nulls from server response in lot of scenarios and App crashes. Code: - (NSMutableDictionary *)recursive:(NSMutableDictionary *)dictionaryResponse { NSMutableDictionary *dictionary=[[NSMutableDictionary alloc]initWithDictionary:dictionaryResponse]; for (NSString *key in [dictionary allKeys]) { id nullString = [dictionary objectForKey:key]; if (

Best practice on using @property ivars

半世苍凉 提交于 2020-01-04 20:21:32
问题 Could someone share some knowledge on whats best practice / code convention on using @property iVars in init methods or designated initializers? please see my example: @interface MyClass () @property(nonatomic,strong) nsstring *tempString; @property(nonatomic,strong) NSMutableArray *arrItems; @end @implementation ViewController - (id)init { if (self = [super init]) { //Is this best practice / correct _tempString = @""; _arrItems = [[NSMutableArray alloc] initWithCapacity:0]; ... ... //Or this

Best practice on using @property ivars

馋奶兔 提交于 2020-01-04 20:20:53
问题 Could someone share some knowledge on whats best practice / code convention on using @property iVars in init methods or designated initializers? please see my example: @interface MyClass () @property(nonatomic,strong) nsstring *tempString; @property(nonatomic,strong) NSMutableArray *arrItems; @end @implementation ViewController - (id)init { if (self = [super init]) { //Is this best practice / correct _tempString = @""; _arrItems = [[NSMutableArray alloc] initWithCapacity:0]; ... ... //Or this

Error compiling tweak in theos

泄露秘密 提交于 2019-12-29 04:57:06
问题 I set a simple tweak using theos following the tutorial here. However when I run make with the headers from here, I get Making all for tweak WelcomeWagon... Preprocessing Tweak.xm... Compiling Tweak.xm... In file included from Tweak.xm:1: /opt/theos//include/SpringBoard/SpringBoard.h:7:26: error: UIApplication.h: No such file or directory cc1objplus: warnings being treated as errors In file included from /opt/theos//include/SpringBoard/UIApplicationDelegate-Protocol.h:7, from /opt/theos/

UIApplication sharedAppication error: program seems to be accessing wrong file

…衆ロ難τιáo~ 提交于 2019-12-25 01:34:30
问题 in my MainViewController implementation, I need to access variables from two different classes. one of the classes is the AppDelegate and the other is the FlipsideViewController. the way I accessed these was through this code: -(void)someMethod { MyApplicationAppDelegate *appDelegate = (MyApplicationAppDelegate *)[[UIApplication sharedApplication] delegate]; FlipsideViewController *viewController = (FlipsideViewController *)[[UIApplication sharedApplication] delegate]; then I have an array I