Objective-C Programming

173

Solutions

199

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

Hi Experts,

I am very new into iOS programming and I need your help.

I have a simple code in XCode that uses GET to send data to URL and I want to change this to a POST.

When I test the call, both methods work okay, but running from XCode on simulator, GET works okay but POST returns empty value.

AFHTTPRequestOperationManager returns success.

Here is the code for both:

- (IBAction)cmdTestGET:(id)sender {

    AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] init];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
   
    [manager GET:@"http://mytestwebsite/index_test.php"
      parameters: @{@"method":  @"Test_GET",
                    @"data":    @"Hello GET!"}
         success:^(AFHTTPRequestOperation *operation, id responseObject) {
             NSLog(@"JSON: %@", [responseObject description]);
         }
         failure:^(AFHTTPRequestOperation *operation, NSError *error) {
             NSLog(@"Error: %@", [error description]);
         }];
}

- (IBAction)cmdTestPost:(id)sender {
   
    AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] init];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
   
    [manager POST:@"http://mytestwebsite/index_test.php"
                parameters: …
0
Get HTML5 Certified
LVL 9
Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

I am a rookie with programming but wanted to delve into programming for Androids.  What language should i use?  or what development program.?  also, does this language translate to coding pretty well if i wanted to create the same app for ios.
any commentary would be greatly appreciated
0
I need to open my OS X application when any powerpoint presentation opens.
I got VBA call back when powerpoint open (Auto_Open()). But I need a call back for each presentation open.

 In windows we can open  each presentation in separate powerpoint app (difference instance).
In Mac , Powerpoint app will open once and all presentation will open under same powerpoint application .

I need a call back when each presentation file open and I need to do run code snippets in my cocoa application.
0
{
  "EmployeeApp": [
    {
      "id": "1",
      "name": "Mr.ABC",
      "email": "ABC@XYZ.COM",
      "address": "xxx",
      "hr_review": {
        "1": {
          "hr_name": "Mr. f r",
          "hr_id": "13",
          "hr_comment": "he is one of the nice employee for company",
        },
        "2": {
          "hr_name": "Mr. b c",
          "hr_id": "14",
          "hr_comment": "Takes pride in work and strives to improve work performance",
        }
      }
    },
    {
      "id": "2",
      "name": "Mr.PQR",
      "email": "PQR@XYZ.COM",
      "address": "xxx",
    "hr_review": {
        "1": {
          "hr_name": "Mr. f r",
          "hr_id": "13",
          "hr_comment": "Forms and required paperwork are completed on time with minimal errors.",
        },
        "2": {
          "hr_name": "Mr. b c",
          "hr_id": "14",
          "hr_comment": "Maintains good working relationships with coworkers",
        }
      }
    }
  ]
}

Open in new window

0
I created a OSX application which contains powerpoint slides and can add these slides to any existing powerpoint presentation. I am using applescript and vba script to add slides from my OSX application to powerpoint. In Powerpoint 2016 mac version it is asking for "Grand file Access" permission popup always when I am adding slides.

Is there any way to remove this popup programatically.
Screen-Shot-2016-09-30-at-11.51.00-A.png
Screen-Shot-2016-09-30-at-11.51.14-A.png
And some times it is not pointing to the correct file location, and at that time the "Grant Access" button is not enabled.

Please help me. Thanks in Advance.
0
I need to observe powerpoint actions in my OSX app.
Scenario: I need to perform some actions in my OSX application when user clicks on save button in PowerPoint. Is there any ways to to this. I have achieved this functionality in Windows application by VBA Macro Events, but in PowerPoint Mac version the VBA Macro Events are not supported.
Thanks in advance
Please help me
0
When working with reverse geocoding some address could be ambiguous for given location and the returned array of placemarks can contain multiple values (address gets multiple hits). This happens very rarely. Usually practice is to take first or last object from given array. So, I want to know why is this common practice. I've looked in Apple documentation and they also took object at index 0. Does the first object contains the most accurate address if the array of placemarks contains more than one object for given location (lat, long)? Thanks for your answers.
0
Hi,
Does 2nd line below scan through all Worksheet within Excel file? If not, how to adjust it to scan through all Worksheets, except one specific sheet with a given name?
                    Excel.Worksheet Worksheet0;
                        ...
                        foreach (Excel.Worksheet sheet in Book0.WorkbookPart.Workbook.Descendants<Sheet>().Where(s => s.Name == Worksheet0))

Open in new window

0
Hi,
How to correct this
Error	2	'DocumentFormat.OpenXml.Packaging.SpreadsheetDocument' does not contain a definition for 'WorksheetParts' and no extension method 'WorksheetParts' accepting a first argument of type 'DocumentFormat.OpenXml.Packaging.SpreadsheetDocument' could be found (are you missing a using directive or an assembly reference?)

Open in new window


due to 2nd line below?

                    SpreadsheetDocument Book0 = SpreadsheetDocument.Open(openFileDialog1.FileName, false);
                    WorksheetPart worksheetPart = Book0.WorksheetParts.First();

Open in new window

0
Hi,
How to correct
Error	2	The type or namespace name 'Packaging' does not exist in the namespace 'System.IO' (are you missing an assembly reference?)

Open in new window


due to this line?

using System.IO.Packaging;

Open in new window

0
Ready to get started with anonymous questions?
LVL 9
Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Hi,

It does take nearly 30 minutes to finish scanning these two sheets
https://app.box.com/s/zkm75d29hef82zct7bkw784iro8kmn64

using such codes
                    foreach (Excel.Worksheet sheet in Book0.Worksheets)
                    {
                        Excel.Range usedRange = sheet.UsedRange;

                        RowID++; Worksheet0.Cells[RowID, 1] = "^^^^" + sheet.Name + "^^^^"; RowID++;

                        foreach (Excel.Range row in usedRange.Rows)
                        {
                            RowID++;
                            for (int i = 0; i < row.Columns.Count; i++)
                                /*if (!string.IsNullOrEmpty(rowData[i]))
                                    j = 0;
                                else
                                    j++;*/

                                if (!string.IsNullOrEmpty(Convert.ToString(row.Cells[1, i + 1].Value2)))
                                {
                                    Worksheet0.Cells[RowID, i + 1] = row.Cells[1, i + 1].Value2;
                                    Worksheet0.Cells[RowID, i + 1].Interior.Pattern = row.Cells[1, i + 1].Interior.Pattern;
                                    ...

Open in new window

Why? Any other way to efficiently/quickly read the attached two Excel Worksheets?
0
Hi,
I get Error and STacktrace below

Exception from HRESULT: 0x800A03EC    at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at Microsoft.Office.Interop.Excel.Range.set__Default(Object RowIndex, Object ColumnIndex, Object value)
   at WindowsFormsApplication2.Form1.menuItem5_Click(Object sender, EventArgs e) in c:\dp13\General Application\WindowsFormsApplication5\WindowsFormsApplication2\Form1.cs:line 120

Open in new window

due to last line below
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Office.Interop;
using Microsoft.Office.Interop.Excel;
using System.IO.Compression;
using System.Diagnostics;
using System.Text; // This was needed to make ASCIIEncoding function
using Excel = Microsoft.Office.Interop.Excel;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        ...
        private void menuItem5_Click(object sender, System.EventArgs e)
        {
            string File1;
            File1 = "C:/dp2/List0.txt";
            const string fileName = @"c:/dp2/List0.dat";

            int RowID = 0, ColID = 0;
            Stopwatch stopwatch = new Stopwatch();
     

Open in new window

0
Hello Experts,

I have built a Windows desktop application that reads through a bunch of files and folders and analyzes them, and creates image previews while it loops through them.

Problem is that sometimes, when the file/folder structure is too large, it is taking nearly 100% of the system processor and RAM. I was able to successfully limit the RAM to take maximum 20% of the system's total, but I cannot manage to limit the CPU allowed resources.

Can you please share a piece of code  with me that will do the trick?
0
Hi,
To the codes like
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public void AddMenu()
        {
            MainMenu mnuFileMenu = new MainMenu();
            this.Menu = mnuFileMenu;
            System.Windows.Forms.MenuItem myMenuItemFile = new System.Windows.Forms.MenuItem("&File");
            System.Windows.Forms.MenuItem myMenuItemNew = new System.Windows.Forms.MenuItem("&New");
            mnuFileMenu.MenuItems.Add(myMenuItemFile);
            mnuFileMenu.MenuItems.Add(myMenuItemNew);
        }
        private void Form1_Load(object sender, System.EventArgs e)
        {
            AddMenu();
        }
    }
}

Open in new window

why can't the menu be shown to the form, by this project below?
https://app.box.com/s/oxsbqcr0kd72e4y3ww8ugogigoroibx0
0
Hi, I'm looking for a video tutorial series for Cocoa and Swift 2. I've searched high and low, but none that are current with Xcode 7.x and Swift 2. I've found a couple that are great, but most are Xcode 6 and Objective-C or iOS with Swift 1, but my question is specific - Xcode 7.x and Swift 2.

Does anyone have a link to a good tutorial series that meets those requirements?

Yes...I know that iOS is very similar to Cocoa, but I'd really like to find a tutorial set for Cocoa and not iOS.

Thanks,
Fulano
0
Hi,
Any advice to these
namespace ClassLibrary1
{
    public class Class1
    {
        bool allowappend = true;
        string File1="c:/dp2/oup.txt";
        string s = "9quali52ty3";
        byte[] ASCIIValues = Encoding.ASCII.GetBytes(s);
        foreach(byte b in ASCIIValues) {
                using (StreamWriter sw = new StreamWriter(@File1, allowappend, Encoding.Unicode))
                {
                    sw.WriteLine(b);
                    sw.WriteLine("");
                }
}
}
}

Open in new window


due to these
Error	1	Invalid token 'foreach' in class, struct, or interface member declaration	C:\dp11\ClassLibrary1\ClassLibrary1\Class1.cs	38	9	ClassLibrary1
Error	2	; expected	C:\dp11\ClassLibrary1\ClassLibrary1\Class1.cs	38	24	ClassLibrary1
Error	3	Invalid token ')' in class, struct, or interface member declaration	C:\dp11\ClassLibrary1\ClassLibrary1\Class1.cs	38	38	ClassLibrary1
Error	4	; expected	C:\dp11\ClassLibrary1\ClassLibrary1\Class1.cs	39	97	ClassLibrary1
Error	5	Invalid token '(' in class, struct, or interface member declaration	C:\dp11\ClassLibrary1\ClassLibrary1\Class1.cs	41	33	ClassLibrary1
Error	6	Invalid token ')' in class, struct, or interface member declaration	C:\dp11\ClassLibrary1\ClassLibrary1\Class1.cs	41	35	ClassLibrary1
Error	7	Invalid token '(' in class, struct, or interface member declaration	C:\dp11\ClassLibrary1\ClassLibrary1\Class1.cs	42	33	ClassLibrary1
Error	8	Type or namespace definition, or end-of-file expected	

Open in new window

0
hello
  i would like to know how to determine the location of an object pointed at by the camera on an ios and android,
My thinking is the location of the user/camera is determined by using the location services on the mobile device, utilize the compass and camera in the phone to determine the distance to object(building) in the center of the camera view?
utililize the distance and compass/angles to determine the lat/lon of the pointed at building. Reverse geo-code the coordinate to get the actual address.
Is this feasible? are there any API's provided by Android/IOS that would facilitate this?
0
Hi,
For Chinese word, I think there're many tens of thousands for use. Is there any automatic way to list out all Chinese word, from anything, like a Chinese dictionary?

But I can only select less than 2 thousand distinct Chinese words from these

http://www.zhongwen.com/

http://www.mdbg.net/chindict/chindict.php?page=cedict

Any other advice?
0
Hi,
For Chinese word, I think there're many tens of thousands for use. Is there any automatic way to list out all Chinese word, from anything, like a Chinese dictionary?
0
On Demand Webinar: Networking for the Cloud Era
LVL 9
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Hi,
Using these
            string text = File.ReadAllText( @File0 );
            var matches = Regex.Matches( text, @"(?<line>.*?)((?<eol>\r\n)|\r|\n)|(?<line>.+?)\z" ).Cast<Match>();

            foreach( var m in matches )
            {
                if( m.Groups["eol"].Success )
                {
                    using (StreamWriter sw = new StreamWriter(@File1, allowappend, Encoding.Unicode))
                    {
                        sw.WriteLine("GOOD: {m.Groups[line]}");
                        sw.WriteLine("");
                    }
                }
                else
                {
                    using (StreamWriter sw = new StreamWriter(@File1, allowappend, Encoding.Unicode))
                    {
                        sw.WriteLine("BAD:  {m.Groups[line]}");
                        sw.WriteLine("");
                    }
                }
            }

Open in new window

I cannot show which line is having the problem. What to adjust, in above, as I want to show the relevant line, which is not having either CR or LF, at the end of it, for every line within the given text file?
0
I am working with iPad developers on a project.

There are several pages that the iPad simply pulls in a url from my web service like an iframe.  I believe that is "includes" in iPad????

In any case... we are getting unexpected results...

Is there an online tool that I can test how those html pages will render in an iPad App?

Since these iPad developers are offshore... and 12 hours time difference
Any "try this" is literally a 2 day turn around.
0
I have next expressions:
1)      DataValue += (1<<i);
2)      if( ((DataValue>>i)&0x1) == 0x1 )
         {
            ; //Do something
         }
I need help to understand step by step what happens in the expressions above.
Could you write them in expanded format, simple line by line, eventually with some explanations?
0
In an IOS Swift application I have a function that is returning a date as a string like ("2016-04-18"). I need help with Swift code for a function that will take this string or any other string in this format (for any other date) and convert it into NSDate and return me that date as  a string in the following format "18 April 2016".
So if I give this function any other date in the format "2016-03-03" then I will get back "3 March 2016".
Thank you for your help.
0
good day.  i need some help with reading from a plist.  i am an objective-c noob and would appreciate any help and code examples.  i don't believe i am far off.

i have a root.plist with two text field items.

my code to read from the list:

 -(void)readConfigurationItemsFromSettingsBundle{
        NSString *settingsBundle = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"];
        if(!settingsBundle) {
            NSLog(@"Could not find Settings.bundle");
            return;
        }
        
        NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[settingsBundle stringByAppendingPathComponent:@"Root.plist"]];
        NSArray *preferences = [settings objectForKey:@"PreferenceSpecifiers"];
   
        for (NSString *str in preferences)
          NSLog(@"--%@", str);
  }

Open in new window


here are my results:

 --{
    Key = "server_ip";
    Title = "server ip address";
    Type = PSTextFieldSpecifier;
}
--{
    Key = "audio_number";
    Title = "audio notification #";
    Type = PSTextFieldSpecifier;
}

i'm looking for the actual values within each key, but i don't know how to go about it....

thank you.
0
UINavigationController seems to not be working. The expected behavior is to click on one of the items in the table, and have it navigate to the next page. Furthermore, I was hoping to see a navigation bar at the top of the table, but I don't.

// AppDelegate.h
#import <UIKit/UIKit.h>
#import "TableViewControllerMusicians.h"
#import "ViewController2.h"
#import "ViewController3.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UITabBarController *tabBar;

@property (strong, nonatomic) UINavigationController *nav;
@property (strong, nonatomic) TableViewControllerMusicians *tvMusicians;

@property (strong, nonatomic) ViewController2 *vc2;
@property (strong, nonatomic) ViewController3 *vc3;

Open in new window


// AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    self.window = [[UIWindow alloc] init];
    self.window.backgroundColor = [UIColor lightGrayColor];
    self.window.frame = [UIScreen mainScreen].bounds;
    
    self.tabBar = [[UITabBarController alloc] initWithNibName:nil bundle:nil];

    self.tvMusicians = [[TableViewControllerMusicians alloc] initWithStyle:UITableViewStylePlain];
    self.tvMusicians.title = @"Musicians";
    
    self.nav = [[UINavigationController alloc] initWithRootViewController:self.tvMusicians];
    
    self.vc2 = [[ViewController2 alloc] initWithNibName:nil bundle:nil];
    self.vc2.title = @"VC2";
    self.vc2.tabBarItem.title = @"My VC2";
    
    self.vc3 = [[ViewController3 alloc] initWithNibName:nil bundle:nil];
    self.vc3.title = @"VC3";
    self.vc3.tabBarItem.title = @"My VC3";
    
    
    self.tabBar.viewControllers = [NSArray arrayWithObjects: self.tvMusicians, self.vc2, self.vc3, nil];
    
    self.window.rootViewController = self.tabBar;
    
    [self.window makeKeyAndVisible];
    
    return YES;
}

Open in new window


// TableViewControllerMusicians.m

Open in new window

0

Objective-C Programming

173

Solutions

199

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!