Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7584227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:52:10+00:00 2026-05-30T18:52:10+00:00

I have a struct as defined by the following: typedef struct { NSString *SportName;

  • 0

I have a struct as defined by the following:

typedef struct {
    NSString *SportName;
    NSInteger numberOfPeriods;
    CFTimeInterval periodLength;
    NSString *periodName;
    CFTimeInterval secondaryClockTime;
    NSString *LeftSecondaryCounterName;
    NSString *RightSecondaryCounterName;
    bool PossessionArrow;
} GamePreset;

Is it possible to write variables of type GamePreset to a plist file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:52:11+00:00Added an answer on May 30, 2026 at 6:52 pm

    There’s no built-in support for writing an arbitrary struct as a property list. You have to write a method that converts the struct to a property list.

    In theory, you could do it at run-time by parsing the result of @encode(GamePreset), which is replaced (at compile-time) by a string describing GamePreset:

    NSLog(@"encode = %s", @encode(GamePreset));
    ...
    2012-03-04 00:57:43.456 encodetest[43337:903] encode = {?=@qd@d@@B}
    

    This has serious drawbacks. One is that you don’t get the field names, so your plist won’t be particularly useful unless the reader knows the struct format, and any change to the struct‘s layout will make saved plists unreadable.

    Another big drawback is that the @encode string doesn’t have any information about structure padding. You have to account for it when parsing the string. I think you can use NSGetSizeAndAlignment to help with this.

    If you want to risk your sanity and try this, read the “Type Encodings” section of the Objective-C Runtime Programming Guide.

    I recommend you just bite the bullet and write a simple function that takes a GamePreset * and returns an NSDictionary * using hardcoded knowledge of the structure layout.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a struct defined as the following: typedef struct { string foo; }
I'm trying to read the bitmap header. I have defined the following struct: typedef
I have the following struct in C++: #define MAXCHARS 15 typedef struct { char
I have set up the following struct: typedef struct _thread_node_t { pthread_t thread; struct
I have a structure defined like so: typedef struct { int n; int *n_p;
I have a struct A that is defined as follows: typedef struct A {
Please have a look at the following code: #include <stdio.h> #include <stdlib.h> typedef struct
I have the following data structure in C: typedef struct { void* buffer; ...
Lets say, I have the following text file: Listing 1: Endianess=little AddressModel=32 typedef struct{
I have following struct defination: typedef union U08_16_t { unsigned long s32;//message32 unsigned char

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.