Skip to content

Conversation

panguin6010
Copy link

This PR adds a new command to set values in iOS NSUserDefaults, complementing the existing get command.

Features

  • Set string, integer, float, and boolean values in NSUserDefaults
  • Automatic type detection based on input
  • Optional --type flag for explicit type specification
  • Changes persist across app restarts via synchronize()

Usage

ios nsuserdefaults set <key> <value> [--type string|int|float|bool]```

## Examples

```bash
ios nsuserdefaults set username "john.doe"
ios nsuserdefaults set isEnabled true
ios nsuserdefaults set maxRetries 5
ios nsuserdefaults set apiVersion 2.5 --type float

Changes

  • TypeScript Agent: Implemented set() function with type-specific setters (setBool_forKey_, setInteger_forKey_, setDouble_forKey_, setObject_forKey_)
  • TypeScript Agent: Fixed get() to use standardUserDefaults() for consistency with set()
  • RPC Layer: Added iosNsuserDefaultsSet export
  • Python Command: Added set() command with argument parsing and intelligent type detection
  • Tests: Added 6 new test cases covering all value types and error scenarios
  • Documentation: Added help file with usage examples

Testing

All tests pass:

python -m unittest tests.commands.ios.test_nsuserdefaults -v

This commit adds a new command to set values in iOS NSUserDefaults, complementing the existing get command.

Features:

Set string, integer, float, and boolean values in NSUserDefaults
Automatic type detection based on input
Optional --type flag for explicit type specification
Changes persist across app restarts via synchronize()
Changes:

TypeScript: Implemented set() function with type-specific setters
TypeScript: Fixed get() to use standardUserDefaults() for consistency
RPC: Added iosNsuserDefaultsSet export
Python: Added set command with argument parsing and type detection
Tests: Added 6 new test cases covering all value types
Docs: Added help file with usage examples
Usage: ios nsuserdefaults set [--type string|int|float|bool]

Examples: ios nsuserdefaults set username "john.doe" ios nsuserdefaults set isEnabled true ios nsuserdefaults set maxRetries 5 ios nsuserdefaults set apiVersion 2.5 --type float
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant