Is this a good start for an Objective-C program written without a framework? The Next CEO of Stack OverflowHandling SIGINT signal for a server programIs this proper code for removing a CCSprite under certain conditions?Objective-C class for placing UI elements based on screen sizeHow can I remove this for-loop in this competitive FizzBuzz code?SQLConnect - A library for connecting Objective-C/Swift applications to Microsoft SQL ServerUsing a TSV text file and map for a Q&A program“Silly program” for moving the mouse and doing other thingsQuicksort for Objective-CInterview Coding Challeng for iOS Part 1 - the Static Objective-C LibraryInterview coding challenge for iOS Part 2 - the application in Objective-C and Swift

"Eavesdropping" vs "Listen in on"

Reference request: Grassmannian and Plucker coordinates in type B, C, D

Purpose of level-shifter with same in and out voltages

Lucky Feat: How can "more than one creature spend a luck point to influence the outcome of a roll"?

What does "shotgun unity" refer to here in this sentence?

Do I need to write [sic] when including a quotation with a number less than 10 that isn't written out?

How to avoid supervisors with prejudiced views?

Is dried pee considered dirt?

what's the use of '% to gdp' type of variables?

Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?

Is there a way to save my career from absolute disaster?

Spaces in which all closed sets are regular closed

Reshaping json / reparing json inside shell script (remove trailing comma)

How to Implement Deterministic Encryption Safely in .NET

Expressing the idea of having a very busy time

Can this note be analyzed as a non-chord tone?

Would a completely good Muggle be able to use a wand?

Is it convenient to ask the journal's editor for two additional days to complete a review?

Can someone explain this formula for calculating Manhattan distance?

Why don't programming languages automatically manage the synchronous/asynchronous problem?

Players Circumventing the limitations of Wish

I dug holes for my pergola too wide

What day is it again?

Why is information "lost" when it got into a black hole?



Is this a good start for an Objective-C program written without a framework?



The Next CEO of Stack OverflowHandling SIGINT signal for a server programIs this proper code for removing a CCSprite under certain conditions?Objective-C class for placing UI elements based on screen sizeHow can I remove this for-loop in this competitive FizzBuzz code?SQLConnect - A library for connecting Objective-C/Swift applications to Microsoft SQL ServerUsing a TSV text file and map for a Q&A program“Silly program” for moving the mouse and doing other thingsQuicksort for Objective-CInterview Coding Challeng for iOS Part 1 - the Static Objective-C LibraryInterview coding challenge for iOS Part 2 - the application in Objective-C and Swift










0












$begingroup$


I have been developing a cross-platform game based on open C libraries (mainly glfw) with a direct focus on Windows development. The beginning of my programming career taught me familiarity in Objective-C, however I've been using pure C for the past few years in embedded applications.



Now that I'm trying to return to proper desktop program development, I'm wondering if it's a good idea to transfer my Objective-C skills to Windows in order to tidy up my C code. My current way of programming is creating a struct for data that I need and then creating functions around those structs: struct Point int x, int y; and then float Point_calculateDistance(struct Point *obj1, struct Point *obj2). This approach to me seemed very redundant and too object-oriented to write all in C. It would make more sense to me to write an Objective-C class to do this where everything can be more encapsulated.



I prefer not to use any framework for my code to increase the portability. I'm currently using VS Code and MSYS2 (mingw64) with GCC 8.3.0. I threw together a working example that demonstrates how I attempt to build a simple class. Does my code look reasonable? Am I performing any bad habits (within reason considering that I'm not using a framework)? Does this currently leak memory? Let me know what you think.



#include <objc/objc.h>
#include <objc/runtime.h>
#include <objc/Object.h>
#include <stdio.h>
#include <stdlib.h>


@interface Test : Object
int value;

+(const char *)classStringValue;
-(void)incrementBy: (int)num;
@end

@implementation Test
+(id)alloc
id obj = malloc(class_getInstanceSize(self));
object_setClass(obj, self);
return obj;


-(void)dealloc
free(self);


-(id)init
value = 0;
return self;


+(const char *)classStringValue
return "This is the string value of the Test class";


-(const char *)integerString
if (value >= 5)
return "high";
else
return "low";



-(void)incrementBy: (int)num
value += num;

@end

int main(int argc, char **argv)
printf("%sn", [Test classStringValue]);
Test *testobj = [[Test alloc] init];

printf("%sn", [testobj integerString]);
[testobj incrementBy: 5];
printf("%sn", [testobj integerString]);

printf("%dn", (int)[testobj class]);
printf("%dn", (int)[Object class]);
printf("%dn", [Object isEqual: testobj]);
printf("%dn", [testobj isEqual: testobj]);

[testobj dealloc];
return EXIT_SUCCESS;











share|improve this question









$endgroup$
















    0












    $begingroup$


    I have been developing a cross-platform game based on open C libraries (mainly glfw) with a direct focus on Windows development. The beginning of my programming career taught me familiarity in Objective-C, however I've been using pure C for the past few years in embedded applications.



    Now that I'm trying to return to proper desktop program development, I'm wondering if it's a good idea to transfer my Objective-C skills to Windows in order to tidy up my C code. My current way of programming is creating a struct for data that I need and then creating functions around those structs: struct Point int x, int y; and then float Point_calculateDistance(struct Point *obj1, struct Point *obj2). This approach to me seemed very redundant and too object-oriented to write all in C. It would make more sense to me to write an Objective-C class to do this where everything can be more encapsulated.



    I prefer not to use any framework for my code to increase the portability. I'm currently using VS Code and MSYS2 (mingw64) with GCC 8.3.0. I threw together a working example that demonstrates how I attempt to build a simple class. Does my code look reasonable? Am I performing any bad habits (within reason considering that I'm not using a framework)? Does this currently leak memory? Let me know what you think.



    #include <objc/objc.h>
    #include <objc/runtime.h>
    #include <objc/Object.h>
    #include <stdio.h>
    #include <stdlib.h>


    @interface Test : Object
    int value;

    +(const char *)classStringValue;
    -(void)incrementBy: (int)num;
    @end

    @implementation Test
    +(id)alloc
    id obj = malloc(class_getInstanceSize(self));
    object_setClass(obj, self);
    return obj;


    -(void)dealloc
    free(self);


    -(id)init
    value = 0;
    return self;


    +(const char *)classStringValue
    return "This is the string value of the Test class";


    -(const char *)integerString
    if (value >= 5)
    return "high";
    else
    return "low";



    -(void)incrementBy: (int)num
    value += num;

    @end

    int main(int argc, char **argv)
    printf("%sn", [Test classStringValue]);
    Test *testobj = [[Test alloc] init];

    printf("%sn", [testobj integerString]);
    [testobj incrementBy: 5];
    printf("%sn", [testobj integerString]);

    printf("%dn", (int)[testobj class]);
    printf("%dn", (int)[Object class]);
    printf("%dn", [Object isEqual: testobj]);
    printf("%dn", [testobj isEqual: testobj]);

    [testobj dealloc];
    return EXIT_SUCCESS;











    share|improve this question









    $endgroup$














      0












      0








      0





      $begingroup$


      I have been developing a cross-platform game based on open C libraries (mainly glfw) with a direct focus on Windows development. The beginning of my programming career taught me familiarity in Objective-C, however I've been using pure C for the past few years in embedded applications.



      Now that I'm trying to return to proper desktop program development, I'm wondering if it's a good idea to transfer my Objective-C skills to Windows in order to tidy up my C code. My current way of programming is creating a struct for data that I need and then creating functions around those structs: struct Point int x, int y; and then float Point_calculateDistance(struct Point *obj1, struct Point *obj2). This approach to me seemed very redundant and too object-oriented to write all in C. It would make more sense to me to write an Objective-C class to do this where everything can be more encapsulated.



      I prefer not to use any framework for my code to increase the portability. I'm currently using VS Code and MSYS2 (mingw64) with GCC 8.3.0. I threw together a working example that demonstrates how I attempt to build a simple class. Does my code look reasonable? Am I performing any bad habits (within reason considering that I'm not using a framework)? Does this currently leak memory? Let me know what you think.



      #include <objc/objc.h>
      #include <objc/runtime.h>
      #include <objc/Object.h>
      #include <stdio.h>
      #include <stdlib.h>


      @interface Test : Object
      int value;

      +(const char *)classStringValue;
      -(void)incrementBy: (int)num;
      @end

      @implementation Test
      +(id)alloc
      id obj = malloc(class_getInstanceSize(self));
      object_setClass(obj, self);
      return obj;


      -(void)dealloc
      free(self);


      -(id)init
      value = 0;
      return self;


      +(const char *)classStringValue
      return "This is the string value of the Test class";


      -(const char *)integerString
      if (value >= 5)
      return "high";
      else
      return "low";



      -(void)incrementBy: (int)num
      value += num;

      @end

      int main(int argc, char **argv)
      printf("%sn", [Test classStringValue]);
      Test *testobj = [[Test alloc] init];

      printf("%sn", [testobj integerString]);
      [testobj incrementBy: 5];
      printf("%sn", [testobj integerString]);

      printf("%dn", (int)[testobj class]);
      printf("%dn", (int)[Object class]);
      printf("%dn", [Object isEqual: testobj]);
      printf("%dn", [testobj isEqual: testobj]);

      [testobj dealloc];
      return EXIT_SUCCESS;











      share|improve this question









      $endgroup$




      I have been developing a cross-platform game based on open C libraries (mainly glfw) with a direct focus on Windows development. The beginning of my programming career taught me familiarity in Objective-C, however I've been using pure C for the past few years in embedded applications.



      Now that I'm trying to return to proper desktop program development, I'm wondering if it's a good idea to transfer my Objective-C skills to Windows in order to tidy up my C code. My current way of programming is creating a struct for data that I need and then creating functions around those structs: struct Point int x, int y; and then float Point_calculateDistance(struct Point *obj1, struct Point *obj2). This approach to me seemed very redundant and too object-oriented to write all in C. It would make more sense to me to write an Objective-C class to do this where everything can be more encapsulated.



      I prefer not to use any framework for my code to increase the portability. I'm currently using VS Code and MSYS2 (mingw64) with GCC 8.3.0. I threw together a working example that demonstrates how I attempt to build a simple class. Does my code look reasonable? Am I performing any bad habits (within reason considering that I'm not using a framework)? Does this currently leak memory? Let me know what you think.



      #include <objc/objc.h>
      #include <objc/runtime.h>
      #include <objc/Object.h>
      #include <stdio.h>
      #include <stdlib.h>


      @interface Test : Object
      int value;

      +(const char *)classStringValue;
      -(void)incrementBy: (int)num;
      @end

      @implementation Test
      +(id)alloc
      id obj = malloc(class_getInstanceSize(self));
      object_setClass(obj, self);
      return obj;


      -(void)dealloc
      free(self);


      -(id)init
      value = 0;
      return self;


      +(const char *)classStringValue
      return "This is the string value of the Test class";


      -(const char *)integerString
      if (value >= 5)
      return "high";
      else
      return "low";



      -(void)incrementBy: (int)num
      value += num;

      @end

      int main(int argc, char **argv)
      printf("%sn", [Test classStringValue]);
      Test *testobj = [[Test alloc] init];

      printf("%sn", [testobj integerString]);
      [testobj incrementBy: 5];
      printf("%sn", [testobj integerString]);

      printf("%dn", (int)[testobj class]);
      printf("%dn", (int)[Object class]);
      printf("%dn", [Object isEqual: testobj]);
      printf("%dn", [testobj isEqual: testobj]);

      [testobj dealloc];
      return EXIT_SUCCESS;








      objective-c windows






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 11 mins ago









      dylanweberdylanweber

      1828




      1828




















          0






          active

          oldest

          votes












          Your Answer





          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216611%2fis-this-a-good-start-for-an-objective-c-program-written-without-a-framework%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216611%2fis-this-a-good-start-for-an-objective-c-program-written-without-a-framework%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          बाताम इन्हें भी देखें सन्दर्भ दिक्चालन सूची1°05′00″N 104°02′0″E / 1.08333°N 104.03333°E / 1.08333; 104.033331°05′00″N 104°02′0″E / 1.08333°N 104.03333°E / 1.08333; 104.03333

          Why is the 'in' operator throwing an error with a string literal instead of logging false?Why can't I use switch statement on a String?Python join: why is it string.join(list) instead of list.join(string)?Multiline String Literal in C#Why does comparing strings using either '==' or 'is' sometimes produce a different result?How to initialize an array's length in javascript?How can I print literal curly-brace characters in python string and also use .format on it?Why does ++[[]][+[]]+[+[]] return the string “10”?Why is char[] preferred over String for passwords?Why does this code using random strings print “hello world”?jQuery.inArray(), how to use it right?

          How can we generalize the fact of finite dimensional vector space to an infinte dimensional case?$k[x]$-module and cyclic module over a finite dimensional vector spaceSubspace of a finite dimensional space is finite dimensionalIf V is an infinite-dimensional vector space, and S is an infinite-dimensional subspace of V, must the dimension of V/S be finite? ExplainWhy is an infinite dimensional space so different than a finite dimensional one?base for finite dimensional vector space is not infinite dimensional vector space?Any finite-dimensional vector space is the dual space of anotherHaving Trouble Understanding Meaning Of A Finite-Dimensional Vector SpaceProve that “Every subspaces of a finite-dimensional vector space is finite-dimensional”Ring as a finite dimensional Vector space over a field KQuestion regarding basis and dimension