Push new node in firebase if not

Here is my data structure

At the top I have company id, and then I have client id, and then I have time stamp, and then I have data, so I want to check if this company identifier is present. I want to add a new client to this company, if there is no company identifier, I want to add a new node with a similar image above. what am i doing here. Every time he adds a new node

LoginResponse *loginResponseObj = [Utililities loadLoginResponseObjectWithKey:LOGIN_RESPONSE_KEY_FOR_USERDEFAULT];
NSMutableDictionary *dataDict = [NSMutableDictionary dictionary];
[dataDict setValue:[NSNumber numberWithFloat:[LocationManager sharedManager].location.coordinate.latitude] forKey:@"lat"];
[dataDict setValue:[NSNumber numberWithFloat:[LocationManager sharedManager].location.coordinate.latitude] forKey:@"lng"];

NSMutableDictionary *timeStampDict = [NSMutableDictionary dictionary];
NSTimeInterval timeInSeconds = [[NSDate date] timeIntervalSince1970];
[timeStampDict setValue:dataDict forKey:[NSString stringWithFormat:@"%.0f",timeInSeconds]];
NSMutableDictionary *fcmDict = [NSMutableDictionary dictionary];
[fcmDict setValue:timeStampDict forKey:loginResponseObj.workerInfo.fcmId];

NSMutableDictionary *companyDict = [NSMutableDictionary dictionary];
[companyDict setValue:fcmDict forKey:[NSString stringWithFormat:@"%.0f",loginResponseObj.workerInfo.companyId]];

[[self.ref child:[NSString stringWithFormat:@"%.0f",loginResponseObj.workerInfo.companyId]]setValue:companyDict];
+4
source share
2 answers

I had a similar problem and found in the project code, for example:

[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];

I just deleted it.

+3
source

, , .

, : -

if(@available(iOS 11, *)) {
   [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]} forState:UIControlStateNormal];
   [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]} forState:UIControlStateHighlighted];

} else {
   [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-60, -60) forBarMetrics:UIBarMetricsDefault];
}

0

Source: https://habr.com/ru/post/1684195/


All Articles