Objective-C Programming

178

Solutions

208

Contributors

Objective-C is an object-oriented programming language that is a strict superset of C (any valid C code is equally valid Objective-C code), and it inherits its object-oriented capabilities from Smalltalk. All procedural syntax is identical to that of C, and all object-oriented syntax is an implementation of Smalltalk messaging. It is the main programming language used by Apple for OS-X and iOS and their respective APIs/ Objective-C inherits the syntax, primitive types, and flow control statements of C and adds syntax for defining classes and methods.

Share tech news, updates, or what's on your mind.

Sign up to Post

I am trying to add an action to a NSButton but it is not working

I create my NSButtton programmatically:

-(NSView *)rowTable:(CGFloat) heightOnPanel :(NSString *) textValue: (CGFloat) width: (CGFloat) height :(int) intColor{
    NSView *viewce = [[NSView alloc] initWithFrame:CGRectMake(0, heightOnPanel, 320, 40)];
    NSButton *layerBt = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, width, height)];

    [layerBt setTitle:textValue];

    [layerBt setButtonType:NSMomentaryPushInButton];
    [layerBt setTarget:nil];
    [layerBt setAction:@selector(buttonPressed:)];
    [viewce addSubview:layerBt];

    return viewce;
}

Open in new window



and here is IBAction method:


- (IBAction)buttonPressed:(id) sender{
    NSLog(@"hello world");
}

Open in new window


Could you point me to what I am missing?

Thanks
0
Starting with Angular 5
LVL 13
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

IOS app in swift
Single view controller with a table view. Project runs as it's supposed to. My question is: How do I move my table view down the page a bit so I can add some text above the table view? I think the answer is in this extension class so I'll post that first. Thanks!

Extension.swift
import UIKit

extension UIView {
    
    func anchor (top: NSLayoutYAxisAnchor?, left: NSLayoutXAxisAnchor?, bottom: NSLayoutYAxisAnchor?, right: NSLayoutXAxisAnchor?,  paddingTop: CGFloat, paddingLeft: CGFloat, paddingBottom: CGFloat, paddingRight: CGFloat, width: CGFloat, height: CGFloat, enableInsets: Bool) {
        var topInset =  CGFloat(0)
        var bottomInset = CGFloat(0)
        
        if #available(iOS 11, *), enableInsets {
            let insets = self.safeAreaInsets
            topInset = insets.top
            bottomInset = insets.bottom
            
            print("Top: \(topInset)")
            print("bottom: \(bottomInset)")
        }
        
        translatesAutoresizingMaskIntoConstraints = false
        
        if let top = top {
           self.topAnchor.constraint(equalTo: top, constant: paddingTop+topInset).isActive = true
        }
        if let left = left {
            self.leftAnchor.constraint(equalTo: left, constant: paddingLeft).isActive = true
        }
        if let right = right {
            rightAnchor.constraint(equalTo: right, constant: -paddingRight).isActive = true
        }
        if let bottom = bottom {
       

Open in new window

0
IOS project using swift
On my story board I have a launch screen that is the entry point. Now I want another view controller, I drag a view controller onto the storyboard. I create a cocoa touch class that is a subclass of UIViewController, naming it DTViewController. On storyboard, I select my new view using the left most icon on the top of the view and go to custom class. I select DTViewController as my custom class.  To stop warnings about my view being unreachable I check "Use StoryboardID" and enter MyDeskTop as the Storyboard ID. I drag a label onto the new view.

I have the following code in AppController.swift
private func handleAppState(){
if let user = Aut.auth().currentUser{
let vc = DTViewController()
rootViewController = NavigationController(vc)
} else {
rootViewController = LoginViewController()
}
}

Open in new window


When I run the app the splash screen appears and then the DTViewController appears. The problem is it's not picking up on the View in the Storyboard, just the DTViewController class. My evidence is the label doesn't show up but if I change the background color in code in DTViewController the change shows.

What am I doing wrong?
Thanks!
0
im facing issue in the encryption and decryption on ios im not able to decrypt the  encrypted data given by .net and here encrypted data given by me is decrypted by the .net
0
Is there any 3rd party libraries? I have to create different radio button as shared screenshot and the text field data will changed as clicked by user and while final submitting all data will stored on dB and Also payment will be done by only one method.
Screen-Shot-2017-10-27-at-12.29.55-P.png
0
Filelist like:
/Users/Utilizator/Documents/sample.sh

Open in new window

Many things, but no results (
0
So I would like to make this program read a user inputted matrix instead of the one that is provided in the main function. Also, the limit to the 2d matrix should be more than 9, but no more than about 100 and should also be user defined.

The main function purpose that I had in mind would be something like:
int main(){
    int graph[V][V];
  printf("Enter number of towns: ");
  scanf("%d", V);
  printf("Enter distance matrix");
  scanf("%d", graph[V][V]);
  dijkstra(graph, 0);
return 0;}

Open in new window

which is giving me a great headache trying to write.. Any help would be greatly appreciated. Thank you.


// A C / C++ program for Dijkstra's single source shortest path algorithm.
// The program is for adjacency matrix representation of the graph
  
#include <stdio.h>
#include <limits.h>
  
// Number of vertices in the graph
#define V 9
  
// A utility function to find the vertex with minimum distance value, from
// the set of vertices not yet included in shortest path tree
int minDistance(int dist[], bool sptSet[])
{
   // Initialize min value
   int min = INT_MAX, min_index;
  
   for (int v = 0; v < V; v++)
     if (sptSet[v] == false && dist[v] <= min)
         min = dist[v], min_index = v;
  
   return min_index;
}
  
// A utility function to print the constructed distance array
int printSolution(int dist[], int n)
{
   printf("Vertex   Distance from Source\n");
   for (int i = 0; i < V; i++)
      printf("%d \t\t %d\n", i, dist[i]);
}
  
// Funtion that 

Open in new window

0
i am using turbo c++ in my pc and the cursor has an issue that when i type the code and i have to enter a line in my typed code then the cursor simply moves to next line instead of adding a line .Moreover on doing any sort of correction in data like adding some new words in a particular line then the succeeding words get erased instead of shifting...
0

Objective-C Programming

178

Solutions

208

Contributors

Objective-C is an object-oriented programming language that is a strict superset of C (any valid C code is equally valid Objective-C code), and it inherits its object-oriented capabilities from Smalltalk. All procedural syntax is identical to that of C, and all object-oriented syntax is an implementation of Smalltalk messaging. It is the main programming language used by Apple for OS-X and iOS and their respective APIs/ Objective-C inherits the syntax, primitive types, and flow control statements of C and adds syntax for defining classes and methods.

Top Experts In
Objective-C Programming
<
Monthly
>

No Top Experts for this time period. Answer questions to earn the title!