[Solved] Determining the type of an iOS device in Xcode [duplicate]

[ad_1] – (NSString *) IphoneModel { size_t size; sysctlbyname(“hw.machine”, NULL, &size, NULL, 0); char *machine = (char*)malloc(size); sysctlbyname(“hw.machine”, machine, &size, NULL, 0); NSString *platform = [NSString stringWithCString:machine encoding: NSUTF8StringEncoding]; free(machine); if ([platform isEqualToString:@”iPhone1,1″]) return @”iPhone 1G”; if ([platform isEqualToString:@”iPhone1,2″]) return @”iPhone 3G”; if ([platform isEqualToString:@”iPhone2,1″]) return @”iPhone 3GS”; if ([platform isEqualToString:@”iPhone3,1″]) return @”iPhone 4″; if … Read more

[Solved] Multiple Arrays in Multiple UITableViewCell [closed]

[ad_1] you can Add value from different array in different cell like bellow.. Also i add controls in UITableCell for just an example which through you can add multiple controls in the cell with frame.. – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* cellIdentifier = @”gridCell”; UITableViewCell *yourCell = [tableView dequeueReusableCellWithIdentifier:nil]; if(yourCell == nil) … Read more

[Solved] How to read formatted string from a text file?

[ad_1] ok so this is how I did it … I just used the fact that ObjC is a superset of C char personName[256]; char imgFilename[512]; int personNumber; NSArray *array = [outputString componentsSeparatedByString:@”\n”]; int lines = [array count]; FILE *file = fopen([filePath UTF8String],”r”); for (int i = 0; i<lines; i++) { fscanf(file,”%d %s %s”,&personNumber, personName, … Read more

[Solved] SwiftUI – how to observe(.sink/ .onReceive) PassthroughSubject inside a View [closed]

[ad_1] If you have a Struct as Model or ViewModel and you need to update your SwiftUI View here it is how to do just that with SwiftUI + Combine. import Combine struct ViewModel { var textChangedPublisher: AnyPublisher<String, Never> { textChangedSubject.eraseToAnyPublisher() } private let textChangedSubject = PassthroughSubject<String, Never>() func triggerUpdate() { let newStr = DateFormatter().string(from: … Read more

[Solved] How to pass NSUInteger into NSDictionary

[ad_1] You can use NSNumber class for doing the same: NSDictionary *parameters = @{@”index”:[NSNumber numberWithUnsignedInteger:indexPath.row]}; Or in Modern Objective C: NSDictionary *parameters = @{@”index”:@(indexPath.row)}; 0 [ad_2] solved How to pass NSUInteger into NSDictionary

[Solved] How to send data to the server(api) using swift

[ad_1] you can send data to server by using Alamofire API. It’s documention and implemention all the stuff are mentioned in the following link. https://github.com/Alamofire/Alamofire Just install it using Pods and it’s very easy to implement. create Network Class and create following function inside it. func get_Request(currentView : UIViewController,action : NSString,completionHandler: (NSDictionary -> Void)) { … Read more

[Solved] Why is this out of index?

[ad_1] Not sure what this is: var mainController = ViewController() var movie = ViewController().self.movieArray[0] Regardless, ViewController() instantiates a new object of that class. At that point, it’s very likely movieArray has never been initialized and has no objects in it. 5 [ad_2] solved Why is this out of index?

[Solved] How to change text color in tableView section in swift

[ad_1] override func tableView(tableView: UITableView!, viewForHeaderInSection section: Int) -> UIView! { var customView:UIView? customView.frame = // set frame according to tableview width and header height customView.backgroundColor = UIColor.greenColor() return customView } Hope this will help you. [ad_2] solved How to change text color in tableView section in swift

[Solved] Add 1 Day to a Date [closed]

[ad_1] The most reliable way to get the next occurrence of a time is nextDate(after:matching:matchingPolicy: of Calendar because it considers also daylight saving changes. assuming datePicker is the NSDatePicker instance: let date = datePicker.date let calendar = Calendar.current // get hour and minute components of the given date let components = calendar.dateComponents([.hour, .minute], from: date) … Read more

[Solved] While decoding json from webservice, it shows an error: Could not cast value of type ‘__NSArrayM’ (0x10b84bdb0) to ‘NSDictionary’ (0x10b84c288)

[ad_1] Try this var desriptionArray = [String]() for dataValues in responseObject[“result”] as! [[String: AnyObject]] { let name = dataValues [“description”] as! String desriptionArray .append(name) } OR for (index , element) in (responseObject[“result”] as! [Any]).enumerated() { let nameDict = element as! [String : AnyObject] let strDecription = nameDict[“description”] as! String desriptionArray .insert(strDecription, at: index) } [ad_2] … Read more

[Solved] Textfield values set to empty when coming back from previous view controller [closed]

[ad_1] When you push back to the origin viewController, It’s better to replace using “push” Segue by “popViewController” method . It’s also good using data consistent strategy. And the reason: You should consider the viewController’s lifecycle. When you push back to the origin viewController, using “push” Segue makes the origin viewController’s “viewDidLoad” method is called … Read more