xcode,cocoa,netfs , Mount SMB drive in Xcode using cocoa and objective-c

Mount SMB drive in Xcode using cocoa and objective-c


Tag: xcode,cocoa,netfs

I am trying to build a little app to log into an SMB network drive, but I can't get anything to work for doing the actual connecting. Anyone have any experience with NetFSMountURLAsync? Or even better, an example?


If you are having trouble, I'd start with the Sync version:

let serverPath = NSURL(string: "smb://yourserverpath/share")! as CFURL
let mountPath = NSURL(string: "/localmountpointyouwanttouse_shouldalreadyexist_ifnot_create_it_before")! as CFURL
let mountOptions = NSMutableDictionary(dictionary: ["MountAtMountDir": false]) as CFMutableDictionaryRef
NetFSMountURLSync(serverPath, mountPath, nil, nil, nil, mountOptions, nil)

if you want to use the default mount point, just pass nil in there as well.

NetFSMountURLSync(serverPath, nil, nil, nil, nil, mountOptions, nil)

really it should work even if you only pass in the serverPath. I only included the mountOptions so you have an example if you needed to set any.

NetFSMountURLSync(serverPath, nil, nil, nil, nil, nil, nil)

The 3rd and 4th arguments are user and pass, which you can supply if you don't want the OS to handle that part.


Transferring an Xcode project to another computer with all files/frameworks

I am trying to copy over my Xcode project from one computer to another but it seems to lose frameworks and the locations for the images although i copied those too. PS I am using xcode and coding an app with a friend. Is there a useful source that can...

SKEmitterNode particles lag at start

I'm playing around with SKEmitterNode in my own little game. I'm shooting a cannon ball and when the ball hits one of the boxes in the scene, the box gets destroyed and a particle effect with a simple texture "BOOM" is created to make a transition when the box disappears....

PFUser not unwrapped - swift

I'm beginning to learn swift with parse and i've run into this error: "Value of optional type 'PFUser?' not unwrapped; did you mean to use '!' or '?' I can't seem to get it to work... PFFacebookUtils.logInWithPermissions(["public_profile", "user_about_me", "user_birthday"], block: { user, error in if user == nil { println("the...

Cursor doesn't update in NSTextField as it autoresizes when resizing the enclosing NSWindow

I have an NSTextField that autoresizes. Its text is centered. When I start typing in the field and then resize the enclosing NSWindow, the cursor stays where it's at rather than repositioning to the appropriate place : I've also made an XCode project demonstrating this problem : https://www.dropbox.com/sh/cohhmslyl9ti43b/AAC6ULteopsQCMDsEArJU15Ta?dl=0 Does anyone...

How do I make is so the entered number is mulitplied by the slider number

So, I've created an iOS app that multiplies the entered number by the number that's in the slider. Please forgive my ignorance, but as you can tell, I'm just learning. The section where the user enters their number is the multiplier text field. I tried to convert it to an...

control may reach end of non-void function xcode

I have a third party library code segment which has the following structure: class A; A func() { if(...) { return A(...); } else if(...) { return A(...); } else { LOG(...); } } And it gives the error "control may reach end of non-void function" in Xcode. The same...

UIView within a container view not showing

I couldn't get the blue rectangle view to show. IT is currently the subview of the grey view and has vertical/horizontal constraints. I don't have enough "reputations" to post images so heres the link to the screenshot: http://imgur.com/gallery/KCFA1O6/new Thanks....

Swift error: Could not find an overload for '<' that accepts the supplied arguments

if (password.utf16 > 5) { var alert = UIAlertView(title: "Invalid", message: "Password must be greater then 5", delegate: self, cancelButtonTitle: "OK") alert.show() } i used the code as above and i got the error message : Could not find an overload for '<' that accepts the supplied arguments. may i...

Unexpected NSWindow becomes key window

I have a main NSWindow in my application with a button. When the button is pressed it does something like the following: NSWindow *newWindow = [NSWindow initWithContentRect:[screen frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; [newWindow makeKeyAndOrderFront:self]; [self.previousWindow orderOut:self]; This works fine most of the time, but if I have a second window open...

Is it possible to obtain an unique iCloud user ID on cocoa?

My iOS app is currently on beta in TestFlight, and as a way to retribute to the nice people who helped me test it I would like to offer them some goodies such as, for instance, the full final version of the app for free. For this, I was thinking...

Running app from console gets CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 8.1'

I am trying to run an iOS app from the console executing the following command: xctool/xctool.sh -workspace Supermaxi.xcworkspace -scheme Supermaxi build and I am getting this response [Info] Loading settings for scheme 'Supermaxi' ... (11036 ms) === BUILD === xcodebuild build Supermaxi Pods / Pods-FunctionalTests-KIF (Debug) ✓ Check dependencies (379...

How can I display the time offset (years, months, weeks, …) from two dates at my labels?

I am getting Use of unresolved identifier 'self' in my app. After reading this link, I wrapped the code in a class. Note: I am using an extension I got from this answer at S.O. class SetDate { var seconds = date2.secondsFrom(date1) var minutes = date2.minutesFrom(date1) var hours = date2.hoursFrom(date1)...

New warnings in iOS9

I have this new warning about the Google Framework in my app: (null): URGENT: all bitcode will be dropped because '/Users/myname/Library/Mobile Documents/com~apple~CloudDocs/foldername/appname/GoogleMobileAds.framework/GoogleMobileAds(GADSlot+AdEvents.o)' was built without bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. Note:...

NSPredicate crash with path which contains square brackets

I have to search paths which contains square brackets in it from core data. But when I trying to create search query like below, xcode crashes. path == /my/local/[path] I've tried to escape square brackets, from one brackets to 16 brackets, but nothing works. That path is from another application,...

Xcode referencing old copies of files

Changes I've been making to code in certain files are being ignored by Xcode. I've traced it to the fact that Xcode is keeping its own older version of the code files somehow... these older/duplicate files are not shown anywhere in the Finder window for the project's folder and persist...

Turn a switch Off or On on the basis of another switch state

How can I turn a switch off inside a different switch? Here's an example - When the isMale switch is turned on, turn off the isFemale switch. - (IBAction)isMale:(id)sender { if ([sender isOn]) { //TURN isFemale SWITCH OFF } else { ... } } and - (IBAction)isFemale:(id)sender { if ([sender...

Objective C - bold and change string text size for drawing text onto pdf

I've created a .xib file with a uiview solely for the pdf document that I have created. I've primarily followed this tutorial for code: http://www.raywenderlich.com/6818/how-to-create-a-pdf-with-quartz-2d-in-ios-5-tutorial-part-2 From the above, I can't edit labels (plain or attributed) from the interface builder as even after changing size, it doesn't apply when the app...

Coco2dx - Changing To Background Image

I need someone's help. Actually I have no idea what to replace to get a custom background image. I'm just can't do it anymore. -(id) init { // always call "super" init // Apple recommends to re-assign "self" with the "super's" return value if( (self=[super initWithColor:ccc4(219,31,94, 999)]) ) { ws=[[CCDirector...

When trying to get dynamically created UILabel to wrap, text disappears

I'm trying to display some description text that varies from a couple of words to a hundred words. I've set my UILabel to wrap to compensate using the code below descText.frame = CGRect(x: 115, y: 160, width: 465, height: 21) descText.textAlignment = NSTextAlignment.Left descText.numberOfLines = 0 descText.lineBreakMode = NSLineBreakMode.ByWordWrapping descText.sizeToFit()...

TableViewCell overlaps text

I'm having a problem with my TableViewCell I have two type of cell in my storyboard. when i scroll, the text overlaps in some cells. I Try everything but I do not know how else to do. thank you very much for the help public func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath:...

UITapGestureRecognizer sender is the gesture, not the ui object

I've got a button called and I gave it a UIGestureRecognizer so that an IBAction is only run when the button is long pressed. You do this by adding a UILongPressGestureRecognizer to the button iteself. Then you control drag that gesture recognizer to a function like this: @IBAction func handleGesture(sender:...

change Auto Layout dynamically

I have to show 3 Labels like LABEL1 | LABEL2 | Label3 //Horizontally I want these 3labels width are equally divided according to Screen size width How can I achieve this with nib file directly? Thanks Question 2 Label1 | Label2 | Lable3 //All Labels widths are equally //All Labels...

AFNetworking file upload

I'm trying to upload file with AFNetworking and it is working with iOS Simulator but not working Real devices, i tried 2 different way but same. Can some one help me to solve this issue please Thank you very much. this is first code NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask,...

AutoLayout complains about constraints for 2 UITextFields with no borders

I am trying to build my login view that has only 2 TextFields, and 2 buttons. I am applying the "Add Missing Constraints" property so that Xcode applies the corresponding constraints to all the elements in my LoginViewController in the storyboard. I am restricting my app to run only in...

Swift 2 : NSData(contentsOfURL:url) returning nil

I have a webpage address which contains a JSON file. I'm trying to access the JSON file as NSDictionary in Swift 2. Every time I call NSData(contentsOfURL:url!) where url is type of NSURL?, it returns nil. I'm using Xcode 7 Beta, and the project was first made in Xcode 6....

Initializing a xib view as a subview of another NSView

I'm trying to learn OSX development, and I've created a view in a .xib file, and I'm trying to initialize and then add this view as a subview. I've googled how to do this, and all of the solutions are for iOS and use a call such as MyViewClass* myViewObject...

Xcode UIWebView not changing page with changed URL

I'm automatically generating a NSURL based on the distance of a pan gesture on the screen (long story...). Anyways, I'm having no problem generating the URL. The URL dynamically changes, and then I have an NSTimer that repeats every second which tells a UIWebView to reload with the new URL....

Xcode + AWS Integration Apple Mach-O Linker Error

I have a very simple Xcode project that I started and am now trying to integrate the Amazon Web Service (AWS) SDK into my project. I followed the instructions posted on their instruction page and everything looks good EXCEPT that I've got the following output... duplicate symbol _OBJC_CLASS_$_XMLDictionaryParser in: /Volumes/Macintosh...

How to always show debug window in XCode6

I'm having trouble keeping my debug window open in XCode6. Every time I run the code the debug window disappears. I then have to press CMD SHIFT Y to show it again or use the upper right window icon. How do I make the debugger window stay at all times?

Command-Line Testing Using Cocoa Touch

I have developed several test for an application, and I would like to run this application using the command-line. I have read this tutorial; however, I haven't been able to run them. When executing the following command: xcodebuild test -project MyApplication.xcodeproj -scheme MyApplication -destination 'platform=iOS Simulator,name=iPhone 6' I am getting...

Xcode - Colours look different but should be the same

In my app, I am using the following color: #3D6D86 It is set to be a background color on a view controller and also to be the color for the navigation bar on a different view controller. However the problem is that the color appears different. I converted the hex...

UIWebView path depends on previous pressed button Xcode

I have a ViewController (A), containing n buttons. all buttons map to other ViewController(B) containing a WebView to show a different PDF. Instead of creating n ViewController, I would know how to change path according to which button was pressed. my wrong tries: 1- use tags of buttons in ClassB...

How do you work with views in MainMenu.xib?

I'm coming over from iOS development and I can't figure out this basic thing: if I open MainMenu.xib in Interface Builder and I drag a button onto the main window's view, what class should I connect that button's action to -- the App Delegate? If I want to add a...

Stop async operations on window close

In my app delegate I have put the callback to stop the program when the window is shut. func applicationShouldTerminateAfterLastWindowClosed(sender: NSApplication) -> Bool { return true } This doesn't work however because (I assume) there is an async bluetooth task running. What is the best way to stop everything running...

Why label still append 0 once press clear button “C”?

I am making calculator in swift. Functioning very well so far except the display which is UILabel. I want to get clear out display by pressing C button, for that I did this way inside clear() I wrote history.text ="\0" this is caused append 0 next time when press new...

Chance of a conditional occurring in Swift: Xcode

I am quite new to Xcode and swift so sorry if this is a bad description. Is there a way that there is a chance of your conditional occurring so instead of it happening 100% of the time when the conditions are met, it only happens 50% of the time...

Swift timer in milliseconds

I want to change the timer every millisecond but it doesnt work as expected. NSTimer.scheduledTimerWithTimeInterval(0.001, target: self, selector: Selector("advanceTimer:"), userInfo: nil, repeats: true); func advanceTimer(timer: NSTimer){ self.time += 0.001; let milliseconds = self.time * 100; let remaingMilliseconds = Int((milliseconds % 1000) / 10); let seconds = Int((milliseconds / 1000) %...

Can't figure out coder aDecoder: NSCoder

I'm making an app for archiving books, I'm at the point of hooking up a button to save the data, but I can't get past the initialisation. Here is the error Xcode is giving me : Property 'self.bookStore' not initialised at super.init call. And here is my code : import...

How can I fix crash when tap to select row after scrolling the tableview?

I have a table view like this: when the user tap one row, I want uncheck the last row and check the selected row. So I wrote my code like this: (for example my lastselected = 0) func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { var lastIndexPath:NSIndexPath = NSIndexPath(forRow: lastSelected, inSection:...

type casting in objective-c, (NSInteger) VS. integerValue

I don't very understand about the diference between (NSInteger)aNumberValue and [aNumberValue integerValue], then do some test. For example, here is a response data from server: You can see it's an int but the value is hold by NSNumber. I retrieve the data by writting NSInteger count = (NSInteger) dic[@"count"];, and...

How to get NSTableView to use a custom cell view mixed with preset cell views?

I have a NSTableView configured in Interface Builder which uses several default cell views. However the first column's cell view needs to be created from a custom class. How do I implement NSTableViewDataSource method tableView.viewForTableColumn() so that it creates the default cell views for the remaining columns? Here's my method...

How to use existing SQLite database in swift?

I know there are some resources available for this but none of them clearly show the way how to do it properly. I have already populated .sqlite database (MTrader.db) and i want to connect it to my swift project and load the data from the database into spinner. I tried...

Build error after I localized Info.plist

I localized Info.plist : And I got this build error : error: could not read data from '/Users/cherif/Apps/Wesh/Info.plist': The file “Info.plist” couldn’t be opened because there is no such file. Actually there are now two Info.plist files : fr.lproj/Info.plist Base.lproj/Info.plist How to localize the Info.plist path ?...

canEvaluatePolicy Extra argument 'error' in call Swift Xcode 7

I work with Xcode 7 with swift and I would use the Touch Id. Only I have a error when I use canEvaluatePolicy. I understand my error, I call an argument too. Only if I do not call, it makes me a error because I did not manage my error...

Read plist inside ~/Library/Preferences/

I'm trying to access in ~/Library/Preferences/ but my code doesn't work. NSString *resPath = @"~/Library/Preferences/"; NSError *error = nil; NSArray *filenames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:resPath error:&error]; if (!error) { for (NSString * filename in filenames) { NSLog(@"%@", filename); } } Maybe I should ask for some permission.. Any idea?...

Getting video from Asset Catalog using On Demand ressources

I attributed to my .mp4 video the "tokyo" tag for example, and set it as installed during the app installation. Now before I was using a Path to get it from my resources, now it's different because it's located on the Asset Catalog. After found documentations, I tried something like...

Put Swipe Gesture over UIWebView to Get Scroll Direction in IOS

I want to get the scroll direction in webView. I read the code about getting scroll direction here. -(void)userDidScrollWebView:(id)scrollPoint{ // NSLog(@"scrolled:::"); NSString *x1 = [webView stringByEvaluatingJavaScriptFromString: @"scrollX"]; NSString *y1 = [webView stringByEvaluatingJavaScriptFromString: @"scrollY"]; NSLog(@"scroll x=%@ y=%@", x1,y1); if ([y1 isEqualToString: @"0"]) { NSLog(@"RELAOD ME"); } } I have 2 Questions...

Change NSTextField border and BG color while editing

I have a NSTextField that uses no border and window background color while it is displayed but I want it to change to have the default border and white BG color when being edited. I know I can change these properties with: nameTextField.bezeled = true nameTextField.backgroundColor = NSColor.textBackgroundColor() What I...