[Solved] Class method access by dot operator [duplicate]

NSMutableString.string is a hack. It “works” for the same reason that myString.length and [myString length] produce the same result. However, since dot notation is not used with an actual property, it is an abuse of the language feature, because properties have a different semantic. For example, when you access a property multiple times, you naturally … Read more

[Solved] Add objective c code to swift file [closed]

This is rough translation to Swift…no tested. // Define some colors. var darkGray: UIColor = UIColor.darkGrayColor() var lightGray: UIColor = UIColor.lightGrayColor() // Navigation bar background. UINavigationBar.appearance().barTintColor = darkGray UINavigationBar.appearance().tintColor = lightGray // Color of typed text in the search bar. var searchBarTextAttributes: [NSObject : AnyObject] = [NSForegroundColorAttributeName: lightGray, NSFontAttributeName: UIFont.systemFontOfSize(UIFont.systemFontSize())] UITextField.appearanceWhenContainedInInstancesOfClasses([UISearchBar.self]).defaultTextAttributes = searchBarTextAttributes // Color … Read more

[Solved] Creating a global multi dimensional array Swift 4 [closed]

Keep products as structures: struct Product { let id: Int let quantity: Int let price: Double } then define array: internal static var productArray = [Product]() and add your products. let product = Product(id: 1, quantity: 99, price: 1.99) productArray.append(product) internal static prefix lets you to reach the array throughout the app. However, I don’t … Read more

[Solved] how to does not record in sqlite if it is already in table [closed]

– (int) GetCount :(NSString *)UserID { [self createEditableCopyOfDatabaseIfNeeded]; [self initializeDatabase]; int count = 0; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@”dbfav2table.sqlite”]; if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) { sqlite3_stmt *statement; NSString *sql_str = [NSString stringWithFormat:@”SELECT count(*) FROM tablename WHERE userID=’%@'”, UserID]; const char *sqlStatement = (char … Read more

[Solved] How could I select music files in iOS app [closed]

See if below code works for you, Add ‘NSAppleMusicUsageDescription’ to your Info.plist for the privacy authority. Make sure your music is available in your iPhone. It will not work in the simulator. import UIKit import AVFoundation import MediaPlayer class ViewController: UIViewController, MPMediaPickerControllerDelegate { var musicPlayer: AVAudioPlayer? var pickerVC: MPMediaPickerController? var mediaItems = [MPMediaItem]() let currentIndex … Read more

[Solved] Xcode: Set a button background image to change everytime the button is pressed

Follow this sample logic .This may be useful for you. -(void)viewDidLoad{ isCount = 0; // int value. UIImage * image1 = [UIImage imageNamed:@”SampleImage1.png”]; UIImage * image2 = [UIImage imageNamed:@”SampleImage2.png”]; UIImage * image3 = [UIImage imageNamed:@”SampleImage3.png”]; UIImage * image4 = [UIImage imageNamed:@”SampleImage4..png”]; UIImage * image5 = [UIImage imageNamed:@”SampleImage5.png”]; UIImage * image6 = [UIImage imageNamed:@”SampleImage6.png”]; UIImage * … Read more

[Solved] Xcode 8: fix for error (has no member ‘backgroundColor’) [closed]

You should get the outlet of the buttons to edit its properties. What you have got is a action of that button for the a particular event like touchUpInside. You should get the Outlet of the button like this: @IBOutlet weak var sampleButton: UIButton! and then set the backgroundColor in the viewDidLoad() : sampleButton.backgroundColor = … Read more

[Solved] Multiple Unresolved Identifiers in Swift

Looks like you may have an extra curly bracket since the unresolved identifier means that it doesn’t know about the item specified at the location that it’s written. I think you have an extra curly bracket after the “Declare hide keyboard tap” block of code. Proofread your code for small mistakes like that. Usually when … Read more